lossy compression jpeg
TRANSCRIPT
![Page 1: lossy compression JPEG](https://reader036.vdocuments.site/reader036/viewer/2022071903/55c4c117bb61eb061e8b4710/html5/thumbnails/1.jpg)
Lossy Compression
By:Mahmoud Hikmet Bzhar Omer
Supervisor:Dr.Roojwan Sdiq
![Page 2: lossy compression JPEG](https://reader036.vdocuments.site/reader036/viewer/2022071903/55c4c117bb61eb061e8b4710/html5/thumbnails/2.jpg)
Overview• What's Comparession ?• What’s lossless and lossy compression ?• What’s JPEG?• The Major Steps in JPEG Coding involve: Transform RGB to YIQ or YUV and subsample color. DCT(Discrete Cosine Transformation). Quantization. Zig-zag ordering DPCM on DC component Run-length encoding. Entropy coding.
![Page 3: lossy compression JPEG](https://reader036.vdocuments.site/reader036/viewer/2022071903/55c4c117bb61eb061e8b4710/html5/thumbnails/3.jpg)
What is Comparession ?
• Compression is the reduction in size of data in order to save space or transmission time. Learn how files are compressed .
![Page 4: lossy compression JPEG](https://reader036.vdocuments.site/reader036/viewer/2022071903/55c4c117bb61eb061e8b4710/html5/thumbnails/4.jpg)
What’s lossless and lossy compression ?
• Lossless: The compression of a file, all original data can be recovered when the file is uncompressed.
•Lossy : -The compressed data is not the same as the original data, but a close approximation of it.
![Page 5: lossy compression JPEG](https://reader036.vdocuments.site/reader036/viewer/2022071903/55c4c117bb61eb061e8b4710/html5/thumbnails/5.jpg)
What is JPEG?
• "Joint Photographic Expert Group" -- an international standard in 1992.• Works with colour and greyscale images, Many
applications e.g., satellite, medical, ..
![Page 6: lossy compression JPEG](https://reader036.vdocuments.site/reader036/viewer/2022071903/55c4c117bb61eb061e8b4710/html5/thumbnails/6.jpg)
JPEG compression involves the following:
![Page 7: lossy compression JPEG](https://reader036.vdocuments.site/reader036/viewer/2022071903/55c4c117bb61eb061e8b4710/html5/thumbnails/7.jpg)
DCT : Discrete Cosine Transform
• DCT converts the information contained in a block(8x8) of pixels from spatial domain to the frequency domain.
1-D DCT: 1-D Inverese DCT:
1N
0n2N
1)(2nf(n)cos2
a(u))F(
1N
02N
1)(2n)cosF(2
a(u))(f’
n
0p 1a(p)21a(0)
![Page 8: lossy compression JPEG](https://reader036.vdocuments.site/reader036/viewer/2022071903/55c4c117bb61eb061e8b4710/html5/thumbnails/8.jpg)
Example subimage 2*2
154 123
192 186D
Subtract 128 from each value to convert to signed
26 -5
64 58D
First Row=21
second Row= 2N1)(2ncos
N/2
![Page 9: lossy compression JPEG](https://reader036.vdocuments.site/reader036/viewer/2022071903/55c4c117bb61eb061e8b4710/html5/thumbnails/9.jpg)
1- = 0.7071
2-
21
N*21)(2ncos
N/2
D(1,0)=2*2
*1)0*(2cos 12/2
D(1,0)=4
cos
D(1,0)=0.7071
D(1,1)=2*2
*1)1*(2cos 12/2
D(1,1)=4
cos 3
D(1,1)=-0.70710.7071 0.7071
0.7071 -0.7071T
![Page 10: lossy compression JPEG](https://reader036.vdocuments.site/reader036/viewer/2022071903/55c4c117bb61eb061e8b4710/html5/thumbnails/10.jpg)
0.7071 0.7071
0.7071 -0.7071
0.7071 0.7071
0.7071 -0.707126 -564 58* *
T D -T
63.639 33.234
-26.87 -40.305
0.7071 0.7071
0.7071 -0.7071*
68.5 21.5
-47.5 9.5DCT=
![Page 11: lossy compression JPEG](https://reader036.vdocuments.site/reader036/viewer/2022071903/55c4c117bb61eb061e8b4710/html5/thumbnails/11.jpg)
Quantization:• The quantization step is the main source for loss in JPEG
compression
• Encoder: Each value in the current block is divided by 16 and rounded down to create the quantised block.
• Round(DCT/Q)
68.5 21.5
-47.5 9.5
16 11
12 12
Q4 2
-4 1
4 2
-4 1QDCT
![Page 12: lossy compression JPEG](https://reader036.vdocuments.site/reader036/viewer/2022071903/55c4c117bb61eb061e8b4710/html5/thumbnails/12.jpg)
Quantization:
• The quantization step is the main source for loss in JPEG compression.
• Decoder: Each value in the quantised block is multiplied by quntize block.
4 2
-4 1QDCT16 11
12 12*
64 22
-48 12Q-1
![Page 13: lossy compression JPEG](https://reader036.vdocuments.site/reader036/viewer/2022071903/55c4c117bb61eb061e8b4710/html5/thumbnails/13.jpg)
• DCT-1=round(T*Q-1*T)+128
DCT-inverse
0.7071 0.7071
0.7071 -0.7071
0.7071 0.7071
0.7071 -0.707126 -564 58
T Q-1 -T
* *
11.314 24.041
79.195 7.071 *0.7071 0.7071
0.7071 -0.7071=
=
= 25 -9
61 51 +128 128
128 128
153 119
189 179=
![Page 14: lossy compression JPEG](https://reader036.vdocuments.site/reader036/viewer/2022071903/55c4c117bb61eb061e8b4710/html5/thumbnails/14.jpg)
154 123
192 186
D
-153 119
189 179
DCT-1
1 4
3 7=
![Page 15: lossy compression JPEG](https://reader036.vdocuments.site/reader036/viewer/2022071903/55c4c117bb61eb061e8b4710/html5/thumbnails/15.jpg)
Zig-Zag Scan
• Why? to group low frequency coefficients in top of vector and high frequency coefficients at the bottom
−26, −3, 0, −3, −2, −6, 2, −4, 1, −4, 1, 1, 5, 1, 2, −1, 1, −1, 2, 0, 0, 0,0, 0, −1, −1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, EOB
![Page 16: lossy compression JPEG](https://reader036.vdocuments.site/reader036/viewer/2022071903/55c4c117bb61eb061e8b4710/html5/thumbnails/16.jpg)
• The 1x64 vectors have a lot of zeros in them, more so towards the end of the vector. • Higher up entries in the vector capture higher frequency (DCT) components
which tend to be capture less of the content.• Could have been as a result of using a quantization table
• Encode a series of 0s as a (skip,value) pair, where skip is the number of zeros and value is the next non-zero component. • Send (0,0) as end-of-block sentinel value.
. . .
1x64
0 0 0 0 0 1 1 0 0 0 0 0
5,1
0 0
7,2
0 . . .2
RLE on AC Components
Run-length encode:−26, −3, 0, −3, −2, −6, 2, −4, 1, −4, {2 x 1}, 5, 1, 2, −1, 1, −1, 2, {5 x0} , −1, −1,
![Page 17: lossy compression JPEG](https://reader036.vdocuments.site/reader036/viewer/2022071903/55c4c117bb61eb061e8b4710/html5/thumbnails/17.jpg)
• Is based on the frequency of occurance of data item(pixel in image).
• The principle is to use a lower number of bits to encode the data occurs more frequently.
H(x)==log 2 xi
number of bit for each character. entropy for each character.
Huffman Coding
![Page 18: lossy compression JPEG](https://reader036.vdocuments.site/reader036/viewer/2022071903/55c4c117bb61eb061e8b4710/html5/thumbnails/18.jpg)
Example
Symbol Xi sorting Xi Symol Code number ofbit______ __ ______ _____ _____ ___________A 0.3 0.3 A 00 2B 0.2 0.23 C 01 2C 0.23 0.2 B 11 2D 0.07 0.15 E 010 3E 0.15 0.07 D 0110 4F 0.05 0.05 F 1110 4
H(x)= =2log 2 0.3 + 2log 2 0.23 + 2log 2 0.2 + 3log 2 0.15 + 4log 2 0.07 + 4log 2 0.05= -0.21
![Page 19: lossy compression JPEG](https://reader036.vdocuments.site/reader036/viewer/2022071903/55c4c117bb61eb061e8b4710/html5/thumbnails/19.jpg)
Thank you