You are on page 1of 38

Digital Image Processing, 2nd ed. www.imageprocessingbook.

com

Unit 5: Image Compression

•Fundamentals
•Redundancies
•Fidelity criteria
•Image Compression Models
•Error free compression
•Lossy Compression
•Image compression Standards :Binary Image &
continuous tone still image compression standards
•Video compression standards

© 2002 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 2nd ed. www.imageprocessingbook.com

Image Compression

© 2002 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 2nd ed. www.imageprocessingbook.com

Image Compression

© 2002 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 2nd ed. www.imageprocessingbook.com

Image Compression

© 2002 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 2nd ed. www.imageprocessingbook.com

Image Compression

© 2002 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 2nd ed. www.imageprocessingbook.com

EXAMPLE OF Psychovisal Redundancy

© 2002 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 2nd ed. www.imageprocessingbook.com

IGS quantization procedure

1. Set initial SUM = 0000 0000

2. if most significant 4 bits of current pixel A = 1111


new_SUM = A + 0000
else
new_SUM = A + least significant 4 bits of old SUM

© 2002 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 2nd ed. www.imageprocessingbook.com

IGS QUANTIZATION EXAMPLE

© 2002 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 2nd ed. www.imageprocessingbook.com

Fidelity criteria
Objective Fidelity criteria

© 2002 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 2nd ed. www.imageprocessingbook.com

Subjective Fidelity criteria

© 2002 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 2nd ed. www.imageprocessingbook.com

General Compression System Model

© 2002 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 2nd ed. www.imageprocessingbook.com

Chapter 8
Image Compression

© 2002 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 2nd ed. www.imageprocessingbook.com

ERROR FREE COMPRESSION

• Huffman Coding
• LZW Coding
• Bit Plane Coding
•Constant Area Coding
• Run length coding
•Lossless Predictive Coding

© 2002 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 2nd ed. www.imageprocessingbook.com

Chapter 8
Image Compression

Another Method
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. www.imageprocessingbook.com

Assignment :
Q1 Generate the IGS code for following gray level values
of pixels.

100,120,130,170,160,110

Q2 Generate Huffman code for certain message, The


frequency of occurrence of elements given below

A=20,B=30,C=10,D=0,E=10,F=20,G=10

© 2002 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 2nd ed. www.imageprocessingbook.com

LZW Coding

LZW (Lempel-Ziv-Welch) coding, assigns fixed-length


code words to variable length sequences of source
symbols, but requires no a priori knowledge of the
probability of the source symbols.

The nth extension of a source can be coded with fewer


average bits per symbol than the original source.

LZW is used in:


•Tagged Image file format (TIFF)
•Graphic interchange format (GIF)
Portable document format (PDF)
LZW was formulated in 1984
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. www.imageprocessingbook.com

LZW Coding

The Algorithm:
•A codebook or “dictionary” containing the source symbols
is constructed.

•For 8-bit monochrome images, the first 256 words of the


dictionary are assigned to the gray levels 0-255

•Remaining part of the dictionary is filled with sequences


of the gray levels

© 2002 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 2nd ed. www.imageprocessingbook.com

LZW Coding

Consider 4x4 , 8 Bit image:: 512 Word Dictionary


39 39 126 126 Dictionary Entry
Location
39 39 126 126
0 0
39 39 126 126
1 1
39 39 126 126 : :
255 255
256 --
: :
511 --

© 2002 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 2nd ed. www.imageprocessingbook.com

LZW Coding

© 2002 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 2nd ed. www.imageprocessingbook.com

Important features of LZW:


•The dictionary is created while the data are being encoded. So
encoding can be done “on the fly”

•The dictionary need not be transmitted. Dictionary can be built


up at receiving end “on the fly”

•If the dictionary “overflows” then we have to reinitialize the


dictionary and add a bit to each one of the code words.

•Choosing a large dictionary size avoids overflow, but spoils


compressions

