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

8 - Image Transforms PDF

The document outlines various image transforms including the Fourier transform, discrete cosine transform, and Haar transform. It explains that image transforms convert an image from the spatial domain to another domain where calculations and operations may be simpler. The forward and inverse transforms are described using kernel functions. Key properties of transforms like orthogonality, completeness, and unitarity are defined. The discrete Fourier transform and its 2D version are explained in detail using matrix notation.

Uploaded by

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

8 - Image Transforms PDF

The document outlines various image transforms including the Fourier transform, discrete cosine transform, and Haar transform. It explains that image transforms convert an image from the spatial domain to another domain where calculations and operations may be simpler. The forward and inverse transforms are described using kernel functions. Key properties of transforms like orthogonality, completeness, and unitarity are defined. The discrete Fourier transform and its 2D version are explained in detail using matrix notation.

Uploaded by

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

Outline

• Image Transforms
• 1D and 2D Fourier Transform
• Properties of 2D-DFT
• Discrete Cosine Transform
• Discrete Sine Transform
• Walsh Transform
• Haar Transform

28-Jan-19 1
Image Transform
•Why we need to study different image transforms?

Original Difficult Solution Solution to Original


Problem in Problem in Spatial
Spatial Domain Domain

Transform
Inverse
Transform

Relatively easy
Problem in Solution Solution in
Transformed
Domain Transformed Domain

28-Jan-19 2
Image Transform
• In general, 2D linear Transforms can be expressed
M 1 N 1
as: T (u, v)   f ( x, y )r ( x, y, u, v)
Where, x 0 y 0
•f(x, y) is the input image, r(x, y, u, v) is called the forward transformation kernel.
•Eqn. is evaluated for u=0,1,2…..M-1 and v=0,1,2,…….N-1
•x and y are spatial variables, M and N are the row and column dimensions of f.
•Variables u and v are called as transform variables.
•T(u,v) is called the forward transform of f(x,y).

•Inverse transform can be expressed as:


M 1 N 1
f ( x, y )   T (u, v) s( x, y, u, v)
u 0 v 0
Where,
•s(x, y, u, v) is called the inverse transformation kernel.
•Eqn. is evaluated for x=0,1,2…..M-1 and y=0,1,2,…….N-1
28-Jan-19 3
Image Transforms
• In general, image transform pairs can be expressed as:
M 1 N 1
T (u, v)   f ( x, y )r ( x, y, u, v)
x 0 y 0
M 1 N 1
f ( x, y )   T (u, v) s( x, y, u, v)
u 0 v 0
• Forward and inverse kernels or basis functions or images
are said to be separable if:
r ( x, y, u, v)  r1 ( x, u)r2 ( y, v) s( x, y, u, v)  s1 ( x, u)s2 ( y, v)
• They are symmetric if r1(x,y) is functionally equal to r2(x,y)
r ( x, y, u, v)  r1 ( x, u)r1 ( y, v) s( x, y, u, v)  s1 ( x, u)s1 ( y, v)
• It means that 2D transforms can be computed using two 1D
transforms
28-Jan-19 4
Image Transforms
• When Forward and Inverse kernels of a transform pair are
separable and symmetric, and f(x,y) is a Square image of
size MXM then the forward transform eqn. in matrix form
is: Where, F is an MXM matrix of f(x,y),
A is an MxM matrix with elements aij=r1(i,j ) and
T  AFA T is the resulting MXM transform with values T(u,v)
for u,v =0,1,2…M-1 called Transform coefficients
• Inverse transform is computed by: BTB  BAFAB
Where, B is an inverse transformation matrix.
• If B=A-1 then F  BTB and
• if B is not equal to A-1 then use of above eqn. gives
approximations
Fˆ  BAFAB
28-Jan-19 5
CONT..
• Orthonormality: no two basis represent the same
information in the image.
• Completeness: all information in the image are
represented in the set of basis functions.
• Unitary Transform:
– let a 1D linear transform is represented as: g=AN f
– The transform is called Unitary iff
• A-1=A*T≡AH(i.e. Hermitian Conjugate)
– “Orthogonal” if A is Unitary and real
• i.e. A=A* and AAH=AAT=I. or A-1=AT
• An orthogonal matrix is unitary but an unitary matrix not
necessarily be orthogonal
28-Jan-19 6
Numerical

Matrix Unitary Orthogonal


1 NO NO
2 YES YES
3 YES YES
4 NO NO
5 YES NO
28-Jan-19 7
CONT..
• Steps for image processing in linear transform
domain are:

•For example, Fourier Transform

Fourier
Transform

Apply the
mask

Inverse Fourier
Transform

28-Jan-19 8
Fourier Transform
•Fourier Transform (FT)is analogous to a glass prism.
•The prism separates light into various color
components, each depending on its wavelength (or
frequency) content.
•FT may be viewed as a "mathematical prism" that
separates a function into various components, also
based on frequency content.
•Any periodic or non periodic (area under the curve is
finite) function can be expressed as the integral of
sines and/or cosines multiplied by a weighing
function.
28-Jan-19 9
CONT..
• 1D FT for a continuous function is:

 f (t )e
 j 2 t
F ( )  dt


