transforms notes
transforms notes
Enhancement in Frequency
Domain
Types of Matrix
• Symmetric Matrix: A is called symmetric if
𝐴" = 𝐴
• Hermitian Matrix: A is called Hermitian if
𝐴∗" = 𝐴
• Orthogonal Matrix
𝐴%& = 𝐴"
• Unitary Matrix
𝐴%&= 𝐴∗"
Types of Matrix
• Toeplitz Matrix: A NXN matrix is a Toeplitz matrix if
• The diagonals contain the same elements
• Each of the sub diagonals contain the same elements
𝐴 𝐵 𝐶 𝐷
𝐸 𝐴 𝐵 𝐶
𝐹 𝐸 𝐴 𝐵
𝐺 𝐹 𝐸 𝐴
• Circulant Matrix : each row is obtained by the circular shift of the previous
row
𝐴 𝐵 𝐶 𝐷
𝐷 𝐴 𝐵 𝐶
𝐶 𝐷 𝐴 𝐵
𝐵 𝐶 𝐷 𝐴
LINEAR SYSTEM
• f(m,n)-----Input sequence, g[m,n]= output sequence
f(m,n) g[m,n]
T
• The 2-D system can be written as
𝑔 𝑚, 𝑛 = 𝑇𝑓 𝑚, 𝑛
(infinitely high,
For that matter, since all of the area occurs right in one spot, one can write:
Delta functions – pg 1
Impulse Response
𝛿 𝑚 − 𝑚& , 𝑛 − 𝑛& T ℎ 𝑚, 𝑛; 𝑚& , 𝑛&
• When the input is a delta function at location [𝑚& , 𝑛& ], the output at
location [𝑚, 𝑛] is given by
• This is called the impulse response of the system. Takes general, negative
as well as complex values
𝑔 𝑚, 𝑛 = 𝑇𝑓 𝑚, 𝑛
4 5 6
11 13 15
• Ans: 𝑌 = 11 13 15
7 8 9
Convolution Example
123
Pb) Convolve ℎ 𝑚, 𝑛 = 3 4 5 with 𝑥 𝑚, 𝑛 = 4 5 6
789
SOLUTION: After convolution of the two signals the dimension of the
resultant matrix is given by
3 10 21 22 15
• 𝑌 = 12 31 58 49 30
21 52 94 76 45
Convolution Example
11 123
Pb) Convolve ℎ 𝑚, 𝑛 = 1 1 with 𝑥 𝑚, 𝑛 = 4 5 6
11 789
SOLUTION: After convolution of the two signals the dimension of the
resultant matrix is given by
1 3 5 3
5 12 16 9
• 𝑌 = 12 27 33 18
11 24 28 15
7 15 17 9
Image Transforms
• Most image processing applications are real timed
• Require very fast and simple operations
• Often Processing in frequency domain is easier than in the time
domain
• Fourier transform: a
continuous signal can be
represented as a
(countable) weighted sum
of sinusoids.
• Transform an intensity
image into the domain of
spatial frequency
1-D continuous FT
n 1D – FT
real(g(wx)) imag(g(wx))
w =0
n 1D – DFT of length N
w =7
x x
Fourier Transform
• CTFT:
𝑥 𝑡 → 𝑋(Ω)
>
•𝑋 Ω = ∫%> 𝑥 𝑡 𝑒 %VWX 𝑑𝑡
• DTFT: A continuous time signal x(t) is converted to discrete time
signal x(nT) by sampling process (T : sampling interval)
• 𝑋 𝑒 VY = ∑>
I[%> 𝑥 𝑛𝑇 𝑒
%VWIX
• 𝑓 𝑚, 𝑛 → 2𝐷 𝐷𝐹𝑇 → 𝐹(𝑘, 𝑙)
%VdrfH %VdrsI
• F 𝑘, 𝑙 = ∑q%& g%&
q[i ∑g[i 𝑓 𝑚, 𝑛 exp q
exp g
• Inverse Transform
&
2𝑥 + 1 𝜋 1
𝐶(1) = G 𝑓(𝑥) cos = 𝑓 0 − 𝑓(1)
4 2
…[i
& &
d d
DCT Matrix= & &
−
d d
1 2
• Apply DCT to F= and show energy compaction.
2 1
• Solution: 𝐷𝐶𝑇 = 𝑇𝐹𝑇 "
& 1 1 1 2 1 1
𝐷𝐶𝑇 = d
1 −1 2 1 1 −1
& 1 1 3 −1
𝐷𝐶𝑇 =d
1 −1 3 1
& 6 0 3 0
𝐷𝐶𝑇 =d =
0 −2 0 −1
)
1 2𝑥 + 1 𝜋 1 𝜋 3𝜋 5𝜋 7𝜋
𝐶(1) = G 𝑓(𝑥) cos = 𝑓 0 cos + 𝑓 1 cos + 𝑓 2 cos + 𝑓(3) cos
2 &'( 8 2 8 8 8 8
)
1 2𝑥 + 1 𝜋 1 𝜋 3𝜋 5𝜋 7𝜋
𝐶(2) = G 𝑓(𝑥) cos = 𝑓 0 cos + 𝑓 1 cos + 𝑓 2 cos + 𝑓(3) cos
2 &'( 4 2 4 4 4 4
)
1 2𝑥 + 1 3𝜋 1 3𝜋 9𝜋 15𝜋 21𝜋
𝐶(3) = G 𝑓(𝑥) cos = 𝑓 0 cos + 𝑓 1 cos + 𝑓 2 cos + 𝑓(3) cos
2 &'( 8 2 8 8 8 8
0.5 0.5 0.5 0.5
0.6533 0.2706 − 0.2076 − 0.6533
• 𝐷𝐶𝑇 𝑀𝑎𝑡𝑟𝑖𝑥 =
0.5 0.5 0.5 0.5
0.2706 − 0.6533 0.6533 − 0.2706
1 2 3 4
5 6 7 8
• Apply DCT to 𝐹 =
1 2 3 4
5 6 7 8
WALSH TRANSFORM
• Square-wave functions and take only two values +1 or -1.
• The Walsh Transform basis is given by
I%&
1
ℎ(𝑥, 𝑢) = ’(−1)[”• (…)”–—˜—• (Š)
𝑁
“[i
y x 0 1 2 3
0 1/4 1/4 1/4 1/4
& &
ℎ(2,1) = • ∏“[i(−1)[”0 (d)”12"20 (&)
&
ℎ(2,1) = • −1 ”3 (d)”" (&) × −1 ”" (d)”3 (&)
&
ℎ(2,1) = • −1 i×i × −1 &×&
&
ℎ(2,1) = • 1 × −1
&
ℎ 2,1 = − •
Easy Method
• Step 1: Write the binary representation of x
• Step 2: Write the binary representation of u in reverse order
• Step 3: Check the number of overlaps pf 1 between x and u
• Step 4: If the number of overlaps of 1 is
• Zero then sign is positive
• Even then sign is positive
• Odd then sign is negative
• When x=2, binary is 1 0, when u=1, binary is 0 1 ( reverse 1 0)
1 0
• Look for overlap of ones
1 0
• Number of overlaps =1 (odd) so negative ( already done in previous
eg)
Properties of Walsh Transform
• The 2-D Walsh transform is separable and symmetric.
• It can be implemented as a sequence of two 1-D Walsh transforms, in
a fashion similar to that of the 2-D DFT.
• Remember that the Fourier transform basis functions consist of
complex sinusoids.
• The Walsh transform consists of basis functions whose values are only
1 and −1.
• They have the form of square waves.
• These functions can be implemented more efficiently in a digital
environment than the exponential basis functions of the Fourier
transform.
• For any function f(x), the 1-D Walsh Transform is given by
& g%&
W(𝑢) = ∑…[i 𝑓(𝑥) ∏I%&
“[i (−1)[”0 (…)”12"20 (Š)
g
…[i “[i
&'( 5'(
𝐻g 𝐻g
𝐻dg =
𝐻g −𝐻g
1 1 1 1
𝐻• = 1 −1 1 −1
1 1 −1 −1
1 −1 −1 1
• Similarly, Hadamard matrix for 8,16 etc can be formed.
Sequency ordered Walsh Matrix from Hadamard
Matrix
• Sequency : Number of sign changes in a row
1 1 1 1
• 𝐻• = 1 −1 1 −1 No of sign changes : 0,3, 1, 2
1 1 −1 −1
1 −1 −1 1
• Arrange the rows in the sequency 0,1,2 3. We get the Walsh Matrix
1 1 1 1
• Walsh Matrix: 𝑊• = 1 1 −1 −1 Sequency: 0,1,2,3
1 −1 −1 1
1 −1 1 −1
Problem:
1. Prove that Hadamard transform works for the following image:
2 2
𝐹=
2 1
&
(Hint: 𝑇 = 𝐴×𝐹×𝐴 where 𝐴 = 𝐻d )
d
2121
1232
3. Given image 𝐹 = . Apply Walsh Transform and Hadamard
2343
1232
Transform and compare the results ( 2D case: T=W.F.WT)
• Let 𝑓(𝑥, 𝑦) denote the following constant 4 × 4 digital image that is
zero outside 0 ≤ 𝑥 ≤ 3, 0 ≤ 𝑦 ≤ 3, with 𝑟 a constant value.
𝑟 𝑟 𝑟 𝑟
𝑓(𝑥, 𝑦) = 𝑟𝑟 𝑟𝑟 𝑟𝑟 𝑟𝑟
𝑟 𝑟 𝑟 𝑟
Give the standard Hadamard Transform of 𝑓(𝑥, 𝑦) without carrying out
any mathematical manipulations.
𝑟 𝑟 𝑟 𝑟
𝑟 𝑟 𝑟 𝑟
Repeat the same with 𝑓(𝑥, 𝑦) = 0 0 0 0
0 0 0 0
Criticism of Fourier Spectrum
It’s giving you the spectrum of the
‘whole time-series’
time, t
Wavelet Analysis is based on a short duration
wavelet of a specific center frequency
time, t
Wavelet Transform
• What is a wavelet…?
• Flexibility.
FT Vs WT
Scaling
n Wavelet analysis produces a time-scale view of the signal.
n Scaling means stretching or compressing of the signal.
n scale factor (a) for sine waves:
f ( t ) = sin(t ) ; a = 1
f ( t ) = sin(2t ) ; a = 1 2
f ( t ) = sin(4t ) ; a = 1 4
Scaling (Cont’d)
n Scale factor works exactly the same with
wavelets:
f ( t ) = Y(t ) ; a = 1
f ( t ) = Y ( 2t ) ; a = 1 2
f ( t ) = Y ( 4t ) ; a = 1 4
What is a wavelet?
• A function that “waves” above and below the x-axis with the
following properties:
• Varying frequency
• Limited duration
• Zero average value
• This is in contrast to sinusoids, used by FT, which have infinite
duration and constant frequency.
Sinusoid Wavelet
Basis Functions Using Wavelets
• Like sin( ) and cos( ) functions in the Fourier Transform,
wavelets can define a set of basis functions ψk(t):
f (t ) = å aky k (t )
k