Lab4 TransformCoding
Lab4 TransformCoding
Lab4 TransformCoding
4.1.1 Investigate DCT image coding efficiency for different images and different coding
parameters (program dctcodng.m). Observe artifacts due to the block size and coding mask size.
Optimize nonlinear P-th law quantization of spectral coefficients.
4.1.2 Investigate 2-D Walsh transform image coding efficiency for different images and different
coding parameters (program walsh_codng.m). Observe artifacts due to the block size and coding mask
size. Optimize nonlinear P-th law quantization of spectral coefficients
4.2.2. Quantization. In JPEG standard, the DCT coefficients are quantized, using a quantization table
for DCT coefficients of luminance (intensity). A standard quantization table is shown in Fig. 1. The
{ }
entries w r , s in this table define the interval, to which a coefficient value is mapped.
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
{ }
Figure 1. Intensity Quantization Table w r , s
In order to control the tradeoff between reconstructed image quality and the bit rate, the quantization
table can be modified using the quality parameter Q that can assume values from 1 to 100. Quantized
DCT coefficients {α }are obtained as
r ,s
αˆ r = round (α r , s / w
~ ),
r ,s
where
w r ,s [
~ = floor (ScFact ⋅ w + 50) 100
r ,s ]
and
*)
The Matlab implementation presented here is based on C. Weidmann’s mini project ([5]), K.
Scretting’s Entropy Coding Matlab Implementation ([6]) and IJPEG software ([4]).
⎧1, Q = 100
⎪
ScFact = ⎨ 200 − 2 * Q , 50 ≤ Q ≤ 99
⎪ 5000 Q , 1 ≤ Q ≤ 50
⎩
1. Generate different quantization matrices and use matlab program encode_jpg_block.m to
perform quantization of 8x8 blocks of the input image. Calculate bit allocation for each
quantized DCT coefficient.
2. Design different quantization tables for different Q-quality factors (matlab program
scld_qnt_jpg.m )
3. Calculate quantization matrices for Q = 1,50,100. Find which Q corresponds to conventional
JPEG quality (no scaling), to the worst quality, to the to best quality (compression with no
losses at all).
4. Define the range in which DCT coefficients of 8x8 block of 8-bit image vary and estimate the
number of quantization levels for DCT coefficients for different values of the quality factor.
4.2.3 Zigzag rearrangement. JPEG reorders the coefficients in each block by means of zigzag scan,
thus converting a 8x8 squared array of quantized DCT coefficients to a 1-D string of 64 elements with
the first one representing the DC component and the others representing AC elements.
4.2.4 Entropy coding. In JPEG, a run length/entropy coding is applied to quantized AC coefficients
(the sequence of DC coefficients is DPCM coded separately). The baseline implementation of the
JPEG standard uses Sannon-Huffman coding.
1. Using program entrpy_calc.m calculate the entropy of encoded data at different stages of the
coding:
a. Entropy of 8x8 block of the original image
b. Entropy of the block after substraction of 128.
c. Entropy of the quantized DCT block.
d. Entropy of Sannon-Huffman encoded string
Compare these entropy values for different blocks. Which coding stage (DCT transformation,
DCT coefficients quantization or Entropy coding) mostly contributes to compression
efficiency?
2. Compute the entropy of quantized DCT block for different quality factors. Explain the
dependence of quantized DCT block entropy on scaling factor of the quantization table.
3. Using program JPEGlike.m, perform Sannon-Huffman coding of quantized and rearranged
DCT matrices. Encode the string, investigate the encoding results in “res”-output (see
program help for more details), and finally decode the string using the same program
JPEGlike.m. Check the “Losslessness” of this stage of coding-decoding.
4.2.5. Decoding
1. Use Matlab program jpgcodng.m to get JPG-coded images using different input parameters.
Compare visual image quality coded with different Q factors.
2. Compare output parameters of coding with different Q factors.
a. PSNR/MSE.
b. Entropy at the different stages of coding vs. Q-factor
c. BPP vs. Q-factor.
3. Measure PSNR/MSE vs. Compression Ratio
4. Investigate the Quality Losses due to coding/compression. Compare coding error of images
coded with different Q-factors. Investigate Fourier spectra of compression errors. In which
regions of the image the largest errors are? Which artifacts appear at very low rates (high
compression)?
References
1. W.B. Pennebaker and J.L. Mitchell, ``The JPEG Still Image Data Compression Standard'',
Van Nostrand Reinhold, 1993.
2. J. Kieffer, ``Lectures on Source Coding'', http://www.ee.umn.edu/users/kieffer/ece5585.html
3. Official JPEG committee web site: www.jpeg.org
4. Independent JPEG group site www.ijg.org
5. Coding Mini Project by Claudio Weidmann
lcavwww.efl.ch/~weidmann/Spclass/transform_codes
6. Arithmetic Coding and Sannon-Huffmann Coding in Matlab by Karl Skretting
www.ux.his.no/~karlsk/proj99/
7. Leonid Yaroslavsky, Murray Eden, “ Fundamentals of Digital Optics”, Birkhauser Boston
1996
8. Al Bovik, “Handbook of Image and Video Processing”, Academic Press, A Harcourt Science
and Technology Company, 1999