0% found this document useful (0 votes)
6 views25 pages

Lecture 146 418

The document discusses image transforms, which are mathematical operations that convert images from one representation to another. It covers applications such as preprocessing, image compression, and feature extraction, as well as concepts like unitary matrices, energy conservation, and orthogonality. The document also addresses computational complexity and the use of separable transforms to reduce computation time.

Uploaded by

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

Lecture 146 418

The document discusses image transforms, which are mathematical operations that convert images from one representation to another. It covers applications such as preprocessing, image compression, and feature extraction, as well as concepts like unitary matrices, energy conservation, and orthogonality. The document also addresses computational complexity and the use of separable transforms to reduce computation time.

Uploaded by

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

02-Jun-11

Image Transforms
2

Image transforms can be simple arithmetic or complex


mathematical operations on images which convert images from
one representation to another.
IMAGE TRANSFORMS
Image (NxN) Image (NxN)
{XN} Transform
{YN}

Y=AX
By
Dr. Banshidhar Majhi Image (NxN)
{YN}
Inverse
Transform
Image (NxN)
{XN}

X=A-1Y

Dr. Banshidhar Majhi,


Image Transforms Professor, CSE dept. of NIT Rourkela

Applications Basic Process of Transform Coding


3 4

Preprocessing
† Filtering

† Enhancement

Image Compression

Feature Extraction
† Edge detection
† Corner detection

Dr. Banshidhar Majhi, Dr. Banshidhar Majhi,


Image Transforms Professor, CSE dept. of NIT Rourkela Image Transforms Professor, CSE dept. of NIT Rourkela

1
02-Jun-11

Unitary Matrix Properties of Unitary Transform y =Ax


5 6

Image transformation represents a given image into series Energy Conservation


sum of unitary matrices † || y ||2 = || x ||2

„ || y ||2 = || Ax ||2= (Ax)*T (Ax)= x*T A*T A x = x*T x = || x ||2


A matrix is called unitary if
Rotation
A−1 = 
A*T ≡ A H
† A unitary transformation is a rotation of a vector in an N-
Hermitian conjugate
dimension space, i.e., a rotation of basis coordinates

Unitary Matrices are basis images

Dr. Banshidhar Majhi, Dr. Banshidhar Majhi,


Image Transforms Professor, CSE dept. of NIT Rourkela Image Transforms Professor, CSE dept. of NIT Rourkela

Contd.. What is orthogonal ?


7 8

Energy Compaction A set of real valued continuous functions


{an(t)} = {ao(t), a1(t),…} is said to be orthogonal over
† Many common unitary transforms (like DCT, KLT etc.) tend to (t0, t0+T) if
pack a large fraction of signal energy into just a few transform
⎧k if m = n
coefficients
∫a m (t ). an (t ) dt = ⎨
⎩0 if m ≠ n
Decorrelation T

if k = 1 then an (t ) is orthonormal
† Highly correlated input elements Î quite uncorrelated output
coefficients
† Covariance matrix E[( y – E(y) ) ( y – E(y) )*T ]

Dr. Banshidhar Majhi, Dr. Banshidhar Majhi,


Image Transforms Professor, CSE dept. of NIT Rourkela Image Transforms Professor, CSE dept. of NIT Rourkela

2
02-Jun-11

Example Orthogonal Expansion


9 10

{sinωt, sin2ωt} Any arbitrary signal x(t); {t0, t0+T}


Can be represented by series summation of a set of
orthogonal basis functions.

x(t ) = ∑ cn an (t )
n =0

cn nth coefficient of expansion

Dr. Banshidhar Majhi, Dr. Banshidhar Majhi,


Image Transforms Professor, CSE dept. of NIT Rourkela Image Transforms Professor, CSE dept. of NIT Rourkela

Contd.. Discrete Formulation


11 12


Let the set of samples represented by {u(n): 0 ≤ n ≤ N-1}
x (t ) = ∑n = 0
c n a n ( t ), t 0 ≤ t < t 0 + T
is a vector of dimension N

⇒ ∫ x (t)a m ( t ) dt = ∫ ∑ n = 0
c na n ( t ) a m ( t ) dt

Premultiply u by a unitary matrix A of dimension N*N,


T T

= c 0 ∫ a 0 (t )a m ( t ) dt +
T we get another vector
c1 ∫ a1 (t )a ( t ) dt + ... +
T
m
v= Au
c m ∫
T
a m (t )a m ( t ) dt + ... Transformed vector
Transformation matrix

⇒ ∫ x ( t ) a m ( t ) dt = kc m ⇒ ∫ x(t )am(t )dt = cm, if k = 1


T
T
Orthonormal Set
Dr. Banshidhar Majhi, Dr. Banshidhar Majhi,
Image Transforms Professor, CSE dept. of NIT Rourkela Image Transforms Professor, CSE dept. of NIT Rourkela

3
02-Jun-11

Contd.. Example
13 14

In the form of series summation Let ⎡u 0 ⎤ ⎡ v0 ⎤ ⎡a00 a01 a02 ⎤


N −1 U = ⎢⎢ u1 ⎥⎥
V = ⎢⎢ v1 ⎥⎥ A = ⎢⎢ a10 a11 a12 ⎥⎥
v(k ) = ∑ a ( k , n )u ( n )
n=0
0 ≤ k ≤ N −1 ⎢⎣u2 ⎥⎦ ⎢⎣v2 ⎥⎦ ⎢⎣a20 a21 a22 ⎥⎦

