image compression
DESCRIPTION
Image Compression. Fundamentals: Coding redundancy The gray level histogram of an image can reveal a great deal of information about the image That probability (frequency) of occurrence of gray level r k is p(r k ),. Image Compression. Fundamentals: Coding redundancy - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Image Compression](https://reader035.vdocuments.net/reader035/viewer/2022062517/56813b6d550346895da472ca/html5/thumbnails/1.jpg)
G52IIP, School of Computer Science, University of Nottingham
1
Image Compression
Fundamentals: Coding redundancy
The gray level histogram of an image can reveal a great deal of information about the image
That probability (frequency) of occurrence of gray level rk is p(rk),
1,...,2,0 Lkn
nrp kk
![Page 2: Image Compression](https://reader035.vdocuments.net/reader035/viewer/2022062517/56813b6d550346895da472ca/html5/thumbnails/2.jpg)
G52IIP, School of Computer Science, University of Nottingham
2
Image Compression
Fundamentals: Coding redundancy
If the number of bits used to represent each value of rk is l(rk), the average number of bits required to represent each pixel is
To code an MxN image requires MNLavg bits
1
0
L
kkkavg rprlL
![Page 3: Image Compression](https://reader035.vdocuments.net/reader035/viewer/2022062517/56813b6d550346895da472ca/html5/thumbnails/3.jpg)
G52IIP, School of Computer Science, University of Nottingham
3
Image Compression
Fundamentals: Coding redundancy
some pixel values more common than others
![Page 4: Image Compression](https://reader035.vdocuments.net/reader035/viewer/2022062517/56813b6d550346895da472ca/html5/thumbnails/4.jpg)
G52IIP, School of Computer Science, University of Nottingham
4
Image Compression
Fundamentals: Coding redundancy
To code an MxN image requires MNLavg bits
If m-bit natural binary code is used to represent the the gray levels, then
1
0
L
kkkavg rprlL
mrmprprlLL
kk
L
kkkavg
1
0
1
0
![Page 5: Image Compression](https://reader035.vdocuments.net/reader035/viewer/2022062517/56813b6d550346895da472ca/html5/thumbnails/5.jpg)
G52IIP, School of Computer Science, University of Nottingham
5
Image Compression
Fundamentals: Coding redundancy
To code an MxN image requires MNLavg bits
If m-bit natural binary code is used to represent the the gray levels, then
1
0
L
kkkavg rprlL
mrmprprlLL
kk
L
kkkavg
1
0
1
0
![Page 6: Image Compression](https://reader035.vdocuments.net/reader035/viewer/2022062517/56813b6d550346895da472ca/html5/thumbnails/6.jpg)
G52IIP, School of Computer Science, University of Nottingham
6
Image Compression
Fundamentals: Coding redundancy Variable length Coding: assign fewer bits to
the more probable gray levels than to less probable ones can achieve data compression
![Page 7: Image Compression](https://reader035.vdocuments.net/reader035/viewer/2022062517/56813b6d550346895da472ca/html5/thumbnails/7.jpg)
G52IIP, School of Computer Science, University of Nottingham
7
Image Compression
Fundamentals: Interpixel (spatial) redundancy
neighboring pixels have similar values
Binary imagesGray scale image (later)
![Page 8: Image Compression](https://reader035.vdocuments.net/reader035/viewer/2022062517/56813b6d550346895da472ca/html5/thumbnails/8.jpg)
G52IIP, School of Computer Science, University of Nottingham
8
Image Compression
Fundamentals: Interpixel (spatial) redundancy: Binary imagesRun-length coding
Mapping the pixels along each scan line into a sequence of pairs (g1, r1), (g2, r2), …,
Where gi is the ith gray level, ri is the run length of ith run
![Page 9: Image Compression](https://reader035.vdocuments.net/reader035/viewer/2022062517/56813b6d550346895da472ca/html5/thumbnails/9.jpg)
G52IIP, School of Computer Science, University of Nottingham
9
Image Compression
Example: Run-length coding
decode
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
123456
11
12
13
14
15
16
789
123456789
1 2 3 4 5 6 7 8 9 11 12 13 14 15 16
11
12
13
14
15
16
10
10 10
Row 1: (0, 16)Row 2: (0, 16)Row 3: (0, 7) (1, 2) (0, 7)Row 4: (0, 4), (1, 8) (0, 4)Row 5: (0, 3) (1, 2) (0, 6) (1, 3) (0, 2)Row 6: (0,2) (1, 2) (0,8) (1, 2) (0, 2)Row 7: (0, 2) (1,1) (0, 10) (1,1) (0, 2)Row 8: (1, 3) (0, 10) (1,3)Row 9: (1, 3) (0, 10) (1, 3)Row 10: (0,2) (1, 1) (0,10) (1, 1) (0, 2)Row 11: (0, 2) (1, 2) (0, 8) (1, 2) (0, 2)Row 12: (0, 3) (1, 2) (0, 6) (1, 3) (0, 2)Row 13: (0, 4) (1,8) (0, 4)Row 14: (0, 7) (1, 2) (0, 7)Row 15: (0, 16)Row 16: (0, 16)
encode
![Page 10: Image Compression](https://reader035.vdocuments.net/reader035/viewer/2022062517/56813b6d550346895da472ca/html5/thumbnails/10.jpg)
G52IIP, School of Computer Science, University of Nottingham
10
Image Compression
Fundamentals: Psychovisual redundancy
some color differences are imperceptible
![Page 11: Image Compression](https://reader035.vdocuments.net/reader035/viewer/2022062517/56813b6d550346895da472ca/html5/thumbnails/11.jpg)
G52IIP, School of Computer Science, University of Nottingham
11
Image Compression
Fidelity criteria
Root mean square error (erms) and signal to noise ratio (SNR):
Let f(x,y) be the input image, f’(x,y) be reconstructed input image from compressed bit stream, then
1
0
1
0
2
1
0
1
0
22/1
1
0
1
0
2
,,'
,'
,,'1
M
x
N
y
M
x
N
yM
x
N
yrms
yxfyxf
yxf
SNRyxfyxfMN
e
![Page 12: Image Compression](https://reader035.vdocuments.net/reader035/viewer/2022062517/56813b6d550346895da472ca/html5/thumbnails/12.jpg)
G52IIP, School of Computer Science, University of Nottingham
12
Image Compression
Fidelity criteria
erms and SNR are convenient objective measures
Most decompressed images are view by human beings
Subjective evaluation of compressed image quality by human observers are often more appropriate
![Page 13: Image Compression](https://reader035.vdocuments.net/reader035/viewer/2022062517/56813b6d550346895da472ca/html5/thumbnails/13.jpg)
G52IIP, School of Computer Science, University of Nottingham
13
Image Compression
Fidelity criteria
![Page 14: Image Compression](https://reader035.vdocuments.net/reader035/viewer/2022062517/56813b6d550346895da472ca/html5/thumbnails/14.jpg)
G52IIP, School of Computer Science, University of Nottingham
14
Image Compression
Image compression models
![Page 15: Image Compression](https://reader035.vdocuments.net/reader035/viewer/2022062517/56813b6d550346895da472ca/html5/thumbnails/15.jpg)
G52IIP, School of Computer Science, University of Nottingham
15
Image Compression
Exploiting Coding Redundancy
These methods, from information theory, are not limited to images, but apply to any digital information. So we speak of “symbols” instead of “pixel values” and “sources” instead of “images”.
The idea: instead of natural binary code, where each symbol is encoded with a fixed-length code word, exploit nonuniform probabilities of symbols (nonuniform histogram) and use a variable-length code.
![Page 16: Image Compression](https://reader035.vdocuments.net/reader035/viewer/2022062517/56813b6d550346895da472ca/html5/thumbnails/16.jpg)
G52IIP, School of Computer Science, University of Nottingham
16
Image Compression
Exploiting Coding Redundancy
Entropy
is a measure of the information content of a source.
If source is an independent random variable then you can’t compress to fewer than H bits per symbol.
Assign the more frequent symbols short bit strings and the less frequent symbols longer bit strings. Best compression when redundancy is high (entropy is low, histogram is highly skewed).
1
02 )(log)(
L
kkk rprpH
![Page 17: Image Compression](https://reader035.vdocuments.net/reader035/viewer/2022062517/56813b6d550346895da472ca/html5/thumbnails/17.jpg)
G52IIP, School of Computer Science, University of Nottingham
17
Image Compression
Exploiting Coding Redundancy
Two common methods
Huffman coding and, LZW coding
![Page 18: Image Compression](https://reader035.vdocuments.net/reader035/viewer/2022062517/56813b6d550346895da472ca/html5/thumbnails/18.jpg)
G52IIP, School of Computer Science, University of Nottingham
18
Image Compression
Exploiting Coding Redundancy
Huffman Coding
Codebook is precomputed and static. Compute probabilities of each symbol by histogramming
source. Process probabilities to precompute codebook: code(i). Encode source symbol-by-symbol: symbol(i) -> code(i). The need to preprocess the source before encoding begins
is a disadvantage of Huffman coding
![Page 19: Image Compression](https://reader035.vdocuments.net/reader035/viewer/2022062517/56813b6d550346895da472ca/html5/thumbnails/19.jpg)
G52IIP, School of Computer Science, University of Nottingham
19
Image Compression
Exploiting Coding Redundancy
Huffman Coding
![Page 20: Image Compression](https://reader035.vdocuments.net/reader035/viewer/2022062517/56813b6d550346895da472ca/html5/thumbnails/20.jpg)
G52IIP, School of Computer Science, University of Nottingham
20
Image Compression
Exploiting Coding Redundancy
Huffman Coding
![Page 21: Image Compression](https://reader035.vdocuments.net/reader035/viewer/2022062517/56813b6d550346895da472ca/html5/thumbnails/21.jpg)
G52IIP, School of Computer Science, University of Nottingham
21
Image Compression
Exploiting Coding Redundancy
Huffman Coding
Average length of the code is 2.2.bits/symbol The entropy of the source is 2.14 bits/symbol
![Page 22: Image Compression](https://reader035.vdocuments.net/reader035/viewer/2022062517/56813b6d550346895da472ca/html5/thumbnails/22.jpg)
G52IIP, School of Computer Science, University of Nottingham
22
Image Compression
Exploiting Coding Redundancy
Huffman Coding
![Page 23: Image Compression](https://reader035.vdocuments.net/reader035/viewer/2022062517/56813b6d550346895da472ca/html5/thumbnails/23.jpg)
G52IIP, School of Computer Science, University of Nottingham
23
Image Compression
Exploiting Spatial/Interpixel Redundancy
Predictive Coding Image pixels are highly correlated (dependent) Predict the image pixels to be coded from those
already coded
![Page 24: Image Compression](https://reader035.vdocuments.net/reader035/viewer/2022062517/56813b6d550346895da472ca/html5/thumbnails/24.jpg)
G52IIP, School of Computer Science, University of Nottingham
24
Image Compression
Exploiting Spatial/Interpixel Redundancy
Predictive Coding Differential Pulse-Code Modulation (DPCM) Simplest form: code the difference between pixels
Original pixels:82, 83, 86, 88, 56, 55, 56, 60, 58,
55, 50, ……
DPCM:82, 1, 3, 2, -32, -1, 1, 4, -2, -3, -
5, ……
![Page 25: Image Compression](https://reader035.vdocuments.net/reader035/viewer/2022062517/56813b6d550346895da472ca/html5/thumbnails/25.jpg)
G52IIP, School of Computer Science, University of Nottingham
25
Image Compression
Exploiting Spatial/Interpixel Redundancy
Predictive Coding Key features: Invertible, and lower entropy (why?)
H I(k) HD(k)
high entropy image reduced entropy imageK-10 K-11-K
image histogram (high entropy)
DPCM histogram (low entropy)
![Page 26: Image Compression](https://reader035.vdocuments.net/reader035/viewer/2022062517/56813b6d550346895da472ca/html5/thumbnails/26.jpg)
G52IIP, School of Computer Science, University of Nottingham
26
Image Compression
Exploiting Spatial/Interpixel Redundancy
Higher Order (Pattern) Prediction Use both 1D and 2D patterns for prediction
1D Causal:
1D Non-causal:
2D Causal:
2D Non-Causal:
![Page 27: Image Compression](https://reader035.vdocuments.net/reader035/viewer/2022062517/56813b6d550346895da472ca/html5/thumbnails/27.jpg)
G52IIP, School of Computer Science, University of Nottingham
27
Image Compression
Exploiting Spatial/Interpixel Redundancy
2D Causal:
![Page 28: Image Compression](https://reader035.vdocuments.net/reader035/viewer/2022062517/56813b6d550346895da472ca/html5/thumbnails/28.jpg)
G52IIP, School of Computer Science, University of Nottingham
28
Image Compression
Quantization
Quantization: Widely Used in Lossy Compression
Represent certain image components with fewer bits (compression)
With unavoidable distortions (lossy)
Quantizer Design Find the best tradeoff between
maximal compression minimal distortion
![Page 29: Image Compression](https://reader035.vdocuments.net/reader035/viewer/2022062517/56813b6d550346895da472ca/html5/thumbnails/29.jpg)
G52IIP, School of Computer Science, University of Nottingham
29
Image Compression
Quantization
Scalar quantization
24 408 ... 248
21 3 4
Uniform scalar quantization:
Non-uniform scalar
quantization:
![Page 30: Image Compression](https://reader035.vdocuments.net/reader035/viewer/2022062517/56813b6d550346895da472ca/html5/thumbnails/30.jpg)
G52IIP, School of Computer Science, University of Nottingham
30
Image Compression
Quantization
Scalar quantization
![Page 31: Image Compression](https://reader035.vdocuments.net/reader035/viewer/2022062517/56813b6d550346895da472ca/html5/thumbnails/31.jpg)
G52IIP, School of Computer Science, University of Nottingham
31
Image Compression
Quantization
Vector quantization and palletized images (gif format)
![Page 32: Image Compression](https://reader035.vdocuments.net/reader035/viewer/2022062517/56813b6d550346895da472ca/html5/thumbnails/32.jpg)
G52IIP, School of Computer Science, University of Nottingham
32
Image Compression
Palletized color image (gif) A true colour image – 24bits/pixel, R – 8 bits, G – 8 bits, B –
8 bits
A gif image - 8bits/pixel
1677216 possible colours
256 possible colours
![Page 33: Image Compression](https://reader035.vdocuments.net/reader035/viewer/2022062517/56813b6d550346895da472ca/html5/thumbnails/33.jpg)
G52IIP, School of Computer Science, University of Nottingham
33
Image Compression
Palletized color image (gif) A true colour image – 24bits/pixel, R – 8 bits, G – 8 bits, B –
8 bits
A gif image - 8bits/pixel
1677216 possible colours
256 possible colours
Exploits psychovisua
l redundancy
![Page 34: Image Compression](https://reader035.vdocuments.net/reader035/viewer/2022062517/56813b6d550346895da472ca/html5/thumbnails/34.jpg)
G52IIP, School of Computer Science, University of Nottingham
34
Image Compression
Palletized color image (gif)
r0 g0 b0
r1 g1 b1
r255 g255 b255
(r, g, b)
Colour Table
For each pixel in the original image
Find the closest colour in the Colour Table
Record the index of that colour (for storage or transmission)
To reconstruct the image, place the indexed colour from the Colour Table at the corresponding spatial location
![Page 35: Image Compression](https://reader035.vdocuments.net/reader035/viewer/2022062517/56813b6d550346895da472ca/html5/thumbnails/35.jpg)
G52IIP, School of Computer Science, University of Nottingham
35
Image Compression
Palletized color image (gif)
r0 g0 b0
r1 g1 b1
r255 g255 b255
(r, g, b)
Colour Table
For each pixel in the original image
Find the closest colour in the Colour Table
Record the index of that colour (for storage or transmission)
To reconstruct the image, place the indexed colour from the Colour Table at the corresponding spatial location
How to choose the colours in the table/pallet?
![Page 36: Image Compression](https://reader035.vdocuments.net/reader035/viewer/2022062517/56813b6d550346895da472ca/html5/thumbnails/36.jpg)
G52IIP, School of Computer Science, University of Nottingham
36
Image Compression
Construct the pallet (vector quantization, k-means algorithm)
(r, g, b)
R
G
B
A pixel corresponding toA point in the 3 dimensional R, G, B space
![Page 37: Image Compression](https://reader035.vdocuments.net/reader035/viewer/2022062517/56813b6d550346895da472ca/html5/thumbnails/37.jpg)
G52IIP, School of Computer Science, University of Nottingham
37
Image Compression
Construct the pallet (vector quantization, k-means algorithm)
R
G
B
Map all pixels into the R, G, B space, “clouds” of pixels are formed
![Page 38: Image Compression](https://reader035.vdocuments.net/reader035/viewer/2022062517/56813b6d550346895da472ca/html5/thumbnails/38.jpg)
G52IIP, School of Computer Science, University of Nottingham
38
Image Compression
Construct the pallet (vector quantization, k-means algorithm)
R
G
BGroup pixels that are close to each other, and replace them by one single colour
![Page 39: Image Compression](https://reader035.vdocuments.net/reader035/viewer/2022062517/56813b6d550346895da472ca/html5/thumbnails/39.jpg)
G52IIP, School of Computer Science, University of Nottingham
39
Image Compression
R
G
Br0 g0 b0
r1 g1 b1
r255 g255 b255
Colour Table
Representative colours placed in the colour table
![Page 40: Image Compression](https://reader035.vdocuments.net/reader035/viewer/2022062517/56813b6d550346895da472ca/html5/thumbnails/40.jpg)
G52IIP, School of Computer Science, University of Nottingham
40
Image Compression
Discrete Cosine Transform (DCT) 2D-DCT
Inverse 2D-DCT
1
0
1
02 2
)12(cos
2
)12(cos),(
)()(4),(
N
m
N
n N
vn
N
umnmx
N
vCuCvuX
1
0
1
0 2
)12(cos
2
)12(cos),()()(),(
N
u
N
v N
vn
N
umvuXvCuCnmx
1,,11
02
1)(
Nu
uuC
where
![Page 41: Image Compression](https://reader035.vdocuments.net/reader035/viewer/2022062517/56813b6d550346895da472ca/html5/thumbnails/41.jpg)
G52IIP, School of Computer Science, University of Nottingham
41
Image Compression
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
2D-DCTimage block
DCT block
low frequenc
y
high frequenc
ylow
frequency
high frequency
DC component
![Page 42: Image Compression](https://reader035.vdocuments.net/reader035/viewer/2022062517/56813b6d550346895da472ca/html5/thumbnails/42.jpg)
G52IIP, School of Computer Science, University of Nottingham
42
JPEG Compression
Image
RG
B
YVU colorcoordinate
ChrominanceDownsampling(4:2:2 or 4:2:0)
8 X 8 FDCT
Quantizer
QuantizationTable
zigzag
DifferentialCoding
HuffmanEncoding
HuffmanEncoding
Bit-stream
DecodedImage
RG
B
ChrominanceUpsampling
(4:2:2 or 4:2:0)
8 X 8IDCT
YVU colorcoordinate
Dequantizer
QuantizationTable
De-zigzag
De-DC coding
HuffmanDecoding
HuffmanDecoding
Bit-stream
![Page 43: Image Compression](https://reader035.vdocuments.net/reader035/viewer/2022062517/56813b6d550346895da472ca/html5/thumbnails/43.jpg)
G52IIP, School of Computer Science, University of Nottingham
43
JPEG Compression
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
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
DCT
scalar quantization
zig-zag scan
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
8 x8x blocks
![Page 44: Image Compression](https://reader035.vdocuments.net/reader035/viewer/2022062517/56813b6d550346895da472ca/html5/thumbnails/44.jpg)
G52IIP, School of Computer Science, University of Nottingham
44
JPEG Compression
),(
),(),('
vuQ
vuXRoundvuX
X(u,v): original DCT coefficientX’(u,v): DCT coefficient after quantizationQ(u,v): quantization value
• The Baseline System – Quantization
![Page 45: Image Compression](https://reader035.vdocuments.net/reader035/viewer/2022062517/56813b6d550346895da472ca/html5/thumbnails/45.jpg)
G52IIP, School of Computer Science, University of Nottingham
45
JPEG Compression
Why quantization?
to achieve further compression by representing DCT coefficients with no greater precision than is necessary to achieve the desired image quality
Generally, the “high frequency coefficients” has larger quantization values
Quantization makes most coefficients to be zero, it makes the compression system efficient, but it’s the main source that make the system “lossy”
![Page 46: Image Compression](https://reader035.vdocuments.net/reader035/viewer/2022062517/56813b6d550346895da472ca/html5/thumbnails/46.jpg)
G52IIP, School of Computer Science, University of Nottingham
46
JPEG Compression
Quantization is the step where we actually throw away data.Luminance and Chrominance Quantization Table Smaller numbers in the upper left direction larger numbers in the lower right directionThe performance is close to the optimal condition
( , )( , )
( , )Quantization
F u vF u v round
Q u v
( , ) ( , ) ( , )deQ QuantizationF u v F u v Q u v
Quantization
Dequantization
![Page 47: Image Compression](https://reader035.vdocuments.net/reader035/viewer/2022062517/56813b6d550346895da472ca/html5/thumbnails/47.jpg)
G52IIP, School of Computer Science, University of Nottingham
47
JPEG Compression
( , )( , )
( , )Quantization
F u vF u v round
Q u v
( , ) ( , ) ( , )deQ QuantizationF u v F u v Q u v
Quantization
Dequantization
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
18 22 37 56 68 109 103 77
24 35 55 64 81 104 113 92
49 64 78 87 103 121 120 101
72 92 95 98 112 100 103 99
YQ
17 18 24 47 99 99 99 99
18 21 26 66 99 99 99 99
24 26 56 99 99 99 99 99
47 66 99 99 99 99 99 99
99 99 99 99 99 99 99 99
99 99 99 99 99 99 99 99
99 99 99 99 99 99 99 99
99 99 99 99 99 99 99 99
CQ
![Page 48: Image Compression](https://reader035.vdocuments.net/reader035/viewer/2022062517/56813b6d550346895da472ca/html5/thumbnails/48.jpg)
G52IIP, School of Computer Science, University of Nottingham
48
JPEG Compression
Exploiting Psychovisual Redundancy
Exploit variable sensitivity of humans to colors:
We’re more sensitive to differences between dark intensities than bright ones.
Encode log(intensity) instead of intensity.
We’re more sensitive to high spatial frequencies of green than red or blue.
Sample green at highest spatial frequency, blue at lowest.
We’re more sensitive to differences of intensity in green than red or blue.
Use variable quantization: devote most bits to green, fewest to blue.
![Page 49: Image Compression](https://reader035.vdocuments.net/reader035/viewer/2022062517/56813b6d550346895da472ca/html5/thumbnails/49.jpg)
G52IIP, School of Computer Science, University of Nottingham
49
JPEG Compression
Exploiting Psychovisual Redundancy
NTSC Video
Y bandlimited to 4.2 MHzI to 1.6 MHzQ to .6 MHz
![Page 50: Image Compression](https://reader035.vdocuments.net/reader035/viewer/2022062517/56813b6d550346895da472ca/html5/thumbnails/50.jpg)
G52IIP, School of Computer Science, University of Nottingham
50
JPEG Compression
Exploiting Psychovisual Redundancy
In JPEG and MPEG
Cb and Cr are sub-sampled