National University of Sciences and
Technology (NUST)
School of Electrical Engineering and Computer Science
(SEECS)
Digital Image Processing
(EE-333)
1 Khawar Khurshid, 2012
Image
Compression
2 Khawar Khurshid, 2012
Motivation
• Storage needed for a two-hour standard television
movie (Color)
– Image size = 720 x 480 pixels
– Frame rate = 30 fps (frame per seconds)
frames pixels bytes
30 x (720 x 480) x3 = 31,104,000 bytes/sec
sec frame pixel
For 2 hour movie
bytes sec
31,104,000 x (602 ) x 2 hrs = 2.24 x 1011 bytes = 224 GB
sec hr
3 Khawar Khurshid, 2012
Image Compression
Principal objective
To minimize the number of bits required to represent an image
Applications
Transmission: Broadcast TV, remote sensing via satellite, military
communications via aircraft, radar and sonar, teleconferencing, computer
communications, …
Storage: Educational and business documents, medical images (CT, MRI
and digital radiology), motion pictures, satellite images, weather maps,
geological surveys, ...
4 Khawar Khurshid, 2012
Overview
• Image data compression methods fall into two common categories:
• Information preserving compression
– Especially for image archiving (storage of legal or medical
records)
– Compress and decompress images without losing information
• Lossy image compression
– Provide higher levels of data reduction
– Result in a less than perfect reproduction of the original image
5 Khawar Khurshid, 2012
Data vs. Information
• Data are the means to convey information; various amounts of data
may be used to represent the same amount of information
• Part of data may provide no relevant information: data redundancy
• Probability and Information
• Compression
– Reducing the amount of data to represent a given quantity of information
6
Khawar Khurshid, 2012
Relative Data Redundancy
• Let b and b’ refer to amounts of data in two data sets that
carry the same information
b
Compression Ratio (C )
b
1
Releative data redundancy (R ) 1
C
of the first dataset b
if b = b’, C = 1 and R = 0, relative to the second data set, the first set
contains no redundant data
if b >> b’, C ∞ and R 1, relative to the second data set, the first set
contains highly redundant data
if b << b’, C 0 and R -∞, relative to the second data set, the first set is
highly compressed
7
C = 10 means 90% of the data in the first data set is redundant
Khawar Khurshid, 2012
Data Redundancy
• Image compression techniques can be designed for
reducing or eliminating the data redundancy
• Three basic data redundancies
– Spatial and Temporal redundancy
– Coding redundancy
– Irrelevant information
8
Khawar Khurshid, 2012
Spatial Redundancy
• Image features
– All 256 gray levels are equally
probable uniform histogram
(variable length coding can not
be applied)
– The gray levels of each line are
selected randomly so pixels are
independent of one another in
A computer generated
vertical direction
(synthetic) 8-bit image
– Pixels along each line are M = N = 256
identical, they are completely
dependent on one another in
horizontal direction
Spatial redundancy
9
Khawar Khurshid, 2012
Spatial Redundancy
• The spatial redundancy can be eliminated by using run-length pairs (a
mapping scheme)
• Run length pairs has two parts
– Start of new intensity
– Number of consecutive pixels having that intensity
• Example (consider the image shown in previous slide)
– Each 256 pixel line of the original image is replaced by a single 8-bit
intensity value
– Length of consecutive pixels having the same intensity = 256
256 x 256 x 8
– Compression Ratio = 128
[256 256] x 8
10
Khawar Khurshid, 2012
Coding Redundancy
• A natural m-bit coding method assigns m-bit to each gray level without
considering the probability that gray level occurs
very likely to contain coding redundancy
• Basic concept?
– Utilize the probability of occurrence of each gray level (histogram) to
determine length of code representing that particular gray level:
variable-length coding
– Assign shorter code words to the gray levels that occur most
frequently or vice versa
11
Khawar Khurshid, 2012
Coding Redundancy
Let 0 rk 1: Gray levels (discrete random variable)
pr (rk ) :Propability of occurrence of rk
nk :Frequency of gray level rk
n :Total number of pixels in the image
L :Total number of gray level
l (rk ) :Number of bits used to represent rk
Lavg :Average length of code words assigned to gray levels
L 1
nk
Lavg l (rk ) pr (rk ) where pr (rk ) , k 0,1, 2, , L 1
k 0 n
Hence, the total number of bits required to code and MxN pixel image is MNLavg
For a natural m-bit coding Lavg= m
12
Khawar Khurshid, 2012
Coding Redundancy - Example
• Code 1: Natural code (m = 8) is used,
Lavg = 8 bits
• Code 2: Variable length code
Lavg = (0.25)2 + 0.47(1) + 0.25(3) + 0.03(3)
= 1.81 bits
256 x 256 x 8
• Compression Ratio = 4.42
A computer generated 256 x 256x1.81
(synthetic) 8-bit image
M = N = 256 • R = 1 – 1/4.42 = 0.774
13
Khawar Khurshid, 2012
Coding Redundancy – Example
• Code 1: Natural code (m = 8) is used,
Lavg = 8 bits
• Code 2: Variable length code
Lavg = (0.25)2 + 0.47(1) + 0.25(3) + 0.03(3)
= 1.81 bits
256 x 256 x 8
• Compression Ratio = 4.42
A computer generated 256 x 256x1.81
(synthetic) 8-bit image
M = N = 256
• R = 1 – 1/4.42 = 0.774
77.4% data in the image is redundant
14
Khawar Khurshid, 2012
Irrelevant Information
• The eye does not respond with equal
sensitivity to all visual information
A computer generated
(synthetic) 8-bit image
• Certain information has less relative M = N = 256
importance than other information in normal This image appears
homogeneous so we can
visual processing use its mean value to
encode this image
• The elimination of visually redundant data
results in a loss of quantitative information
lossy data compression method
• Quantization
Histogram of the image
15
Khawar Khurshid, 2012
Redundancy
• Coding redundancy
– Due to different occurrence rates
• Inter-pixel Redundancy
– Spatial Redundancy
• Psycho-visual redundancy
– Eye Response – Irrelevant Information
16
Khawar Khurshid, 2012
Redundancy
17 www.restructure.wordpress.com Khawar Khurshid, 2012
Redundancy - Recap
• Compression Ratio?
• Relative Redundancy?
18
Khawar Khurshid, 2012