•Inverse FT is:
 F ( )e
j 2 t
f (t )  d


•The above two eqn.s are called Fourier Transform


Pair.
•By Euler’s eqn. we can write:
F ( )   f (t )[cos(2t )  j sin(2t )]dt

28-Jan-19 10
CONT

Fourier
Transform

28-Jan-19 11
CONT..
•1D-Discrete Fourier Transform (DFT):
M 1
F (u )   f ( x)e  j 2ux / M

x 0
M 1
1
f ( x) 
M
 F (u)e
u 0
j 2ux / M

•The above two eqn.s are called Discrete Fourier


Transform Pair.

28-Jan-19 12
CONT
•Signal sampled at T intervals have replicas in
frequency domain with cycle 1/T.

Fourier
Transform

•Under-sampling causes Aliasing

Fourier
Transform

28-Jan-19 13
CONT
Nyquist Theorem: If maximal frequency of f(x) is fmax ,
sampling rate should be larger than 2fmax in order to
fully reconstruct f(x) from its samples.
2fmax is the Nyquist frequency.

1
f s   2 f max
T

28-Jan-19 14
CONT..
•2D Discrete Fourier Transform (DFT):
M 1 N 1
F (u, v)   f ( x, y )e  j 2 ( ux / M  vy / N )

x 0 y 0 u=0,1,2…..M-1 and v=0,1,2,…….N-1

M 1 N 1
1
f ( x, y ) 
MN
 F (u, v)e
x 0 y 0
j 2 ( ux / M  vy / N )

•The above two eqn.s are called 2D-Discrete


Fourier Transform Pair.

28-Jan-19 15
DFT example 0 1 3 4
•Find the DFT of Image matrix F of size 4x4 1 2 3 5

 r ( x, y, u, v)  r1 ( x, u)r2 ( y, v) 2 3 5 6
4 5 6 7

e j 2 (ux/ M vy / N )  e j 2ux/ M e j 2vy / N


r1 ( x, u)  e  j 2ux/ M •For u,x =0, 1,2,3
•Fourier coefficients are computed as: T=AFA Where, Matrix A for a 4x4 DFT

 a11 a12 a13 a14  r1(0,0)=e0=1 r1(0,1)=e0=1 r1(0,2)=e0=1 r1(0,3)=e0=1


a ..... ...... a  r1(1,0)=e0=1 r1(1,1)=e-j2π/4=-j r1(1,2)= e-j4π/4=-1
A   21 24 
r1(1,3)= e-j2π3/4=j
a31 ...... ......   1 1 1 1 
  1  j  1  j 
 41
a ...... ...... a 44 
A 
where aij=r1(i,j) 1  1 1  1 
 
1  j  1  j 

28-Jan-19 16
DFT example
•Fourier coefficients are computed as: T=AFA
1 1 1 1  0 1 3 4 1 1 1 1 
1  j  1  j  1  j  1  j 
  1 2 3 5
 
1  1 1  1  2 3 5 6 1  1 1  1 
   
1  j  1  j  4 5 6 7   
1 j 1 j 

Fourier 57 -10 + 11i -9 -10 - 11i

coefficientsT= -8+11i
-9
1
-2 + 1i
1i
1
-1
-2 - 1i
-8- 11i -1 - 1i 1

28-Jan-19 17
IDFT example
•To get the reconstructed image F from Fourier coefficients we use: F=BTB
1 Where, B=A-1=A*T
 s( x, y, u, v)  s1 ( x, u ) s2 ( y, v) 1 1 1 1 
MN 1  j  1  j 
1 j 2 (ux/ M vy / N ) 1 j 2ux/ M j 2vy / N
e  e e A 
MN MN 1  1 1  1 
1 1 1 1  
1 j  1  j  1  j  1  j 
B  A*  
T 
1  1 1  1 
 
1  j  1 j  1 1 1 1
1 1 1  
1 1 1 j  1  j 
  57 -10 + 11i -9 -10 - 11i
1 1 j  1  j  -8+11i 1 1i -1 4 1  1 1  1 
4 1  1 1  1 
-9 -2 + 1i 1 -2 - 1i  
-8- 11i -1 - 1i 1 1  j  1 j 
 
1  j  1 j  0 1 3 4
1 2 3 5
Matrix F 2 3 5 6
28-Jan-19 4 5 6 7 18
1 1 1 1 
CONT… 1  j  1  j 
• Basis image or function for DFT A 
1  1 1  1 
 
•For u=0 and v=0 the basis image will be : 1  j  1  j 
1 1 1 1 1 1 1  j 1 j
1 1 1 1 1 1 1  j 1 j 
A00     1 1 1 1   A01     1  j  1 j  
1 1 1 1 1 1 1  j 1 j
     

1 1 1 1 1 1 1  j 1 j

1 1  1 1  1 1 1  j 1  j
1 1  1 1  1 1 1  j  1  j 
A02     1  1 1  1   A03     1  j  1  j   
1 1  1 1  1 1 1  j 1  j
     

1 1  1 1  1 
1 1  j 1  j

1   1  j 1 j 
 j   j  1 j 1  1  1  j 1 j 
 j   j 1  j  1
