Title: IMAGE COMPRESSION
1IMAGE COMPRESSION
2OVERVIEW
- Introduction
- Lossless Compression techniques
- Lossy Image coding techniques
- Image Compression standards
3INTRODUCTION
- Digital Image processing creates significant
numbers of large files containing digital image
data -
- Why Compression ???
- Often these must be exchanged between different
users and systems
4PRIME TARGET
- Redundant and Irrelevant Information
- Compression techniques exploit inherent
redundancy and irrelevancy by transforming a data
file into a smaller file
5Classification
- Lossless compression
- lossless compression for legal and medical
documents, computer programs - exploit only data redundancy
- Lossy compression
- digital audio, image, video where some errors or
loss can be tolerated - exploit both data redundancy and irrelevant data
6Performance Measure
- Compression efficiency
- Complexity
- Distortion Measurement ( lossy algorithm)
7Lossless Compression Techniques
- Image can be recovered exactly upon decompression
- These algorithms fall into two broad categories
- Dictionary-based techniques
- Statistical methods
8DictionaryBased Techniques
- Generates a compressed file containing
fixed-length codes, representing a particular
sequence of bytes in the original file - Run-Length Encoding
- Simplest particularly for few gray levels
- In an image stored line by line, a series of
pixels having the same gray-level value is called
a run
9- Code can be stored specifying the value followed
by length of the run, rather than simply storing
the value many times over - WWWWWWWWWWWWBWWWWWWWWWWWWBBB
- 12WB12W3B
10- LZW (Lemple Ziv Welch) Encoding
- Like RLE, it effects compression by encoding
strings of characters - Unlike RLE, it builds up a table of strings and
their corresponding codes as it encodes the file
11LZW Example
12(No Transcript)
13Statistical Encoding Methods
- Generates a compressed file using variable length
codes, representing a particular sequence of
bytes in the original file - Huffman Coding
- It uses Binary encoding tree representing
commonly occurring values in few bits and less
commonly occurring values in more bits
14(No Transcript)
15(No Transcript)
16Lossy Compression algorithm
- Eliminates redundant as well as irrelevant
information - only an approximate reconstruction of the
original image is possible - Achieves higher compression ratios
17Vector Quantization
- Composed of two operations
- Encoder
- takes an input vector and outputs the index of
the codeword that offers the lowest distortion - Once the closest codeword is found, the index of
that codeword is sent - Decoder
- The decoder receives the index of the codeword,
and outputs the codeword
18(No Transcript)
19Codebook Design
- The algorithm
- Determine the number of code words, N, or the
size of the codebook - Select N code words at random, and let that be
the initial codebook (randomly chosen from the
set of input vectors) - Using the Euclidean distance measure, cluster the
vectors around each codeword ( by finding the
Euclidean distance between it and each
codeword, The input vector belongs to the cluster
of the codeword that yields the minimum distance
20- Compute the new set of code words. This is done
by obtaining the average of each cluster. Add
the component of each vector and divide by the
number of vectors in the cluster. - Repeat steps 3 and 4 until either the code words
don't change or the change in the code words is
small.
21Digital Image Compression Standards
22 JPEG
- Joint Photographic Experts Group
23JPEG cont.
- Work commenced in 1986
- International standard ISO/IEC 10918-1 and CCITT
Rec. T.81 in 1992 Widely used for image exchange,
WWW, and digital photography - Motion-JPEG is de facto standard for digital
video editing
24JPEG Modes
- Sequential DCT based mode
- Sequential lossless mode
- Progressive DCT based mode
- Hierarchical mode
25Steps in JPEG Baseline
26- The picture is divided in blocks of 8 x 8 pixels
- Each block is transformed into coordinates of the
discrete-cosine space, so each block of pixels is
represented by the amplitudes of 2D-Cosine waves
with different frequencies, with these amplitudes
forming a new block
27Discrete Cosine Transformation
- DCT converts the information from spatial domain
to frequency domain - Consider an unsorted list of 12 numbers between
0 and 3 -gt (2, 3, 1, 2, 2, 0, 1, 1, 0, 1, 0, 0).
Consider a transformation of the list involving
two steps - sort the list
- Count the frequency of occurrence of each of the
numbers - (4,4,3,1 ) spatial info lost, captured freq. info
28(No Transcript)
29Quantization
- To reduce number of bits per sample
- F(u,v) round(F(u,v)/q(u,v))
- Example 101101 45 (6 bits)
- Truncate to 4 bits 1011 11 ( 11 x 4 44)
3 bits 101 5 (8 x 5 40)
more bits we truncate the more precision
we lose - Quantization error is the main source of the
Lossy Compression - Uniform Quantization
- q(u,v) is a constant
- Non-uniform Quantization -- Quantization Tables
- Custom quantization tables can be put in
image/scan header - JPEG Standard defines two default quantization
tables, one each for luminance and chrominance
30Quantization cont
- These coefficients are weighted by a matrix, each
coefficient is divided by a number (weight)
specific for the coefficients position in the
block and then rounded to integer numbers (higher
frequencies are divided by a larger number) -
31Zig-Zag Scan
- why?-To group low frequency coefficients in top
of vector and high frequency coefficients at the
bottom - Maps 8 x 8 matrix to a 1 x 64 vector
32Zig-Zag Scan
8x8
. . .
1x64
33DPCM on DC Components
- The DC component value in each 8x8 block is large
and varies across blocks, but is often close to
that in the previous block. - Differential Pulse Code Modulation (DPCM) Encode
the difference between the current and previous
8x8 block. Remember, smaller number -gt fewer bits
3445
45
1x64
1x64
54
9
1x64
1x64
48
-6
1x64
1x64
. . .
. . .
32
12
1x64
1x64
36
4
1x64
1x64
35Entropy Coding DC Components
- DC components are differentially coded as
(SIZE,Value) - The code for a Value is derived from the
following table -
36Example If a DC component is 40 and the previous
DC component is 48. The difference is -8.
Therefore it is coded as 1010111 0111 The
value for representing 8 (see Size_and_Value
table) 101 The size from the same table reads
4. The corresponding code from the table at left
is 101.
37RLE on AC Components
- The 1x64 vectors have a lot of zeros in them,
more so towards the end of the vector - Higher entries in the vector capture higher
frequency (DCT) components which tend to capture
less of the content. - Could have been as a result of using a
quantization table - Encode a series of 0s as a (skip,value) pair,
where skip is the number of zeros and value is
the next non-zero component - Send (0,0) as end-of-block sentinel value
38Entropy Coding AC Components
- AC components (range 1023..1023) are coded as
(S1,S2 pairs) - S1 (RunLength/SIZE)
- RunLength The length of the consecutive zero
values 0..15 - SIZE The number of bits needed to code the next
nonzero AC components value. 0-A - (0,0) is the End_Of_Block for the 8x8 block.
- S1 is Huffman coded (see AC code table below)
- S2 (Value)
- Value Is the value of the AC component.(refer to
size_and_value table)
39Huffman Table for AC components
40Entropy Coding Example
40
12
0
0
0
0
0
0
- Consider encoding the AC components by arranging
them in a zig-zag order -gt 12,10, 1, -7 2 0s, -4,
56 zeros - 12 read as zero 0s,12 (0/4)12 ? 10111100
- 1011 The code for (0/4 from AC code table)
- 1100 The code for 12 from the Size_and_Value
table. - 10 (0/4)10 ? 10111010
- 1 (0/1)1 ? 001
- -7 (0/3)-7 ? 100000
- 2 0s, -4 (2/3)-4 ? 1111110111011
- 1111110111 The 10-bit code for 2/3
- 011 representation of 4 from Size_and_Value
table. - 56 0s (0,0) ? 1010 (Rest of the components are
zeros therefore we simply put the EOB to signify
this fact)
10
-7
-4
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
41JPEG Modes
- Sequential Mode
- Each image is encoded in a single left-to-right,
top-to-bottom scan. - The technique we have been discussing so far is
an example of such a mode, also referred to as
the Baseline Sequential Mode. - It supports only 8-bit images as opposed to
12-bit images as described before
42JPEG Modes
- Lossless Mode
- Truly lossless
- It is a predictive coding mechanism as opposed to
the baseline mechanism which is based on DCT and
quantization (the source of the loss).
43- Simple block diagram of the technique
Predictive Difference
Huffman EnCoder
Lossless Coding
44- Predictive Difference
- For each pixel a predictor (one of 7 possible) is
used that best predicts the value contained in
the pixel as a combination of up to 3 neighboring
pixels. - The difference between the predicted value and
the actual value (X)contained in the pixel is
used as the predictive difference to represent
the pixel. - The predictor along with the predictive
difference are encoded as the pixels content. - The series of pixel values are encoded using
huffman coding
45- The very first pixel in location (0, 0) will
always use itself - Pixels at the first row always use P1
- Pixels at the first column always use P2
- The best (of the 7) predictions is always chosen
for any pixel
C
B
A
X
46JPEG Modes
- Progressive Mode
- It allows a coarse version of an image to be
transmitted at a low rate, which is then
progressively improved over subsequent
transmissions.
47Progressive mode cont.
- Spectral Selection Sends DC component and first
few AC coefficients first, then gradually some
more ACs
Spectral Selection
First Scan
Second Scan
Third Scan
. .
Nth Scan
Image Pixels
48Progressive mode cont.
- Successive Approximation All the DCT components
are sent few bits at a time
Pixels ordered (zig-zag-wise)
LSB
MSB
7
6
5
4
0
3
2
1
. . .
One Pixel
First Scan
. . .
Second Scan
. . .
Third Scan
. .
. .
. . .
5th Scan
49Progressive mode cont..
- example send n1 (say 4) bits (starting with
MSB) of all pixels in the first scan, the next
n2(say 1) bits of all pixels in the second and so
on
50Hierarchical Mode
- Used primarily to support multiple resolutions of
the same image which can be chosen from depending
on the targets capabilities
513-level Hierarchical Encoder
L4
I4
4x4
Encode
Decode
I4
Decode
2x2
-
L2
I2
2x2
Decode
Encode
Decode
L1
-
I
I
Encode
Decode
52JPEG 2000
- Features
- Improved compression efficiency (vs. JPEG)
- Highly scalable embedded data streams
- Progressive lossy to lossless compression
within a single data stream - Arbitrarily crop images in the compressed domain
- Selectively enhance quality of spatial regions
of interest - Support for very large images
53JPEG 2000 Compression
54Comparision JPEG vs JPEG 2000
55Comparision JPEG vs JPEG 2000
56HD PHOTO
- Gives a high-dynamic-range image encoding while
requiring only integer operations (with no
divides) - Preferred image format for MS xps and vista
- Microsoft claims that HD Photo offers a
perceptible image quality comparable to JPEG 2000 - computational and memory performance closely
comparable to JPEG - delivers a lossy compressed image of better
perceptive quality than JPEG at less than half
the file size - lossless compression compresses images 2.5
times.
57Motion JPEG
- It is a video codec where each video field
(frame) is separately compressed into a JPEG
image - resulting quality of video compression is
independent from the motion in the image (which
differs from MPEG video where quality often
decreases when footage contains lots of movement)
58- Characteristics of M-JPEG
- At low bandwidth availability, priority is given
to image resolution (i.e. transmitted images
would maintain their quality, however some images
would be dropped) - Images have a consistent file size
- Still the most widespread picture compression
format used today
59MPEG
- "Moving Picture Coding Experts Group", standards
body for delivery of video and audio. - MPEG-1 Target VHS quality on a CD-ROM or Video
CD (VCD) (352 x 240 CD audio _at_ 1.5 Mbits/sec) - MPEG-2 allows different levels and profiles
- Both standards have four parts
- Video Defines the video compression decoder
- Audio Defines the audio compression decoder
- System Describes how various streams(video,
audio or generic data) are multiplexed and
synchronized. - Conformance Defines a set of tests designed to
aid in establishing that particular
implementations conform to the design.
60MPEG cont..
- Each picture is divided into macroblocks of 16 X
16 pixels. - Macroblocks are intracoded for I frames and
predictive coded or intracoded for P and B frames - Macroblocks are divided into six blocks of 8 X 8
pixels (4 luminance and 2 chrominance) and DCT is
applied to each block and transform coefficients
are quantized and zig-zag scanned and
variable-length coded.
61MPEG cont.
- Some macroblocks need information that is not
present in the previous reference frame. - Maybe, such information is available in a
succeeding frame! - Add a third frame type (B-frame) To form a
B-frame, search for matching macroblocks in both
past and future frames - Typical pattern is IBBPBBPBB IBBPBBPBB IBBPBBPBB
Actual pattern is up to encoder, and need not be
regular
62Bitstream Order Vs Display Order
- Bitstream (Transmit) order 1(I), 4(P), 2(B),
3(B), 7(P), 5(B), 6(B), 10(I), 8(B), 9(B)
I
P
B
B
P
B
B
I
B
B
B
B
P
B
1
4
2
3
7
5
6
10
8
9
-2
-1
-3
11
63Frame and Macroblock Prediction Types
- Anchor frame A frame that can be used for
prediction - We now discuss the various frame types and
Macroblock types
64MPEG Notation
- Though the standard does not dictate this, the
pattern (order) of frames are commonly referred
by the following notation (N,M) where - N is the number of frames from one
I-frame(inclusive) to the next (exclusive). - M is the number of frames from one
anchor(inclusive) to the next(exclusive).
65MPEG2
- MPEG-2 is a standard for digital TV. It meets
the requirements for HDTV and DVD (Digital
Video/Versatile Disc) - MPEG2 Supports the following levels
66MPEG4
- Originally targeted at very low bit-rate
communication (4.8 to 64 Kb/sec), it now aims at
the following ranges of bit-rates - video -- 5 Kb to 5 Mb per second
- audio -- 2 Kb to 64 Kb per second
- It emphasizes the concept of Visual Objects --gt
Video Object Plane (VOP) - Objects can be of arbitrary shape, VOPs can be
non-overlapped or overlapped - Supports content-based scalability
- Supports object-based interactivity
- Individual audio channels can be associated with
objects - Good for video composition, segmentation, and
compression networked VRML, audiovisual
communication systems (e.g., text-to-speech
interface, facial animation), etc. - Standards being developed for shape coding,
motion coding, texture coding, etc.
67CONCLUSION
- Why compression
- Performance issues
- Lossless compression techniques
- Run Length Encoding, LZW Encoding
- Lossy compression techniques
- Vector Quantization
- Compression standards
- JPEG, MPEG
68READING
- Digital Image Compression Algorithms and
Standards By Weidong Kou - Digital Image processing- By Kenneth Castleman
- Gregory K Wallace The JPEG still picture
compression standard 1991 - http//www.onssi.com/downloads/OnSSI_WP_compressio
n_techniques.pdf