Compression
Compression
Prepared by
T. RAVI KUMAR NAIDU
Image Compression
• The goal of image compression is to reduce the amount of
data required to represent a digital image.
Image Compression
Need For Image Compression
• Because much of this information is graphical or pictorial in
nature, the storage and communications requirements are
immense.
compression
Compression ratio:
Data Redundancy
• Let n1 and n2 denote the number of information carrying units
in two data sets that represent the same information
• The relative redundancy RD is define as :
1
RD 1
CR
where CR, commonly called the compression ratio, is
n1
CR
n2
Data Redundancy
• If n1 = n2 , CR = 1 and RD = 0 no redundancy
1. Coding Redundancy
2. Interpixel Redundancy
3. Psychovisual Redundancy
• P(rk): probability of rk
Example:
Coding Redundancy (cont’d)
• Case 2: l(rk) = variable length
variable length
• How close is to ?
• Criteria
– Subjective: based on human observers
[ f ( x, y) f ( x, y)]
x 0 y 0
The root-mean-square error averaged over the whole image is
1
erms [ f ( x, y ) f ( x, y )]2
MN
Objective Fidelity Criteria
• A closely related objective fidelity criterion is the mean square
signal to noise ratio of the compressed-decompressed image
M 1 N 1
x 0 y 0
f ( x, y ) 2
SNRms
M 1 N 1
[ f ( x
x 0 y 0
, y ) f ( x , y )] 2
Subjective vs Objective Fidelity Criteria
Compression
Error-Free Compression
Lossy Compression
(Loss-less)
Compression Types
Compression Types
Huffman Coding
(addresses coding redundancy)
g ( x, y, u, v) g1 ( x, u).g2 ( y, v)
g1 g2 g ( x, y, u, v) g1 ( x, u).g1 ( y, v)
Transform Coding ( Lossy Compression)
1 [bi ( x ) pi (u )bi ( y ) pi ( v )]
g ( x, y, u, v) h( x, y, u, v) (1) i0 ( N 2m )
N
bk(z) is the kth bit (from right to left) in the
binary representation of z.
Transform Coding ( Lossy Compression)
p0 (u ) bm1 (u )
p1 (u ) bm1 (u ) bm2 (u )
p2 (u ) bm2 (u ) bm3 (u )
pm1 (u ) b1 (u ) b0 (u )
Transform Coding ( Lossy Compression)
Discrete Cosine Transform (DCT):
g ( x, y , u , v ) h ( x, y , u , v )
(2 x 1)u (2 y 1)v
(u ) (v) cos cos
2N 2N
1
for u 0
where (u ) N
2
for u 1,2, , N 1
N
Dictionary-Based Compression
• The compression algorithms we studied so far use a statistical model
to encode single symbols
– Compression: Encode symbols into bit strings that use fewer bits.
• Dictionary-based algorithms do not encode single symbols as
variable-length bit strings; they encode variable-length strings of
symbols as single tokens
– The tokens form an index into a phrase dictionary
– If the tokens are smaller than the phrases they replace,
compression occurs.
• Dictionary-based compression is easier to understand because it uses
a strategy that programmers are familiar with-> using indexes into
databases to retrieve information from large amounts of storage.
– Telephone numbers
– Postal codes
44
Dictionary-Based Compression: Example
• Consider the Random House Dictionary of the English Language,
Second edition, Unabridged. Using this dictionary, the string:
A good example of how dictionary based compression works
can be coded as:
1/1 822/3 674/4 1343/60 928/75 550/32 173/46 421/2
• Coding:
– Uses the dictionary as a simple lookup table
– Each word is coded as x/y, where, x gives the page in the
dictionary and y gives the number of the word on that page.
– The dictionary has 2,200 pages with less than 256 entries per
page: Therefore x requires 12 bits and y requires 8 bits, i.e.,
20 bits per word (2.5 bytes per word).
– Using ASCII coding the above string requires 48 bytes,
whereas our encoding requires only 20 (<-2.5 * 8) bytes:
50% compression.
45
Dictionary-Based Compression
Dictionary-Based Compression
Dictionary-Based Compression
Dictionary-Based Decompression
Run-Length Coding (RLC)
• Run : the repetition of a symbol.
• Run-length: number of repeated symbols.
• Instead of encoding the consecutive symbols, it is
more efficient to encode the run-length and the value
that these consecutive symbols commonly share.
• Application:
– Adopted in JPEG (multi-level image coding)
– Binary document coding
– Adopted in facsimile coding standards: the CCITT
Recommendations T.4 and T.6.
Run-Length Coding (RLC)
Classification:
• RLC using only the horizontal correlation between pixels on the
same scan line is called 1-D RLC.
Software Research
Image Compression Standards
Binary Image Compression Standards
CCITT Group 3 and 4
They are designed as FAX coding methods.
The Group 3 applies a non-adaptive 1-D run length coding
and optionally 2-D manner.
Both standards use the same non-adaptive 2-D coding
approach, similar to RAC technique.
They sometime result in data expansion. Therefore, the
Joint Bi-level Imaging Group (JBIG), has adopted several
other binary compression standards, JBIG1 and JBIG2.
Image Compression Standards
• Continuous Tone Still Image Compression
Standards
• JPEG
• JPEG 2000
• Mixed Raster Content (MRC)
Software Research
Image Compression Standards
Continues Tone Still Image Comp.
What Is JPEG?
"Joint Photographic Expert Group". Voted as international
standard in 1992.
Temporal redundancy
Prediction along the motion trajectories (motion compensation
prediction)
Motion Estimation
The accuracy of motion estimation has a big influence on
coding efficiency.
Motion estimation is a very time-consuming work.
Some fast algorithms are needed.
Image Compression Standards
MPEG
Frame types
I frames: intra-picture
P frames: predicted picture
B frames: bidirectional predicted picture
Input
Frame 1 Frame 2 Frame 3 Frame 4 Frame 5 Frame 6 Frame 7
stream
MPEG
compression
Forward
prediction
Bidirectional
Example sequence transmitted as I P B B I B B prediction
Thank you!