Which part of the DCT matlab example performs quantization?

2 views (last 30 days)
In the link, https://www.mathworks.com/help/images/discrete-cosine-transform.html it is mentioned that "The input image is divided into 8-by-8 or 16-by-16 blocks, and the two-dimensional DCT is computed for each block. The DCT coefficients are then quantized, coded, and transmitted. The JPEG receiver (or JPEG file reader) decodes the quantized DCT coefficients". According to wikipedia, the quantization table is as shown:
quant = [
16 11 10 16 24 40 51 61;
12 12 14 19 26 58 60 55;
14 13 16 24 40 57 69 56;
14 17 22 29 51 87 80 62;
18 22 37 56 68 109 103 77;
24 35 55 64 81 104 113 92;
49 64 78 87 103 121 120 101;
72 92 95 98 112 100 103 99
];
However, i couldn't seem track down which part of the code performs quantization in the example. Could anyone point out?

Answers (1)

Walter Roberson
Walter Roberson on 12 Aug 2019
Notice that there is no coding or transmitting of coefficients in the example either.
You have to read a bit carefully. The paragraph you are referring to starts
DCT is used in the JPEG image compression algorithm. The input image is divided into 8-by-8 or 16-by-16 blocks, and the two-dimensional DCT is computed for each block. The DCT coefficients are then quantized, coded, and transmitted.
which is true -- but that process is not describing the example. The example is described in the paragraph before that.
  2 Comments
Stewart Tan
Stewart Tan on 12 Aug 2019
@Walter Roberson thanks, so the example doesn't perform quantization. May i also ask why is 10 chosen in the sentence "Discard all but 10 of the 64 DCT coefficients in each block"? I know that it is directing towards discarding the higher frequency coefficients but why 10? Is the user able to choose how many to preserve or is there a reasoning behind?
Walter Roberson
Walter Roberson on 12 Aug 2019
In the general case, jpeg compression programs usually offer a quality setting, and the quality settting usually controls the number of coefficients that are kept.
10 was probably chosen because of the triangle 1+2+3+4 = 10 . Probably if only 6 had been used then the quality of reconstruction would have been notably worse, and probably if more had been used such as 15 the reconstruction would have been better enough to make it difficult for the reader to see the problems.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!