© 2002 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 2nd ed. www.imageprocessingbook.com

Decoding LZW:
Let the bit stream received be:
39 39 126 126 256 258 260 259 257 126

In LZW, the dictionary which was used for encoding need not be
sent with the image. A separate dictionary is built by the
decoder, on the “fly”, as it reads the received code words.

© 2002 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 2nd ed. www.imageprocessingbook.com

Bit Plane Coding


An m-bit gray scale image can be converted into m binary images by
bit-plane slicing. These individual images are then encoded using run-
length coding.

However, a small difference in the gray level of adjacent pixels can


cause a disruption of the run of zeroes or ones.

Eg: Let us say one pixel has a gray level of 127 and the next pixel has
a gray level of 128.
In binary: 127 = 01111111
& 128 = 10000000
Therefore a small change in gray level has decreased the run-lengths in
all the bit-planes!
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. www.imageprocessingbook.com

GRAY CODE
•Gray coded images are free of this problem which
affects images which are in binary format.
• In gray code the representation of adjacent gray
levels will differ only in one bit (unlike binary
format where all the bits can change.

© 2002 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 2nd ed. www.imageprocessingbook.com

Let gm-1…….g1g0 represent the gray code representation of a


binary number.
Then:
g i  ai  ai 1 0i  m2
g m 1  am 1
In gray code:
127 = 01000000
128 = 11000000

© 2002 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 2nd ed. www.imageprocessingbook.com

Bit Plane Coding

© 2002 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 2nd ed. www.imageprocessingbook.com

Bit Plane Coding

© 2002 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 2nd ed. www.imageprocessingbook.com

Chapter 8
Image Compression

© 2002 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 2nd ed. www.imageprocessingbook.com

Lossless Predictive Coding

© 2002 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 2nd ed. www.imageprocessingbook.com

•Based on eliminating the interpixel redundancy in an image


•We extract and code only the new information in each pixel
•New information is defined as the difference between the actual (fn) and
the predicted value, fˆn of that pixel.

ˆ
en  f n  f n

© 2002 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 2nd ed. www.imageprocessingbook.com

Decompression:
f n  en  fˆn

Most general
ˆf  round   f 
m

 i n i 
form :
n
 i 1 

Most Simple form

ˆf  f
n n 1
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. www.imageprocessingbook.com

Lossy Predictive Coding

© 2002 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 2nd ed. www.imageprocessingbook.com

Lossy compression
•Lossless compression usually gives a maximum compression of 3:1
(for monochrome images)
•Lossy compression can give compression upto 100:1 (for
recognizable monochrome images) 50:1 for virtually indistinguishable
images
•The popular JPEG (Joint Photographic Experts Group) format uses
lossy transform-based compression.

© 2002 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 2nd ed. www.imageprocessingbook.com

Assignment

Q1> Write short note on :


•Image compression Standards :Binary Image &
continuous tone still image compression standards
•Video compression standards
•JPEG 2000

© 2002 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 2nd ed. www.imageprocessingbook.com

© 2002 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 2nd ed. www.imageprocessingbook.com

Arithmetic Coding
• Arithmetic coding bypasses the idea of replacing an
input symbol with a specific code. It replaces a
stream of input symbols with a single floating-point
output number.
• Arithmetic coding is especially useful when dealing
with sources with small alphabets, such as binary
sources, and alphabets with highly skewed
probabilities.

© 2002 R. C. Gonzalez & R. E. Woods


35
Digital Image Processing, 2nd ed. www.imageprocessingbook.com

Arithmetic Coding

© 2002 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 2nd ed. www.imageprocessingbook.com

0.8 0.16 0.072 0.0688

0.4 0.08 0.056 0.0624 0.06496

0.2 0.048 0.0592 0.06368


0.04

© 2002 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 2nd ed. www.imageprocessingbook.com

End of Unit5 : Image Compression

© 2002 R. C. Gonzalez & R. E. Woods

You might also like