I have been assigned to encode and decode images using the Shannon-Fano technique. I’ll be writing in Matlab.
I am able to access the data array of the image in Matlab, so I can see the value of each pixel. I understand the basics of using the Shannon-Fano technique for text, but not images.
Would I need to loop through each pixel and count the number of occurrences for each pixel value?
Thanks for pointing me in the right direction.
Imagine that this picture is actually a text and every pixel is a letter. If you have 8-bit picture, then you might have 256 different letters. How would you encode a text with 256 different letters? Yes, exactly the same way you encode text with 26 different letters, or 5 different letters, for that matter.
What you want to do in each case, is to make a histogram, sort it, based on frequency of each value, and then encode the image/text. So yes, you have to count each pixel value. Good luck!