⎡a00 a10 a20 ⎤
where A −1 = A *T A−1 = A∗T = ⎢⎢ a01 a11 a21 ⎥⎥
As A is a unitary matrix we can get back u as ⎢⎣a02 a12 a22 ⎥⎦
N −1
U = A−1V = A∗T V
u ( n) = ∑ v ( k ) a ( k , n)

0 ≤ n ≤ N −1 ∗ ∗ ∗
k =0 ⎡u 0 ⎤ ⎡v0 ⎤ ⎡a00 ⎤ ⎡a10 ⎤ ⎡a20 ⎤
The columns ofA∗T U = ⎢⎢ u1 ⎥⎥ = A−1 ⎢⎢ v1 ⎥⎥ = ⎢⎢ a01 ⎥⎥ v0 + ⎢⎢ a11 ⎥⎥ v1 + ⎢⎢ a21 ⎥⎥ v2
⎣⎢u2 ⎦⎥ ⎣⎢v2 ⎦⎥ ⎣⎢a02 ⎦⎥ ⎣⎢a12 ⎦⎥ ⎣⎢a22 ⎦⎥
i.e., {
(ak∗ ≈ a ∗ (k , n ), 0 ≤ n ≤ N − 1 ) } T
are called the basis vectors of A basis vectors b1 b2 b3
Dr. Banshidhar Majhi, Dr. Banshidhar Majhi,
Image Transforms Professor, CSE dept. of NIT Rourkela Image Transforms Professor, CSE dept. of NIT Rourkela

Contd.. Contd..
15 16

‰ Set of complete orthonormal discrete basis function satisfies the


In case of an image, an image can be represented by a set of basis images
following properties
Image u ( m, n) 0 ≤ m, n ≤ N − 1
N −1 N −1 ak ,l (m, n) Orthonormality
v(k , l ) = ∑∑ a k ,l ( m , n )u ( m , n ) 0 ≤ k , l ≤ N − 1
N −1 N −1

∑∑ a (m, n)ak∗',l ' (m, n) = δ (k − k ' , l − l ')


m =0 n=0
k ,l
ak ,l (m, n) N × N matrix/ N2 numbers of such matrices m=0 n=0
Completeness
Inverse Transform
N −1 N −1
N −1 N −1
∑∑ a (m, n)ak∗,l (m' , n' ) = δ (m − m' , n − n')
u(m, n) = ∑∑ ak∗,l (m, n)v(k , l ) 0 ≤ m, n ≤ N −1 k =0 l =0
k ,l

k =0 l =0

Dr. Banshidhar Majhi, Dr. Banshidhar Majhi,


Image Transforms Professor, CSE dept. of NIT Rourkela Image Transforms Professor, CSE dept. of NIT Rourkela

4
02-Jun-11

Computational Complexity Separable Transforms


17 18

To Compute transform coefficient v(k , l ) where {ak (m), k = 0,1,..N − 1} are 1D orthonormal sets of basis vectors
N −1 N −1
{bl (n), l = 0,1,..N − 1}
v(k , l ) = ∑∑ ak ,l (m, n)u (m, n) 0 ≤ k , l ≤ N − 1 should be unitary matrices themselves i.e.
In most cases we choose A & B to be same A ≈ {a(k , m)} and B = {a (l , n)}
m =0 n =0

For each v(k , l ) no. of complex multiplications and additions N −1 N −1


v(k , l ) = ∑∑ a ( k , m ) u ( m , n ) a ( l , n ); V = AUA T
~ O(N2), so for all v(k , l )~O(N4) which is quite expensive for m =0 n=0
N −1 N −1
practical size Images. u (m , n) = ∑∑
k =0 l =0
a ∗ ( k , m ) v ( k , l ) a ∗ ( l , n ); U = A ∗T VA ∗

How to reduce computation time?? V = AU A T


Using separable unitary transforms V T = A [ AU ]T
These are called 2D separable transformation
ak,l (m, n) = ak (m).bl (n) ≈ a(k, m)b(l, n) The 2D transform can be performed first by transforming each column of U
and then transforming each row of the result to obtain rows of V
complexity is 2N3
Dr. Banshidhar Majhi, Dr. Banshidhar Majhi,
Image Transforms Professor, CSE dept. of NIT Rourkela Image Transforms Professor, CSE dept. of NIT Rourkela

Concept of Basis Images Concept of Basis Images


19 20

∗ ∗T
Let a denotes the kth column of A
k Then the transformation equation can be written as
Define the matrices N −1 N −1
v( k , l ) = ∑∑ ak ,l (m, n)u (m, n) ≈ U , Ak∗,l
Ak∗,Tl = (ak∗ al∗ )T m =0 n =0
N −1 N −1
u (m, n) = ∑∑ ak∗,l (m, n)v(k , l )
Define the inner product of two NxN matrices F and G k =0 l =0
N −1 N −1
⇒ U = u (m, n) = ∑∑ v(k , l ) Ak∗,l
N −1 N −1
F , G = ∑∑ f (m, n )g ∗ (m, n ) k =0 l =0
m =0 n = 0
U is represented by linear combination of N2 Matrices.
These matrices are called basis images
Ak∗,l k , l = 0,1, 2..N − 1
Dr. Banshidhar Majhi, Dr. Banshidhar Majhi,
Image Transforms Professor, CSE dept. of NIT Rourkela Image Transforms Professor, CSE dept. of NIT Rourkela

