0% found this document useful (0 votes)
2 views

Unit 5 - Image Transforms

Image transforms are utilized to enhance understanding and processing of images by converting them into a mathematical domain that allows for efficient computation and information extraction. Various types of transforms, such as Fourier and Discrete Wavelet Transforms, help in energy compaction and compression, while maintaining essential information. The document also discusses the significance of unitary and orthogonal properties in transforms, which are crucial for preserving energy and enabling reversible transformations.

Uploaded by

gipalaj384
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Unit 5 - Image Transforms

Image transforms are utilized to enhance understanding and processing of images by converting them into a mathematical domain that allows for efficient computation and information extraction. Various types of transforms, such as Fourier and Discrete Wavelet Transforms, help in energy compaction and compression, while maintaining essential information. The document also discusses the significance of unitary and orthogonal properties in transforms, which are crucial for preserving energy and enabling reversible transformations.

Uploaded by

gipalaj384
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 157

Unit 5

Image Transforms
Why Image Transform?

 Working with the transformed version of an image


rather than the image itself may give us more
understanding of an image without changing the
information content present in the signal
 It offers us mathematical convenience
 Image Transform offers Fast Computation
 It offers better image processing and extraction
of information
Why Image Transformation
 It offers energy compaction
 The coefficients of the transformed image caries information.
 However, most of the information is contained in very few
coefficients.
 The remaining coefficients carry minimal information.
 Thus we can remove these coefficients removed without losing
much information.
 By doing so, the file size is reduced (lossy compression)
 Transform is reversible, i.e., transform domain can revert to the
spatial domain
 The decompressed image can be obtained by doing inverse
transform
Introduction
 Transform give us more insight into the
properties of the image.

 It is used for image enhancement, restoration,


encoding, etc.

 Restoration  removal of noise


 Encoding coding techniques to compress
the image
Types of Transforms
 Fourier Transform
 Walsh transform
 Hadamard Transform
 Slant Transform
 Discrete cosine function
 Discrete Wavelet Transform
 Karunen-Loeve (Hotelling) Transform
Types of Transforms
 Fourier transform is a orthogonal transform for which
basis functions are derived from the family of
Sinusoids
 Walsh transform, Hadamard Transform and Slant
transform are non-sinusoidal orthogonal transform
Classification of Image
Transforms
Sinusoidal Non-Sinusoidal Statistical
transformati transformation information as
basis funtion basis function
on basis
function
Hadamard KL Transform
Walsh (Hotelling)
DCT SVD
Slant
DFT
DWT
DST
Basis Function of each
transform
 DFT  is generated using exponential function
(sine and cos)
 DCT is generated using cosine equation
 Walsh and Hadamard transform is generated
using square wave (+1,-1)
 Slant transform uses sawtooth waveform
 Wavelet Transform  uses wavelets
 KL transform  uses statistics of image
Computation of Transform
F : Transformed image 𝑇
𝑓 𝑖𝑠 𝑡h𝑒𝑡𝑟𝑎𝑛𝑠𝑝𝑜𝑠𝑒 𝑜𝑓 𝑓
A = is the transform matrix
f : input image 𝐴𝑇 𝑖𝑠 𝑡h𝑒 𝑡𝑟𝑎𝑛𝑠𝑝𝑜𝑠𝑒𝑜𝑓 𝑇

Transformed image

• 2D image : 𝑇
𝐹=𝐴. 𝑓 . 𝐴

Transform, A has to be suitably selected : DCT, Walsh, Hadamard, etc

The difference between the different types of transform is the


BASIS FUNCTION
Conditions for perfect
transform
1. Unitary matrix
2. Orthoganality (Transpose of matrix = Inverse
of a matrix)
3. Separable
Unitary Transform

 The discrete transform matrix (A) is a unitary matrix


i.e. A*T= A-1
(*  conjugate , T Transpose)
Significance of Unitary Transform
Leads to ENERGY CONSERVATION (Energy of signal is
preserved )

𝐹=𝐴. 𝑓 ′

¿| 𝑓 |∨¿ ¿
2
Energy in original image 

¿|𝐹|∨¿ ¿
2
Energy in Transformed image 

Note: We will not go into the proof of this property


Significance of Unitary Transform

Because A is unitary it results in Energy Conservation 

| | 2
| | 2
¿ 𝑓 ∨¿ =¿ 𝐹 ∨¿ ¿¿

Conservation of Energy property between the spatial


domain and the transformed domain

This means information is preserved under a unitary


transformation.

Note: We will not go into the proof of this property


Significance of Unitary
Transform
 Most unitary transforms pack a large fraction
of the energy of the image into relatively few
of the transform coefficients.
 This means that relatively few of the
transform coefficients have significant values
and these are the coefficients that are close
to the origin (small index coefficients).
 This property is very useful for compression
purposes.
Orthogonal Matrix
 A matrix is termed as an orthogonal matrix if its
transpose is equal to the inverse matrix of it.
 A AT = I
 Where ‘I’ is the identity matrix
 AT = A-1
 Since transform A is symmetric
 A-1 = A
