Image Compression
Presented By
Dr. R. K. Karsh
Assistant Professor
Department of Electronics and Communication Engineering
National Institute of Technology Silchar
Image compression
psychovisual
Image Compression
• The goal of image compression is to reduce the amount
of data required to represent a digital image.
Data ≠ Information
• Data and information are not synonymous terms!
• Data is the means by which information is conveyed.
• Data compression aims to reduce the amount of data
while preserving as much information as possible.
Compression Ratio
compression
Compression ratio:
Relevant Data Redundancy
Example:
Coding - Definitions
• Code: a list of symbols (letters, numbers, bits etc.)
• Code word: a sequence of symbols used to represent
some information (e.g., gray levels).
• Code word length: number of symbols in a code word.
Image Compression (cont’d)
• Lossless
– Information preserving
– Low compression ratios
• Lossy
– Not information preserving
– High compression ratios
Trade-off: information loss vs compression ratio
Measuring Information
• A key question in image compression is:
“What is the minimum amount of data that is
sufficient to describe completely an image
without loss of information?”
• How do we measure the information content of an
image?
Measuring Information (cont’d)
• We assume that information generation is a
probabilistic process.
• Idea: associate information with probability!
A random event E with probability P(E) contains:
Note: I(E)=0 when P(E)=1
How much information does a pixel contain?
• Suppose that gray level values are generated by a
random process, then rk contains:
units of information!
(assume statistically independent random events)
How much information does an image contain?
• Average information content of an image:
L −1
E = I (rk ) P( rk )
k =0
using
units/pixel
Entropy:
(e.g., bits/pixel)
Redundancy - revisited
• Redundancy:
where:
Note: if Lavg= H, then R=0 (no redundancy)
Image Compression Model
We will focus on the Source Encoder/Decoder only.
Image Compression Model (cont’d)
• Mapper: transforms data to account for interpixel redundancies.
Image Compression Model (cont’d)
• Quantizer: quantizes the data to account for psychovisual
redundancies.
Image Compression Model (cont’d)
• Symbol encoder: encodes the data to account for coding
redundancies.
Image Compression Models (cont’d)
• The decoder applies the inverse steps.
• Note that quantization is irreversible in general.
Fidelity Criteria
• How close is to ?
• Criteria
– Subjective: based on human observers
– Objective: mathematically defined criteria
Lossless Compression
Taxonomy of Lossless Methods
Huffman Coding
(addresses coding redundancy)
• A variable-length coding technique.
• Source symbols are encoded one at a time!
– There is a one-to-one correspondence between source
symbols and code words.
• Optimal code - minimizes code word length per
source symbol.
Huffman Coding (cont’d)
• Forward Pass
1. Sort probabilities per symbol
2. Combine the lowest two probabilities
3. Repeat Step2 until only two probabilities remain.
Huffman Coding (cont’d)
• Backward Pass
Assign code symbols going backwards
Huffman Coding (cont’d)
• Lavg assuming Huffman coding:
• Lavg assuming binary coding:
Huffman Coding/Decoding
• Coding/Decoding can be implemented using a look-up
table.
• Decoding can be done unambiguously.
Lossy Compression
• Transform the image into some other domain to reduce
interpixel redundancy.
~ (N/n)2 subimages
Lossy Methods - Taxonomy
DCT (Discrete Cosine Transform)
Forward:
Inverse:
if u=0 if v=0
if u>0 if v>0
DCT (cont’d)
• Basis functions for a 4x4 image (i.e., cosines of
different frequencies).
DCT (cont’d)
Using DFT WHT DCT
8 x 8 sub-images
yields 64 coefficients
per sub-image.
Reconstructed images
by truncating
50% of the
coefficients
More compact
transformation
RMS error: 2.32 1.78 1.13
DCT (cont’d)
• Sub-image size selection:
Reconstructions
original 2 x 2 sub-images 4 x 4 sub-images 8 x 8 sub-images
DCT (cont’d)
• DCT minimizes "blocking artifacts" (i.e., boundaries
between subimages do not become very visible).
DFT
has n-point periodicity
DCT
has 2n-point periodicity
Image coding standards
JPEG Compression
Entropy
encoder
Accepted
as an
internatio
nal image
compressi
on
standard
in 1992. Entropy
decoder
JPEG - Steps
1. Divide image into 8x8 subimages.
For each subimage do:
2. Shift the gray-levels in the range [-128, 127]
3. Apply DCT → 64 coefficients
1 DC coefficient: F(0,0)
63 AC coefficients: F(u,v)
Example
[-128, 127] (non-centered
spectrum)
JPEG Steps
4. Quantize the coefficients (i.e., reduce the amplitude of
coefficients that do not contribute a lot).
Q(u,v): quantization table
Example
• Quantization Table Q[i][j]
Example (cont’d)
Quantization
JPEG Steps (cont’d)
5. Order the coefficients using zig-zag ordering
- Creates long runs of zeros (i.e., ideal for run-length encoding)
JPEG Steps (cont’d)
6. Encode coefficients:
6.1 Form “intermediate” symbol sequence.
6.2 Encode “intermediate” symbol sequence into
a binary sequence.
JPEG
JPEG Modes
• JPEG supports several different modes
– Sequential Mode
– Progressive Mode
– Hierarchical Mode
– Lossless Mode
• The default mode is “sequential”
– Image is encoded in a single scan (left-to-right, top-to-
bottom).
Progressive JPEG
• Image is encoded in multiple scans, in order to
produce a quick, rough decoded image when
transmission time is long.
Sequential
Progressive
Progressive JPEG (cont’d)
• Each scan encodes a subset of DCT coefficients.
• We’ll examine the following algorithms:
(1) Progressive spectral selection algorithm
(2) Progressive successive approximation algorithm
(3) Combined progressive algorithm
Progressive JPEG (cont’d)
(1) Progressive spectral selection algorithm
– Group DCT coefficients into several spectral bands
– Send low-frequency DCT coefficients first
– Send higher-frequency DCT coefficients next
Example
Progressive JPEG (cont’d)
(2) Progressive successive approximation algorithm
– Send all DCT coefficients but with lower precision.
– Refine DCT coefficients in later scans.
Example
Example
after 0.9s after 1.6s
after 3.6s after 7.0s
Progressive JPEG (cont’d)
(3) Combined progressive algorithm
– Combines spectral selection and successive approximation.
Hierarchical JPEG
• Hierarchical mode encodes the image at different
resolutions.
• Image is transmitted in multiple passes with increased
resolution at each pass.
Hierarchical JPEG (cont’d)
N/4 x N/4
N/2 x N/2
NxN