5
02-Jun-11

Example Contd..
21 22

1 ⎛1 1⎞ ⎛1 2⎞
A= ⎜
2 ⎜⎝1
U = ⎜⎜

− 1⎟⎠

4 ⎟⎠
Inverse Transform gives
⎝3
1 ⎛1 1 ⎞ ⎛1 2 ⎞ ⎛1 1⎞
Transformed Image V = ⎜⎜ ⎟⎜ ⎟⎜ ⎟
2 ⎝1 − 1⎠⎟ ⎝⎜ 3 4 ⎠⎟ ⎝⎜1 − 1⎠⎟ 1 ⎛1 − 1⎞⎛ 5 − 1⎞⎛1 1⎞
A∗T VA∗ = ⎜⎜ ⎟⎜ ⎟⎜ ⎟
1⎛ 4
= ⎜⎜
6 ⎞⎛1
⎟⎜
1⎞
⎟ 2 ⎝1 − 1⎟⎠⎜⎝ − 2 0 ⎟⎠⎜⎝1 − 1⎟⎠
2 ⎝− 2 − 2 ⎟⎠⎜⎝1 − 1⎟⎠
⎛ 5 − 1⎞ 1 ⎛3 − 1⎞⎛1 − 1⎞ ⎛ 1 2⎞
= ⎜⎜ ⎟⎜ ⎟=⎜ ⎟
− 1⎟⎠⎜⎝1 − 1⎟⎠ ⎜⎝ 3 4 ⎟⎠
= ⎜⎜ ⎟
⎝− 2 0 ⎟⎠ 2 ⎝7
To get basis images, take outer product of the columns of A ∗T = U ⇒ Original Image
1⎛1⎞ 1 ⎛1 1⎞
A ∗
= ⎜⎜ ⎟⎟ (1 1 ) = ⎜⎜ ⎟
1 ⎟⎠
0,0
2 ⎝1⎠ 2 ⎝1
1 ⎛1 − 1⎞
A 0∗,1 = ⎜⎜ ⎟ = A1∗, 0
2 ⎝ 1 − 1 ⎟⎠
1 ⎛ 1 − 1⎞
A1∗,1 = ⎜⎜ ⎟
2 ⎝−1 1 ⎟⎠
Dr. Banshidhar Majhi, Dr. Banshidhar Majhi,
Image Transforms Professor, CSE dept. of NIT Rourkela Image Transforms Professor, CSE dept. of NIT Rourkela

Some Transformation Techniques Fourier Transform (1D)


23 24

Discrete Fourier Transform Continuous Fourier Transform (CFT)



Discrete Cosine Transform W ( f ) = F {w ( t )} = ∫ w (t ) e
− j 2 π ft
dt
Karhunen-Loeve Transform −∞

W(f ) = X(f )+ jY(f )


Haar Transform W ( f ) = W ( f ) e jθ ( f ) Frequency, [Hz]

Walsh Transform Phase


Amplitude Spectrum
Hadamard Transform Spectrum

Inverse Fourier Transform (IFT)



w ( t ) = F -1{W (f )} = ∫ W (f ) e + j2πft df
−∞
Dr. Banshidhar Majhi, Dr. Banshidhar Majhi,
Image Transforms Professor, CSE dept. of NIT Rourkela Image Transforms Professor, CSE dept. of NIT Rourkela

6
02-Jun-11

Discrete Fourier Transform (1D) 2D – Discrete Fourier Transform


25 26

Equal time intervals


ƒ Image: f(x, y), 0≤x≤N-1, 0≤y≤N-1
„ Discrete Domains
‰ Discrete Time: n = 0, 1, 2, 3, …………, N-1 ⎛ xu yv ⎞
− j 2π ⎜ + ⎟
‰ Discrete Frequency: k = 0, 1, 2, 3, …………, N-1 ƒ Transform kernel: g ( x, y, u , v) = e ⎝ N N ⎠

Equal frequency intervals

„ Discrete Fourier Transform ƒ Discrete Fourier Transform of f(x, y)is


N −1 ⎛ 2π ⎞
− j⎜ ⎟ nk
X [ K ] = ∑ x[n] e ⎝ N ⎠
; K = 0, 1, 2,….., N-1
1 N −1 N −1 ⎛ ux vy ⎞
− j 2π ⎜ + ⎟
n =0 F (u , v) = ∑∑ f (x, y )e ⎝N N⎠
N x =0 y =0
„ Inverse DFT N −1 N −1 ⎛ ux vy ⎞
⎛ 2π ⎞ 1 j 2π ⎜ + ⎟
f ( x, y ) =
N −1
1
∑∑ F (u, v)e
j⎜ ⎟ nk
∑ X [K ] e
⎝ N N ⎠
x[n] = ⎝ N ⎠
; n = 0, 1, 2,….., N-1
N K =0
N u =0 v =0

Dr. Banshidhar Majhi, Dr. Banshidhar Majhi,


Image Transforms Professor, CSE dept. of NIT Rourkela Image Transforms Professor, CSE dept. of NIT Rourkela

Contd.. Contd..
27 28

