# Chapter14

```240-373
Image Processing
[email protected]
http://fivedots.coe.psu.ac.th/~montri
240-373: Chapter 14: The Frequency Domain
1
Chapter 14
The Frequency Domain
240-373: Chapter 14: The Frequency Domain
2
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
3
240-373: Chapter 14: The Frequency Domain
4
240-373: Chapter 14: The Frequency Domain
5
The Hartley Transform
• Discrete Hartley Transform (DHT)
– The M x N image is converted into a second image
(also M x N)
– M and N should be power of 2 (e.g. .., 128, 256,
512, etc.)
– The basic transform depends on calculating the
following for each pixel in the new M x N array

1 M 1 N 1
 ux vy 
 ux vy 
H (u, v) 
f ( x, y)  cos(2 )    sin(2 )  

MN x0 y 0
M N 
 M N 

240-373: Chapter 14: The Frequency Domain
6
The Hartley Transform
where f(x,y) is the intensity of the pixel at position
(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 kernel of
the transformation” (or ”basis function”)
240-373: Chapter 14: The Frequency Domain
7
The Hartley Transform
• Fast Hartley Transform (FHT)
– M and N must be power of 2
– Much faster than DHT
– Equation:
H (u, v)  T (u, v)  T (M  u, v)  T (u, N  v)  T (M  u, N  v)/ 2
240-373: Chapter 14: The Frequency Domain
8
The Fourier Transform
• The Fourier transform
– Each element has real and imaginary values
– Formula:
F (u , v)    f ( x, y )e
2 i ( ux  vy )
dxdy
– f(x,y) is point (x,y) in the original image and
F(u,v) is the point (u,v) in the frequency image
240-373: Chapter 14: The Frequency Domain
9
The Fourier Transform
• Discrete Fourier Transform (DFT)
1
F (u, v) 
MN
– Imaginary part
M 1 N 1
 f ( x, y)e
 ux vy 
 2 i   
M N 
x 0 y 0
1 M 1 N 1
 ux vy 
Fi (u, v)  
f ( x, y) sin 2   

MN x0 y 0
M N 
– Real part
1 M 1 N 1
 ux vy 
Fr (u, v) 
f
(
x
,
y
)
cos
2

  

MN x0 y 0
M N 
– The actual complex result is Fi(u,v) + Fr(u,v)
240-373: Chapter 14: The Frequency Domain
10
Fourier Power Spectrum and Inverse
Fourier Transform
• Fourier power spectrum
F (u, v)  Fr (u, v)  Fi (u, v)
2
2
• Inverse Fourier Transform
1
f ( x, y) 
MN
240-373: Chapter 14: The Frequency Domain
M 1 N 1
 F (u, v)e
 ux vy 
2 i   
M N 
x 0 y 0
11
Fourier Power Spectrum and Inverse
Fourier Transform
• Fast Fourier Transform (FFT)
– Much faster than DFT
– M and N must be power of 2
– Computation is reduced from M2N2 to
MN log2 M . log2 N (~1/1000 times)
240-373: Chapter 14: The Frequency Domain
12
Fourier Power Spectrum and Inverse
Fourier Transform
• Optical transformation
– A common approach to view image in frequency
domain
A
D
B
C
Original image
240-373: Chapter 14: The Frequency Domain
C
B
D
A
Transformed image
13
Power and Autocorrelation Functions
• Power function:

1
P(u , v)  F (u , v)  H (u, v) 2  H (u,v) 2
2

• Autocorrelation function
2
– Inverse Fourier transform of F (u , v )
or
– Hartley transform of 1 H (u , v) 2  H (u ,v) 2 
2
240-373: Chapter 14: The Frequency Domain
14
Hartley vs Fourier Transform
240-373: Chapter 14: The Frequency Domain
15
Interpretation of the power function
240-373: Chapter 14: The Frequency Domain
16
Applications of Frequency Domain
Processing
• Convolution in the frequency domain
240-373: Chapter 14: The Frequency Domain
17
Applications of Frequency Domain
Processing
– useful when the image is larger than 1024x1024
and the template size is greater than 16x16
– Template and image must be the same size
1 1 0 0
1 1 1 1 0 0

1 1 0 0 0 0
0 0 0 0
240-373: Chapter 14: The Frequency Domain
18
– 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)
240-373: Chapter 14: The Frequency Domain
19
0 1
2
0
4 5 6 0
8 9 10 0
0 0
0
0
240-373: Chapter 14: The Frequency Domain
1 2 0 0

45
58
44 12
7 3 0 0
97 110 76 32

0 0 0 0
26 29 10 16
0 0 0 0
3
13
14
0
20
– Convolution in frequency domain is “real
convolution”
Normal convolution
0 1
2
0
4 5 6 0
8 9 10 0
0 0
0
1 2 0 0

0
45
58
44 12
7 3 0 0
97 110 76 32

0 0 0 0
26 29 10 16
0 0 0 0
3
13
14
0
1
4
0
Real convolution
0 1
2
0
4 5 6 0
8 9 10 0
0 0
0
0 0 0 0
4
0 0 0 0
4 20 33 18


0 0 3 7
36 72 85 38
0
240-373: Chapter 14: The Frequency Domain
0 0 2 1
56 87 97 30
21
Convolution using the Fourier transform
Technique 1: Convolution using the Fourier
transform
USE: To perform a convolution
OPERATION:
– zero-padding both the image (MxN) and the
template (m x n) to the size (N+n-1) x (M+m-1)
– Applying FFT to the modified image and template
– Multiplying element by element of the transformed
image against the transformed template
240-373: Chapter 14: The Frequency Domain
22
Convolution using the Fourier transform
OPERATION: (cont’d)
– Multiplication is done as follows:
F(image)
(r1,i1)
F(template)
(r2, i2)
F(result)
(r1r2 - i1i2, r1i2+r2i1)
i.e. 4 real multiplications and 2 additions
– Performing Inverse Fourier transform
240-373: Chapter 14: The Frequency Domain
23
Hartley convolution
Technique 2: Hartley convolution
USE: To perform a convolution
OPERATION:
– zero-padding both the image (MxN) and the
template (m x n) to the size (N+n-1) x (M+m-1)
image
0 1
2
template
0
1 2 0 0
4 5 6 0
8 9 10 0
7 3 0 0
0 0 0 0
0 0
0 0 0 0
0
0
240-373: Chapter 14: The Frequency Domain
24
Hartley convolution
– Applying Hartley transform to the modified image
and template
image
11.25
2.25
3.75
template
 5.25
3.25
3.25
0.75
0.75
 2.25  3.75  0.75 2.75
3.75 0.75 1.25  1.75
3.25 1.75 0.75 2.25
- 1.75 - 1.75 - 1.25 - 1.25
 9.75  0.25  3.25 1.25
- 1.75 - 0.25 - 1.25 - 2.75
240-373: Chapter 14: The Frequency Domain
25
Hartley convolution
– Multiplying them by evaluating:
 I (u, v)T (u, v)  I (u, v)T ( N  u, M  v)
NM 

R(u, v) 

I
(
N

u
,
M

v
)
T
(
u
,
v
)

2 
 I ( N  u, M  v)T ( N  u, M  v)

240-373: Chapter 14: The Frequency Domain
26
Hartley convolution: Cont’d
Giving:
585
 33
 213
45
 417 75  49
 105  11  25
39
45
 27
125
 59
25
– Performing Inverse Hartley transform, gives:
0
1
4
4
4 20 33 18
36 72 85 38
56 87 97 30
240-373: Chapter 14: The Frequency Domain
27
Hartley convolution: Cont’d
240-373: Chapter 14: The Frequency Domain
28
Deconvolution
• Convolution
R = I * T
• Deconvolution I = R *-1 T
• Deconvolution of R by T = convolution of R
• by some ‘inverse’ of the template T (T’)
240-373: Chapter 14: The Frequency Domain
29
Deconvolution
• Consider periodic convolution as a matrix
operation. For example
1 2 3
4 5 6
7 8 9
*
1 1 0
1 1 0
0 0 0
240-373: Chapter 14: The Frequency Domain

12 16 14
24 28 26
18 22 20
30
Deconvolution
is equivalent to
A
1

1
0

1
(1 2 3 4 5 6 7 8 9) 1
0

0
0

0
B
C
0 1 0 0 0 1 0 1

1 0 0 0 0 1 1 0
1 1 0 0 0 0 1 1

0 1 1 0 1 0 0 0
1 0 1 1 0 0 0 0   12 16 14 24 28 26 18 22 20
1 1 0 1 1 0 0 0

0 0 1 0 1 1 0 1
0 0 1 1 0 1 1 0

0 0 0 1 1 0 1 1 
240-373: Chapter 14: The Frequency Domain
AB
=C
ABB-1 = CB-1
A
= CB-1
31
```

27 cards

24 cards

17 cards

44 cards

36 cards