# Image compression

What happens when an image is compressed by thresholding (choosing a suitable threshold and setting the values below the threshold to zero)? Setting the values to zero doesn't mean removing them. They still need to be coded to to be stored or transmitted over a channel, and thus no reduction in the size of image occurs. Is my understanding correct? Are there any steps following the setting to zero step (example Huffman Coding) is performed in order to reduce the number of bits required to encode the image?

Thresholding alone cannot perform data compression. You need to employ some encoding strategy to discard those ignored coefficients, to achive actual bit reduction.

For example, in lossy JPEG image compression, quantization of DCT coefficients helps you reduce the number of states the variables can take; hence reduce the number of bits necessary to encode the codebook.

Thresholding is applied after quantization, and sets a number of coefficients to zero. Typically, consecutive groups of coefficients tend to go to zero together, especially after zigzag scanning pattern. In effect, for a typical nonzero DCT coefficient, there will be a tail of zero coefficients following. Then instead of individually storing each coefficient alone, you define some special symbols for every 1-nonzero-K-zero combination, and store the codeword instead. This is a variant of run length coding (RLC), and is the very step where the actual bit-reduction happens.

• The idea is applicable, as you said, with DCT coefficients, and can also be applied with wavelet coefficients, since both transforms have high energy compaction property, right?
– Noha
Dec 28, 2019 at 7:38
• I think also that Huffman coding, which is an entropy based coding technique, can be applied after setting the coefficients to zero. Its main idea is to assign shorter code words with most probable values and longer code words with values with less probability of occurrence, thus ensuring minimum average length for code words. With DCT and wavelet coefficients, I think the number of zero coefficients after the thresholding stage will be large, and thus can be encoded with small number of bits using Huffman coding. Do you agree?
– Noha
Dec 28, 2019 at 7:45
• to first comment yes. To the second comment yes but no :Huffman is not applied to DCT coefficients directly but to the special symbol/category run length coded elements. To get a clear view; I recommend you read Standard Codecs from Ghanbari... Dec 28, 2019 at 15:54
• Ok, I will read them. What about Huffman coding? when can it be applied? I know that when it is applied alone, it performs lossless data compression. When can it be applied after a lossy compression step to encode the data in less number of bits?
– Noha
Dec 28, 2019 at 17:26
• Yes Huffman entropy coding is also performed on the final stage of JPEG (dct) and JPEG2000 (wavelet) based image codecs. Dec 28, 2019 at 18:38