In general, Transform kernel can be represented as: Let R(u,v), I(u,v) be real part and imaginary part of
2π 2π F(u,v)
−j − j (ux + vy )
wN = e N
wNux + vy = e N
Modulus: (
F (u , v) = R 2 (u , v ) + I 2 (u , v ) )12

Discrete Fourier Transform of f(x, y) can be


represented as ⎛ I (u , v ) ⎞
Phase: Φ (u , v ) = tan −1 ⎜⎜ ⎟⎟
⎝ R (u , v ) ⎠
N −1 N −1
1
F (u , v ) =
N
∑∑ f (x, y )w
x =0 y =0
ux + vy
N
Power Spectrum: E (u , v) = R 2 (u , v ) + I 2 (u , v )
N −1 N −1
1
f ( x, y ) = ∑∑ F (u, v) w ( − ux + vy )
N
N u =0 v =0
Dr. Banshidhar Majhi, Dr. Banshidhar Majhi,
Image Transforms Professor, CSE dept. of NIT Rourkela Image Transforms Professor, CSE dept. of NIT Rourkela

7
02-Jun-11

Amplitude and Phase Images and their spectrums


29 30

Image domain Frequency domain Image domain Frequency domain

F (x)

amplitude

phase

original
∠F (x)
Dr. Banshidhar Majhi, Dr. Banshidhar Majhi,
Image Transforms Professor, CSE dept. of NIT Rourkela Image Transforms Professor, CSE dept. of NIT Rourkela

Properties of 2-D Fourier Transform Separability


31 32

• Separability ‰ The implementation steps for the two-dimensional DFT


• Linearity may be visualized as shown in the diagram below
• Scaling
• Shift Theorem Column Row
Transforms Transforms
• Rotation f(x,y) F(x,v) F(u,v)
• Periodicity and conjugation Multiply by N

• Convolution
• Correlation
• Average

Dr. Banshidhar Majhi, Dr. Banshidhar Majhi,


Image Transforms Professor, CSE dept. of NIT Rourkela Image Transforms Professor, CSE dept. of NIT Rourkela

8
02-Jun-11

Separability (contd. ) Linearity


33 34

‰ DFT is a linear operator

F[ a f1(x,y)+b f2(x,y)] = aF1(u,v)+bF2(u,v)


f(x,y) F(u,v)

f(x,y) F(x,v) F(u,v)

Dr. Banshidhar Majhi, Dr. Banshidhar Majhi,


Image Transforms Professor, CSE dept. of NIT Rourkela Image Transforms Professor, CSE dept. of NIT Rourkela

Linearity (contd..) Scaling


35 36

1 ⎛u v⎞
f (ax, by ) ⎯DFT
⎯⎯→ F⎜ , ⎟
ab ⎝ a b ⎠
f1(x,y) f2(x,y) 2f1(x,y)+3f2(x,y) Phase Spectrum

F1(u,v) F2(u,v) Phase Spectrum (2F1(u,v)+3F2(u,v))

Dr. Banshidhar Majhi, Dr. Banshidhar Majhi,


Image Transforms Professor, CSE dept. of NIT Rourkela Image Transforms Professor, CSE dept. of NIT Rourkela

9
02-Jun-11

Scaling (contd..) Shift Theorem


37 38

f ( x − x0 , y − y0 ) F (u, v ) exp[ − j 2π (ux 0 + vy0 ) / N ]

f(x,y) F(u,v)

f ( x , y ) exp[ j 2π (u0 x + v 0 y ) / N ] F ( u − u0 , v − v 0 )

f(2x,3y) F(u,v)
Dr. Banshidhar Majhi, Dr. Banshidhar Majhi,
Image Transforms Professor, CSE dept. of NIT Rourkela Image Transforms Professor, CSE dept. of NIT Rourkela

Shift Theorem (contd..) Rotation


39 40

In polar coordinates, f (x,y) and F(u,v) can be represented by f(r,


θ) and F(w,φ) alternatively. Then
f (r, θ+ θ0) F(w,φ + θ0)

Original Image Spectrum Image


Mesh Plot

(a) a sample image (b) its spectrum (c) rotated image (d) resulting spectrum

Tx = 50, Ty =50 Spectrum Image


Mesh Plot
Dr. Banshidhar Majhi, Dr. Banshidhar Majhi,
Image Transforms Professor, CSE dept. of NIT Rourkela Image Transforms Professor, CSE dept. of NIT Rourkela

10
02-Jun-11

Periodicity and conjugation Convolution


41 42

2-D convolution is defined as:


Periodicity :
F(u,v) = F(u+aN,v+bN) 1 M −1 N −1

f (x,y) = f (x+aN,y+bN)
f e ( x, y ) ∗ g e ( x, y ) =
MN
∑∑ f
m =0 n =0
e (m, n) g e ( x − m, y − n)

Where a, b = 0, ±1, ± 2,…… Then: f(x, y)*g(x, y)Ù F(u, v)G(u, v)


Conjugation:
F(u,v) = F*(-u,-v) f(x, y)g(x, y)ÙF(u, v)*G(u, v)
|F(u,v)| = |F(-u,-v)|

Dr. Banshidhar Majhi, Dr. Banshidhar Majhi,


Image Transforms Professor, CSE dept. of NIT Rourkela Image Transforms Professor, CSE dept. of NIT Rourkela

Convolution (contd..) Correlation


43 44

