240-373: Chapter 14: The Frequency Domain 1 Montri Karnjanade cha [email protected] .th http://fivedots.c oe.psu.ac.th/~mon tri 240-373 Image Processing
Nov 14, 2014
240-373: Chapter 14: The Frequency Domain
1
Montri [email protected]://fivedots.coe.psu.ac.th/~montri
240-373 Image Processing
240-373: Chapter 14: The Frequency Domain
2
Chapter 14
The Frequency Domain
240-373: Chapter 14: The Frequency Domain
3
The Frequency Domain
• Any wave shape can be approximated by a sum of periodic (such as sine and cosine) functions.
• a--amplitude of waveform• f-- frequency (number of times the wave
repeats itself in a given length)• p--phase (position that the wave starts)• Usually phase is ignored in image
processing
240-373: Chapter 14: The Frequency Domain
4
240-373: Chapter 14: The Frequency Domain
5
240-373: Chapter 14: The Frequency Domain
6
The Hartley Transform
• Discrete Hartley Transform (DHT)– The M x N image is converted into a second i
mage (also M x N)– M and N should be power of 2 (e.g. .., 128, 25
6, 512, etc.)– The basic transform depends on calculating t
hh hhhhhh hhh hhh hhhh hhhhh hh hhh hhh M x N hhhhh
1
0
1
0
)2sin()2cos(),(1
),(M
x
N
y N
vy
M
ux
N
vy
M
uxyxf
MNvuH
240-373: Chapter 14: The Frequency Domain
7
The Hartley Transform
where f(x,y) is the intensity of the pixel at posit ion (x,y)
H(u,v) is the value of element in frequency domain
– The results are periodic– The cosine+sine (CAS) term is call “ the kern
el of the transformation ” (or ”hhhhh hhhhhhhh”)
240-373: Chapter 14: The Frequency Domain
8
The Hartley Transform
• Fast Hartley Transform (FHT)– M hhh N must be power of 2– Much faster than DHT– hhhhhhhhh
2/),(),(),(),(),( vNuMTvNuTvuMTvuTvuH
240-373: Chapter 14: The Frequency Domain
9
The Fourier Transform
• The Fourier transform– Each element has real and imaginary values– hhhh hhhh
– f(x,y) is point (x,y) in the original image andF(u,v) is the point (u,v) in the frequency imagh
dxdyeyxfvuF vyuxi )(2),(),(
240-373: Chapter 14: The Frequency Domain
10
The Fourier Transform
• Discrete Fourier Transform (DFT)
– Imaginary part
– Real part
– The actual complex result is Fi(u,v) + Fr(u,v)
1
0
1
0
2sin),(1
),(M
x
N
yi N
vy
M
uxyxf
MNvuF
1
0
1
0
2cos),(1
),(M
x
N
yr N
vy
M
uxyxf
MNvuF
1
0
1
0
2
),(1
),(M
x
N
y
N
vy
M
uxi
eyxfMN
vuF
240-373: Chapter 14: The Frequency Domain
11
Fourier Power Spectrum and Inverse Fourier Transform
• Fourier power spectrum
• Inverse Fourier Transform
22 ),(),(),( vuFvuFvuF ir
1
0
1
0
2
),(1
),(M
x
N
y
N
vy
M
uxi
evuFMN
yxf
240-373: Chapter 14: The Frequency Domain
12
Fourier Power Spectrum and Inverse Fourier Transform
• Fast Fourier Transform (FFT)– Much faster than DFT– M hhh N must be power of 2– Computation is reduced from M2N2 to
MN log2
M . log2
N (~1 /1 0 0 0 times)
240-373: Chapter 14: The Frequency Domain
13
Fourier Power Spectrum and Inverse Fourier Transform
• Optical transformation– A common approach to view image in
frequency domain
Original image Transformed image
A BD C
C D
B A
240-373: Chapter 14: The Frequency Domain
14
Power and Autocorrelation Functions
• Power function:
• Autocorrelation function
– hhhhhhh hhhhhhh hhhhhhhhh hhhh– hhhhhhh hhhhhhhhh hh
22 ),(),(2
1),(),( vuHvuHvuFvuP
2),( vuF
22 ),(),(2
1vuHvuH
240-373: Chapter 14: The Frequency Domain
15
Hartley vs Fourier Transform
240-373: Chapter 14: The Frequency Domain
16
Interpretation of the power function
240-373: Chapter 14: The Frequency Domain
17
Applications of Frequency Domain Processing
• Convolution in the frequency domain
240-373: Chapter 14: The Frequency Domain
18
Applications of Frequency Domain Processing
– 102useful when the image is larger than 41024x and the template size is greater than
16x16– Template and image must be the same size
0000
0000
0011
0011
11
11
240-373: Chapter 14: The Frequency Domain
19
– Use FHT or FFT instead of DHT or DFT– Number of points should be kept small– The transform is periodic
• zeros must be padded to the image and the template• minimum image size must be (N+n-1) x (M+m-1)
– Convolution in frequency domain is “real convolution” Normal convolution
Real convolution
240-373: Chapter 14: The Frequency Domain
20
014133
16102926
327611097
12445845
0000
0000
0037
0021
0000
01098
0654
0210
240-373: Chapter 14: The Frequency Domain
21
– Convolution in frequency domain is “real convolution”
Normal convolution
Real convolution
014133
16102926
327611097
12445845
0000
0000
0037
0021
0000
01098
0654
0210
30978756
38857236
1833204
4410
1200
7300
0000
0000
0000
01098
0654
0210
240-373: Chapter 14: The Frequency Domain
22
Convolution using the Fourier transform
1Technique : Convolution using the Fourier transform
USE: To perform a convolution OPERATION:
– - zero padding both the image (MxN) and the temp - -late (m x n) to the size (N+n 1 ) x (M+m 1 )
– hhhhhhhh hhh hh hhh hhhhhhhh hhhhh hhh hhhhhat e
– hhhhhhhhhhh hhhhhhh hh hhhhhhh hh hhh hhhhhh or med i mage agai nst t he t r ansf or med t empl at
e
240-373: Chapter 14: The Frequency Domain
23
Convolution using the Fourier transform
OPERATION: (cont’d)– Multiplication is done as follows: F (image) F (template) F(result)
(r1
hi1
) (r2
h i2
) (r1
r2
- i1
i2
h r1
i2
+r2
i1
)
4 2i.e. real multiplications and additions– Per f or mi ng I nver se Four i er t r ansf or m
240-373: Chapter 14: The Frequency Domain
24
Hartley convolution
2Technique : Hartley convolution USE: To perform a convolution
OPERATION:– - zero padding both the image (MxN) and the t
emplate ( mx n) to the size - (N+n 1 ) x (M+m-1)
image template
0000
0000
0037
0021
0000
01098
0654
0210
240-373: Chapter 14: The Frequency Domain
25
Hartley convolution
– hhhhhhhh h hhhhhh hhhhhhhhh hh hhh h hhhhhhh h mage and template
image template
2.75-1.25-0.25-1.75-
1.25-1.25-1.75-1.75-
2.250.751.753.25
0.750.753.253.25
25.125.325.075.9
75.125.175.075.3
75.275.075.325.2
25.575.325.225.11
240-373: Chapter 14: The Frequency Domain
26
Hartley convolution
– Multiplying them by evaluating:
),(),(
),(),(
),(),(),(),(
2),(
vMuNTvMuNI
vuTvMuNI
vMuNTvuIvuTvuINM
vuR
240-373: Chapter 14: The Frequency Domain
27
Hartley convolution: Cont’d
h hhhhhh
– Performing Inverse Hartley transform, gives:
125255927
452511105
394975417
2134533585
30978756
38857236
1833204
4410
240-373: Chapter 14: The Frequency Domain
28
Hartley convolution: Cont’d
240-373: Chapter 14: The Frequency Domain
29
Deconvolution
• Convolution R = I * T
• Deconvolution I = R *-1 T
• Deconvolution of R by T = convolution ofR
• by some ‘inverse’ of the template T (T’)
240-373: Chapter 14: The Frequency Domain
30
Deconvolution
• Consider periodic convolution as a matrix operation. For example
202218
262824
141612
000
011
011
*
987
654
321
240-373: Chapter 14: The Frequency Domain
31
Deconvolution
is equivalent to A B C
AB = C
ABB-1 = CB-1
A = CB-1
202218262824141612
110110000
011011000
101101000
000110110
000011011
000101101
110000110
011000011
101000101
)987654321(