Significance of Orthogonality
of T
 The inverse of the transform is same as the
array itself
 A-1 = A
 Thus this property allows us to use the same
transform matrix A to find the
 transformed matrix of an image
 Recover the original image from the transformed
matrix
Separable Property of a
Transform
T ( 𝑥 , 𝑦 ,𝑢 , 𝑣 ) =𝑇 ( 𝑥 , 𝑢 ) . 𝑇 ( 𝑦 , 𝑣)

 Transform applied to a 2D image (x,y) to get


(u,v) is equivalent to
 Applying 1D transform to rows of 2D image
and then to columns of 2D image
What is separable property
of a transform ?
Instead of applying 2D
transform, we can also
apply 1D transform.

Applying 1D transform
to row first and then
column gives same
result as applying 1D
transform to column first
and row first
Fourier Transform
Fourier Transform
What do you mean by
frequency of an image ?
Let us revisit frequency of a
sine wave

Frequency is the rate at


which the signal
changes direction per
second
Understanding frequency in
an image

Frequency in images is the rate at which intensity values change


High frequency image  intensity value changes quickly from one pixel to next
Low frequency image  intensity is relatively uniform in brightness or intensity changes
slowly
Images contain both high as well as low frequency components
Frequency of an image

 Frequency = How rapidly the signal changes in


space
 Rate at which image intensity changes, such
as lines or edges, have many frequency
components.
Frequency of an image
Image : f(x,y)

High Intensity Intensity Intensity variation


Intensity
variation variation in x and y direction
variation
in y direction in x direction
in y direction
Let us understand
Discrete Fourier Transform
DFT
Discrete Fourier Transform

 The DFT is a Fourier Transform is an important image processing


method that is used to decompose an image into its components sine
and cosine.

 DFT as Discrete Fourier Transform is used as a transform from pixel-


domain into frequency-domain.

 Practically, the most frequent pixels will be put in one corner and
the least frequent pixels will be in the opposing corner.

 we know which pixels are most and least frequent


Discrete Fourier Transform
(DFT)
 DFT is computed for a finite length sequence
from 0 to N-1
 x[n]={x[0], x[1], x[2], x[3],…,x[N-1]}

Equation of DFT:

N is the length of the input sequence


k, n varies from 0 to N-1
Inverse Discrete Fourier
Transform (IDFT) Transform
matrix T

Equation of DFT: k = 0,1,2,..,N-1

𝑁 −1
1
Equation of IDFT: 𝑥 ( 𝑛) =
𝑁
∑ 𝑋 (𝑘)𝑒 𝑗 2 𝜋 𝑛𝑘/ 𝑁
k = 0,1,2,..,N-1
𝑘=0

T*  conjugate of T
Matrix representation of the
FT Equation
Equation of DFT:

By substituting k=0 . . . N-1


n = 0,.., N-1
=

The Transformed image :


𝑋 =𝑇 . 𝑥 ′
DFT Matrix
=

𝑗𝜃
𝑆𝑖𝑛𝑐𝑒 , 𝑒 =𝑐𝑜𝑠 𝜃+ 𝑗 𝑠𝑖𝑛 𝜃

[ ]
1 1 1 1
1 − 𝑗 −1 𝑗
𝑇=
1 −1 1 −1
1 𝑗 −1 − 𝑗
DFT Transform matrix
Order 2
=

Order 4

Normalized Transform

=
To find DFT of 1D sequence

Equation of DFT:

𝑋 =𝑇 . 𝑥 ′
Numericals
Lab to compute
t in
u DFT using Matrix method
gh
Ta
1. Compute the DFT of x(n) = {1 1}

𝑋=𝑇 . 𝑥 ′

=
b
Numericals
t i
L
n
a
to compute
h
Ta DFT using Matrix method
ug

1. Compute the Inverse DFT of X=[2,0]

N order of DFT
(number of samples)
x=

x=
b
Numericals
t in
La
to compute
h
Ta DFT using Matrix method
ug

1. Compute the DFT of x(n) = {1 2 2 1}

𝐹 =𝑇 . 𝑓 ′

Note : to verify the answer

Check these two should have same value with sign reversal of j term
ab
L
ght in Compute IDFT of
au
T

1
𝑥= 𝑇 ∗. 𝑋
𝑁
=

== =
ab
ht in
L Example of DFT
g
auCompute
T 2 D DFT of the 4 x 4 gray scale
image given below

[ ]
1 11 1
1 11 1
𝑓 (𝑥 , 𝑦 )=
1 11 1
1 11 1

The DFT basis function (kernel) for N=4 is

[ ]
1 1 1 1
1 − 𝑗 −1 𝑗
𝑇=
1 −1 1 −1
1 𝑗 −1 − 𝑗

The Transformed image : 𝐹 =𝑇 . 𝑓 . 𝑇 ′


ab
L
t in
gh
au
T 𝐹 =𝑇 . 𝑓 . 𝑇 ′

x x