2-D correlation is defined as:


M −1 N −1
1
f e ( x, y) D ge ( x, y) =
MN
∑∑ f
m= 0 n = 0
e
*
(m, n) g e ( x + m, y + n)

Original image Spectrum


Correlation Theorems:
f ( x , y ) D g ( x , y ) ⇔ F * ( u, v ) G ( u, v )

f * ( x , y ) g ( x , y ) ⇔ F ( u , v ) D G ( u, v )

Convolved image(convolved with mean filter) Spectrum


Dr. Banshidhar Majhi, Dr. Banshidhar Majhi,
Image Transforms Professor, CSE dept. of NIT Rourkela Image Transforms Professor, CSE dept. of NIT Rourkela

11
02-Jun-11

Average Contd..
45

Average of 2D image f (x, y) is defined as:


< < image
N −1 N −1
_
1
f ( x, y) = 2
N
∑ ∑ f ( x, y)
x =0 y =0

Let u=v=0 , then:


N −1 N −1
1
F (0,0) =
N
∑ ∑ f ( x, y)
x =0 y =0
and its
spectrum
_
1
f ( x, y) = F ( 0,0)
N
46
Dr. Banshidhar Majhi,
Image Transforms Professor, CSE dept. of NIT Rourkela

Fast Fourier Transform Visualizing the DFT


47 48

Consider the power spectrum of the 1D square wave


350

300

recursive algorithm 250

200

• decimation in time = odd even in freq. domain 150

• decimation in freq. domain = odd even in time 100

50

N → N log N
4 2
0
0 1 2 3 4 5 6 7

Dr. Banshidhar Majhi, Dr. Banshidhar Majhi,


Image Transforms Professor, CSE dept. of NIT Rourkela Image Transforms Professor, CSE dept. of NIT Rourkela

12
02-Jun-11

Visualizing the DFT(circular shifting) Filtering in Frequency Domain


49 50

The FT is centered about the origin


Multiply pixel f(x,y) of the input image by (-1)x+y
But the DFT is centered about N/2
Compute the DFT:F(u,v)
We need to correct with a circular shift operation
G(u,v) = F (u,v) H(u,v)
Or, multiply by (-1)k prior to taking the transform
350
g1(x,y)= F -1{G(u,v)}
300 g(x,y) = g1(x,y)*(-1)x+y
250

200

150

100

50

0
0 1 2 3 4 5 6 7

Dr. Banshidhar Majhi, Dr. Banshidhar Majhi,


Image Transforms Professor, CSE dept. of NIT Rourkela Image Transforms Professor, CSE dept. of NIT Rourkela

Contd.. DFT basis images


51 52

Dr. Banshidhar Majhi,


Image Transforms Professor, CSE dept. of NIT Rourkela

13
02-Jun-11

Example-1 Example-2
53 54

img=imread('lena.bmp','bmp'); A=imread('lena.bmp','bmp');
subplot(121);imshow(img);
m = fft2(A);
title('original image ')
fimg=fftshift(fft2(img)); m = fftshift(m);
subplot(122); imshow(abs(fimg)/10000) subplot(2,2,1);imshow(A);
title(' transformed image ')
original image transformed image
title('Original Image');
subplot(2,2,3)
mm = log(1+abs(m));
mm = mm/max(max(mm))*255;
imshow(uint8(mm));
title('Modulus');

Dr. Banshidhar Majhi, Dr. Banshidhar Majhi,


Image Transforms Professor, CSE dept. of NIT Rourkela Image Transforms Professor, CSE dept. of NIT Rourkela

Contd.. Contd..
55 56 Original Image Reconstruction Image

subplot(2,2,4)
ma= angle(m);
ma = (ma-min(min(ma)))/(max(max(ma)) -
min(min(ma)) )*255;
imshow(uint8(ma));
title('Phase');
[i,j] = find(abs(m)==max(max(abs(m)))); Modulus Phase

m(i,j) = m(i,j)*2;
s = ifft2(m);
subplot(2,2,2)
imshow(uint8(abs(s)));
title('Reconstruction Image');

Dr. Banshidhar Majhi, Dr. Banshidhar Majhi,


Image Transforms Professor, CSE dept. of NIT Rourkela Image Transforms Professor, CSE dept. of NIT Rourkela

14
02-Jun-11

Discrete Cosine Transform (DCT) Contd..


57 58
‰ DCT expresses a sequence of finite data points in
Transform kernel of two-dimensional DCT is
terms of a sum of cosine functions oscillating at
different frequencies. ⎡π (2 x + 1)u ⎤ ⎡π (2 y + 1)v ⎤
C ( x, y, u, v) = α (u ) ⋅α (v) ⋅ cos ⎢ ⎥ ⋅ cos ⎢
‰ These cosine functions are treated as its basis ⎣ 2 N ⎦ ⎣ 2 N ⎥⎦
function.
Fast algorithm exists. where
‰ 1 2
Most popular in image compression application
α ( 0) = , α (i) = , 1≤ i ≤ N
‰
N N
because of its energy compaction property.
Clearly, the kernel for the DCT is both separable and
‰ Adopted in JPEG.
symmetric, and hence the DCT may be implemented as a
‰ The periodicity implied by DCT implies that it series of one dimensional DCTs.
causes less blocking effect than DFT.
‰ Can be implemented by 2n points FFT. Dr. Banshidhar Majhi,
Image Transforms Professor, CSE dept. of NIT Rourkela

