Image Compression (Chapter 8) : CS474/674 - Prof. Bebis
Image Compression (Chapter 8) : CS474/674 - Prof. Bebis
• Lossless
– Information preserving
– Low compression ratios
• Lossy
– Not information preserving
– High compression ratios
compression
Compression ratio:
Data Redundancy (cont’d)
Example:
Types of Data Redundancy
(1) Coding
(2) Interpixel
(3) Psychovisual
N x M image
rk: k-th gray level Expected value:
P(rk): probability of rk E ( X ) = ∑ xP( X = x)
x
l(rk): # of bits for rk
Coding Redundancy (con’d)
• l(rk) = constant length
Example:
Coding Redundancy (cont’d)
• l(rk) = variable length
• Consider the probability of the gray levels:
variable length
Interpixel redundancy
• Interpixel redundancy implies that any pixel value can be
reasonably predicted by its neighbors (i.e., correlated).
∞
f ( x) o g ( x) = ∫ f ( x) g ( x + a )da
−∞
autocorrelation: f(x)=g(x)
Interpixel redundancy (cont’d)
• To reduce interpixel redundnacy, the data must be
transformed in another format (i.e., through a transformation)
– e.g., thresholding, differences between adjacent pixels, DFT
original threshold
thresholded
(1+10) bits/pair
Psychovisual redundancy
• How close is to ?
• Criteria
– Subjective: based on human observers
– Objective: mathematically defined criteria
Subjective Fidelity Criteria
Objective Fidelity Criteria
• Backward Pass
Assign code symbols going backwards
Huffman Coding (cont’d)
• Lavg using Huffman coding:
Encode message: a1 a2 a3 a3 a4
0 1
Encode
a1 a2 a3 a3 a4
[0.06752, 0.0688)
or,
0.068
Example
a4
0.8 0.72 0.688 0.5856 0.57152
Decode 0.572
a3
0.4 0.56 0.624 0.5728 056896
a2
a3 a3 a1 a2 a4
0.2 0.48 0.592 0.5664 0.56768
a1
0.0 0.4
0.56 0.56 0.5664
LZW Coding (interpixel redundancy)
Initial Dictionary
Consider a 4x4, 8 bit image Dictionary Location Entry
39 39 126 126 0 0
39 39 126 126 1 1
. .
39 39 126 126 255 255
39 39 126 126 256 -
511 -
LZW Coding (cont’d)
As the encoder examines image
39 39 126 126 pixels, gray level sequences
39 39 126 126 (i.e., blocks) that are not in the
39 39 126 126 dictionary are assigned to a new
39 39 126 126 entry.
Dictionary Location Entry
0 0
1 1
- Is 39 in the dictionary……..Yes
. . - What about 39-39………….No
255 255
256 - 39-39
- Then add 39-39 in entry 256
511 -
Example
39 39 126 126 Concatenated Sequence: CS = CR + P
39 39 126 126
(CR) (P)
39 39 126 126
39 39 126 126
CR = empty
If CS is found:
(1) No Output
(2) CR=CS
else:
(1) Output D(CR)
(2) Add CS to D
(3) CR=P
Decoding LZW
e.g., (0,1)(1,1)(0,1)(1,0)(0,2)(1,4)(0,2)
Lossy Compression
• Transform the image into a domain where compression
can be performed more efficiently (i.e., reduce interpixel
redundancies).
~ (N/n)2 subimages
Example: Fourier Transform
K << N
K-1 K-1
Transform Selection
forward
inverse
if u=0 if v=0
if u>0 if v>0
DCT (cont’d)
64 coefficients
per subimage
50% of the
coefficients
truncated
DFT
i.e., n-point periodicity
gives rise to
discontinuities!
DCT
i.e., 2n-point periodicity
prevents
discontinuities!
DCT (cont’d)
• Modes of operation:
(1) Sequential DCT-based encoding
(2) Progressive DCT-based encoding
(3) Lossless encoding
(4) Hierarchical encoding
JPEG Compression
(Sequential DCT-based encoding)
Entropy
encoder
Entropy
decoder
JPEG Steps
(i.e., non-centered
spectrum)
JPEG Steps
Quantization
JPEG Steps (cont’d)
DC
0 0 0 0 0 0 476
(6,9)(476)
= [-210, 210-1]
1 ≤SIZE≤10
If RUN-LENGTH > 15, use symbol (15,0) , i.e., RUN-LENGTH=16
Entropy Encoding (e.g, variable length)
Entropy Encoding (e.g, Huffman)
Symbol_1 Symbol_2
(Variable Length Code (VLC)) (Variable Length Integer (VLI))
xm dm Entropy
Encoder
Predictor
pm
Lossy Differential Pulse Code
Modulation (DPCM) Coding
• Similar to lossless DPCM except that (i) it uses
quantization and (ii) the pixels are predicted from the
“reconstructed” values of certain neighbors.