EE465: Introduction to Digital Imag e Processing 1 Lossy Image Compression: a Quick Tour of JPEG Coding Standard Why lossy for grayscale images? Tradeoff between Rate and Distortion Transform basics Unitary transform and properties Quantization basics Uniform Quantization and 6dB/bit Rule JPEG=T+Q+C T: DCT, Q: Uniform Quantization, C: Run-length and Huffman coding
65
Embed
Lossy Image Compression: a Quick Tour of JPEG Coding Standard
Lossy Image Compression: a Quick Tour of JPEG Coding Standard. Why lossy for grayscale images? Tradeoff between Rate and Distortion Transform basics Unitary transform and properties Quantization basics Uniform Quantization and 6dB/bit Rule JPEG=T+Q+C - PowerPoint PPT Presentation
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
EE465: Introduction to Digital Image Processing 1
Lossy Image Compression:a Quick Tour of JPEG Coding StandardWhy lossy for grayscale images?
Tradeoff between Rate and Distortion
Transform basics Unitary transform and properties
Quantization basics Uniform Quantization and 6dB/bit Rule
EE465: Introduction to Digital Image Processing 35
What is Quantization?
In Physics To limit the possible values of a magnitude or
quantity to a discrete set of values by quantum mechanical rules
In image compression To limit the possible values of a pixel value or a
transform coefficient to a discrete set of values by information theoretic rules
EE465: Introduction to Digital Image Processing 36
Examples
Unlike entropy, we encounter it everyday (so it is not a monster)
Continuous to discrete a quarter of milk, two gallons of gas, normal
temperature is 98.6F, my height is 5 foot 9 inches
Discrete to discrete Round your tax return to integers The mileage of my car is about 55K.
EE465: Introduction to Digital Image Processing 37
A Game Played with BitsPrecision is finite: the more precise, the
more bits you need (to resolve the uncertainty) Keep a card in secret and ask your partner to
guess. He/she can only ask Yes/No questions: is it bigger than 7? Is it less than 4? ...
However, not every bit has the same impact How much did you pay for your car? (two
thousands vs. $2016.78)
EE465: Introduction to Digital Image Processing 38
Scalar vs. Vector Quantization
We only consider the scalar quantization (SQ) in this course Even for a sequence of values, we will process
(quantize) each sample independently
Vector quantization (VQ) is the extension of SQ into high-dimensional space Widely used in speech compression, but not for
image compression
EE465: Introduction to Digital Image Processing 39
Definition of (Scalar) Quantization
x f f -1 xsS
original value
quantizationindex
quantized value
Quantizer
x Q x
f finds the closest (in terms of Euclidean distance) approximation of x from a codebook C (a collection of codewords) and assign its index to s; f-1 operates like a table look-up to return the corresponding codeword
EE465: Introduction to Digital Image Processing 40
Numerical Example (I)
0 1-1
C={-1,0,1}
Three codewords
else
x
x
xQ
0
5.01
5.01
)(
S={1,2,3}
1 2 3
red: codewordsgreen: index in C
x
x
0.5-0.5
1
-1
xR
EE465: Introduction to Digital Image Processing 41
Numerical Example (II)
24 408
C={8,24,40,56,72,…,248}
sixteen codewords
]255,0[,1616
8)(
x
xxQ
S={1,2,3,…,16}
1 2 3
red: codewordsgreen: index in C
x
x
...
...
248
16
x{0,1,…,255}
16 32
24
40
(note that the scales are different)
8floor operation
EE465: Introduction to Digital Image Processing 42
EE465: Introduction to Digital Image Processing 47
JPEG Coding Algorithm Overview
EE465: Introduction to Digital Image Processing 48
Transform Coding of Images
Why not transform the whole image together? Require a large memory to store transform
matrix It is not a good idea for compression due to
spatially varying statistics within an imageIdea of partitioning an image into blocks
Each block is viewed as a smaller-image and processed independently
It is not a magic, but a compromise
EE465: Introduction to Digital Image Processing 49
Block-based DCT Example
JI
note that white lines are artificially added to the border of each 8-by-8 block to denote that each block is processed independently
EE465: Introduction to Digital Image Processing 50
Boundary Padding
padded regions
Example
1213141516171819
1213141516171819
1213141516171819
1213141516171819
When the width/height of an image is not the multiple of 8, the boundary isartificially padded with repeated columns/rows to make them multiple of 8
EE465: Introduction to Digital Image Processing 51
Work with a Toy Example
169130
173129
170181
170183
179181
182180
179180
179179169132
171130
169183
164182
179180
176179
180179
178178167131
167131
165179
170179
177179
182171
177177
168179169130
165132
166187
163194
176116
15394
153183
160183
Any 8-by-8 block in an image is processed in a similar fashion
EE465: Introduction to Digital Image Processing 52
Encoding Stage I: Transform
• Step 1: DC level shifting
169130
173129
170181
170183
179181
182180
179180
179179169132
171130
169183
164182
179180
176179
180179
178178167131
167131
165179
170179
177179
182171
177177
168179169130
165132
166187
163194
176116
15394
153183
160183
412
451
4253
4255
5153
5452
5152
5151414
432
4155
3654
5152
4851
5251
5050393
393
3751
4251
4951
5443
4949
4051412
374
3859
3566
4812
2534
2555
3655
128 (DC level)
_
EE465: Introduction to Digital Image Processing 53
• Step 2: 8-by-8 DCT
412
451
4253
4255
5153
5452
5152
5151414
432
4155
3654
5152
4851
5251
5050393
393
3751
4251
4951
5443
4949
4051412
374
3859
3566
4812
2534
2555
3655
13
42
12
09
40
21
13
4430
55
47
73
30
46
32
16113
916
109
621
179
3310
810
17201024
2727
132
6078
4413
1827
2738
56313
Encoding Step 1: Transform (Con’t)
88DCT
EE465: Introduction to Digital Image Processing 54
Encoding Stage II: Quantization
99103
101120
100112
121103
9895
8778
9272
644992113
77103
10481
10968
6455
5637
3524
22186280
5669
8751
5740
2922
2416
1714
13145560
6151
5826
4024
1914
1610
1212
1116
Q-table
8,1
ˆ:
:
1
ji
Qsxf
Q
xsf
ijijij
ij
ijij
: specifies quantization stepsize (see slide #28)
Notes: Q-table can be specified by customerQ-table is scaled up/down by a chosen quality factor Quantization stepsize Qij is dependent on the coordinates (i,j) within the 8-by-8 block Quantization stepsize Qij increases from top-left to bottom-right
EE465: Introduction to Digital Image Processing 55
Encoding Stage II: Quantization (Con’t)
13
42
12
09
40
21
13
4430
55
47
73
30
46
32
16113
916
109
621
179
3310
810
17201024
2727
132
6078
4413
1827
2738
56313
00
00
00
00
00
00
00
0000
00
00
00
00
00
00
0000
00
00
01
10
11
01
1100
01
01
23
21
13
23
520
Example
f
xijsij
EE465: Introduction to Digital Image Processing 56