Contd.. Basis images of an 8x8 DCT


59 60

Forward transform
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 ⎦

Inverse Transform
N −1 N −1
⎡ π (2 x + 1)u ⎤ ⎡ π (2 y + 1)v ⎤
f ( x, y) = ∑∑ α (u )α (v) F (u, v) cos ⎢ cos
u = 0 v =0 ⎣ 2 N ⎥⎦ ⎢⎣ 2 N ⎥⎦
where u, v, x, y = 0, 1, 2, …, N-1
Forward and inverse transformations are same
Dr. Banshidhar Majhi, Dr. Banshidhar Majhi,
Image Transforms Professor, CSE dept. of NIT Rourkela Image Transforms Professor, CSE dept. of NIT Rourkela

15
02-Jun-11

Properties of DCT Example


61 62

Separability
2D DCT/ IDCT expression shows that they are separable.
So they can be implemented as two 1-D DCT/IDCT
Fast DCT
Original Image DCT Coefficients
FDCT is possible in the same manner as FFT
Periodicity
Magnitude of DCT coefficient is periodic with period 2N

DCT Coefficients
(Zoomed) Mesh Plot
Dr. Banshidhar Majhi,
Image Transforms Professor, CSE dept. of NIT Rourkela

Image Reconstruction in DCT Contd..


63 64

Original image Reconstructed image

Using 6 DCT Using 15 DCT


coefficients coefficients
Using only 1
DCT coefficient

Using 3 DCT Using 10 DCT Using 64 DCT


coefficients coefficients coefficients
Coefficients are selected
out of 8x8 window

Dr. Banshidhar Majhi, Dr. Banshidhar Majhi,


Image Transforms Professor, CSE dept. of NIT Rourkela Image Transforms Professor, CSE dept. of NIT Rourkela

16
02-Jun-11

Karhunen-Loeve Transform Contd..


⎡ x1 ⎤
65 66 ⎢x ⎥
† K-L transform is a linear combination of orthogonal Covariance matrix of a population of vectors X = ⎢ 2⎥
⎢: ⎥

{ }
functions of ensembles of input images. ⎢ ⎥
C x = E ( X − μ x )( X − μ x ) ⎣ xn ⎦
T
† Basis functions are image dependent

† No fast algorithm exists


Where
† Not so useful in image compression
1 M
† Usually used for comparison μx = ∑ Xk
M k =1
Thus
† Transform kernel is not fixed unlike other transforms
1 M
† Based on second order statistical properties of image Cx = ∑
M k =1
X k X kT − μx μxT
† Also called Hotelling transform or method of principal
components C x ⇒ real & symmetric
So, Orthogonal vectors of Cx can be calculated
Dr. Banshidhar Majhi, Dr. Banshidhar Majhi,
Image Transforms Professor, CSE dept. of NIT Rourkela Image Transforms Professor, CSE dept. of NIT Rourkela

Contd.. Example
67 68

‰ Calculate eigenvectors and eigenvalues of Cx Input matrix

‰ Sort eigenvectors depending on decreasing values of ⎧ ⎛ 3 ⎞⎛ 4 ⎞⎛ 4 ⎞⎛ 4 ⎞⎛ 5 ⎞⎛ 5 ⎞⎛ 5 ⎞⎛ 6 ⎞⎫


x = ⎨ ⎜⎜ ⎟⎟⎜⎜ ⎟⎟⎜⎜ ⎟⎟⎜⎜ ⎟⎟⎜⎜ ⎟⎟⎜⎜ ⎟⎟⎜⎜ ⎟⎟⎜⎜ ⎟⎟⎬
eigenvalues
⎩ ⎝ 4 ⎠⎝ 3 ⎠⎝ 4 ⎠⎝ 5 ⎠⎝ 4 ⎠⎝ 5 ⎠⎝ 6 ⎠⎝ 5 ⎠⎭
‰ Select some of the eigenvectors
‰ These eigenvectors are considered as transformed matrix Mean Vector ⎛
⎜ 4 .5 ⎞

μ x = ⎜ ⎟
‰ Calculate the transformed images ⎜⎜
⎝ 4 .5 ⎟⎟

Y = A( X − μ x )

‰ Y is called as principal component coefficients.


‰This transformation is called K-L transform
Dr. Banshidhar Majhi, Dr. Banshidhar Majhi,
Image Transforms Professor, CSE dept. of NIT Rourkela Image Transforms Professor, CSE dept. of NIT Rourkela

17
02-Jun-11

Contd.. Contd..
69 70

⎛ 0 . 75 0 . 375 ⎞
C X = ⎜⎜ ⎟⎟
⎝ 0 . 375 0 . 75 ⎠ We get two Eigen vectors
1 ⎛1 ⎞
Compute Eigen values e = ⎜⎜ ⎟⎟
1 1
2 ⎝ ⎠
( 0 . 75 − λ ) 2 = ( 0 . 375 ) 2
1 ⎛ 1 ⎞
⇒ 0 . 75 − λ = ± 0 . 375 e = ⎜⎜ ⎟⎟
2 − 1
2 ⎝ ⎠
⇒ λ = 0 . 75 ± 0 . 375
Transform Matrix
λ 1 = 1 . 125 ⎡1 1 ⎤
→ A = 1
λ 2 = 0 . 375 ⎢1 − 1 ⎥⎦
2 ⎣
Dr. Banshidhar Majhi, Dr. Banshidhar Majhi,
Image Transforms Professor, CSE dept. of NIT Rourkela Image Transforms Professor, CSE dept. of NIT Rourkela

