Digital Image Processing, 2nd ed. [Link].
com
Chapter 4
Image Enhancement in the
Frequency Domain
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. [Link]
Background
• Any function that periodically repeats itself can be
expressed as the sum of sines and/or cosines of
different frequencies, each multiplied by a
different coefficient (Fourier series).
• Even functions that are not periodic (but whose
area under the curve is finite) can be expressed as
the integral of sines and/or cosines multiplied by a
weighting function (Fourier transform).
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. [Link]
Background
• The frequency domain
refers to the plane of the two
dimensional discrete Fourier
transform of an image.
• The purpose of the Fourier
transform is to represent a
signal as a linear combination
of sinusoidal signals of
various frequencies.
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. [Link]
Image transforms are Mathematical tools that help us to convert
images from spatial domain to freq domain.
Adv:
[Link] may isolate the critical components of image pattern so that they
are directly accessible for analysis.
[Link] may place image data in to more compact form ...so easy to
store and transmit.
[Link] is useful for fast computation of 2D convolution and correlation.
[Link] is reversible.
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. [Link]
Introduction to the Fourier Transform
and the Frequency Domain
• The one-dimensional Fourier transform and its inverse
– Fourier transform (continuous case)
F (u)=∫ f ( x )e
− j2πux
dx where j= √−1
– Inverse Fourier transform: jθ
e = cos θ+j sin θ
f ( x )=∫ F( u)e j2πux du
• The two-dimensional Fourier transform and its inverse
– Fourier transform (continuous case)
F (u,v )=∫∫ f ( x,y )e
− j2π (ux+vy )
dx dy
– Inverse Fourier transform:
f ( x,y )=∫∫ F (u,v )e
j2π ( ux+vy )
du dv
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. [Link]
Introduction to the Fourier Transform
and the Frequency Domain
• The one-dimensional Fourier transform and its inverse
– Fourier transform (discrete case) DTC
M −1
1
F (u)=
M
∑ f ( x )e− j2πux/ M for u=0,1,2, .. . ,M −1
x=0
– Inverse Fourier transform:
M −1
f ( x )= ∑ F (u)e j2πux /M for x= 0,1,2,. .. ,M −1
u=0
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. [Link]
Introduction to the Fourier Transform
and the Frequency Domain
• Since e jθ= cos θ+j sin θ and the fact cos(−θ )=cos θ
then discrete Fourier transform can be redefined
M −1
1
F ( u)=
M
∑ f ( x )[ cos2π ux / M − j sin2π ux / M ]
x=0
for u= 0,1,2, .. . ,M − 1
– Frequency (time) domain: the domain (values of u) over
which the values of F(u) range; because u determines the
frequency of the components of the transform.
– Frequency (time) component: each of the M terms of F(u).
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. [Link]
Inorder to compute F(u) sub u=0 in the exponential term and
summing over all the values of x.
We then substitute u=1 .
We repeate this process for all values of u in order to obtail
complete Fourier transform.
It takes M2 summations and multiplications to compute FT.
Like f(x) the transform is a discrete quantity and it has the
same number of components as f(x).
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. [Link]
A useful analogy to compare the Fourier transform is glass prism.
The prism is a physical device that separates light in to various
color components each depending on its wavelength(freq) content.
FT that separates a function in to various components also based
on freq content.
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. [Link]
Introduction to the Fourier Transform
and the Frequency Domain
• F(u) can be expressed in polar coordinates:
F (u)=|F (u )|e jφ (u )
1
where |F (u )|= [ R 2 (u )+I 2 (u) ] (magnitude or spectrum )
2
φ (u )=tan −1
[ ]
I ( u)
R (u )
(phase angle or phase spectrum )
– R(u): the real part of F(u)
– I(u): the imaginary part of F(u)
• Power spectrum:
2 2 2
P ( u )=|F ( u )| =R ( u) +I ( u )
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. [Link]
The One-Dimensional Fourier Transform
Example
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. [Link]
Introduction to the Fourier Transform
and the Frequency Domain
• The two-dimensional Fourier transform and its inverse
– Fourier transform (discrete case) DTC
M−1 N −1
1
F (u,v)= ∑∑
MN x=0 y= 0
f ( x,y)e− j2π (ux /M+vy / N )
for u= 0,1,2, .. . ,M−1, v= 0,1,2, .. . ,N −1
– Inverse Fourier transform:
M−1 N−1
f ( x,y)= ∑ ∑ F (u,v )e j2π ( ux/ M+vy /N )
u=0 v=0
for x= 0,1,2, .. . ,M−1, y= 0,1,2,. .. ,N −1
• u, v : the transform or frequency variables
• x, y : the spatial or image variables
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. [Link]
Introduction to the Fourier Transform
and the Frequency Domain
• We define the Fourier spectrum, phase anble, and power
spectrum as follows:
1
|F (u,v )|= [ R 2 (u,v )+I 2 (u,v ) ]
2
( spectrum )
φ (u,v )=tan
[
−1 I (u,v )
R(u,v ) ] (phase angle )
P(u,v )=|F (u,v )|2 =R 2 (u,v )+I 2 (u,v ) (power spectrum )
– R(u,v): the real part of F(u,v)
– I(u,v): the imaginary part of F(u,v)
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. [Link]
Introduction to the Fourier Transform
and the Frequency Domain
• Some properties of Fourier transform:
M N
ℑ [ f ( x,y )(−1) ] =F( u− ,v− ) (shift )
x+y
2 2
M−1 N −1
1
F( 0,0)= ∑ ∑
MN x=0 y=0
f ( x,y ) (average)
F( u,v)=F∗(−u,−v ) (conujgate symmetric )
|F (u,v)|=|F(−u,−v)| (symmetric)
© 2002 R. C. Gonzalez & R. E. Woods
The Two-Dimensional DFT and Its Inverse
The 2D DFT F(u,v) can be obtained by
1. taking the 1D DFT of every row of image f(x,y), F(u,y),
2. taking the 1D DFT of every column of F(u,y)
(a)f(x,y) (b)F(u,y) (c)F(u,v)
Digital Image Processing, 2nd ed. [Link]
The Two-Dimensional DFT and Its Inverse
shift
© 2002 R. C. Gonzalez & R. E. Woods
The Two-Dimensional DFT and Its Inverse
The Property of Two-Dimensional DFT
Rotation
DFT
DFT
The Property of Two-Dimensional DFT
Linear Combination
A
DFT
B
DFT
0.25 * A
+ 0.75 * B
DFT
The Property of Two-Dimensional DFT
Expansion
A
DFT
B DFT
Expanding the original image by a factor of n (n=2), filling
the empty new values with zeros, results in the same DFT.
Two-Dimensional DFT with Different Functions
Sine wave Its DFT
Rectangle
Its DFT
Two-Dimensional DFT with Different Functions
2D Gaussian Its DFT
function
Impulses
Its DFT
Digital Image Processing, 2nd ed. [Link]
Filtering in the Frequency Domain
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. [Link]
Basics of Filtering in the Frequency Domain
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. [Link]
Some Basic Filters and Their Functions
• Multiply all values of F(u,v) by the filter function (notch filter):
H ( u,v )=
1 {
0 if ( u,v )=( M / 2, N / 2)
otherwise . }
– All this filter would do is set F(0,0) to zero (force the average value of
an image to zero) and leave all frequency components of the Fourier
transform untouched.
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. [Link]
Some Basic Filters and Their Functions
Lowpass filter
Highpass filter
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. [Link]
Some Basic Filters and Their Functions
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. [Link]
Correspondence between Filtering in
the Spatial and Frequency Domain
• Convolution theorem:
– The discrete convolution of two functions f(x,y) and h(x,y)
of size MXN is defined as
M −1 N−1
1
f ( x,y )∗h( x,y )=
MN
∑ ∑ f ( m,n) h( x −m,y−n )
m=0 n= 0
– Let F(u,v) and H(u,v) denote the Fourier transforms of
f(x,y) and h(x,y), then
f ( x,y )∗h( x,y )⇔ F (u,v ) H (u,v ) Eq. (4.2-31)
f ( x,y )h( x,y )⇔ F (u,v )∗H (u,v ) Eq. (4.2-32)
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. [Link]
Correspondence between Filtering in
the Spatial and Frequency Domain
• Aδ ( x − x 0 ,y − y 0 ) :an impulse function of strength A, located at
coordinates (x0,y0)
M −1 N−1
∑ ∑ s ( x,y ) Aδ( x− x 0 ,y− y 0 )=As( x 0 ,y 0 )
x=0 y=0
M −1 N−1
∑ ∑ s ( x,y )δ ( x,y )=s (0,0)
x=0 y=0
where δ ( x,y) : a unit impulse located at the origin
• The Fourier transform of a unit impulse at the origin (Eq.
(4.2-35)) : 1 M −1 N −1 1
F (u,v )=
MN
∑ ∑ δ ( x,y )e
− j2π ( ux/M+vy / N )
=
MN
x=0 y= 0
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. [Link]
Correspondence between Filtering in
the Spatial and Frequency Domain
• Let f ( x,y )=δ( x,y ) , then the convolution (Eq. (4.2-36))
M −1 N−1
1
f ( x,y )∗h( x,y )= ∑ ∑
MN m=0 n= 0
δ (m,n)h( x −m,y−n )
1
= h( x,y )
MN
• Combine Eqs. (4.2-35) (4.2-36) with Eq. (4.2-31), we obtain
f ( x,y )∗h( x,y )⇔ F (u,v )H ( u,v )
δ( x,y )∗h( x,y )⇔ ℑ [ δ ( x,y ) ] H (u,v )
1 1
h( x,y ) H (u,v )
MN MN
h( x,y )⇔ H (u,v )
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. [Link]
Correspondence between Filtering in
the Spatial and Frequency Domain
• Let H(u) denote a frequency domain, Gaussian filter function
given the equation 2
−u2 /2σ
H (u )=Ae
where σ : the standard deviation of the Gaussian curve.
• The corresponding filter in the spatial domain is
2 2
−2π 2 σ x
h( x )= √2π σAe
• Note: Both the forward and inverse Fourier transforms of a
Gaussian function are real Gaussian functions.
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. [Link]
Correspondence between Filtering in
the Spatial and Frequency Domain
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. [Link]
Correspondence between Filtering in
the Spatial and Frequency Domain
• One very useful property of the Gaussian function is that both it and its
Fourier transform are real valued; there are no complex values associated
with them.
• In addition, the values are always positive. So, if we convolve an image
with a Gaussian function, there will never be any negative output values to
deal with.
• There is also an important relationship between the widths of a Gaussian
function and its Fourier transform. If we make the width of the function
smaller, the width of the Fourier transform gets larger. This is controlled
by the variance parameter 2 in the equations.
• These properties make the Gaussian filter very useful for lowpass filtering
an image. The amount of blur is controlled by 2. It can be implemented
in either the spatial or frequency domain.
• Other filters besides lowpass can also be implemented by using two
different sized Gaussian functions.
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. [Link]
Smoothing Frequency-Domain Filters
• The basic model for filtering in the frequency domain
G(u,v )=H (u,v )F (u,v )
where F(u,v): the Fourier transform of the image to be smoothed
H(u,v): a filter transfer function
• Smoothing is fundamentally a lowpass operation in the
frequency domain.
• There are several standard forms of lowpass filters (LPF).
– Ideal lowpass filter
– Butterworth lowpass filter
– Gaussian lowpass filter
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. [Link]
Ideal Lowpass Filters (ILPFs)
• The simplest lowpass filter is a filter that “cuts off” all high-
frequency components of the Fourier transform that are at a
distance greater than a specified distance D0 from the origin of
the transform.
• The transfer function of an ideal lowpass filter
H ( u,v )=
1
0 {
if D ( u,v )≤ D 0
if D ( u,v )>D 0 }
where D(u,v) : the distance from point (u,v) to the center of ther
frequency rectangle
1
D ( u,v )= [ ( u − M / 2 )2 + ( v − N / 2 ) ]
2 2
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. [Link]
Ideal Lowpass Filters (ILPFs)
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. [Link]
Ideal Lowpass Filters (ILPFs)
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. [Link]
Ideal Lowpass Filters
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. [Link]
Ideal Lowpass Filters
Another Example frequency
Figure 4.13 (a) A frequency-domain
ILPF of radius 5. (b) Corresponding
spatial filter. (c) Five impulses in the
spatial domain, simulating the values
of five pixels. (d) Convolution of (b)
spatial
and (c) in the spatial domain.
f ( x,y )∗h( x,y )⇔ F (u,v ) H (u,v ) spatial
spatial
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. [Link]
Butterworth Lowpass Filters (BLPFs)
With order n
1
H ( u,v )= 2n
1+ [ D ( u,v )/ D 0 ]
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. [Link]
Butterworth Lowpass
Filters (BLPFs)
n=2
D0=5,15,30,80,and 230
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. [Link]
Butterworth Lowpass Filters (BLPFs)
Spatial Representation
n=1 n=2 n=5 n=20
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. [Link]
Gaussian Lowpass Filters (FLPFs)
2
− D 2 ( u,v )/ 2D
0
H ( u,v )=e
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. [Link]
Gaussian Lowpass
Filters (FLPFs)
D0=5,15,30,80,and 230
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. [Link]
Additional Examples of Lowpass Filtering
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. [Link]
Additional Examples of Lowpass Filtering
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. [Link]
Sharpening Frequency Domain Filter
H hp ( u,v )=H lp ( u,v )
Ideal highpass filter
H ( u,v )=
{ 0
1
if D ( u,v )≤ D 0
if D ( u,v )>D 0 }
Butterworth highpass filter
1
H ( u,v )= 2n
1+ [ D 0 / D ( u,v ) ]
Gaussian highpass filter
2
− D 2 (u,v )/ 2D
0
H ( u,v )=1 −e
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. [Link]
Highpass Filters
Spatial Representations
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. [Link]
Ideal Highpass Filters
{
H ( u,v )=
0
1
if D ( u,v )≤ D 0
if D ( u,v )>D 0 }
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. [Link]
Butterworth Highpass Filters
1
H ( u,v )= 2n
1+ [ D 0 / D ( u,v ) ]
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. [Link]
Gaussian Highpass Filters
2
− D 2 (u,v )/ 2D
0
H ( u,v )=1 −e
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. [Link]
The Laplacian in the Frequency Domain
• The Laplacian filter
2 2
H ( u,v )=−( u +v )
• Shift the center:
H (u,v )=− (u− [ M 2
2
N 2
) +(v − )
2 ] Frequency
domain
Spatial domain
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. [Link]
g( x,y )=f ( x,y )−∇ 2 f ( x,y )
where
∇ 2 f ( x,y ): the Laplacian-filtered
image in the spatial domain
For display
purposes only
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. [Link]
Implementation
Some Additional Properties of the 2D Fourier Transform
• Periodicity, symmetry, and back-to-back properties
shift
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. [Link]
Implementation
Some Additional Properties of the 2D Fourier Transform
• Separability
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. [Link]
Implementation
More on Periodicity
Convolution
f ( x)∗h( x )=
M−1
1
M
∑ f (m)h( x−m )
m= 0
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. [Link]
extend
extend
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. [Link]
Summary of Some Important Properties
of the 2-D Fourier Transform
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. [Link]
Summary of Some Important Properties
of the 2-D Fourier Transform
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. [Link]
Summary of Some Important Properties
of the 2-D Fourier Transform
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. [Link]
Summary of Some Important Properties
of the 2-D Fourier Transform
© 2002 R. C. Gonzalez & R. E. Woods