# 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?

Yes you are right.

Thresholding alone cannot perform data compression. By the way, I assume you meant thresholding of transform (DCT) coefficients.

Quantization helps you reduce the number of states the variables can take; hence reduce the number of bits necessary to encode the codebook (totality of codewords).

Thresholding, is applied after (or simultaneously with) quantization and lets you set a number of coefficients to zero. When they are set to zero however, typically a consecutive group of coefficients go to zero together, especially after zigzag scanning of those coefficients .

In effect, for every nonzero DCT coefficient there's 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 its codeword instead. This is a variant of run length coding (RLC) and is the very step where the 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 '19 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 '19 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 '19 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 '19 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 '19 at 18:38