Properties of K-L Transform Principal Component Coefficients


71 72

Decorrelation
† E[ y yH ]= E[ (UH x) (UH x)H ]= UH E[ x xH ] U = diag{λ1, λ2, … , λN}

† Note: Other matrices (unitary or nonunitary) may also


decorrelate the transformed sequence

Minimizing MSE under basis restriction


† If only allow to keep m coefficients for any 1≤ m ≤N, what’s
the best way to minimize reconstruction error? Lena image Energy compaction in lena image
Æ Keep the coefficients w.r.t. the eigenvectors of the first m
largest Eigen values

Dr. Banshidhar Majhi, Dr. Banshidhar Majhi,


Image Transforms Professor, CSE dept. of NIT Rourkela Image Transforms Professor, CSE dept. of NIT Rourkela

18
02-Jun-11

Image Reconstruction in K-L Transform Haar Wavelet Transform


73

One dimensional transformation on each row followed by one


dimensional transformation of each column.

Extracted coefficients would be


† Approximation
† Vertical
1 PC 10 PCs 20 PCs † Horizontal
† Diagonal

Approximation coefficients are further decomposed into the next level


Original image
50 PCs All PCs
4 level decomposition is used

Dr. Banshidhar Majhi, Dr. Banshidhar Majhi,


Image Transforms Professor, CSE dept. of NIT Rourkela Image Transforms Professor, CSE dept. of NIT Rourkela

Contd.. Approach

For a 2X2 matrix

⎛a b⎞ ⎛a + b a − b⎞
x = ⎜⎜ ⎟⎟ x = ⎜⎜ ⎟⎟
⎝c d ⎠ ⎝c + d c − d ⎠

1 ⎛a + b + c + d a −b + c − d ⎞
y = ⎜⎜ ⎟
2 ⎝ a + b − c + d a − b − c + d ⎟⎠

Graphical Representation - Wavelet decomposition


(level = 2)

Dr. Banshidhar Majhi, Dr. Banshidhar Majhi,


Image Transforms Professor, CSE dept. of NIT Rourkela Image Transforms Professor, CSE dept. of NIT Rourkela

19
02-Jun-11

Example Properties of Haar transform


78

2 2 9 5 4 14 0 4 The Haar transform is real and orthogonal. Therefore,


2 0 5 2 Column wise Summation 2 7 2 3
Hr=Hr*
6 7 4 7 13 11 -1 -3
3 4 8 8 7 16 -1 0 The Haar transform is a very fast transform.

On an Nx1 vector it can be implemented in O(N) operations


Row wise Summation

The Haar transform has poor energy compaction for Images


Approximation Horizontal

3 10.5 1 3.5 6 21 2 7
Finding Average
10 13.5 -1 -1.5 20 27 -2 -3
1 3.5 -1 0.5 2 7 -2 1
3 -2.5 0 -1.5 6 -5 0 -3
Vertical Diagonal
Dr. Banshidhar Majhi,
Image Transforms Professor, CSE dept. of NIT Rourkela

Basis images of Haar Transform 1-step Haar Decomposition


79 80

Original image Haar transformed image

Dr. Banshidhar Majhi, Dr. Banshidhar Majhi,


Image Transforms Professor, CSE dept. of NIT Rourkela Image Transforms Professor, CSE dept. of NIT Rourkela

20
02-Jun-11

2-step Haar Decomposition Discrete Walsh Transform (1-D)


81
b ( x ) bn−1−i ( u )
1 n −1 i

g ( x, y ) = ∏ (−1)
 N i =0
1− D Forward Kernel

where,
N → No. of Samples
n → No. of bits needed to represent x and u
b k ( z ) → k th bit in digital representation of z
n −1 b ( x ) bn−1−i ( u )
1 N −1 i

W (u ) = ∑ f ( x)∏ (−1)
 N x =0 i =0
Dr. Banshidhar Majhi, 1− D Forward Transform Dr. Banshidhar Majhi,
Image Transforms Professor, CSE dept. of NIT Rourkela Image Transforms Professor, CSE dept. of NIT Rourkela

Contd.. Discrete Walsh Transform (2-D)

n −1 bi ( x ) bn−1−i ( u ) {bi ( x ) bn−1−i ( u ) + bi ( y ) bn−1−i ( v )}


1 n −1
h( x, u ) = ∏ (−1) g ( x, y, u , v) = ∏ ( −1)
 N i =0
Difference
 i =0
lies in
2 − D Forward Kernel

1− D Inverse Kernel n −1 {bi ( x ) bn−1−i ( u ) +bi ( y ) bn−1−i ( v )}


Multiplicative 1 N −1 N −1

Factor W (u, v) = ∑ ∑ f ( x, y)∏ (−1)


N −1 n −1 bi ( x ) bn−1−i ( u )
N y =0 x =0 i =0
f ( x) = ∑W (u)∏ (−1) 
2 − D Forward Transform
x =0
 i =0
1− D Inverse Transform

Dr. Banshidhar Majhi, Dr. Banshidhar Majhi,


