I once learnt that the Huffman Encoding is used to rid of redundant information, thus reducing file size. I am not sure how using a DCT, or FFT on an image can help in reducing file size. It does not work on redundancy, then how does it reduce the total amount of data?
2 Answers
If you take an image as is (especially a photograph, as opposed to line art, a document scan...), there's very little redundancy in it for Huffman encoding to do its work - because the image contains many small fluctuations and details which are not perceptible to the human eye but nevertheless present in the data. DCT followed by coefficient truncation/quantization eliminates the barely perceptible details and creates redundancy for Huffman compression to work on.
-
1$\begingroup$ +1 Didn't realize that they use reduced quantization too, but that makes sense. Much less crude then simply tossing coefficients. $\endgroup$– Jim ClayCommented Sep 27, 2014 at 16:11
The reason it works is that for most images, most of the energy is in the low frequencies and can be captured by relatively few DCT coefficients. So what happens is the algorithms compute the DCT and only keep the high energy coefficients. The rest are simply thrown away. This results in some degradation in the image of course, but, assuming the algorithm did its job well, not much.
-
$\begingroup$ ok so this means that the DCT result contains numbers which are smaller in magnitude and use less bits? Why not use some other type of special arbitrary function for images rather than just do a DCT? $\endgroup$ Commented Sep 27, 2014 at 20:26
-
2$\begingroup$ No, the numbers have less resolution, not less magnitude. In other words, they are taking away the least significant bits, not the most significant. Regarding why use the DCT, the simple (but true) answer is that it works. Are there other functions that would work better? Probably, but how does one find a function that works better across a wide range of images? I am not an expert in this field, but I would guess that wavelet transforms are promising and probably the basis for the more modern algorithms. $\endgroup$– Jim ClayCommented Sep 27, 2014 at 20:48