Fundamentals of Image Compression PDF
Fundamentals of Image Compression PDF
01101…
Compression Decompression
(encoding) (decoding)
Compressed
File
Original Decompressed
uncompressed Image
Image
Image/Video
Image/Video
Compression
Compression
Predictive
Predictive Transform
Transform Importance
Importance Hybrid
Hybrid
Coding
Coding Coding
Coding Oriented
Oriented Coding
Coding Coding
Coding
Delta
Delta modulation
modulation DCT
DCT Bit
Bit allocation
allocation JPEG
JPEG
DPCM
DPCM KL
KL Sub-sampling
Sub-sampling H.26X
H.26X
ME/MC
ME/MC Subband
Subband Quantization
Quantization MPEG-X
MPEG-X
Wavelet
Wavelet
Scalar
Scalar Vector
Vector
…
Requantization
Requantization – the process of limiting the value of a function
at any sample to one of a predetermined number of permissible
values
A general usage or gray-scale reduction is to reduce the number
of bits per pixel (bpp)
• False contouring – as the number of gray levels decreases,
false edges or lines will appear in the image
• The false contouring effect can be visually improved upon
by using an IGS (Improved Gray-Scale) quantization –
adding a small random number to each pixel before
quantization
Requantization (cont.)
Types of Quantizer
• Scalar Quantizers
» Uniform Scalar Quantizer
» Non-uniform Scalar Quantizer
» The Lloyd-Max Quantizer
» Entropy-constrained Quantizer
• Vector Quantizer
Idea - the quantization levels are finely spaced in the range that
gray levels occur frequently, while coarsely spaced outside of it
Optimal quantization
• A quantization function can be regarded as a staircase, in
which si is called decision levels and ti reconstruction levels
• s is mapped to ti if it lies in the half-open interval (si -1, si]
⎧0 i=0
⎪
si = ⎨(ti + ti +1 )/2 i = 1, 2, . . ., L/2 − 1
⎪∞ i = L/2
and ⎩
s-i = -si, t-i = -ti
» Each ti is the centroid of the area under p(s) over two si
» si is halfway between two ti
20 Fundamentals of Image Compression
Entropy-constrained Quantizers
Color Quantization
Interpolation
256 × 256
23 256 × 256 Fundamentals of Image Compression
Fidelity Criteria
Objective criteria
• root-mean-square (rms) error: eRMS
M −1 N −1
1
e RMS =
MN
∑ ∑ [ Iˆ ( r, c ) − I ( r, c )]
r =0 c =0
2
M −1 N −1
∑∑ Iˆ(r , c) 2
SNR RMS = r =0 c =0
M −1 N −1
∑∑ [ Iˆ(r , c) − I (r , c)]
r =0 c =0
2
( L − 1) 2
SNR PEAK = 10 log10
1 M −1 N −1 ˆ
∑∑
MN r =0 c =0
[ I (r , c) − I (r , c)]2
010010…
Î(r, c) Postprocessing Decoder
Decompression
(decoding)
The encoder removes input redundancies (interpixel,
psychovisual, and coding redundancy)
29 Fundamentals of Image Compression
encoder Compressed
File
Inverse Symbol
Î(r, c) mapper decoder
decoder
mapper - reduce interpixel redundancy, reversible (predictive
coding, run-length coding, Transform coding)
quantizer - reduce psychovisual redundancy, irreversible
(uniform quantization, nonuniform quantization)
symbol encoder - reduce coding redundancy, reversible
(Huffman coding, arithmetic coding, LZW)
30 Fundamentals of Image Compression
Predictive Coding
Predictive Coding
+ Bit
+ Quantization Allocation
–
+
Predictor +
+
Decoder
Compressed Symbol ên + În Decompressed
data ∑ data
decoder
+
Ĩn Predictor
33 Fundamentals of Image Compression
Predictor (cont.)
I(r-1 , c-1) I(r-1 , c) I(r-1 , c+1)
Examples:
• First-order predictor:
I(r , c-1) I(r , c)
Iˆ ( r , c ) = I ( r, c - 1)
• Second-order predictor:
Iˆ ( r , c ) = 1 / 2[ I ( r, c - 1) + I ( r - 1, c )]
• Third-order predictor:
» Iˆ ( r , c ) = I ( r, c - 1) - I ( r - 1, c - 1) + I ( r - 1, c )
In 3-D case, the prediction is based on the above pixels and the
previous pixels of preceding frames
{ }
m −1
(
i.e., σ e = E x m − x m
2
ˆ )2
= E ⎨⎜ x m − ∑ α i x i ⎟ ⎬
⎜ ⎟
⎪⎩ ⎝ i =0 ⎠ ⎪⎭
39 Fundamentals of Image Compression
DPCM (cont.)
[
∂E ( xm − xˆm )
2
]
∂αi
=
{
∂E [xm − (α0 x0 + α1 x1 + L + αm −1 xm −1 )]
2
}
∂αi
= -2 E [( xm − xˆm )xi ] = 0 i = 0 ,1,L , m-1 (1)
From (1) :
⎧ m −1 ⎫
E{xm xi } = E{xˆm xi } = E ⎨(∑ αi xi ) xi ⎬
⎩ i =0 ⎭
Rmi = E{ α0 x0 xi + α1 x1 xi + L + αm −1 xm −1 xi }
= α0 R0i + α1R1i + L + αm-1R(m −1 )i
i = 0 ,1,L, m-1 (2)
DPCM (cont.)
If xˆm is obtained by the predictor that uses the optimal
αi thus obtained, then
{
σ e2 = E ( xm − xˆ m ) 2 }
= E {( xm − xˆ m ) xm } -E {( xm − xˆ m ) xˆ m }
But E {( xm − xˆ m ) xˆ m } = 0 from Eq. (1) Thus,
σ e2 = E {( xm − xˆ m ) xm }
[ ]
= E xm2 - E [xˆ m xm ]
= Rmm − (α0 R0 m + α1 R1m + L + α m −1 Rm −1m ) (3)
DPCM (cont.)
Results (cont.)
Results (cont.)
Conclusions
Prediction
Lossless JPEG
0 No
1 A
2 B
前一行 .......... B C D ..........
3 C
.......... A X ... ..........
4 A+B-C
5 A-(B-C)/2
6 B-(A-C)/2
7 (A+B)/2
50 Fundamentals of Image Compression
Conclusions (cont.)
Post processor
• JPEG: transformed dc components
• MPEG-4: transformed dc, ac
Entropy Coding
Information Theory
Huffman Coding
Arithmetic Coding
Information Theory
Information theory provides the mathematical framework to
determine the minimum amount of data that is sufficient to
describe completely an image without loss of information
A event E that occurs with probability P(E) will contain
1
I ( E ) = log = − log P ( E )
P( E )
unit of information, I(E) is called the self-information of E
0.80
0.60
H(P)
0.40
0.20
0.00
Example:
Example :
s1 = 0 s1 = 0
s2 = 10 s2 = 01
s3 = 110 s3 = 011
s4 = 111 s4 = 111
instantaneous non-instantaneous
101100111- s2s3s1s4 011111111- s3s4s4
No code word si which is a prefix of another code word, sj
Example:
Huffman Coding
Encoding steps:
Initialization: Given the probability distribution of the source
symbols
Step 1: source reduction
» Order the probabilities of the source symbols
» Combine two lowest probability symbols into a single
symbol that replaces them in the next source reduction
Step 2: codeword construction
» Code each reduced source starting with the smallest
source and work back to the original source
n
H ( z ) = −∑ P(ai ) logP (ai )
i =1
L−1
Lavg = ∑l (ak ) p(ak )
k =0
Huffman coding
• encodes individual symbols
• relies heavily on accurate knowledge of symbol statistics
• disadvantage of Huffman coding – the length of Huffman
codes have to be an integer, while the entropy value of a
symbol may be a faction number
¾ Theoretical possible compressed message cannot be
achieved
For example, if p(s) = 0.9, then
I(s) = –log(0.9) = 0.15 bits
Arithmetic coding
• An entire sequence of symbols is assigned a single
arithmetic codeword
• The codeword defines an interval of real numbers between
0 and 1
• Theoretically achieve the maximum compression
Example: 1
?
Si Pi subinterval 0.90
k 0.05 [0.00,0.05) r
l 0.20 [0.05,0.25) 0.70
u 0.10 [0.25,0.35) e
w 0.05 [0.35,0.40) 0.40
e 0.30 [0.40,0.70) w
0.35
r 0.20 [0.70,0.90) u
0.25
? 0.10 [0.90,1.00)
l
Alphabet (k, l, u, w, e, r, ?) 0.05
? : end-of-message 0 k
r r r r r r r r
e e e e e e e e
w w w w w w w w
u u u u u u u u
l l l l l l l l
k k k k k k k k
0 .05 .06 .070 .0710 .07128 .071312 0.0713336
72 Fundamentals of Image Compression
Arithmetic Coding (cont.)
Encoding process
Low = 0.0 ; high =1.0 ;
while not EOF do
range = high - low ; read(c) ;
high = low + range×high_range(c) ;
low = low + range×low_range(c) ;
endofwhile
output(low);
Conclusions