A11     1  j 1 j   
  1   1 j 1  j  A31     1  j  1 j   
     1  1 j 1  j
 j   j 1  j  1    
 j    j  1 j 1 
28-Jan-19 19
DFT Basis image (4x4)

28-Jan-19 20
Cont..

Log of the magnitude Shift F(0,0) to the centre


28-Jan-19 21
Cont..

Original image Magnitude spectrum

Shifted Magnitude spectrum Log of Shifted Magnitude spectrum


28-Jan-19 22
Cont..

Phase
Original image

Topside view of phase angle Another view of phase angle


28-Jan-19 23
Examples of DFT

28-Jan-19 24
Examples of DFT

28-Jan-19 25
Examples of DFT

28-Jan-19 26
Examples of DFT

28-Jan-19 27
Cont..
• Some more examples of magnitude spectrum.

28-Jan-19 28
Cont..
• Some more examples of log of magnitude.

28-Jan-19 29
Cont..
• Phase angle examples.

28-Jan-19 30
Cont..

Mag.

Phase

28-Jan-19 31
Cont..

Mag.

Phase

28-Jan-19 32
Cont..

Chee
tah
Mag.

Zebra
Phase

28-Jan-19 33
Cont..

Zebra
Mag.

Cheetah
Phase

28-Jan-19 34
Properties of 2D DFT

28-Jan-19 35
Properties of 2D DFT

28-Jan-19 36
Properties of 2D DFT
Separability : F(u,v) 2-D transform of an image is equal to
computing two 1-D transforms :
•First 1D along each row gives F(x,v);
•Second 1D to F(x,v) along each column obtaining F(u,v)
M 1 N 1
F (u, v)   e  j 2ux / M
 f ( x, y ) e  j 2vy / N

x 0 y 0
M 1
F (u, v)   F ( x, v)e  j 2ux / M N 1
x 0 Where, F ( x, v)   f ( x, y )e  j 2vy / N
y 0

28-Jan-19 37
Properties of 2D DFT
Translation : The magnitude Fourier Spectrum
remains unchanged under translation
f ( x, y)e j 2 (u0 x / M v0 y / N )  F (u  u0 , v  v0 )

f ( x  x0 , y  y0 )  F (u, v)e j 2 (ux0 / M vy0 / N )

28-Jan-19 38
Properties of 2D DFT
Rotation : The Fourier Spectrum rotates by the
same angle .
f (r,  0 )  F (,   0 )
x  r cos  u   cos 
y  r sin  v   sin 

28-Jan-19 39
Properties of 2D DFT
Periodicity :

28-Jan-19 40
Properties of 2D DFT
Scaling:

28-Jan-19 41
Symmetry Properties of 2D DFT
•Any real or complex function can be expressed as:
w( x, y)  we ( x, y)  wo ( x, y)
Where, w( x, y)  w( x, y) w ( x, y)  w( x, y)  w( x, y)
we ( x, y)  o
2 2
•Even functions are symmetric and odd are anti-symmetric
we ( x, y)  we ( x, y) wo ( x, y)  wo ( x, y)
•Or, Odd functions have first term (i.e.w0(0,0)=0 )always 0.
we ( x, y)  we (M  x, N  y) wo ( x, y)  wo (M  x, N  y)
•For eg. Consider the 1D sequences
f ( x)  {2 1 1 1} g ( x)  {0  1 0 1} h( x)  {0  1 0 1 0}
•Which one is odd and even?
Is f ( x)  f (4  x) Is f (1)  f (3) Is g ( x)   g (4  x) Is g (1)   g (3)
Is h( x)  h(5  x) Is h( x)  h(5  x)
28-Jan-19 42
Symmetry Properties of 2D DFT
•FT of a real functn is conjugate symmetric.
f ( x, y) is real  F * (u, v)  F (u,v)

• FT of a imaginary functn is conjugate anti- symmetric


f ( x, y) is imaginary  F * (u,v)  F (u, v)

•FT of a real function has Even Real part and odd


imaginary part
•For e.g. f(x)={1,2,3,4}  {10 (2  2 j)  2 (2  2 j)}
R(u)  {10  2  2  2} I (u)  {0 2 0  2}

28-Jan-19 43
Symmetry Properties of 2D DFT

28-Jan-19 44
Symmetry Properties of 2D DFT

28-Jan-19 45
Summary of Properties of 2D DFT

28-Jan-19 46
Numerical
• Check for evenness and oddness
0 0 0 0 0 0 Test for evenness :
0 0 0 0 0 0 f(x,y)=f(M-x, N-y) for origin at (0,0)
0 0 -1 0 1 0
0 0 -2 0 2 0
Test for oddness :
0 0 -1 0 1 0 f(x,y)=-f(M-x, N-y) for origin at (0,0)
0 0 0 0 0 0

