Image Enhancement:
Filtering in the Frequency Domain
Jean Baptiste Joseph Fourier
Fourier was born in Auxerre,
France in 1768
– Most famous for his work “La
Théorie Analitique de la
Chaleur” published in 1822
– Translated into English in 1878:
“The Analytic Theory of Heat”
Nobody paid much attention when the work
was first published
One of the most important mathematical
theories in modern engineering
Amr Abdel-Dayem 2
The Big Idea
• Any function that periodically repeats itself can be
expressed as a sum of sines and cosines of different
frequencies each multiplied by a different coefficient – a
Fourier series Amr Abdel-Dayem 3
Fourier transform
basis functions
Approximating a
square wave as the
sum of sine waves.
Amr Abdel-Dayem 4
Time and Frequency
! "#$%&'"()(g(t) = sin(2πf t) + (1/3)sin(2 π(3f) t)
Amr Abdel-Dayem 5
Time and Frequency
! "#$%&'"()(g(t) = sin(2πf t) + (1/3)sin(2 π(3f) t)
= +
Amr Abdel-Dayem 6
Frequency Spectra
! "#$%&'"()(g(t) = sin(2πf t) + (1/3)sin(2 π(3f) t)
= +
Amr Abdel-Dayem 7
Frequency Spectra
Amr Abdel-Dayem 8
Frequency Spectra
= +
Amr Abdel-Dayem 9
Frequency Spectra
= +
Amr Abdel-Dayem 10
Frequency Spectra
= +
Amr Abdel-Dayem 11
Frequency Spectra
= +
Amr Abdel-Dayem 12
Frequency Spectra
¥
1
= Aå sin(2p kt )
k =1 k
Amr Abdel-Dayem 13
Fourier Transform
• f(x): continuous function of a real variable x
• Fourier transform of f(x):
¥
Á{ f ( x)} = F (u ) = ò f ( x) exp[- j 2pux]dx Eq. 1
-¥
where j = -1
Amr Abdel-Dayem 14
Fourier Transform
• (u) is the frequency variable.
• The integral of Eq. 1 shows that F(u) is composed of an
infinite sum of sine and cosine terms and…
• Each value of u determines the frequency of its
corresponding sine-cosine pair.
Amr Abdel-Dayem 15
Fourier Transform
• Given F(u), f(x) can be obtained by the
inverse Fourier transform:
Á-1{F (u )} = f ( x)
¥
= ò F (u ) exp[ j 2pux]du
-¥
• The above two equations are the Fourier
transform pair.
Amr Abdel-Dayem 16
Fourier Transform
• Fourier transform pair for a function f(x,y) of
two variables:
¥
Á{ f ( x, y )} = F (u , v) = ò ò f ( x, y) exp[- j 2p (ux + vy)]dxdy
-¥
and
¥
Á-1{F (u , v)} = f ( x, y ) = ò ò F (u , v) exp[ j 2p (ux + vy )]dudv
-¥
where u,v are the frequency variables.
Amr Abdel-Dayem 17
Sampling Theorem
• Consider a continuous signal f(t) whose Fourier transform is zero
for values of frequencies outside a finite interval (band) [-μmax, μ max]
F(μ)
μ
-μmax 0 μmax
• When the signal f(t) is sampled at interval DT, the Fourier transform
of the sampled signal is given by:
..... .....
μ
-1/ 2DT -1/ DT -μmax 0 μmax 1/ DT 1/ 2DT 18
Sampling Theorem
• The original signal can be reconstructed from the sampled signal by
using an ideal lowpass filter as follows
As long as (1/DT) > 2μmax, the signal can be reconstructed without any distortions
Sampling Theorem
• As DT increases (or the sampling frequency decreases)
Amr Abdel-Dayem 20
Sampling Theorem
• The original signal cannot be fully reconstructed
Amr Abdel-Dayem 21
Sampling and the Nyquist rate
• Aliasing can arise when you sample a continuous signal
or image
– occurs when your sampling rate is not high enough to capture
the amount of detail in your image
– formally, the image contains structure at different scales
• called “frequencies” in the Fourier domain
– the sampling rate must be high enough to capture the highest
frequency in the image
• To avoid aliasing:
– sampling rate > 2 * max frequency in the image
• i.e., need more than two samples per period
– This minimum sampling rate is called the Nyquist rate
Amr Abdel-Dayem 22
DFT & Images
• The DFT of a two dimensional image can be visualised
by showing the spectrum of the images component
frequencies
DFT
Amr Abdel-Dayem 23
The DFT and Image Processing
To filter an image in the frequency domain:
1. Compute F(u,v) the DFT of the image
2. Multiply F(u,v) by a filter function H(u,v)
3. Compute the inverse DFT of the result
Amr Abdel-Dayem 24
Some Basic Frequency Domain Filters
Low Pass Filter
High Pass Filter
Amr Abdel-Dayem 25
Smoothing Frequency Domain Filters
Smoothing is achieved in the frequency domain by
dropping out the high frequency components
The basic model for filtering is:
G(u,v) = H(u,v)F(u,v)
where F(u,v) is the Fourier transform of the image
being filtered and H(u,v) is the filter transfer function
Low pass filters – only pass the low frequencies, drop
the high ones
Amr Abdel-Dayem 26
Ideal Low Pass Filter
• Simply cut off all high frequency components that are a
specified distance D0 from the origin of the transform
• changing the distance changes the behaviour of the filter
Amr Abdel-Dayem 27
Ideal Low Pass Filter (cont…)
The transfer function for the ideal low pass filter
can be given as:
ì1 if D(u , v) £ D0
H (u , v) = í
î0 if D(u , v) > D0
Amr Abdel-Dayem 28
Ideal Low Pass Filter (cont…)
Above we show an image, it’s Fourier spectrum and a series of ideal low
pass filters of radius 5, 15, 30, 80 and 230 superimposed on top of it 29
Ideal Low Pass Filter (cont…)
Result of filtering
Original with ideal low
image pass filter of
radius 5
Result of filtering Result of filtering
with ideal low with ideal low
pass filter of pass filter of
radius 15 radius 30
Result of filtering
Result of filtering
with ideal low
with ideal low
pass filter of
pass filter of
radius 230
radius 80
Amr Abdel-Dayem 30
Butterworth Lowpass Filters
• This filter does not have a sharp discontinuity establishing a clear
cutoff between passed and filtered frequencies.
• The transfer function of a Butterworth lowpass filter of order n with
cutoff frequency at distance D0 from the origin is defined as:
1
H (u , v) =
1 + [ D(u , v) / D0 ]2 n
Amr Abdel-Dayem 31
Butterworth Lowpass Filter (cont…)
Result of filtering
Original with Butterworth
image filter of order 2 and
cutoff radius 5
Result of filtering Result of filtering
with Butterworth with Butterworth
filter of order 2 and filter of order 2 and
cutoff radius 15 cutoff radius 30
Result of filtering
Result of filtering
with Butterworth
with Butterworth
filter of order 2 and
filter of order 2 and
cutoff radius 230
cutoff radius 80
Amr Abdel-Dayem 32
Gaussian Lowpass Filters
• The transfer function of a Gaussian lowpass
filter is defined as:
- D 2 ( u ,v ) / 2 D0 2
H (u , v) = e
Amr Abdel-Dayem 33
Gaussian Lowpass Filters (cont…)
Result of filtering
Original with Gaussian
image filter with cutoff
radius 5
Result of filtering Result of filtering
with Gaussian with Gaussian
filter with cutoff filter with cutoff
radius 15 radius 30
Result of Result of filtering
filtering with with Gaussian
Gaussian filter filter with cutoff
with cutoff radius 230
radius 85 Amr Abdel-Dayem 34
Lowpass Filters Compared
Result of
Result of filtering
filtering with
with ideal low
Butterworth filter
pass filter of
of order 2 and
radius 15
cutoff radius 15
Result of filtering
with Gaussian
filter with cutoff
radius 15
Amr Abdel-Dayem 35
Lowpass Filtering Examples
• A low pass Gaussian filter is used to connect
broken text
Amr Abdel-Dayem 36
Lowpass Filtering Examples (cont…)
Amr Abdel-Dayem 37
Lowpass Filtering Examples (cont…)
Amr Abdel-Dayem 38
Sharpening in the Frequency Domain
• Edges and fine detail in images are associated with high
frequency components
• High pass filters – only pass the high frequencies, drop
the low ones
• High pass frequencies are precisely the reverse of low
pass filters, so:
Hhp(u, v) = 1 – Hlp(u, v)
Amr Abdel-Dayem 39
Ideal High Pass Filters
The ideal high pass filter is given as:
ì0 if D(u , v) £ D0
H (u , v) = í
î1 if D(u , v) > D0
where D0 is the cut off distance as before
Amr Abdel-Dayem 40
Ideal High Pass Filters (cont…)
Results of ideal Results of ideal Results of ideal
high pass filtering high pass filtering high pass filtering
with D0 = 15 with D0 = 30 with D0 = 80 41
Butterworth High Pass Filters
The Butterworth high pass filter is given as:
1
H (u , v) =
1 + [ D0 / D(u , v)]2n
where n is the order and D0 is the cut off distance
as before
Amr Abdel-Dayem 42
Butterworth High Pass Filters (cont…)
Results of Results of
Butterworth Butterworth
high pass high pass
filtering of filtering of
order 2 with order 2 with
D0 = 15 D0 = 80
Results of Butterworth high pass
filtering of order 2 with D0 = 30
Amr Abdel-Dayem 43
Gaussian High Pass Filters
The Gaussian high pass filter is given as:
- D 2 ( u ,v ) / 2 D0 2
H (u , v) = 1 - e
where D0 is the cut off distance as before
Amr Abdel-Dayem 44
Gaussian High Pass Filters (cont…)
Results of Results of
Gaussian Gaussian
high pass high pass
filtering with filtering with
D0 = 15 D0 = 80
Results of Gaussian high
pass filtering with D0 = 30
Amr Abdel-Dayem 45
Highpass Filter Comparison
Results of ideal Results of Butterworth Results of Gaussian
high pass filtering high pass filtering of high pass filtering with
46
with D0 = 15 order 2 with D0 = 15 D0 = 15
Laplacian (recall)
¶ f ¶ f 2 2
Ñ f = 2 + 2
2
¶x ¶y
¶2 f
= f (x + 1, y) + f (x -1, y) - 2 f (x, y)
¶ x
2 2
¶2 f
= f (x, y + 1) + f (x, y -1) - 2 f (x, y)
¶ y
2 2
Ñ 2 f = [ f (x + 1, y) + f (x -1, y) + f (x, y + 1) + f (x, y -1)] - 4 f (x, y)
Amr Abdel-Dayem 47
Laplacian in the FD
• It can be shown that:
Á[Ñ 2 f (x, y)]= -(u 2 + v 2 )F(u,v)
• The Laplacian can be implemented in the FD by
using the filter
H(u,v) = -(u 2 + v 2 )
• FT pair:
Ñ 2 f (x, y) Û -[(u - M /2) 2 + (v - N /2) 2 ]F(u,v)
Amr Abdel-Dayem 48
Laplacian in the FD
2-D image of Laplacian
frequency domain
in the frequency
Laplacian in the
domain
frequency domain
Laplacian in the
Inverse DFT of
Zoomed section
of the image on
the left compared
Amr Abdel-Dayem to spatial filter
Other Variations of Image Sharpening
• High boost filter
I0 è ILP è IHP = I0 – ILP è I1 = (b-1) I0 + IHP
– Equiv. to high pass filtering for b=1
– Amplify or suppress original image pixel values when b¹2
• Combine sharpening with histogram equalization
Amr Abdel-Dayem 50
Other Variations of Image Sharpening
Amr Abdel-Dayem 51
Bandreject Filters
• Bandreject filters remove or attenuate a band of
frequencies about the origin of the Fourier
transform.
• Similar to those LPFs and HPFs studied, we can
construct ideal, Butterworth, and Gaussian
bandreject filters
Amr Abdel-Dayem 52
Bandreject Filters
• Ideal bandreject filter
ì W
ï 1 if D (u , v ) < D0 -
2
ïï W W
H (u , v) = í0 if D0 - £ D(u , v) £ D0 +
ï 2 2
ï1 if D(u , v) > D0 + W
ïî 2
Amr Abdel-Dayem 53
Bandreject Filters
• Butterworth bandreject filter
1
H (u , v) = 2n
é D(u , v)W ù
1+ ê 2 2ú
ë D (u , v) - D0 û
n =1
Amr Abdel-Dayem 54
Bandreject Filters
• Gaussian bandreject filter
1 é D 2 ( u ,v ) - D02 ù
- ê ú
2 êë D ( u ,v )W úû
H (u , v) =1 - e
Amr Abdel-Dayem 55
Bandreject Filters
Amr Abdel-Dayem 56
Bandbass Filters
• Bandpass filter performs the opposite of a
bandpass filter
H bp (u , v) = 1 - H br (u , v)
Amr Abdel-Dayem 57