0% found this document useful (0 votes)
7 views33 pages

Transform Coding

The document discusses lossy image compression techniques, focusing on transform coding, particularly the Discrete Cosine Transform (DCT). It outlines the process of transform selection, sub-image selection, and bit allocation, emphasizing the importance of quantization methods like zonal and threshold coding. The DCT is highlighted for its energy compaction properties and computational efficiency in image processing.

Uploaded by

Malavika R Nair
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views33 pages

Transform Coding

The document discusses lossy image compression techniques, focusing on transform coding, particularly the Discrete Cosine Transform (DCT). It outlines the process of transform selection, sub-image selection, and bit allocation, emphasizing the importance of quantization methods like zonal and threshold coding. The DCT is highlighted for its energy compaction properties and computational efficiency in image processing.

Uploaded by

Malavika R Nair
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 33

DIGITAL IMAGE

PROCESSING
Lossy Image compression II DIP DAY 30 26-03-2015
DIP DAY 30 26-03-2015

Learning Objectives
• Explain Transform coding approach for
Lossy image compression.

• Define DCT and explain the properties of


DCT and formation of DCT

• Explain two types of bit allocations done


for lossy image compression
DIP DAY 30 26-03-
2015

Introduction

• Two types of coding (in general)


▫ waveform coding: The coding techniques which operate
directly on the pixels of an image.

▫ Transform coding: The coding techniques which are based


on modifying the transform of an image

• In Transform Coding the image is


transformed to a domain where compression
can be performed more efficiently (i.e.,
reduce interpixel redundancies).
DIP DAY 30 26-03-2015

A Transform coding System


In transform coding a reversible linear transform is used to map the image
into a set of transform coefficients which are then quantized and coded.
DIP DAY 30 26-03-2015

Three Important Steps in Transform Coding

• Transform Selection

• Sub image Selection

• Bit allocation
DIP DAY 30 26-03-2015

Three Important Steps in Transform Coding

• Transform Selection

▫ The transform which packs most of the information in


the smallest number of transform coefficients is selected
to achieve the best compression.
DIP DAY 30 26-03-2015

Transforms
• Discrete Fourier Transform

• Walsh Hadamard Transform

• Discrete cosine Transform

• KL Transform

• Wavelet Transform
2-D Walsh Transform

• The 2-D Walsh transform is defined as


N1 N1 n 1
1
W (u , v) 
N
 
x 0 y 0
f ( x, y )  ( 1) bi ( x ) bn 1 i ( u ) bi ( y ) bn 1 i ( v )
i 0

• The inverse transform is given by

N1 N1 n 1
1
f ( x, y ) 
N

u 0
 W
v 0
(u , v )  (  1) bi ( x ) bn 1 i ( u ) bi ( y ) bn 1 i ( v )

i 0

DIP DAY 30 26-03-2015


DIP DAY 30 26-03-2015

Walsh Basis images


DISCRETE COSINE TRANSFORM

DIP DAY 30 26-03-2015


1-D DCT

• The 1-D discrete cosine transform is defined as


N1
 (2 x  1)u 
C (u ) a (u )  f ( x) cos
x 0  2N 
• The inverse DCT is defined as

N1
 (2 x  1)u 
f ( x)   a (u )C (u ) cos
u 0  2N 

DIP DAY 30 26-03-2015


1-D DCT

• Where
▫ x = 0,1,……N-1
▫ u = 0,1,……N-1

 1
 N u 0

a (u ) 
 2
 u 1, , N  1
 N

DIP DAY 30 26-03-2015


1-D DCT

• So for N=4, the 1-D DCT basis vectors can be found as


follows:
• {Cos(πu/8); Cos(3πu/8); Cos(5πu/8); Cos(7πu/8)} for u =
0,1,2,3.
• The transformation matrix can be obtained as

 1 1 1 1 
 0.924 0.383  0.383  0.924
 
 0.707  0.707  0.707 0.707 
 
 0.383  0.924 0.924  0.383
DIP DAY 30 26-03-2015
DIP DAY 30 26-03-2015

1-D DCT basis vectors for N=8


2-D DCT

• The 2-D DCT pair of equations is given by:


N1 N1
 (2 x  1)u   (2 y  1)v 
C (u , v) a (u )a (v)  f ( x, y ) cos   cos  
x 0 y 0  2N   2N

N  1N  1
 (2 x  1)u   (2 y  1)v 
f ( x, y )    a (u )a (v)C (u , v) cos cos
u 0 v 0 
 2N 
  2N 

u , v 0,1, , N  1
DIP DAY 30 26-03-2015
2-D DCT Basis Images

• The 2-D basis images can be found from the 1-D


basis vectors.
1 1 1 1  0.924 0.924 0.924 0.924 
1 1 1 1  0.383 0.383 0.383 0.383 

1 1 1 1   0.383  0.383  0.383  0.383
  