Lets check for evenness first: Now lets check for oddness:
• Is f(1,1)=f(6-1,6-1) or • Is f(1,1)=-f(6-1,6-1) or f(1,1)=-f(5,5)?
f(1,1)=f(5,5)? •f(1,1)=0 and f(5,5)=0
•f(1,1)=0 and f(5,5)=0 •f(2,2)=-1 and f(4,4)=1, f(3,2)=-2 and
•F(2,2)=-1 and f(4,4)=1 f(3,4)=2
•therefore, f(x,y) ≠ f(M-x, N-y) •f(2,4)=1 and f(4,2)=-1
• therefore, f(x,y) = -f(M-x,N-y)
28-Jan-19 47
Numerical
• Multiply the given image with (-1)x+y. and take DFT
0 1 3 4 G(0,0)=0(-1)0 G(0,0)=0 G(0,1)=1(-1)1 G(0,1)=-1
1 2 3 5
G(0,2)=3(-1)2 G(0,2)=3 G(0,3)=4(-1)3 G(0,3)=-4
2 3 5 6
4 5 6 7
• After multiplication, we get
0 -1 3 -4
-1 2 -3 5
2 -3 5 -6
-4 5 -6 7

• Take DFT, we get •Without multiplication if we take Take DFT, we get


1 -2 - 1i -9 -2 + 1i 57 -10 + 11i -9 -10 - 11i
- 1i 1 -8- 11i -1 -8+11i 1 1i -1
-9 -10 - 11i 57 -10 + 11i -9 -2 + 1i 1 -2 - 1i
1i -1 -8+11i 1 -8- 11i -1 - 1i 1

28-Jan-19 48
Convolution Theorem
•2D Convolution is expressed as:

•Convolution in one domain is multiplication in


the other and vice versa.

•Convolution is the tie between filtering in the


spatial and frequency domains.
28-Jan-19 49
Cont..
• 1D Example,

28-Jan-19 50
Cont..
• 2D Example,

28-Jan-19 51
Correlation
•2D Correlation is expressed as:

•Correlation in one domain is multiplication in


the other and vice versa.

•Correlation is used for matching.

28-Jan-19 52
Summary of Properties

28-Jan-19 53
Aliasing in 2D
•A band limited function f(t,z) has its FT=0 outside the
intervals [-umax,umax] and [-vmax,vmax]
•2D Sampling theorem: A continuous band-limited function
f(t, z) can be recovered with no error from a set of samples if
the sampling intervals are:
1
ft   2umax
T
1
fz   2vmax
Z

28-Jan-19 54
CONT..

FT 2x
Scaling

28-Jan-19 55
CONT….
ZOOMED

MOIRE PATTERN

28-Jan-19 56
CONT..

FT 2x
Scaling

28-Jan-19 57
Discrete Cosine Transform(DCT)
• Most frequently used transformations in Image
compression.
• It is obtained by the same forward and inverse kernel
r ( x, y, u, v)  s( x, y, u, v)
 (2 x  1)u   (2 y  1)v 
  (u ) (v) cos   cos  
 2n   2n
 1  1
 for u  0  for v  0
Where  (u )   n n
 (v )  
 2 2
for u  1,2,....n - 1  for v  1,2,....n - 1
 n  n

28-Jan-19 58
• Properties of DCT:
CONT..
• DCT is real and orthogonal i.e. C=C* implies C-1 = CT or
C.CT=I
• DCT is not the real part of the DFT. However, it is related to
DFT of its symmetric extension.
• DCT is a fast transform. i.e. DCT of N elements can be
calculated using N point FFT in N log2 N operations.
• DCT has excellent energy compaction for highly correlated
data.
• Basis vector for DCT are the eigen vectors of the matrix Q
 
1    0 0 
 
Qc     1  0 
 0  1  
 0   1   
28-Jan-19  0 59
DCT example 0 1 3 4
•Find the DCT of Image matrix F of size 4x4 1 2 3 5
 r ( x, y, u, v)  r1 ( x, u)r2 ( y, v) 2 3 5 6
 (2 x  1)u   (2 y  1)v  4 5 6 7
  (u ) cos   ( v ) cos  
 2n   2n 
 (2 x  1)u  
 1 n for u  0
r1 ( x, u )   (u ) cos   Where  (u )  
For u,x =0, 1,2,3    2 n for u  1,2,....n - 1
2n 

•DCT coefficients are computed as: T=AFAT Where, A is transformation matrix for a 4x4
DCT and is not symmetric and F is the NxN
image
r1(0,0)= √0.25=0.5=r1(1,0)= r1(2,0)= r1(3,0) r1(0,1)=1/√2*cos(pi/8)=0.6533
r1(0,2)=1/√2*cos(pi/4)=0.5 r1(0,3)=1/√2*cos(3*pi/8)=0.2706

r1(1,1)=1/√2*cos(3*pi/8)=0.2706 r1(2,2)=1/√2*cos(5*pi/4)=-0.5
r1(3,3)=1/√2*cos(21*pi/8)=-0.2706
0.5 0.6533 0.5 0.2706 
0.5 0.2706  0.5  0.6533
A 
0.5  0.2706  0.5 0.6533 
 
0.5  0.6533 0.5  0.2706
28-Jan-19 60
DCT example
•DCT coefficients are computed as: T=AFAT, since DCT is not symmetric.
we multiply by AT
0 1 3 4
0.5 0.6533 0.5 0.2706   0.5 0.5 0.5 0.5 
0.5 0.2706  0.5  0.6533 1 2 3 5 0.6533 0.2706  0.2706  0.6533
   
