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
N x M image
rk: k-th gray level
Example: l(rk): # of bits for rk
P(rk): probability of rk
Example:
Coding Redundancy (cont’d)
• Case 2: l(rk) = variable length (code 2 – Huffman code)
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 kind of a
transformation must be applied on the data.
Example Additional savings using
run-length coding
Original
threshold
threshold
11 ……………0000……………………..11…..000…..
Binary image
(1+10) bits/pair
Psychovisual redundancy
• The human eye is more sensitive to the lower frequencies
than to the higher frequencies in the visual spectrum.
• Idea: discard data that is perceptually insignificant!
256 gray levels 16 gray levels 16 gray levels + random noise
C=8/4 = 2:1
Measuring Information
units of information!
using
units/pixel
Entropy:
(e.g., bits/pixel)
Redundancy
• Redundancy:
(data vs info)
where:
image
Entropy Estimation (cont’d)
• First order estimate of H:
R= 6.19 bits/pixel
Estimating Entropy (cont’d)
• Second order estimate of H:
– Use relative frequencies of pixel blocks :
image
Estimating Entropy (cont’d)
16
Differences in Entropy Estimates (cont’d)
Example (cont’d):
• How close is to ?
• Criteria
– Subjective: based on human observers
– Objective: 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:
• Main idea:
– Map a sequence of symbols to a number (arithmetic code) in
the interval [0, 1).
– Encoding the arithmetic code is more efficient.
α1 α2 α3 α3 α4
0 1
– A sub-interval of [0,1) is chosen to represent the first symbol (based on its
probability of occurrence).
0 1
– As more symbols are encoded, the sub-interval gets smaller and smaller.
0 1
– At the end, the symbol sequence is encoded by a number within the final
interval.
Example
Encode
α1 α 2 α 3 α 3 α 4
0.4
code: 0.068
0.2
(any number within sub-interval)
• Huffman Code:
0100011001 (10 bits)
α4
0.8 0.72 0.688 0.5856 0.57152
Decode 0.572
α3
0.4 0.56 0.624 0.5728 0.56896
α2 α3 α3 α1 α2 α 4
0.2 0.48 0.592 0.5664 0.56768
α1
0.0 0.4
0.56 0.56 0.5664
LZW Coding
(addresses interpixel redundancy)
Initial Dictionary
Dictionary Location Entry
0 0
1 1
. .
255 255
256 -
511 -
LZW Coding (cont’d)
Example:
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
* Add 39-39 at location 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
repeat
P=next pixel
CS=CR + P
If CS is found:
(1) No Output
(2) CR=CS
else:
(1) Output D(CR)
(2) Add CS to D
(3) CR=P 10 x 9 bits/symbol = 90 bits vs 16 x 8 bits/symbol = 128 bits
Decoding LZW
e.g., (0,1)(1,1)(0,1)(1,0)(0,2)(1,4)(0,2)
Bit-plane coding
(addresses interpixel redundancy)
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)
Using
8 x 8 sub-images
yields 64 coefficients
per sub-image.
Reconstructed images
by truncating
50% of the
coefficients
DFT
has n-point periodicity
DCT
has 2n-point periodicity
JPEG Compression
Entropy
encoder
Accepted as
an
international
image
compression
standard in
1992.
Entropy
decoder
JPEG - Steps
Quantization
JPEG Steps (cont’d)
6. Encode coefficients:
symbol_1 symbol_2
(SIZE) (AMPLITUDE)
predictive
coding:
# bits
DC coefficients
(1,4) (12) (111110110 1100) are encoded in a
VLC VLI similar way.
Final Symbol Sequence
What is the effect of the “Quality”
parameter?
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)
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)
Sequential
Progressive
Progressive JPEG (cont’d)
N/4 x N/4
N/2 x N/2
NxN