JPEG
JPEG
JPEG
Image Compression
Image = Information +
Redundant data
Why do we need compression?
• Lossless Compression
No information loss
Image can be reconstructed
exactly
• Lossy compression
Information loss is tolerable
Image cannot be reconstructed
exactly
Used where high compression
ratio is required
What is JPEG?
1 7 7
(2 x 1)u (2 y 1)v
F (u , v) C (u )C (v) f ( x, y ) cos cos
4 x 0 y 0 16 16
for u 0,..., 7 and v 0,..., 7
1/ 2 for k 0
where C (k )
1 otherwise
Discrete Cosine
Transform
Example : 48 39 40 68 60 38 50 121
149 82 79 101 113 106 27 62
58 63 77 69 124 107 74 125
80 97 74 54 59 71 91 66
18 34 33 46 64 61 32 37
Y
149 108 80 106 116 61 73 92
211 233 159 88 107 158 161 109
212 104 40 44 71 136 113 66
the luminance of an image 8x8 values of luminance
699.25 43.18 55.25 72.11 24.00 -25.51 11.21 -4.14
DCT
-129.78 -71.50 -70.26 -73.35 59.43 -24.02 22.61 -2.05
85.71 30.32 61.78 44.87 14.84 17.35 15.51 -13.19
-40.81 10.17 -17.53 -55.81 30.50 -2.28 -21.00 -1.26
-157.50 -49.39 13.27 -1.78 -8.75 22.47 -8.47 -9.23
92.49 -9.03 45.72 -48.13 -58.51 -9.01 -28.54 10.38
-53.09 -62.97 -3.49 -19.62 56.09 -2.25 -3.28 11.91
-20.54 -55.90 -20.59 -18.19 -26.58 -27.07 8.47 0.31
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 Q(u,v)
18 22 37 56 68 109 103 77 Quantization matrix
24 35 55 64 81 104 113 92
6.12
-2.91
2.33
0.60
3.86
-0.80
1.87
-1.92
0.37
0.60
0.30
-0.03
0.22
-0.26
-0.24
-0.02
F (u , v)
-8.75 -2.25 0.36 -0.03 -0.13 0.21 -0.08 -0.12
Q(u , v)
3.85 -0.26 0.83 -0.75 -0.72 -0.09 -0.25 0.11
-1.08 -0.98 -0.04 -0.23 0.54 -0.02 -0.03 0.12
-0.29 -0.61 -0.22 -0.19 -0.24 -0.27 0.08 0.00
Fq (u, v)
44 4 6 5 1 -1 0 0
-11 -6 -5 -4 2 0 0 0
6 2 4 2 0 0 0 0
-3 1 -1 -2 1 0 0 0 F (u, v)
-9 -2 0 0 0 0 0 0 Round
4 0 1 -1 -1 0 0 0 Q (u , v )
-1 -1 0 0 1 0 0 0
0 -1 0 0 0 0 0 0
Zig-Zag Ordering
-9 -2 0 0 0 0 0 0
-1,0,-1,0,0,0,0,
0,0,0,-1,0,0,
4 0 1 -1 -1 0 0 0 0,1,0,0,0,
0,0,0,0,
-1 -1 0 0 1 0 0 0
0,0,0,
0 -1 0 0 0 0 0 0 0,0,
0
Run-length Encoding
Example
• 63 AC coefficients:
57, 45, 0, 0, 0, 0, 23, 0, -30, -16, 0,
0, 1, 0, 0, 0, 0, 0, 0, 0,..., 0