0.5  0.2706  0.5 0.6533  2 3 5 6  0.5  0.5  0.5 0.5 
   
0.5  0.6533 0.5  0.2706 4 5 6 7  0.2706  0.6533 0.6533  0.2706 

DCT 14.25 -5.7114 0.25 -0.0696


Coefficients T= -5.2495 -0.5303 0.1353 0.0732
0.75 0.3266 -0.25 0.1353
-0.261 -0.4268 -0.3266 0.5303

DFT 57 -10 + 11i -9 -10 - 11i


-8+11i 1 1i -1
Coefficients T= -9 -2 + 1i 1 -2 - 1i
-8- 11i -1 - 1i 1
28-Jan-19 61
IDCT example
•To get the reconstructed image F from DCT coefficients we use: F=BTBT
 s( x, y, u, v)  s1 ( x, u)s2 ( y, v) Where, B= A-1=A*T=AT
0.5 0.6533 0.5 0.2706 
 (2 x  1)u  0.5 0.2706  0.5  0.6533
s1 ( x, u )   (u ) cos  
 2n  A 
0.5  0.2706  0.5 0.6533 
 0.5 0.5   
0.5  0.6533 0.5  0.2706
0.5 0.5
0.6533 0.2706  0.2706  0.6533
BA 
T 
 0.5  0.5  0.5 0.5 
 
0.2706  0.6533 0.6533  0.2706
 0.5 0.5 0.5 0.5  14.25 -5.7114 0.25 -0.0696 0.5 0.6533 0.5 0.2706 
0.6533 0.2706  0.2706  0.6533 0.5 0.2706  0.5  0.6533
  -5.2495 -0.5303 0.1353 0.0732  
 0.5  0.5  0.5 0.5  0.75 0.3266 -0.25 0.1353 0.5  0.2706  0.5 0.6533 
   
0.2706  0.6533 0.6533  0.2706 -0.261 -0.4268 -0.3266 0.5303  0.5  0.6533 0.5  0.2706 
0 1 3 4
1 2 3 5
Matrix F
2 3 5 6
28-Jan-19 4 5 6 7 62
CONT… 0.5 0.6533 0.5 0.2706 
0.5 0.2706  0.5  0.6533
• Basis image or function for DCT A 
0.5  0.2706  0.5 0.6533 
 
 0.5  0.6533 0.5  0.2706 
•For u=0 and v=0 the basis image will be :
0.5 0.25 0.25 0.25 0.25
0.5 0.25 0.25 0.25 0.25
A00     0.5 0.5 0.5 0.5  
0.5 0.25 0.25 0.25 0.25
   
0.5 0.25 0.25 0.25 0.25
0.5 0.3266 0.1353 -0.1353  0.3266
0.5 0.3266 0.1353 -0.1353  0.3266
A01     0.6533 0.2706  0.2706  0.6533  
0.5 0.3266 0.1353 -0.1353  0.3266
   
 
0.5 0.3266 0.1353 -0.1353  0.3266

0.5 0.25 -0.25 -0.25 0.25


0.5 0.25 -0.25 -0.25 0.25
A02     0.5  0.5  0.5 0.5  
0.5 0.25 -0.25 -0.25 0.25
   
0.5 0.25 -0.25 -0.25 0.25

28-Jan-19 63
DCT Basis image (4x4)

28-Jan-19 64
Discrete Sine Transform(DST)
• Expressed as T=AFA, where A is the DST transformation
(NxN) matrix and F is the NxN image.
• DST is obtained by the same forward and inverse kernel

r ( x, y, u, v)  s( x, y, u, v)

2 2  (u  1)( x  1)   (v  1)( y  1) 


 sin   sin  
N 1 M 1  M 1   N 1 

For u,v=0,1,2…..M-1 and For v=0,1,2…..N-1

28-Jan-19 65
CONT..
• Properties of DST:
• DST is Real, Symmetric and orthogonal i.e. C=C*=C-1= CT
• DST is not the imaginary part of the DFT. However, it is
related to DFT of its anti-symmetric extension.
• DST is a fast transform. i.e. DST of N elements can be
calculated using 2(N+1) point FFT in N log2 N operations.
• Fast Sine transform is usually defined for
N=3,7,15,31,63,255…
• Fast sine transforms are faster than the FFT and the Fast
Cosine transform algorithms.  1  0 
  1   
• Basis vectors for DST are the eigen vectors of : 
Q  
 0  1 

28-Jan-19 66
DST example 0 1 3 4
•Find the DST of Image matrix F of size 4x4 1 2 3 5
 r ( x, y, u, v)  r1 ( x, u)r2 ( y, v) 2 3 5 6

2 2  ( x  1)(u  1)   ( y  1)(v  1)  4 5 6 7


 sin   sin  
N 1 M 1  M 1   N 1 
2  ( x  1)(u  1) 
r1 ( x, u )  sin  
For u,x =0, 1,2,3
M 1  M 1 
•DST coefficients are computed as: T=AFA Where, Matrix A for a 4x4 DFT

r1(0,0)= √(2/5)* sin(pi/5)=0.3717 r1(0,1)=√(2/5)*sin(2*pi/5)=0.6015

