Professional Documents
Culture Documents
H63CMS Jpeg Report Jiaweeyoong
H63CMS Jpeg Report Jiaweeyoong
Part A.
Low Contrast 8x8 Area.
1. The 8x8 pixel region can be done by loading the entire image.
>>imshow(img); % to load the image
The region between x(1:8) and y(987:994) of the original 2048x2048 was selected. Low contrast
region is the region has lighter colour and contains pixel values of 120-255.
>> selectpixel=img(1:8,987:994);
2. The following screenshot is the selected pixel.
>> imshow(selectpixel);
Column 8
0.0007
-0.0046
-0.0010
0.0047
-0.0006
-0.0007
-0.0003
0.0002
>> choosepixel=img(1729:1736,1852:1859);
6. The following screenshot is the selected pixel:
imshow(choosepixel);
3 0 3 5 8 6 3 4
6 1 1 4 8 4 1 3
6 0 0 3 5 3 0 1
4 0 3 3 3 1 0 0
Higher contrast region has a smaller pixel values.
7. By using dct2 function, DCT transform of the selected region is performed and it is stored in a
variable B.
>>B=dct2(choosepixel);
8. The DCT coefficient values obtained are as follow:
>>disp(B);
Columns 1 through 7
Column 8
-1.1636
-3.1078
0.1382
0.9116
-0.2017
-1.8429
0.1310
0.4259
Comparison
9.
Low contrast region
Columns 1 through 7
1.1381 0.0048
0.0024 -0.0020
0.0056 -0.0050
0.0022 0.0015
-0.0026 -0.0025
0.0014 0.0022
0.0017 -0.0009
0.0012 0.0030
0.0016 -0.0000
0.0005 -0.0005
-0.0024 -0.0034
0.0004 0.0012
0.0031 0.0018
0.0004 0.0006
0.0006 -0.0004
0.0002 -0.0005
31.5000 2.2141
-0.5217 3.2664
9.9771 1.2938
-1.4822 -1.1873
-1.6168 5.2273
-0.2693 -2.1857
2.1385 -2.1232
-1.7848 -1.7596
0.7500 -4.7027
1.1183 0.6301
0.3250 -2.7703
0.8045 0.9373
0.6697 -0.2379
-0.1621 0.2840
-0.3932 -0.1026
-0.0552 0.1087
Column 8
Column 8
0.0007
-0.0046
-0.0010
0.0047
-0.0006
-0.0007
-0.0003
0.0002
-1.1636
-3.1078
0.1382
0.9116
-0.2017
-1.8429
0.1310
0.4259
As expected from theory, we notice that the value in the very first cell is the highest and as we along
the array, the values drastically decrease in value because of the following formula:
Part B
10. The DCT coefficents obtained in 4. Are quantised by diving the coefficients by M1 and rounded
off to the nearest integer value and stored in a variable named D.
>>Quotient=(A/M1);
>>D=round(Quotient);
11. The pixels were restored by multiplying D by M1 which is the quantisation matrix used earlier
and perform inverse DCT on the product of D and M1. The quantization matrix is designed to
provide more resolution to more perceivable frequency components over less perceivable
components (usually lower frequencies over high frequencies) in addition to transforming as many
components to 0, which can be encoded with greatest efficiency.
>>product=D*M1;
>> undo = idct2(product);
12. The restored pixel values are being rounded off and the original and restored values are as
follows:
Original Pixel Values
141 141 145 144 141
140 143 144 145 141
143 144 141 146 143
144 143 139 143 143
146 144 144 143 144
146 141 145 143 145
143 139 139 139 143
145 145 140 140 141
145
143
145
144
140
139
139
139
144
143
143
143
144
141
140
140
145
141
139
139
140
140
140
140
From the above table, we can see that there are more deviation at the first 3 columns restored pixel
values. This is because IDCT is not rigorously defined, therefore it does not guarantee that the
decoded output will match the original pixel values. The quality of the restored image is not as good
as the original image because some data were lost during the rounding off stage. DCT itself does not
introduce losses since there are techniques that give lossless jpeg that also use DCT
or the modified versions of DCT.
15.
Original Image
Restored Image
Restored Image
From the 2 tables show above, we can notice that there are no differences between the quality of
the original image and the restored image. The pixel values of the restored image are the same with
the original image. Hence, we can conclude that the compression technique we used in 14. Is a
lossless compression method.
References:
1. http://en.wikipedia.org/wiki/Discrete_cosine_transform#CITEREFAraiAguiNakajima1988
2. http://en.wikipedia.org/wiki/Quantization_(image_processing)