Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Lab4 TransformCoding

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Lab.

4 - Image Coding: Transform methods


Study of transform coding methods: DCT, Walsh transform coding and JPEG coding.

1. Principles of block transform coding

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

2. JPEG coding standard*)


4.2.1. Image blocks. Compute DCT coefficients for a 8x8 block of the original image (8-bit). Subtract
from the block values value of 128 (in 8-bit scale) and compute DCT. Compare the range of resulting
DCT values for both cases. Explain the reason for such a subtraction used in conventional JPEG.

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

49 64 78 87 103 121 120 101

72 92 95 98 112 100 103 99

{ }
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.

Figure 2. Zigzag reordering scheme


1. Use matlab program zigzag_block.m to rearrange quantized DCT coefficients. Compare
streams obtained from adjacent blocks of the same image, not adjacent blocks of the same
image and blocks from different images. Write a program for zigzag rearrangement of a table
of arbitrary size.
2. Compare zigzag ordered streams and those sorted in descending order.
3. Calculate the number of trailing zeros in each stream. In standard JPEG, a special symbol
End Of Block (EOB) is used to indicate the end of trailing zeros. Thus, for each block one
needs at most 6 additional bits (log 2 64) to specify the length of the “nonzero” vector (it
might contain zeros, but its last element is nonzero). Concatenate the “stripped” vectors and
compute the entropy, then add the overhead information of 6 bits/block.

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

Submit: Results and m-files.

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

You might also like