r1(0,2)= √(2/5)*sin(3*pi/5 )=0.6015 r1(0,3)= √(2/5)*sin(4*pi/5)=0.3717

r1(1,1)= √(2/5)*sin(4*pi/5)=0.3717 r1(2,2)= √(2/5)*sin(9*pi/5)=-0.3717

0.3717 0.6015 0.6015 0.3717  r1(3,3)= √(2/5)*sin(16*pi/5)=-0.3717


0.6015 0.3717 -0.3717 -0.6015
A
0.6015 -0.3717 -0.3717 0.6015 
 
0.3717 -0.6015 0.6015 -0.3717

28-Jan-19 67
DST example
•DST coefficients are computed as: T=AFA
0.3717 0.6015 0.6015 0.3717  0 1 3 4 0.3717 0.6015 0.6015 0.3717 
0.6015 0.3717 -0.3717 -0.6015 1 2 3 5 0.6015 0.3717 -0.3717 -0.6015
 
0.6015 -0.3717 -0.3717 0.6015  2 3 5 6 0.6015 -0.3717 -0.3717 0.6015 
   
0.3717 -0.6015 0.6015 -0.3717 4 5 6 7 0.3717 -0.6015 0.6015 -0.3717

DST Coefficients T= DCT Coefficients T=


13.261 -5.5451 3.4395 -1 14.25 -5.7114 0.25 -0.0696
-5.0451 -0.4472 -1 -0.0854 -5.2495 -0.5303 0.1353 0.0732
3.9395 -1 0.739 -0.0451 0.75 0.3266 -0.25 0.1353
-1 -0.5854 -0.5451 0.4472 -0.261 -0.4268 -0.3266 0.5303

57 -10 + 11i -9 -10 - 11i


-8+11i 1 1i -1
DFT Coefficients T= -9 -2 + 1i 1 -2 - 1i
-8- 11i -1 - 1i 1
28-Jan-19 68
DST Basis image (4x4)

28-Jan-19 69
Walsh Hadamard Transform(WHT)
• A computationally simpler transform that is useful in
transform coding.
• WHT consist of alternating plus and minus 1s, unlike other
kernels which are sums of sines and cosines.
• Hadamard transform matrices Hn are NxN matrices.
• Where, N=2n, n=1,2,3 and can be generated by the core
matrix and the Kronecker product recursion.
1 1 1  H  H  H  H  H  1  H n1 H n1 
H 0  1, H1  1  1 n n 1 n 1 H 

1 1
2  2  n1 H n 1 

• For e.g. N=8 i.e. n=3 the H3 becomes


1 H 2 H 2  1  H1 H1 
H 3  H 2  H1   H  H  H 2  H1  H1  2  H  H 
2 2 2  1 1
28-Jan-19 70
Walsh Hadamard Transform(WHT)
• Now, 1 1 1  1  H1 H1 
H1  1  1 H 2  H  H 
2  2  1 1

1 1 1 1 
1 H 2 H 2  1 1  1 1  1 
H3  H  H   
2 2 H2 
2
4 1 1  1  1
1 1 1 1 1 1 1 1 1  1  1 1 
1 1 1 1 1 1 1  1

1 1 1 1 1 1 1  1
 
1 1 1 1 1 1 1 1 1
H3 
8 1 1 1 1 1 1 1  1
 
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
 
1 1 1 1 1 1 1  1
28-Jan-19 71
Walsh Hadamard Transform(WHT)
• The basis vectors of the HT can also be generated by
sampling a class of functions called Walsh functions.
• Also called as WHT 1
r ( x, y, u, v)  s( x, y, u, v) (1)b ( x ,u ) b ( y ,v )
N
m 1
Where b( x, u )   xi ui
i 0
•Where, N=2m e.g. if N=4 then m=2
•xi and ui are the ith bit from right to left in the binary representation
•For eg. x=3 in binary 11, so, x0=1 and x1=1.
•If N=8, then m=3 and x=u=6 in binary 110, so, x0=0, x1=1 and , x2=1.

• Similarly, for b(y,u)

28-Jan-19 72
CONT..
• Properties of WHT:
• WHT is real, symmetric and orthogonal i.e. H=H*= H-1 = HT
or H.HT=I
• WHT is a fast transform. i.e. WHT of N elements can be
implemented in N log2 N additions and subtractions.
• Since WHT contains only +1 and -1 values.
No multiplications are required in the transform
calculations
• Hadamard transform has good to very good energy
compaction for highly correlated images.

28-Jan-19 73
WHT example 0 1 3 4
•Find the WHT of Image matrix F of size 4x4 1 2 3 5
1
 r ( x, y, u, v)  r1 ( x, u)r2 ( y, v)  (1)b ( x ,u ) b ( y ,v ) 2 3 5 6