[ ]
16 00 0
0 00 0
¿
0 00 0
0 00 0
ab
Meaning
ht in
L
ug
Ta As seen the input image has no
variations.
It has a constant shade across

[ ]
1 11 1
1 11 1 Input all pixels (known as dc term)
𝑓 (𝑥 , 𝑦 )=
1 11 1
1 11 1 image
The value of F(0,0) in the
transformed image is always the
dc component (average

[ ]
16 00 0
0 00 0 Output brightness of the image).
𝐹 ( 𝑥 , 𝑦 )=
0 00 0
0 00 0 image
The value of F(0,0) is always
the highest in a transformed
image
DC Component

[ ]
16 00 0
0 00 0
𝐹 ( 𝑥 , 𝑦 )=
0 00 0
0 00 0
ab
t
Find
i
L
n the DFT for given 2d
gh
Ta
u
image
x=

F(u,v)=A f(x,y) AT

1 1 1 1
1  j  1 j 
A  
1  1 1  1 
 
 1 j  1  j 
ab
L
t in
gh
au F(u,v) = A f(x,y) AT
T
=

Separable property says that we can implement 2D transform by performing 1D


transform on row and then column (or column and then row)

][ ] [
1 1 1 1 0 01 0 0 0 4 0
1 − 𝑗 −1 𝑗 0 01 0 0 0 0 0
=¿ ⇒
1 −1 1 −1 0 01 0 0 0 0 0
1 𝑗 −1 − 𝑗 0 01 0 0 0 0 0
ab
L
t in
gh
au
T

=
ab
IDFT in
L example (N = number of rows×number of
t
columns)
h
ug 1
Ta 𝑓 = 𝑻 𝐹𝑻
𝑵𝟐

X= T=

X=
ab
L
x=t in
gh
au
T

[ ][ ][ ]
1 1 1 1 4 −44 −4 4 −4 4 −4
1 𝑗 −1 − 𝑗 0 0 0 0 4 −4 4 −4
=
1 −1 1 −1 0 0 0 0 4 −4 4 −4
1 − 𝑗 −1 𝑗 0 0 0 0 4 −4 4 −4

x==

x=
ab
L
ht in Compute the 2D DFT of
ug
Ta
image x
ab
L
t in
gh
au
T

Addition of all
pixel values
Dc component /
coefficient

DFT is a complex number and so has


magnitude and phase component
ab
Magnitude
ht
L
in and Phase of DFT
ug
computation
Ta

𝑅 (𝑢, 𝑣) 𝐼 (𝑢 , 𝑣)

−1 𝐼 (𝑢 , 𝑣 )
∅ (𝑢 )=𝑡𝑎𝑛
|𝐹 (𝑢 , 𝑣 )|= √ 𝑅 (𝑢 , 𝑣)
2 2
+ 𝐼 (𝑢 , 𝑣 ) 𝑅(𝑢 , 𝑣)
ab
L
t in
gh
au
T

Significance of Magnitude and Phase


Spectrum
ab
L
ht Fourier Transform of
in
ug
Ta
Rice and Cameraman Image

Original Magnitude Phase


Image Spectrum Spectrum
ab
L
ht Fourier Transform of
in
ug
Ta
Rice and Cameraman Image

Original Image Magnitude


Spectrum Phase Spectrum
ab
L
t in
gh
au
T Curious Fact
 All natural images has similar magnitude spectrum so why do they look

different

 Phase in a image matters a lot more than the magnitude

Demonstration

 Take two pictures, swap the phase transforms and compute the

inverse. See what the result look like


Phase Carries More
Information
Importance of magnitude and
phase of DFT
• Magnitude spectrum denotes dominance of a
sinusoid with a particular frequency.
• Magnitude spectrum does not give location of the
frequency
• Phase carries location of the frequency
ab
L
t in
gh
au
T

How does the Transformed


image look like ?
ab
ht Magnitude spectrum of a
in
L
ug
Ta constant shade image

DC coefficient is at the
center for better
understanding of the
transformed iamge.

[ ] [ ]
1 11 1 16 00 0
0 00 0
𝑓 (𝑥 , 𝑦 )=
1 11 1 𝐹 ( 𝑥 , 𝑦 )=
1 11 1 0 00 0
1 11 1 0 00 0
Example of Frequency
Spectrum of
Image
images

Fourier Spectrum

It can be seen that increasing the frequency yields the same 2


symmetrical dots along the y-axis but are getting further apart.
Fourier Examples
Frequency of an image
 Abrupt changes of image intensity, such as lines or
edges, have many frequency components.
 The Fourier transform of a white square (i.e., a step change
of intensity in both the x and y directions) shows
predominantly frequency components along the u and v
axes (Figure A and B).
Example

Variations in
intensity in y
direction

DC term
Average Intensity

Variations in intensity
in x direction
ab
L Two important things to improve
t in
gh visibility of the transformed image
u
Ta

1. Centering the DFT values


2. Log transformation
ab
Centered
ht
L
in Representation of
ug
Ta Frequency Information
 Low frequencies are at the center while high
frequencies are away from the center
ab
How
t in
L to center the DC and the low
gh
Tau frequency terms
Take DFT of f(x,y)(-1) (x+y)

f(x,y)  Original image pixel value


f’(x,y)  centered image pixel value
F(u,v)  centered DFT

Done to center the DFT

f(x,y)  f’(x,y) = (-1)x+y f(x,y) F(u,v)

i.e. before computing the DFT each pixel value of f(x,y)


is first multiplied by (-1) (x+y)
ab
L
t in
gh
au
T

Use of Centered
Representations of
Frequency information
Log transformation and
centering of DFT
Centering  f’(x,y) = (-1)x+y f(x,y)  To get log frequencies at the center

DFT  F(u,v) = DFT(f’(x,y))  To compute Frequency information

Log transformation  log(1+ |F(u,v)|)  To improve visibility

Log transformation is used only for image representation of DFT


of image.
It is not used for processing
Example: Log transformation and
centering of DFT
Magnitude Spectrum of the image

Log
Transformation
of the
Magnitude
Spectrum

 Raw spectral magnitude contains virtually no


information
 We apply log transformation for better
visualization
 It can also be seen that the spectral magnitude is
greatest along certain angles and radii, indicating the
nature of the image being processed.
Example: Log transformation and centering of DFT

DC
coefficients

Image DFT

Log
Centered Transformed
DFT and Centered
DFT
Log transformation and
centering of DFT
 Generally, DC coefficient, F(0,0) is much larger than AC coefficients,
F(u,v)
 Large DC coefficients dominates AC coefficients
 Therefore, AC coefficients may approximate to zero
 Log transformation reduces large range of DFT to the smaller
range
 Ex. F(0,0)= 105 and F(100,50)=10
Log10{F(0,0)}=5
Log10{105}=5
Log10{F(100,50)}=1
Log10{10}=1
NOTE :

Since we have centered the DFT and taken log

We have to be very careful while computing


Inverse as we should reverse these effects to
recover the original image

idft{F(u,v)}= f’(x,y)  (-1)x+y f’(x,y) = f(x,y)


Hadamard Transform
 It has only +1 and -1 as elements in its kernel
matrix.
 Hadamard matrix of order N is a N x N matrix
 And N=2n
 Thus we have 2x2, 4x4, 8x8, 16x16, … hadamard
matrix.
Properties of Hadamard
Transform
 H is real, symmetric and orthogonal
Real (H = H* )
Symmetrix (HT = H)
Orthogonal (HT = H-1)
 The Hadamard Transform is symmetric,
separable, unitary transform
 Fast transform. No multiplication are required.
 Good energy compaction for highly correlated
images
Computation of Transform
F : Transformed image 𝑇
𝑓 𝑖𝑠 𝑡h𝑒𝑡𝑟𝑎𝑛𝑠𝑝𝑜𝑠𝑒 𝑜𝑓 𝑓
A = is the transform matrix
f : input image 𝐴𝑇 𝑖𝑠 𝑡h𝑒 𝑡𝑟𝑎𝑛𝑠𝑝𝑜𝑠𝑒𝑜𝑓 𝑇

Transformed image
𝑇
 1D image : 𝐹=𝐴. 𝑓
• 2D image : 𝑇
𝐹=𝐴. 𝑓 . 𝐴
Transform, A has to be suitably selected : DFT, DCT, Walsh, Hadamard, etc

The difference between the different types of transform is the


BASIS FUNCTION
Inverse Transform of an
F : Transformed imageimage
A = is the transform
f : input image
Recovering the original
Transformed image from Transformed
image image
𝑇
 1D image : 𝐹 = 𝐴 . 𝑓 𝑇
• 1D image : 𝑓 =𝐴 𝐹
• 2D image : 𝐹 = 𝐴 . 𝑓 . 𝐴 𝑇 • 2D image : 𝑇
𝑓 =𝐴 . 𝐹. 𝐴
Hadamard Transform
 Transform is generated by sampling by the square
waveform having different sequences
 Thus Hadamard transform consists of +1 and -1
 Advantage of rectangular basis function is that the
computations are very simple
 Elements of basis function are +1 or -1 which result in very
low computational complexity.
 Also called Walsh Hadamard
 Used in data encryption, data compression (JPEG-XR,
MPEG 4) and video compression
Hadamard Matrix

Order N=4
Order N=1 Order N=2
Hadamard Transform Matrix
 The Hadamard matrix of any order can be
generated recursively as:

 HN HN 
H 2N  
 HN  HN 
Hadamard Transform Matrix
1 1 
H 2  
 1  1

 HN HN 
H 2N 
 HN  H N 

1 1 1 1 
1  1 1  1
H 4  
1 1  1  1
 
1  1  1 1 
Computation of Hadamard
transform

F(x,y) is image, A is transform matrix


F(u,v)=A f(x,y) AT
f(x,y)=AT F(u,v) A
Normalized Hadamard
Transform
 To recover the original image we use
normalized Hadamard Transform.
 Attach outside the transform, A
Why do we normalize ?
 To recover the original image from the
transformed image it is essential that the
transform has to be an Orthogonal matrix  A.AT
= I
 However , A.AT = N I
 Thus to recover the original image  A is
normalized by
Normalized Hadamard
Matrix
1
√2

1
√4
Q. Prove that hadamard
transform is a orthogonal
matrix
i.e to prove that
A.AT = I

Where

11
AA==
√√44
A.AT = I

Where

1
A=
√4
Show that hadamard matrix
of order 2 is unitary
 i.e. A*T= A-1
 A A*T= 1

A=
Find the hadamard transform
of
 f = [1 2 3 4]
 Formula : F = A . fT
Find inverse of F=[10 -2 -4 0]

 F = AT . F
Q. Compute the hadamard transrform for the given image matrix

2 4 1 6
3 1 1 1 1 
2 1 4 1  1 1  1
f 
6 5 3 2 A  H 4   1
  1 1  1  1
1 2 4 3  
1  1  1 1 
√4

F(u,v)=A f(x,y) AT
Q. Compute the hadamard transrform for the given image matrix

2 4 1 6
3 2 1 4 1 1 1 1 
f  1  1 1  1
6 5 3 2
  A  H 4   1
1 2 4 3 1 1  1  1
 
1  1  1 1 
√4
F(u,v)=A f(x,y) AT

 49  7 1 5
 9 3 9 
1 1
F 
  3  11  3 9  4
 
  3  7  11  3
Find inverse of
 49  7 1 5
 9 3 9 1 
1 
F
4   3  11  3 9 
 
  3  7  11  3

f(x,y)=AT F(u,v) A
Hadamard matrix is
sampling the square and
rectangular
Advantage
 Immunity to channel errors
 bandwidth reduction.
 Bandwidth reduction is possible because the image
energy which is uniformly distributed in the spatial
domain, tends to be concentrated near the origin of the
Hadamard domain.
 Many of the higher spatial frequency components are
of very low magnitude, and need not to be transmitted.
Transformed Image
What do you mean by average
brightness?
In Walsh, Hadamard and
cosine Transform
The top left corner F(0,0) of the
transformed image is associated with
the zero frequency.
Zero frequency is referred to as
DC component (average
brightness of, the image)

The transformed coefficient's represent


higher and higher frequency as it
goes from top left to bottom right of
the transformed image.

we can perform filtering


operations in frequency domain
to modify the image according
to our needs.
Walsh Transform
 Based on Hadamard Transform
 Transform is generated by sampling by the
square waveform having different sequences
 Walsh transform is just a sequence ordered
Hadamard transform
 Sequence means, the number of sign changes
in a row
 Walsh focuses on the count of sign change in the
H matrix
Walsh Transform
 a Walsh matrix is a specific square matrix,
with dimensions equal to a power of 2,
 the entries of which are +1 or -1,

A= 1
[
1
1 −1 ]
How to get Walsh transform
matrix from Hadamard
Transform Matrix ?
Generating Walsh Transform
Matrix from Hadamard
Transform
 a Walsh matrix is formed Matrix
by arranging the
rows of Hadamard transform in such a way
that the frequencies are in natural order
Hadamard No. of sign change
transform :
0
3
1
2
Hadamard Transform

0
3
1
2

Walsh Transform

[ ]
1 11 1 0

𝐴= 1 1−1 −1 1
1 −1− 11 2
1 −11 −1 3
Walsh Transform

1 1 1 1
1 1 -1 -1
1 -1 -1 1
1 -1 1 -1
Computation of Walsh
transform

F(x,y) is image, A is transform matrix


F(u,v)=A f(x,y) AT
f(x,y)=AT F(u,v) A
Compute the Walsh
transform of the 1D image
given below :
 f = {1,2,0,3}

 1D image :
𝑇
𝐹=𝐴. 𝑓
Find the walsh transform of
the 2D image given below:

F(u,v)=A f(x,y) AT
Contd….
Slant Transform
 Orthogonal transform
 Transform is generated by sampling by the
sawtooth waveforms
 Order N=2n
 The slant transform provides high energy
compaction property
 Used for detecting diagonal edges
 Fast computational algorithm is possible
Slant transform matrix of
order
2 x 2 slant transform matrix2
is identical to the
Hadamard transform matrix

1 1 1 
S 21  1  1
2  
Construction of slant Matrix
Slant transform of order N can be obtained by recursive operation
Construction of slant Matrix
Slant transform of order N can be obtained by recursive operation
Construct the Slant transform matrix
order N=4
1 0 1 0
a4 b4 -a4 b4 S2 0
1
𝑆4= 0 1 0 1 0 S2
√2
-b4 a4 b4 a4
Construct the Slant
transform matrix order N=4

1 0 1 0
a4 b4 -a4 b4 S2 0
1
𝑆4= 0 1 0 1 0 S2
√2
-b4 a4 b4 a4
0.89

0.45

1 0 1 0
a4 b4 -a4 b4 S2 0
1
𝑆4= 0 1 0 1 0 S2
√2
-b4 a4 b4 a4
1 0 1 0
1 1 0 0
0.89 0.45 -0.89 0.45
1 1 -1 0 0
𝑆4= 1
√2 0 1 0 1
√2 0 0 1 1
-0.45 0.89 0.45 0.89 0 0 1 -1

0.5 0.5 0.5 0.5


0.67 0.22 -0.22 -0.67
𝑆 4 =¿ 0.5 -0.5 -0.5 0.5
0.22 -0.67 0.67 -022
0.5 0.5 0.5 0.5
0.67 0.22 -0.22 -0.67
𝑆 4 =¿ 0.5 -0.5 -0.5 0.5
0.22 -0.67 0.67 -022

 1 1 1 1 
 3 1 1 3 
 
1 5 5 5 5
S 22   
2 1 1 1 1 
 1 3 3 1 
 
 5 5 5 5 
Properties of Slant
Transform
 Real and orthogonal
 Fast transform
 Good energy compaction
Q. Compute the Slant
transform of the given image

f ( x , y)= 1
34
2
[ ] 1
2
1 1 
[
1  1
  3 4 2]
1 2 1 1 1 
1  1

F = S. f. ST
F ( x , y)= 5 − 1
−20 [ ]
1 1 1 
S 21  1  1
2  
Q Find inverse slant
transform of F 1 1 1   5  1 1 1 1 
f = S . f. S
T
1  1   2 0  2 1  1
2     

F ( x , y)= 5 −
−20
1
[ ] f ( x , y)= 1
[ ]
2
34
1 1 1 
S 21  1  1
2  
Q. Find slant transform of given
1D image
 f = {1 2 2 1}

 1D image :
𝑇
𝐹 =𝑆 . 𝑓
 f is a 1 x 4 matrix so requires transform of order 4
 1 1 1 1 
 3 1 1 3 
 
1 5 5 5 5
S 
2 1 1 1 1 
1 3 3 1
   
 5 5 5 5 
Contd….
𝑇
𝐹 =𝑆 . 𝑓
 1 1 1 1 
 3 1 1 3   1
   2
1 5 5 5 5  
 
2 1 1 1 1   2
1 3 3 1  
     1
 5 5 5 5 

 3
 0
F  
  1
 
 0
Q. Find inverse slant transform
of given 1D image
 f = {3 0 -1 0}

 1D image :
𝑇
𝑓 =𝑆 . 𝐹
 F is a 1 x 4 matrix so requires transform of order 4
 1 1 1 1 
 3 1 1 3 
 
1 5 5 5 5
S 
2 1 1 1 1 
1 3 3 1
   
 5 5 5 5 
Contd….
𝑇
𝑓 =𝑆 . 𝐹
 3 1 
 1 1  1
5 5   2
 
1 1 3   
1   2
1 5 5
   
2 1  1 3   1
 1 
 5 5 
1  3 1 
1 
 5 5 

 1
 2
f  
 2
 
 1
Discrete Cosine Transform

 Real valued
 Unitary
 orthogonal
 Basis vectors are sampled form of cosine
signal
 Widely used for image compression
2-D DCT
𝑓 (𝑥 , 𝑦 )  Input image
𝐹 (𝑢, 𝑣 )  Output image
N1 N1
 (2 x  1)u   (2 y  1)v 
F(u , v)  (u ) (v)  f(x, y) cos  cos 
x 0 y 0  2N   2N 

 1  1
 ifu 0  ifv 0
 N  N
 (u )  ,  (v) 
 2  2
 ifu 0  ifv 0
N N
u = 0, 1, …, N-1
v = 0, 1, …, N-1
2D – DCT Transform Matrix
F (0) 0.5 0.5
(A)
0.5 0.5 f (0)
    
 F (1)   0.6532 0.2706  0.2706  0.6532  f (1) 
    
 F (2)  0.5  0.5  0.5 0.5   f (2)
    
 F (3)   0.2706  0.6533 0.6533  0.2706  f (3) 

 0.5 0.5 0.5 0.5 


 0.6532 0.2706  0.2706  0.6532
A  
 0.5  0.5  0.5 0.5 
 
 0.2706  0.6533 0. 6533  0 .2706 
2-D DCT matrix
 0.5 0.5 0.5 0.5 
 0.6532 0.2706  0.2706  0.6532
A  
 0.5  0.5  0.5 0.5 
 
 0.2706  0.6533 0.6533  0.2706

• A AT=I
• Transform is separable, i.e. DCT transform of rows
and columns of image can be computed separately
• Or, F = AfAT
• f = AT F A
Example DCT Transform of 2D
image
Determine DCT of the following image matrix
and prove that DCT has good energy
compaction property

𝑓 =¿
Computation of 2-D DCT
matrix
𝑓 =¿
 0.5 0.5 0.5 0.5 
 0.6532 0.2706  0.2706  0.6532
A  
 0.5  0.5  0.5 0.5 
 
 0 . 2706  0 . 6533 0 . 6533  0 . 2706 

 4.5 5.5 5 5.0


  0.27 0.27 0.92 0 
Af  
  0.5 0.5 0.0 1.0 
 
 0.65  0.65  0.38 0.0
 10  0.19  0.5  0.46
 0.46  0.35  0.73 0.35 
AfAT  F   
 0.5  0.84 0.0  0.73
 
  0.19 0.35 0.84 0.35 
Show that DCT provides
Energy Compaction
 Energy compaction :

 A large portion of the energy of the input image is


contained in a handful of coefficients
Find the energy in the DCT
Transformed image
 E(u,v) = {F(u,v)}2
 10  0.19  0.5  0.46
 0.46  0.35  0.73 0.35 
AfAT  F  
 0.5  0.84 0.0  0.73
 
  0.19 0.35 0.84 0.35 

 102 ( 0.19) 2 ( 0.5) 2 ( 0.46) 2   100 0.04 0.25 0.21


 2   0.21
( 0. 46) 2
(  0.35) 2
(  0.73) 2
( 0. 35) 0.12 0.54 0.12
E   E 
 (0.5) 2 ( 0.84) 2 0.0 ( 0.73) 2   0.25 0.71 0.0 0.54
 2 2 2 2   
 ( 0.19) (0.35) (0.84) (0.35)   0.04 0.12 0.71 0.12

Total energy of transformed image = sum(E)=104


DCT, Walsh, Hadamard,
Wavelet, Slant Transforms
are used for Image
compression. Justify.
Energy of DCT Transform
 100 0.04 0.25 0.21
 0.21 0.12 0.54 0.12
E 
 0.25 0.71 0.0 0.54
 
 0.04 0.12 0.71 0.12

 Total energy of transformed image = sum(E)=104


 Percentage of total energy contained in E(0,0)
 E(0,0)= (100/104) x 100 %= 96%
 Percentage of total energy contained in first four
coefficients
= (100+0.04+0.21+0.12)x100/104 = 96.5%
 This means that we need to preserve only the first
four coefficients to recover the original image.
 This is referred to as ENERGY COMPACTION
Example DCT
• 256x256 image
• Image as 65596
pixels

Low frequency coefficients


Image

• Low frequency
coefficients have High frequency coefficients
higher values than
higher frequencies
DCT Coefficients
DCT compression for 768x768
image
• Original image
has 589824
pixels 589824 coefficients
• DCT of image as are stored and used
589824 pixels for inverse DCT
Example DCT

• Original image
has 589824 589824 coefficients
pixels are stored and used
• DCT of image as for inverse DCT
589824 pixels

Highest 943 coefficients are stored Highest 59 coefficients are stored


and used for inverse DCT and used for inverse DCT
Example DCT Transform of 1D
image
Determine DCT of the following image matrix
and prove that DCT has good energy
compaction property

𝑓 =[ 1 ,2 , 3 , 4 ]
Computation of 2-D DCT
matrix
=[ 1 ,2 , 3 , 4 ]
 0 .5 0 .5 0 .5 0 .5   1 
 0.6532 0.2706  0.2706  0.6532  2
Af 
T  
 0 .5  0 .5  0 .5 0 .5   3 
𝑇   
𝐹=𝐴. 𝑓  0 . 2706  0 . 6533 0 . 6533  0 . 2706   4

 0.5 0.5 0.5 0.5   5 


 0.6532 0.2706  0.2706  0.6532   2.23 
A   F  
 0.5  0 .5  0 .5 0.5   0 
   
 0.2706  0.6533 0.6533  0.2706   0.158
Energy compactness
Find the percentage of energy in the first
two coefficients
 5   25  Total Energy
  2.23   4.97 
F   E   30
 0   0 
   
  0 . 158   0 . 025 
Energy in first two coefficients
E(u,v) = {F(u,v)}2
𝐸=25+ 4.97=29.97
 5 2

 2 
 2 . 23
E  
 02 
 2
29.97 − →?
  0.158 
Energy in first two coefficients is
99.86% of total energy

This shows that almost 100% of the total energy is avilable in only first two
coefficeints.
So we need to preserve the first two coefficients too get the original image
This is referred to as ENERGY COMPACTNESS
Karhunen Loeve Transform
(KL Transform / Hotelling
transform)
 In DCT / DFT we have a fixed Transformation
matrix which is same for any image
 In KL transform, the transformation matrix
depends on the image
 It is a statistical based method used for image
compression
 So in order to apply KL transform to a image, the
statistical properties of the image is required
(mean, covariance)
KL Transformation
 The KL Transform is also known as the Hoteling transform or the Eigen
Vector transform.
 The KL Transform has several important properties that make it useful
for image processing particularly for image compression.
 The main purpose of image compression is to store the image in fewer
bits as compared to original image, now data from neighboring pixels in
an image are highly correlated.
 More image compression can be achieved by de-correlating this data.
The KL transform does the task of de-correlating the data thus
facilitating higher degree of compression
KL Transformation

Forward Transform
X  a vector formed from the input image

A  KL transformation matrix
 mean of the vector X

Inverse Transform 

We have to compute the TRANSFORMATION MATRIX (A)


based on image values
Steps to find TRANSFORMATION
MATRIX (A) based on image
values
 There are four major steps in order to find the
KL transform (A):-
(i) Find the mean vector and covariance matrix
of the given image x
(ii) Find the Eigen values and then the eigen
vectors of the covariance matrix
(iii) Create the transformation matrix A, such
that rows of A are eigen vectors
(IV) Find the KL Transform ()
Numericals on KL transform
 Consider the 4 × 4 image.
 Find its KL Transform
0 0 1 0
0 1 0 0
0 0 0 0
0 0 0 0

0 0 0
0 0 0
Instead of 1 it maybe shaded
0 0 0 0
0 0 0 0
0 0 1 0
0 1 0 0
0 0 0 0
0 0 0 0

Step 1 : from a vector of object (1) in image


3 0 0 1 0
1 2 Column location
2 0 1 0 0 f(x)
2 3 Row location
1 0 0 0 0
0 0 0 0 0
0 1 2 3

Step 2 : find the mean of location


𝑁
1
𝜇𝑥= ∑ 𝑓 𝑥 [
1 2 ( 1 +2 ) / 2
f(x)𝜇 𝑥 =
2 3
𝑁 𝑥=1 ( 2 +3 )/
𝑁
1
Step 3 : Covariance 𝐶 𝑓 = ∑ (𝑓 ¿¿ 𝑥−𝜇)(𝑓 ¿¿ 𝑥−𝜇) ¿¿

1 2
𝑁 𝑥=1
f(x)

[ ] [ ] [ ]
2 3
𝑓 − 𝜇 = 1 − 1 .5 = − 0.5
1 ❑
2 2.5 − 0. 5

𝑓 2 − 𝜇❑ =
3[ ] [
2 − 1.5 = 0.5
2.5 0.5 ] [ ]
[-0.5 -0.5] =

[0.5 0.5] =
𝑁
1
𝐶 𝑓 = ∑ (𝑓 ¿¿ 𝑥−𝜇)(𝑓 ¿¿ 𝑥−𝜇) ¿¿

𝑁 𝑥=1

𝐶𝑓 =
1
2 ([ 0 .25
0.25
0.25
0.25 ] [
+
0 .25
0.25
0.25
0.25 ])
𝐶𝑓 =
1
2 [ 0.5
0.5
0.5
0.5 ]
𝐶𝑓 = [ 0.25
0. 2 5
0.2 5
0.2 5 ]
Step 4 : Eigen Values (

|𝐶 𝑓 − λ 𝐼 |=0

|[ 0 .25
0.25
0.25
0.25 ]
−λ
1
0 [ 0
1
=0
]|

|[ 0 .25
0.25
0.25
0.25

λ
0] [ 0
λ
=0
]|
|[ 0 .25 − λ
0.25
0.25
0.25 − λ
=0
]|
2 2
(0.25 − λ) − ( 0.25 ) =0
2 2
(0.25 − λ) − ( 0.25 ) =0
2 2 ❑ 2
(0.25) +( λ) −(2 ×0.25 × λ) − ( 0.25 ) =0
2 ❑
( λ) −(0. 5 × λ) =0
λ ¿

λ= 0 λ=0.5
Step 4 : find the Eigen vector

Eigen vector for

|𝐶 𝑓 − λ 𝐼 |=0

|[ 0 .25 − λ
0.25
0.25
0.25 − λ ][ ]|=[ 00 ]
𝑥1
𝑥2

|[ 0 .25 − 0
0.25
0.25
0.25 − 0 ][ ]| [ ]
𝑥1
𝑥2
=
0
0

(0.25) 𝑥1❑ +(0.25) 𝑥2 =0



−( 0.25) 𝑥 1
𝑥 2=
0.25

𝐼𝑓 𝑥 1=1 , 𝑥 2=− 1 [ ] [ ]
𝑥1
𝑥2
=
1
−1
Step 4 : find the Eigen vector

Eigen vector for

|𝐶 𝑓 − λ 𝐼 |=0

|[ 0 .25 − λ
0.25
0.25
0.25 − λ ][ ]|=0
𝑥1
𝑥2

|[0 .25 − 0.5


0.25
0.25
0.25 − 0.5 ][ ]|=0
𝑥1
𝑥2


(− 0.25) 𝑥 +( 0.25) 𝑥 2=0
1 [ ] [ ]
𝑥1
𝑥2
=
1
1


(0. 2 5) 𝑥 2 ❑
𝑥1 = 𝐼𝑓 𝑥 2=1 , 𝑥 1=1
0.25
Step 5 : KL transformation matrix (A)

A = [ eigen vector (λ1 ), eigen vector (λ2 ), eigen vector (λ3 ),…]

λ1 > λ2 > λ3 ,…]

Since λ1 = 0.5 > λ2 = 0

A=

KL Transform )
KL Transform )

You might also like