Unit-II Frequency Domain
Unit-II Frequency Domain
( x, y ) 1
2 −2 2 2 ( x 2 + y 2 ) − ( u 2 + v 2 ) / 2 2
A2 e Ae
Applications
⚫ Heat diffusion
⚫ Fast Fourier transform (FFT) developed
in the late 1950s
Introduction to the Fourier Transform
and the Frequency Domain
⚫Fourier transform
F (u, v) = f ( x, y ) e − j 2 ( ux + vy)
dxdy
− −
u = 0,1,2,..., M − 1
M −1
f ( x) = F (u )e j 2 ux / M
,
u =0
x = 0,1,2,..., M − 1
DFT
⚫ The discrete Fourier transform and its
inverse always exist
⚫ f(x) is finite in the book
Sines and cosines
j
e = cos + j sin
M −1
1
F (u ) =
M
f ( x)[cos 2 ux / M − j sin 2 ux / M ]
x =0
Time domain
x
Time components
f (x)
Frequency domain
u
Frequency components
F (u )
Fourier transform and a glass prism
⚫ Prism
Separates light into various color
components, each depending on its
wavelength (or frequency) content
⚫ Fourier transform
Separates a function into various
components, also based on frequency
content
Mathematical prism
Polar coordinates
j ( u )
F (u ) = F (u ) e
⚫ Real part
R (u )
⚫ Imaginary part
I (u )
⚫ Magnitude or spectrum
1
F (u ) = R (u ) + I (u )
2 2 2
I (u )
(u ) = tan −1
R(u )
⚫ Power spectrum or spectral density
P(u ) = F (u ) = R (u ) + I (u )
2 2 2
Samples
f ( x) = f ( x0 + xx)
F (u ) = F (uu )
1
u =
Mx
Some references
⚫ http://local.wasp.uwa.edu.au/~pbourk
e/other/dft/
⚫ http://homepages.inf.ed.ac.uk/rbf/HIP
R2/fourier.htm
Examples
test_fft.c
fft.h
fft.c
Fig4.03(a).bmp
test_fig2.bmp
The two-dimensional DFT and its
inverse
M −1 N −1
1
F (u , v) =
MN
f ( x, y)e
x =0 y =0
− j 2 ( ux / M + vy / N )
,
u = 0,1,2,..., M − 1
v = 0,1,2,..., N − 1
Spatial, or image variables: x, y
Transform, or frequency variables: u,
v
M −1 N −1
f ( x, y ) = F (u , v)e j 2 ( ux / M + vy / N )
,
u =0 v =0
x = 0,1,2,..., M − 1
y = 0,1,2,..., N − 1
⚫ Magnitude or spectrum
1
F (u, v) = R (u, v) + I (u, v)
2 2 2
f ( x, y )(−1) x+ y
= F (u − M / 2, v − N / 2)
Average gray level
⚫ F(0,0) is called the dc component of
the spectrum
M −1 N −1
1
F (0,0) =
MN
f ( x, y)
x =0 y =0
Conjugate symmetric
⚫ If f(x,y) is real
F (u , v) = F * (−u ,−v)
F (u , v) = F (−u ,−v)
Relationships between samples in
the spatial and frequency domains
1 1
u = v =
Mx Ny
⚫ The separation of spectrum zeros in the
u-direction is exactly twice the
separation of zeros in the v direction
Filtering in
the
frequency
domain
⚫ Strong edges that run approximately at
+45 degree, and -45 degree
⚫ The inclination off horizontal of the long
white element is related to a vertical
component that is off-axis slightly to
the left
⚫ The zeros in the vertical frequency
component correspond to the narrow
vertical span of the oxide protrusions
Basics of filtering in the frequency
domain
⚫ 1. Multiply the input image by ( −1) x+ y
to center the transform
⚫ 2. Compute F(u,v)
⚫ 3. Multiply F(u,v) by a filter function
H(u,v)
⚫ 4. Compute the inverse DFT
⚫ 5. Obtain the real part
6. Multiply the result by ( −1)
x+ y
⚫
Fourier transform of the output
image
G (u , v) = H (u , v) F (u , v)
zero-phase-shift filter
⚫ Real H(u,v)
I (u, v)
(u, v) = tan −1
R(u, v)
Inverse Fourier transform of G(u,v)
G (u , v)
−1
f ( x, y ) * h ( x, y ) =
M −1 N −1
1
MN
f (m, n)h( x − m, y − n)
m =0 n =0
f ( x, y ) * h( x, y ) F (u , v) H (u , v)
f ( x, y )h( x, y ) F (u , v) * H (u , v)
Impulse function of strength A
A ( x − x0 , y − y0 )
M −1 N −1
s( x, y) A ( x − x , y − y ) = As( x , y )
x =0 y =0
0 0 0 0
M −1 N −1
s( x, y) A ( x, y) = As(0,0)
x =0 y =0
M −1 N −1
1
F (u , v) =
MN
( x, y )e
x =0 y =0
− j 2 ( u x / M + v y / N )
1
=
MN
f ( x, y ) * h ( x, y ) =
M −1 N −1
1
MN m =0 n =0
(m, n)h( x − m, y − n)
1
= h ( x, y )
MN
f ( x, y ) * h( x, y ) F (u , v) H (u , v)
( x, y ) * h( x, y ) ( x, y )H (u , v)
h( x, y ) H (u , v)
Gaussian filter
− u 2 / 2 2
H (u ) = Ae
−2 2 2 x 2
h( x) = 2 Ae
Highpass filter
− u 2 / 2 12 − u 2 / 2 2 2
H (u ) = Ae − Be
−2 2 12 x 2 −2 2 2 2 x 2
h( x) = 2 1 Ae − 2 2 Be
A B and 1 2
Smoothing Frequency-Domain Filterers
G (u , v) = H (u , v) F (u , v)
1 if D(u, v) D0
H (u, v) =
0 if D(u, v) D 0
D(u, v) = (u − M / 2) + (v − N / 2)
2
2 1/ 2
⚫ Cutoff frequency
D0
⚫ Total image power
M −1 N −1
PT = P(u, v)
u =0 v =0
G (u , v) = H (u , v) F (u , v)
⚫ Convolution
g ( x, y ) = h ( x, y ) * f ( x , y )
⚫ h ( x, y ) : Spatial filter
H (u , v ) was multiplied by ( −1) u + v
Then the inverse DFT
The real part of the inverse DFT was
multiplied by ( −1) x+ y
The filter h( x, y )
⚫ A dominant component at the origin
⚫ Concentric, circular components about
the center component --- ringing
⚫ The radius of the center component
and the number of circles per unit
distance from the origin are inversely
proportional to the value of the cutoff
frequency of the ideal filter.
Butterworth lowpass filters
1
H (u, v) =
1 + D(u, v) / D0
2n
D(u, v) = (u − M / 2) + (v − N / 2)
2
2 1/ 2
⚫ When = D 0
− D 2 ( u ,v ) / 2 D0 2
H (u, v) = e
⚫ No ringing
Additional examples of lowpass
filters
⚫ Machine perception
⚫ Printing and publishing
⚫ Satellite and aerial images
Sharpening Frequency Domain Filters
Highpass filter
H hp (u, v) = 1 − H lp (u, v)
⚫ Spatial filter: h ( x, y )
H (u , v ) was multiplied by ( −1) u + v
Then the inverse DFT
The real part of the inverse DFT was
multiplied by ( −1) x+ y
Ideal highpass filters
0 if D(u, v) D0
H (u, v) =
1 if D(u, v) D 0
D(u, v) = (u − M / 2) + (v − N / 2)
2
2 1/ 2
Butterworth highpass filters
1
H (u, v) =
1 + D0 / D(u, v)
2n
D(u, v) = (u − M / 2) + (v − N / 2)
2
2 1/ 2
Gaussian highpass filters
− D 2 ( u ,v ) / 2 D0 2
H (u, v) = 1 − e
D(u, v) = (u − M / 2) + (v − N / 2)
2
2 1/ 2
The Laplacian in the frequency
domain
d n f ( x)
n = ( ju ) n
F (u )
dx
2 f ( x, y ) 2 f ( x, y )
+
x 2
y 2
= ( ju ) 2 F (u , v) + ( jv) 2 F (u , v)
= −(u 2 + v 2 ) F (u , v)
2 f ( x, y ) = −(u 2 + v 2 ) F (u , v)
H (u , v) = −(u + v ) 2 2
⚫ After centering
H (u, v) = − (u − M / 2) + (v − N / 2)
2 2
⚫ Inverse Fourier transform
f ( x, y ) =
2
−1
− (u − M / 2) + (v − N / 2) F (u, v)
2 2
⚫ Fourier-transform pair
f ( x, y )
2
− (u − M / 2) + (v − N / 2) F (u, v)
2 2
⚫ Subtracting the Laplacian from the
original image
g ( x, y ) = f ( x, y ) − 2 f ( x, y )
g ( x, y ) =
−1 1 + (u − M / 2) 2 + (v − N / 2) 2 F (u, v)
Unsharp masking, high-boost
filtering, and high-frequency
emphasis filtering
⚫ Highpass filtering
f hp ( x, y ) = f ( x, y ) − f lp ( x, y )
⚫ High-boost filtering
f hb ( x, y ) = Af ( x, y ) − f lp ( x, y )
f hb ( x, y ) = ( A − 1) f ( x, y ) + f ( x, y ) − f lp ( x, y )
f hb ( x, y ) = ( A − 1) f ( x, y ) + f hp ( x, y )
⚫ Frequency domain
H hb (u, v) = 1 − H lp (u, v)
H hb (u , v) = ( A − 1) + H hp (u , v)
⚫ High-frequency emphasis
H hfe (u , v) = a + bH hp (u , v)
where a0 and ba
Homomorphic Filtering
Derivations
f ( x, y ) i ( x, y )r ( x, y )
z ( x, y ) = ln f ( x, y )
= ln i ( x, y ) + ln r ( x, y )
z ( x, y ) = ln f ( x, y )
= ln i ( x, y )+ ln r ( x, y )
⚫ Or
Z (u , v) = Fi (u , v) + Fr (u , v)
Frequency domain
S (u, v) = H (u, v) Z (u, v)
= H (u, v) Fi (u, v) + H (u, v) Fr (u, v)
Spatial domain
s ( x, y ) = S (u, v)
−1
= i0 ( x, y )r0 ( x, y )
⚫ Decrease the contribution made by the
low frequencies (illumination)
⚫ Amplify the contribution made by high
frequencies (reflectance)
⚫ Simultaneous dynamic range
compression and contrast enhancement
H (u, v) = ( H − L ) 1 − e − c ( D 2 ( u ,v ) / D0 2 )
+ L
Implementation
Translation
j 2 ( u 0 x / M + v 0 y / N )
f ( x, y ) e F (u − u0 , v − v0 )
− j 2 ( ux0 / M + vy0 / N )
f ( x − x0 , y − y0 ) F (u , v)e
⚫ When u0 = M / 2 and v0 = N / 2
j 2 ( u0 x / M + v0 y / N ) j ( x + y )
e =e
x+ y
= (−1)
x+ y
f ( x, y )(−1) F (u − M / 2, v − N / 2)
u +v
f ( x − M / 2, y − N / 2) F (u, v)(−1)
Distributivity and scaling
f1 ( x, y ) + f 2 ( x, y ) = f1 ( x, y ) + f 2 ( x, y )
af ( x, y ) aF (u , v)
1
f (ax, by) F (u / a, v / b)
ab
Rotation
⚫ Polar coordinates
x = r cos y = r sin
u = w cos v = w sin
⚫ Rotating f ( x, y ) by an angle 0
rotates F (u , v ) by the same angle
f (r , ) F ( w, )
f (r , + 0 ) F ( w, + 0 )
Periodicity and conjugate symmetry
⚫ Periodicity property
F (u, v) = F (u + M , v) =
F (u, v + N ) = F (u + M , v + N )
f ( x, y ) = f ( x + M , y ) =
f ( x, y + N ) = f ( x + M , y + N )
⚫ Conjugate symmetry
F (u , v) = F (−u ,−v)
*
F (u , v) = F (−u ,−v)
F (u , v) = F (−u, v)
F (u, v) = F (u,−v)
Separability
M −1 N −1
1
F (u , v) =
MN
f ( x, y)e
x =0 y =0
− j 2 ( ux / M + vy / N )
M −1 N −1
1 1
=
M
e
x =0
− j 2 ( ux / M )
N
f ( x, y ) e
y =0
− j 2 ( vy / N )
M −1
1
=
M
f ( x, v )e
x =0
− j 2 ( ux / M )
⚫ where
N −1
1
F ( x, v ) =
N
f ( x, y ) e
y =0
− j 2 ( vy / N )
u = 0,1,2,..., M − 1
M −1
f ( x) = F (u )e j 2 ux / M
,
u =0
x = 0,1,2,..., M − 1
⚫ Calculate
M −1
1 * 1
M
f ( x) =
M
F
u =0
*
(u )e − j 2 ux / M
⚫ Inputting F * (u ) into an algorithm
designed to compute the forward
transform gives the quantity
1 *
f ( x)
M
⚫ 2-D
1 *
f ( x, y ) =
MN
M −1 N −1
1
MN u =0 v =0
*
F (u, v)e − j 2 ( ux / M + vy / N )
More on periodicity: the need for
padding
⚫ Convolution: Flip one of the functions
and slide it pass the other
M −1
1
f ( x ) h( x ) =
M
f ( m) h ( x − m)
m =0