Image Compression
Image Compression
• Lossless
– Information preserving
– Low compression ratios
• Lossy
– Information loss
– High compression ratios
compression
Compression ratio:
Relevant Data Redundancy
Example:
Types of Data Redundancy
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)
• To reduce interpixel redundancy, some transformation needs
to be applied on the data.
Grayscale threshold
thresholding
transformation 11 ……………0000……………………..11…..000…..
Add a small
Example: random
number
to each pixel
prior to
quantization
CR=8/4 = 2:1
Data ≠ Information (revisited)
units of information!
using
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:
α1 α2 α3 α3 α4
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.4 0.08
arithmetic code: 0.068 0.04
0.2
(can choose any number
within the final sub-interval)
• Huffman Code:
0100011001 (10 bits)
α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
0 0
1 1
… …
255 255
256 -
… …
511 -
LZW Coding – Main Idea
Example:
As the encoder examines the
39 39 126 126
image pixels, gray level
39 39 126 126
sequences that are not in the
39 39 126 126
dictionary are added to the
39 39 126 126
dictionary.
Dictionary Location Entry
0 0
1 1
- Is 39 in the dictionary……..Yes
. . - What about 39-39………….No
255 255
256 - 39-39
* Add 39-39 at location 256
511 -
39 39 126 126
CR = empty
repeat
P=next pixel
CS=CR + P
If CS is found:
(1) CR=CS
else:
(1) Add CS to D
(2) Output D(CR)
(3) CR=P
10 x 9 bits/symbol = 90 bits vs 16 x 8 bits/symbol = 128 bits
Decoding LZW
Forward:
Inverse:
if u=0 if v=0
if u>0 if v>0
DCT (cont’d)
Sub-images were
reconstructed
by truncating
50% of the
coefficients.
RMS error
Entropy
encoder
Became an
international
image
compression
standard in
1992.
Entropy
decoder
JPEG - Steps
Cq(u,v)
C(u,v)
Quantization
array
6. Encode coefficients:
symbol_1 symbol_2
(SIZE) (AMPLITUDE)
predictive
coding:
64x64 64x64
Note: If RUN-LENGTH > 15, use symbol (15,0) as many times as needed , e.g.,
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 (15, 0)(3, 2)(2)
AC Coefficient Encoding
Symbol_1 Symbol_2
(Variable Length Code (VLC) (Variable Length Integer (VLI)
pre-computed Huffman codes) pre-computed codes)
# bits
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
Error is low!
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
Error is high!
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:
Example
Progressive JPEG (cont’d)
Example:
Example
Example
after 0.9s after 1.6s
f4
N/4 x N/4
f2
down-sample
N/2 x N/2
up-sample
NxN
Problem 1
Problem 2
Problem 3
Quiz #7
• When: 12/6/2021 @ 1pm
• What: Image Compression
• Duration: 10 minutes