Image Enhancement in The Frequency Domain: GZ Chapter 4
Image Enhancement in The Frequency Domain: GZ Chapter 4
Image Enhancement in The Frequency Domain: GZ Chapter 4
domain
GZ Chapter 4
Contents
• In this lecture we will look at image enhancement in the frequency
domain
– The Fourier series & the Fourier transform
– Image Processing in the frequency domain
• Image smoothing
• Image sharpening
– Fast Fourier Transform
Fourier representation
=
The Discrete Fourier Transform (DFT)
• Here we use the GW’s notations
• The Discrete Time Fourier Transform of f(x,y)ß for
x = 0, 1, 2…M-1 and
y = 0,1,2…N-1, denoted by F(u, v), is given by the equation:
M −1 N −1
F (u, v) = ∑∑ f ( x, y)e − j 2π (ux / M +vy / N )
x =0 y =0
M −1 N −1
1 j 2π ( ux / M +vy / N )
f ( x, y ) = ∑∑ F (u , v ) e
MN u =0 v =0
– The angle defined by the inverse tg of the ration between the imaginary
and the real components of the complex function is the phase spectrum
6
Fourier spectra in 2D
7
Main properties
• The value of the DFT in the origin is the mean value of the function
f(x,y)
8
Basics of filtering in the frequency domain
• To filter an image in the frequency domain:
– Compute F(u,v) the DFT of the image
– Multiply F(u,v) by a filter function H(u,v)
– Compute the inverse DFT of the result
Some Basic Frequency Domain Filters
Low Pass Filter (smoothing)
• H(u,v) is the filter transfer function, which is the DFT of the filter
impulse response
• The implementation consists in multiplying point-wise the filter H(u,v)
with the function F(u,v)
• Real filters are called zero phase shift filters because they don’t
change the phase of F(u,v)
11
Filtered image
• The filtered image is obtained by taking the inverse DFT of the
resulting image
12
Smoothing: low pass filtering
Edge detection: high-pass filtering
Original image
Edge detection: greylevel image
15
Filtered image
16
Hints for filtering
• Color images are usually converted to graylevel images before
filtering. This is due to the fact that the information about the
structure of the image (what is in the image) is represented in the
luminance component
• Images are usually stored as “unsigned integers”. Some operations
could require the explicit cast to double or float for being
implemented
• The filtered image in general consists of double values, so a cast to
unsigned integer could be required before saving it in a file using a
predefined format. This could introduce errors due to rounding
operations.
17
Frequency Domain Filters
• 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 transform function
• Filtered image
f ( x, y) = ℑ−1 {F (u, v)}
19
Filtering in spatial and frequency domains
• The filtering operations in spatial and frequency domains are linked
by the convolution theorem
20
Another proof of the convolution theorem
• Starting from the digital delta function, we will prove that the filtering
operation in the signal domain is obtained by the convolution of the
signal with the filter impulse response h(x,y)
• Consider the digital delta function, so an impulse function of strength
A located in (x0,y0)
• Shifting (or sampling) property
21
Getting to the impulse response
• FT of the delta function located in the origin
22
Getting to the impulse response
• It can be observed that if f is a delta, then the result of the
convolution is equal to the function h(x,y) apart from a change in the
amplitude
• Then, h(x,y) is called impulse response because it represents the
response (output) of the filter when the input is a delta
f(x,y)=delta(x,y) h(x,y)
h(x,y)
24
Ideal Low Pass Filter
• Simply cut off all high frequency components that are a specified
distance D0 from the origin of the transform
⎧1 if D(u, v) ≤ D0
H (u, v) = ⎨
⎩0 if D(u, v) > D0
• where D(u,v) is given as:
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 230
radius 80
Ideal Low Pass Filter (cont…)
Result of filtering
with ideal low
pass filter of
radius 5
Ideal Low Pass Filter (cont…)
Result of filtering
with ideal low
pass filter of
radius 15
Butterworth Lowpass Filters
• 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) = 2n
1 + [ D(u, v) / D0 ]
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 230
cutoff radius 80
Butterworth Lowpass Filter (cont…)
Original
image
Result of filtering
with Butterworth
filter of order 2 and
cutoff radius 5
Butterworth Lowpass Filter (cont…)
Result of filtering
with Butterworth
filter of order 2 and
cutoff radius 15
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
Gaussian LP
38
Gaussian Lowpass Filters (cont…)
Result of filtering
Original with Gaussian
image filter with cutoff
radius 5
Result of filtering
Result of filtering
with Butterworth
with ideal low
filter of order 2
pass filter of
and cutoff radius
radius 15
15
Result of filtering
with Gaussian
filter with cutoff
radius 15
Lowpass Filtering Examples
• A low pass Gaussian filter is used to connect broken text
Lowpass Filtering Examples
Lowpass Filtering Examples (cont…)
• Different lowpass Gaussian filters used to remove blemishes in a
photograph
D0=100
D0=80
Lowpass Filtering Examples (cont…)
Original Gaussian
image lowpass filter
Spectrum of Processed
original image image
Sharpening in the Frequency Domain
• Edges and fine details 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)
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
1
H (u, v) =
1 + [ D0 / D(u, v)]2 n
Butterworth Butterworth
of order 2 of order 2
D0 = 15 D0 = 80
Butterworth of order 2
D0 = 30
Gaussian High Pass Filters
• The Gaussian high pass filter is given as:
− D 2 ( u ,v ) / 2 D0 2
H (u, v) = 1 − e
Gaussian
Gaussian high pass
high pass D0 = 80
D0 = 15
Gaussian high
pass D0 = 30
High pass filters comparison
52
Highpass Filter Comparison
Results of ideal
high pass filtering
with D0 = 15
Highpass Filter Comparison
Results of Butterworth
high pass filtering of
order 2 with D0 = 15
Highpass Filter Comparison
Results of Gaussian
high pass filtering with
D0 = 15
Laplacian filter
• It can be shown that
The expression on the left side is the laplacian of the function f, thus
57
Laplacian filter
• Thus, the Laplacian can be implemented in the Fourier domain by
using the filter
58
Laplacian
filter
59
Laplacian
filter
60
High boost filtering
• A special case of unsharp masking
• Idea: HP filters cut the zero frequency component, namely the mean
value. The resulting image is zero mean and looks very dark
• High boost filtering “sums” the original image to the result of HPF in
order to get an image with sharper (emphasized) edges but with
same range of gray values as the original one
• In formulas
– High pass
Frequency domain
61
High boost filtering
62
High boost filtering
• Note: high pass filtering is also called unsharp filtering
• In the Fourier domain
63
High boost filtering
Laplacian
A=2 A=2.7
64
High boost + histogram equalization
Butterworth
65
Rest of Chapter 4
• 2D Fourier transform and properties
• Convolution and correlation
• Need for padding
• Fast Fourier Transform (FFT)
66