Image Transforms Professor, CSE dept. of NIT Rourkela Image Transforms Professor, CSE dept. of NIT Rourkela

21
02-Jun-11

Contd.. Property

{bi ( x ) bn−1−i ( u ) + bi ( y ) bn−1−i ( v )}


• Separable
1 n −1
h( x, y, u , v) = ∏ ( −1) 1
 N i =0 W (u ) = [Weven (u ) + Wodd (u )]
2 − D Inverse Kernel
2
1
{bi ( x ) bn−1−i ( u ) +bi ( y ) bn−1−i ( v )} W (v) = [Weven (u ) − Wodd (u )]
n −1
1 N −1 N −1 2
f ( x, y) = ∑ ∑W (u, v)∏ (−1) where,
N y =0 x =0 i =0
 N
u = 0,1,..., − 1
2 − D Inverse Transform
2
N
M=
2
Dr. Banshidhar Majhi, Dr. Banshidhar Majhi,
Image Transforms Professor, CSE dept. of NIT Rourkela Image Transforms Professor, CSE dept. of NIT Rourkela

Basis images of Walsh Transform Hadamard transform


87 88

Transform matrices can be recursively generated

⎛1 1 ⎞
H1 = ⎜⎜ ⎟⎟
⎝1 − 1⎠
H n = H n −1 ⊗ H1
H 3 = H1 ⊗ H 2 , H 2 = H1 ⊗ H1
"
Note: Hadamard Coefficients need reordering to concentrate
energy

Dr. Banshidhar Majhi, Dr. Banshidhar Majhi,


Image Transforms Professor, CSE dept. of NIT Rourkela Image Transforms Professor, CSE dept. of NIT Rourkela

22
02-Jun-11

Contd.. Basis images of Hadamard Transform


90

n −1

1 ∑{bi ( x )bi (u )+bi ( y )bi ( v )}


g ( x, y, u , v) = (−1) i=0
 N
2 D Forward Kernel
n −1

1 ∑{bi ( x )bi (u )+bi ( y )bi ( v )}


h( x, y, u , v) = (−1) i=0
 N
2 D Inverse Kernel

Dr. Banshidhar Majhi, Dr. Banshidhar Majhi,


Image Transforms Professor, CSE dept. of NIT Rourkela Image Transforms Professor, CSE dept. of NIT Rourkela

Contd.. Hadamard Matrix


n −1
N=2 1 ∑ bi ( x ) bi ( u )
g ( x, u ) = ( −1) i=0
⎡1 1 ⎤ N
H2 = ⎢ ⎥ Hadamard Matrix
u
⎣1 − 1⎦ 0(0) 1(7) 2(3) 3(4) 4(1) 5(6) 6(2) 7(5)
0 + + + + + + + +

⎡H HN ⎤ 1 + - + - + - + - sign changes
H 2N = ⎢ N are not

H − N ⎥⎦
2 + + - - + + - -
ordered (shown
⎣H N x
3 + - - + + - - + in backet)
4 + + + + - - - -
5 + - + - - + - +
6 + + - - - - + +
Dr. Banshidhar Majhi, 7 + - - + - + + - Dr. Banshidhar Majhi,
Image Transforms Professor, CSE dept. of NIT Rourkela Image Transforms Professor, CSE dept. of NIT Rourkela

23
02-Jun-11

Ordered Hadamard Transformation Contd..


n −1

1 ∑ bi ( x ) p i ( u ) N=8
g ( x, u ) = ( − 1) i = 0
N
u
where ,
0 1 2 3 4 5 6 7
p 1 ( u ) = b n −1 ( u ) + b n − 2 ( u ) bi (u) is changed to pi(u) 0 + + + + + + + +

p 2 (u ) = bn − 2 (u ) + bn − 3 (u ) 1 + + + + - - - -
2 + + - - - - + +
. 3 + + - - + + - -
x
. 4 + - - + + - - +
5 + - - + - + + -
. 6 + - + - - + - +

p n −1 ( u ) = b1 ( u ) + b 0 ( u ) 7 + - + - + - + -
Dr. Banshidhar Majhi, Dr. Banshidhar Majhi,
Image Transforms Professor, CSE dept. of NIT Rourkela Image Transforms Professor, CSE dept. of NIT Rourkela

Properties of Hadamard Transform Similarity between Walsh and Hadamard Transform

95 96

Unlike Other Transform, the elements of the basis vectors of Basis images of Walsh and Hadamard transforms
the Hadamard transform take only the binary values +1 , -1, are same.
therefore well suited for DSP
Hadamard transform H is real, symmetric, and orthogonal So Hadamard transform is also known as Walsh
Hadamard transform is a fast transform. The one dimensional
transform or Hadamard-Walsh transform.
transform can be implemented in O(N log2 N) additions and
subtractions

Dr. Banshidhar Majhi, Dr. Banshidhar Majhi,


Image Transforms Professor, CSE dept. of NIT Rourkela Image Transforms Professor, CSE dept. of NIT Rourkela

24
02-Jun-11

Image Reconstruction Image Reconstruction


97 98

Original image Reconstructed image


Original image Reconstructed image

Dr. Banshidhar Majhi, Dr. Banshidhar Majhi,


Image Transforms Professor, CSE dept. of NIT Rourkela Image Transforms Professor, CSE dept. of NIT Rourkela

99

25

You might also like