0% found this document useful (0 votes)
20 views

4-Jpeg Compression

The document discusses lossy compression techniques used in JPEG images. It explains how JPEG compression works by applying discrete cosine transform (DCT) to 8x8 pixel blocks, quantizing the coefficients, ordering them from lowest to highest frequency, then lossless compression of the remaining values. The decompression process reverses these steps to reconstruct the image with some loss of data.

Uploaded by

lawson
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

4-Jpeg Compression

The document discusses lossy compression techniques used in JPEG images. It explains how JPEG compression works by applying discrete cosine transform (DCT) to 8x8 pixel blocks, quantizing the coefficients, ordering them from lowest to highest frequency, then lossless compression of the remaining values. The decompression process reverses these steps to reconstruct the image with some loss of data.

Uploaded by

lawson
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Lossy compression

Sid Lamrous

MITGL01 Course 4 By Sid Lamrous/ Lossy compression


Lossy compression

The principle: we accept a degradation of the decompressed


image - indistinguishable to the eye or weak enough to be
acceptable - in return for a much more interesting
compression rate.
Transformation
Quantification Statistical Compressed
Original image by DCT on 8x8
phase coding image
block

8 x 8 Block
Original image

MITGL01 Course 4 By Sid Lamrous/ Lossy compression


JPEG compression principle (Joint Photographic Expert Group)

255 255 255 0 0 0 0 0


36 255 100 100 36 36 36 36
73 255 100 73 100 73 73 73
109 255 100 100 100 100 100 109
146 146 100 146 100 146 146 146
182 182 100 182 100 100 100 182
Original image 218 218 218 218 100 218 218 218
255 255 255 255 100 100 100 255

■ The following matrix represents the red component of


the coded image in 16 million colors (or 256 shades of
red).
MITGL01 Course 4 By Sid Lamrous/ Lossy compression
Center the matrix

The first step is to subtract 128 (which is the number


of red colors divided by 2) to each value then to apply the DCT.
We get the following result.
50 258 135 -120 -73 -76 -57 -103
-319 148 -9 28 -124 -101 -55 63 Note:
68 170 52 -89 -15 31 80 35 The coefficients having
the most absolute values
-21 25 40 44 16 68 60 30 strong are at the top left
22 81 46 -9 14 14 55 47 of the matrix.
66 33 39 33 -54 4 29 38
-31 68 30 -10 54 -29 13 33
41 -30 0 34 -31 37 36 29
DCT = Discret Cosin Transform (proposed method
in 1974 by Professor Rao of the University of Texas)
Note that at this stage, no information has been lost. The original block can be
reconstructed without any loss using the Reverse DCT and adding 128 to each term.
MITGL01 Course 4 By Sid Lamrous/ Lossy compression
Calculation of the DCT

MITGL01 Course 4 By Sid Lamrous/ Lossy compression


Quantification step

Fq is the quality factor

MITGL01 Course 4 By Sid Lamrous/ Lossy compression


Loss phase

We obtain the following Now let's divide the values of the data matrix by
our quantization matrix. The result is the
quantization matrix: following:

6 11 16 21 26 31 36 41 8
23 8 -5 -2 -2 -1 -2
11 16 21 26 31 36 41 46 -29 9 0 1 -4 -2 -1 1
16 21 26 31 36 41 46 51 4 8 2 -2 0 0 1 0
21 26 31 36 41 46 51 56 -1 0 1 1 0 1 1 0
26 31 36 41 46 51 56 61 0 2 1 0 0 0 0 0
31 36 41 46 51 56 61 66 2 0 0 0 -1 0 0 0
36 41 46 51 56 61 66 71 0 1 0 0 0 0 0 0
41 46 51 56 61 66 71 76 1 0 0 0 0 0 0 0

What is striking is on the one hand the number of zeros and on the other
hand the position non-zero values

MITGL01 Course 4 By Sid Lamrous/ Lossy compression


Using the lossless method

We will be able to go to the third step which


consists in compressing, this one without loss,
the matrix which we have.
The experts of the JPEG group have chosen to
treat 0s in a particular way because of their
number.
We will first use a particular sweep to obtain
the largest possible sequences of 0:

We use a lossless compression method which


can be that of Huffman.

MITGL01 Course 4 By Sid Lamrous/ Lossy compression


Decompression

Transformation
Compressed Statistical Dequantification
by DCT on 8x8 Original image
image decoding phase
block

After statistical decoding, we We must now dequantize by multiplying each


find our compressed matrix value by its quantization coefficient. We get
this:
8 23 8 -5 -2 -2 -1 -2 48 253 128 -105 -52 162 -36 -82
- 9 0 1 -4 -2 -1 1 -319 144 0 26 -124 -72 -41 46
29
4 8 2 -2 0 0 1 0 64 168 52 -62 0 0 46 0
-1 0 1 1 0 1 1 0 -21 0 31 36 0 46 51 0
0 2 1 0 0 0 0 0 0 62 36 0 0 0 0 0
2 0 0 0 -1 0 0 0 62 0 0 0 -51 0 0 0
0 1 0 0 0 0 0 0 0 41 0 0 0 0 0 0
1 0 0 0 0 0 0 0 41 0 0 0 0 0 0 0

MITGL01 Course 4 By Sid Lamrous/ Lossy compression


Next, let's apply the inverse DCT, and add 128 to each
value. Here is the decompressed matrix:
210 275 199 39 -9 27 5 3
110 205 124 55 42 24 20 40
94 237 133 98 98 72 80 71
100 209 111 100 94 102 119 102
153 156 100 136 103 121 126 150
179 150 137 170 102 145 133 174 Original image
212 218 210 224 131 181 175 241
265 263 224 243 121 107 107 232
Note: negative values will be replaced by
0s and values greater than 255 through 255.
MITGL01 Course 4 By Sid Lamrous/ Lossy compression
Sample processing

The first number is the


number of image bits
compressed, the second is
the compression ratio obtained
and the last one indicates the
selected quality.
MITGL01 Course 4 By Sid Lamrous/ Lossy compression
Thank you

You might also like