m 1 N 4 5 6 7
Where, b( x, u )   xi ui
i 0 u,x 0 1 2 3
1
r1 ( x, u )  (1) b ( x ,u ) For u,x =0, 1,2,3 u1 or x1 0 0 1 1
N
Now , N=4, so, m=2 u0 or x0 0 1 0 1
1
r1 (0,0)  (1) x0u0  x1u1=1/√4(-1)00+00 1 r1 (3,2) 
1
(1) x0u0  x1u1
4 
4 4
1 x0u0  x1u1
r1 (1,1)  (1) =1/√4(-1)10+11 =-1/√4
4 =1/√4(-1)11+00  1
1
1 r1 (3,3)  (1) x0u0  x1u1
r1 (1,2)  (1) x0u0  x1u1 4
4
4 =1/√4(-1)10+01 1
 =1/√4(-1)11+11 =1/√4
1 4
r1 (2,2)  (1) x u  x u
0 0 1 1
1 1 1 1 
4 =1/√4(-1)00+11  1
4 1 1  1 1  1 
r1 (3,1) 
1
(1) x u x u
0 0 1 1
=1/√4(-1) 11+10 =-1/√4 H2   
4 4 1 1  1  1
28-Jan-19 1  1  1 1  74
WHT example
•DST coefficients are computed as: T=AFA
1 1 1 1  0 1 3 4 1 1 1 1 
1 1  1 1  1  1 2 3 5 1 1  1 1  1 
   
4 1 1  1  1 2 3 5 6 4 1 1  1  1
1  1  1 1  4 5 6 7 1  1  1 1 

WHT Coefficients T= DCT Coefficients T=


14.25 -2.25 -5.25 0.25 14.25 -5.7114 0.25 -0.0696
-2.25 0.25 -0.75 -0.25 -5.2495 -0.5303 0.1353 0.0732
-4.75 -0.25 -0.25 0.25 0.75 0.3266 -0.25 0.1353
0.75 0.25 0.25 -0.25 -0.261 -0.4268 -0.3266 0.5303

57 -10 + 11i -9 -10 - 11i


-8+11i 1 1i -1
DFT Coefficients T= -9 -2 + 1i 1 -2 - 1i
-8- 11i -1 - 1i 1
28-Jan-19 75
CONT…

28-Jan-19 76
WHT Basis image (4x4)

28-Jan-19 77
Haar Transform(HT)
• Expressed as T=HrFHrT, since Haar is not symmetric, we multiply by
transform matrix’s transpose.
• Where Hr is the Haar transformation matrix and F is the NxN image
• Hr contains Haar basis functions, which are one of the simplest and
oldest known orthonormal functions.
• Haar basis functions hk(z) are defined over a continuous interval (0,1)
for integer k=0,1,2,3….N-1, Where N=2n.
1
h0 ( z )  h00 ( z )  , z  [0,1]
N
 2 (q-1) / 2 p  z  (q-0.5) / 2 p
p/2

1  p/2
hk ( z )  h pq ( z )   2 (q-0.5) / 2  z  q / 2
p p

N 
 0 otherwise
•Such that k=2p + q-1, where 0 ≤ p ≤ n-1, q=0 ,or q=1 for p=0
and 1 ≤ q ≤ 2p for p≠0 and 2p should be the largest power of 2
28-Jan-19 78
1
CONT…
h0 ( z )  h00 ( z )  , z  [0,1]
N  2 p / 2 (q-1) / 2 p  z  (q-0.5) / 2 p
1  p/2
hk ( z )  h pq ( z )   2 (q- 0 .5) / 2 p
 z  q / 2 p

N 
 0 otherwise

•The ith row of the NxN Haar matrix contains the elements
of hi(z)for z=0/N,1/N,2/N………N-1/N.
•For eg. If N=2 the 1st row of the 2x2 Haar matrix is
computed as:
•h0(z)=1/√2 independent of z
•2nd row is computed as: h1(z) for z=0/2, 1/2
When k=1 then p=0 and q=1,therefore,
1 1 1 
0
h1(0)=h01 (0) =2 /√2= 1/√2, Hr2  1  1
2 
h1(1/2)=h01 (1/2) =-20/√2= -1/√2
28-Jan-19 79
h0 ( z )  h00 ( z ) 
1
, z  [0,1] CONT…
N  2 p / 2 (q-1) / 2 p  z  (q-0.5) / 2 p
1  p/2
hk ( z )  h pq ( z )   2 (q- 0 .5) / 2 p
 z  q / 2 p

N 
 0 otherwise
For eg. If N=4 then k=0,1,2,3….N-1, Where N=2n and n=2. Also,
k=2p+q-1, where 0 ≤ p ≤ n-1, q=0 or q=1 for p=0 and 1 ≤ q ≤ 2p for p≠0
and 2p should be the largest power of 2. k 0 1 2 3
•It becomes 0 ≤ p ≤ 1, q=0 or q=1 for p=0; k=q and p 0 0 1 1
1 ≤ q ≤ 2 for p≠0 for p=1;k-1=q q 0 1 1 2
•The ith row of the NxN Haar matrix contains the elements of hi(z)for
z=0/N,1/N,2/N………N-1/N.
•For eg. If N=4 the 1st row of the 4x4 Haar matrix is computed as:
•h0(z)=1/√4;independent of z
•For 2nd row h1(z) i.e. k=1, p=0 & q=1, substitute these values, lower
limit is q-1/2p=0/1=0 , middle limit q-0.5/2p=0.5/1=1/2
and higher limit is q/2p=1/1=1
28-Jan-19 80
1
CONT…
h0 ( z )  h00 ( z )  , z  [0,1]  2 p / 2 (q-1) / 2 p  z  (q-0.5) / 2 p
N 1 
hk ( z )  h pq ( z )   2
p/2
(q-0.5) / 2 p  z  q / 2 p
N 
k 0 1 2 3  0 otherwise
p 0 0 1 1 • for N=4, z=0,1/4,2/4,3/4.
q 0 1 1 2

