$24
Use the Matlab function imwrite to save the les peppers.ti and baboon.ti using quality factors of 90, 70, 50, 30, and 10. Compute the PSNR between each original image and its JPEG compressed version at each quality factor. Additionally, record the le size of the image when it is saved at each quality factor. What is the relationship between the image’s le size and its quality? What distortions are introduced by JPEG compression? Why do you think they occur? At what quality factor do these distortions become unacceptably strong?
Write two Matlab function that implement your own JPEG-like encoder and decoder. The encoder should follow the following process:
Segment the image into 8 8 pixel blocks.
Compute the DCT of each block.
Quantize these DCT coe cients using a user speci ed quantization table Q.
Reorder each block of quantized DCT coe cients into a one-dimensional sequence using zig-zag scan-ning. You can use ZigzagMtx2Vector.m that is provided to you to perform zig-zag scanning and use Vector2ZigzagMtx.m for reconstructing the matrix from a zig-zag scanned sequence.
Encode the resulting sequence. For Entropy Encoding, use the JPEG entropy encode.m module pro-vided. This function will read a matrix, in which each row represents a vectorized DCT block, write a bit stream whose lename is always named as JPEG.jpg, and return the length of this le. JPEG entropy encode.m is an interface for generating a text le, JPEG DCTQ ZZ.txt, and running jpeg entropy encode.exe. For the entropy decoding, use JPEG entropy decode.m, which performs the inverse functionality.
The decoder should reconstruct the image by performing each of these steps in reverse. Please comment your code and append it to your report.
Use your JPEG-like encoder to encode the image peppers.tif. First do this using the standard JPEG luminance quantization table
2
16
11
10
16
24
40
51
61
3
12
12
14
19
26
58
60
55
(1)
6
14
13
16
24
40
57
69
56
7
6
7
14
17
22
29
51
87
80
62
6
7
6
7
6
18
22
37
56
68
109
103
77
7
6
7
6
24
35
55
64
81
104
113
92
7
6
7
6
49
64
78
87
103
121
120
101
7
4
5
6
72
92
95
98
112
100
103
99
7
Record the image’s le size and the PSNR between the original and decompressed image. Next, try changing the quantization table and encoding the image. Is it possible to achieve both a lower le size and a higher PSNR? Include the quantization table that you design in your report.
1