Image Compression
Image Compression
• Lossless
– No information loss
– Low compression ratios
• Lossy
– Information loss
– High compression ratios
compression
Compression ratio:
Relevant Data Redundancy
where
Example:
Types of Data Redundancy
L 1 L 1
Lavg E (l (rk )) l (rk ) P(l (rk )) l (rk ) P(rk ) bits/pixel
k 0 k 0
L=8
/pixel
L=8
/pixel
histograms
auto-correlation
f ( x) o g ( x) f ( x) g ( x a )da
auto-correlation: f(x)=g(x)
Interpixel redundancy (cont’d)
• Interpixel redundancy is typically addressed by applying
some transformation to the data first.
Grayscale threshold
thresholding
transformation 11 ……………0000……………………..11…..000…..
Binary
Original: 1024 bytes
Thresholded: 1024 bits
Psychovisual redundancy
• The human eye is more sensitive to lower frequencies than to
higher frequencies in the visual spectrum.
• Discard data that is perceptually insignificant.
Add a small
Example: random
represent number
to each pixel
pixels using prior to
fewer bits! quantization
CR=8/4 = 2:1
Data ≠ Information (revisited)
units of information!
using
data information
where:
Lavg = 8 bits/pixel
16
• How close is to ?
• Criteria
– Subjective: based on human observers.
– Objective: based on mathematically defined criteria.
Subjective Fidelity Criteria
Objective Fidelity Criteria
(Run-length encoding)
• Backward Pass
Assign code symbols going backwards
Huffman Coding (cont’d)
• Lavg assuming binary coding:
• No one-to-one correspondence:
(source symbols ↔ code words)
0 1
– A sub-interval of [0,1) is chosen to encode the first symbol α1 in the sequence
(based on P(α1)).
0 1
0 1
Subdivide [0,1)
based on P(αi)
Encode
α1 α2 α3 α3 α4
0.4 0.08
arithmetic code: 0.068 0.04
0.2
(can choose any number
within the final sub-interval)
α4 α4 α4 α4 α4
0.8 0.72 0.688 0.5856 0.57152
Decode 0.572
α3 α3 α3 α3 α3
α2 α2 α2 α2 α2 α3 α3 α1 α2 α4
0.2 0.48 0.592 0.5664 0.56768
• No one-to-one correspondence:
111110000001
(1,5) (0, 6) (1, 1)
aaabbbbbbcc (a,3) (b, 6) (c, 2)
• Each pair (symbol, count) can be thought as a “new” symbol
which can be encoded using, for example, Huffman coding.
Bit-plane coding
(addresses interpixel redundancy)
K-1 K-1
What transformations can be used?
Forward:
Inverse:
if u=0 if v=0
if u>0 if v>0
DCT – Basis Functions
Performed experiments
using a large number of
random images.
Entropy
encoder
Became an
international
image
compression
standard in
1992.
Entropy
decoder
JPEG - Steps
Cq(u,v)
C(u,v)
Quantization
6. Encode coefficients:
symbol_1 symbol_2
(SIZE) (AMPLITUDE)
We use
predictive
coding: 64x64 64x64
DC coefficients are
encoded similarly.
De-quantized coefficients
Quantized coefficients (multiply by Q(u,v))
Effect of Quantization:
homogeneous 8 x 8 block (cont’d)
Reconstructed
Original
Effect of Quantization:
non-homogeneous 8 x 8 block
Effect of Quantization:
non-homogeneous 8 x 8 block (cont’d)
De-quantized coefficients
Quantized coefficients (multiply by Q(u,v))
Effect of Quantization:
non-homogeneous 8 x 8 block (cont’d)
Reconstructed
Original
Case Study: Fingerprint Compression
No “blocky” artifacts.
WSQ Algorithm
• FBI’s target bit rate is around 0.75 bits per pixel (bpp)
• Main algorithms:
(1) Progressive spectral selection algorithm
(2) Progressive successive approximation algorithm
(3) Hybrid progressive algorithm
Progressive JPEG (cont’d)
Example:
Progressive JPEG (cont’d)
f2
NxN
Hierarchical JPEG (cont’d)
f4
N/4 x N/4
f2
down-sample
N/2 x N/2
up-sample
NxN
Quiz #7
• When: 12/11/2023
• What: Image Compression