• For eg. If N=4 the 1st row of the 4x4 Haar matrix is computed as:
•h0(z)=1/√4; independent of z
•For 2nd row h1(z) i.e. k=1, p=0 & q=1, substitute these values, lower
limit is q-1/2p=0/1=0 , middle limit q-0.5/2p=0.5/1=1/2
and higher limit is q/2p=1/1=1
•h1(0)= 1/√4*20=1/√4; •h1(1/4)=1/√4*20=1/√4;
•h1(2/4 or 1/2)= 1/√4*-20=-1/√4; •h1(3/4)= 1/√4*-20=-1/√4

28-Jan-19 81
h0 ( z )  h00 ( z ) 
1
, z  [0,1] CONT…
N  2 p / 2 (q-1) / 2 p  z  (q-0.5) / 2 p
1 
hk ( z )  h pq ( z )   2
p/2
(q-0.5) / 2 p  z  q / 2 p
N 
k 0 1 2 3  0 otherwise
p 0 0 • for N=4, z=0,1/4,2/4,3/4.
1 1
q 0 1 1 2 •For 3 row h2(z) i.e. k=2, p=1 & q=1, substitute these
rd

values, lower limit is q-1/2p=0/2=0 ,


•middle limit q-0.5/2p=0.5/2=1/4 and higher limit is q/2p=1/2=0.5
•h2(0)= 1/√4*20.5=1/√4* √2; •h2(1/4)=1/√4*-20.5=1/√4* -√2;
•h2(2/4 or 1/2)= 1/√4*0=0; •h2(3/4)= 1/√4*0=0
•For 4th row h3(z) i.e. k=3, p=1 & q=2, substitute these values, lower
limit is q-1/2p=1/2=0.5 , middle limit q-0.5/2p=1.5/2=3/4
and higher limit is q/2p=2/2=1 1 1 1 1 
  1  1 
•h3(0)= 1/√4*0=0; •h3(1/4)=1/√4*0=0; 1 1 1
H4 
•h3(1/2)=1/√4*2 =1/√4* √2;
0.5 4 2  2 0 0 
 
•h3(3/4)=1/√4*-2 =1/√4* -√2;
0.5
 0 0 2  2 
28-Jan-19 82
CONT…
For eg. If N=8 then k=0,1,2,3….N-1, Where N=2n and n=3.
Also, k=2p+q-1, where 0 ≤ p ≤ n-1, q=0 or q=1 for p=0
and 1 ≤ q ≤ 2p for p≠0 and 2p should be the largest power of 2.
It becomes 0 ≤ p ≤ 2, q=0 or q=1 for p=0 and 1 ≤ q ≤ 4 for p≠0
p 0 0 1 1 1 1 2 2 2 2
q 0 1 1 2 3 4 1 2 3 4
2^p+q-1 0 1 2 3 4 5 4 5 6 7
• for N=8, z=0,1/8,2/8,3/8,4/8,5/8,6/8,7/8;
k 0 1 2 3 4 5 6 7
p 0 0 1 1 2 2 2 2
q 0 1 1 2 1 2 3 4

Hr8=

28-Jan-19 83
CONT..
• Properties of Haar: It is real and orthogonal i.e. H=H*
implies H-1 = HT or H.HT=I
• Haar is very fast transform. On an Nx1 vector it can be
implemented in O(N) operations
• Haar transform has poor energy compaction for images.
• Full potential in feature extraction and image analysis
problems.
1 1 1 
• Basis images can be calculated for 2x2 by H r 2  2 1  1
1 1 1 1  
A00  1     1  1
2 1 1 1
1 1 1 / 2 1 1
2   A01  1     
2 1 1  1
1 1 1 / 2
2  
1  1 1 1
A10  1    
2  1  1  1
1 1 1 / 2
1  1  1  1
2   A11  1     
2  1  1 1 
1 1 1 / 2
2  
28-Jan-19 84
Summary
Image
Properties
Transforms
•Fast Transform, Very good energy compaction, complex
DFT arithmetic
•Useful in DSP, Digital filtering ,analysis of Toeplitz systems
•Fast Transform, real arithmetic, excellent energy compaction
DCT •Useful in Transform coding and wiener filters.
•Very Fast Transform, symmetric, real arithmetic, Very Good
energy compaction for images
DST •Useful in coding, filtering, estimating performance bounds of
image processing problems.
•No multiplications are required, good energy compaction for
images
Hadamard •Useful in digital hardware implementation of image processing
algorithms, compression, filtering and design of codes.
•Very Fast Transform, Poor energy compaction for images.
Haar •Useful in image analysis problems, feature extraction, and image
coding.
28-Jan-19 85

You might also like