1 1 1 1   0.924  0.924  0.924  0.924
 0.707 0.707 0.707 0.707   0.383 0.383 0.383 0.383 
  0.707  0.707  0.707  0.707    0.924  0.924  0.924  0.924

  0.707  0.707  0.707  0.707   0.924 0.924 0.924 0.924 
  
 0.707 0.707 0.707 0.707    0.383  0.383  0.383  0.383
DIP DAY 30 26-03-2015
DIP DAY 30 26-03-2015
2-D Basis Images for N = 4

v
0 1 2 3

3
DIP DAY 30 26-03-2015

DCT-Advantages
• The DCT is a real and orthogonal transform.

• It is a separable transform.

• The DCT has excellent energy compaction properties.

• Among the currently known unitary transforms it is the


best approximation for the optimal KLT.

• There are fast algorithms to compute the DCT similar


to the FFT.
DIP DAY 30 26-03-2015

Example
• Example: x(n) = [1 2 3 4]
• C(k) = [5 -2.23 0 -0.16]
• Reconstruction with first 2 coefficients
▫ x(n) = [1.04 1.89 3.10 3.96]

• With DFT:
• X(k) = [10 -2+ 2i -2 -2- 2i]
• Reconstruction with first 2 coefficients
▫ x(n) = [1.5 1.5 3.5 3.5]
Example:2-D

1 2 3 4 10  4.46 0  0.32


1 2 3 4 0 0 0 0 
A( x, y )  C (k1, k 2) 
1 2 3 4 0 0 0 0 
   
1 2 3 4 0 0 0 0 

1.0429 1.8964 3.1036 3.9571


1.0429 1.8964 3.1036 3.9571
A' ( x, y ) 
1.0429 1.8964 3.1036 3.9571
 
1.0429 1.8964 3.1036 3.9571
DIP DAY 30 26-03-2015
Example:2-D

Using 2-D DFT  40  8  8i  8  8  8i 


0 0 0 0 
X (k1, k 2)  
0 0 0 0 
 
0 0 0 0 

1.5 1.5 3.5 3.5


1.5 1.5 3.5 3.5
A' ( x, y ) 
1.5 1.5 3.5 3.5
 
1.5 1.5 3.5 3.5
DIP DAY 30 26-03-2015
DIP DAY 30 26-03-2015

Three Important Steps in Transform Coding

• Sub image Selection


▫ The sub image size which will reduce the
reconstruction error and the computational complexity
is selected.

▫ A sub image size of 8 or 16 is common. Larger sub


image sizes increases the blocking artifacts.
DIP DAY 30 26-03-2015

Three Important Steps in Transform Coding

• Subimage size selection

original 2 x 2 subimages 4 x 4 subimages 8 x 8 subimages


DIP DAY 30 26-03-2015

Three Important Steps in Transform Coding


• Bit allocation:
▫ The reconstruction error depends on the number and relative
importance of the transform coefficients that are discarded and
the precision used to represent the retained coefficients.

▫ The retained coefficients are selected on the basis of two major


criteria.
▫ On the basis of maximum variance – Zonal coding
▫ On the basis of maximum magnitude – Threshold coding

▫ The overall process of truncating, quantizing and coding the


coefficients of the transformed sub image is called bit allocation.
DIP DAY 30 26-03-2015

BIT ALLOCATION
DIP DAY 30 26-03-
2015

Zonal Coding Implementation


• It is based on the concept that the transform coefficients having
maximum variance carry the most image information and
should be retained for coding.

• The coefficients are allocated the same number of bits


(uniform quantization) or a fixed number of bits is distributed
among the coefficients equally.

• In the second method thus, coefficients with higher variance


are assigned more bits than coefficients with smaller variance
and an optimum Lloyd Max quantizer is designed for each
coefficient.
DIP DAY 30 26-03-
2015

Zonal Coding Implementation


DIP DAY 30 26-03-
2015
DIP DAY 30 26-03-
2015

Threshold Coding Implementation

• The underlying principle is that for any sub image, the


transform coefficients of largest magnitude make the
most significant contribution to reconstructed sub
image quality.

• After applying the threshold masks the resulting n xn


array is reordered in a zigzag fashion and is run length
encoded. And variable length coding is done to the
resulting sequence.
DIP DAY 30 26-03-
2015

Threshold Coding Implementation

• There are three ways to threshold the transformed image,

▫ A single global thresholding can be applied to all sub


images.

▫ A different threshold can be applied for each sub image.

▫ The threshold can be varied as a function of location of


each coefficient within the sub image.
Threshold Coding Implementation

• Usually the third method is used, where the


thresholding and quantization is implemented using a
single equation,

ˆ  T (u , v) 
T (u , v) round  
 Z (u , v ) 
where,
Tˆ (u , v)  thresholde d and quantized approximat ion of T (u , v).
Z (u , v)  element of the transform normalization array.
DIP DAY 30 26-03-2015
DIP DAY 30 26-03-
2015

Threshold Coding Implementation


DIP DAY 30 26-03-
2015

You might also like