0% found this document useful (0 votes)
105 views81 pages

Digital Image Processing: Image Enhancement: Filtering in The Frequency Domain

This document discusses image enhancement in the frequency domain. It introduces the Fourier transform and how it can be used to represent images as a combination of sine and cosine waves of different frequencies. Filtering images in the frequency domain allows for smoothing or sharpening by modifying the amplitude of different frequency components. The fast Fourier transform is described as a way to efficiently compute the Fourier transform of digital images.

Uploaded by

Aseem Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
105 views81 pages

Digital Image Processing: Image Enhancement: Filtering in The Frequency Domain

This document discusses image enhancement in the frequency domain. It introduces the Fourier transform and how it can be used to represent images as a combination of sine and cosine waves of different frequencies. Filtering images in the frequency domain allows for smoothing or sharpening by modifying the amplitude of different frequency components. The fast Fourier transform is described as a way to efficiently compute the Fourier transform of digital images.

Uploaded by

Aseem Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 81

Digital Image Processing

Image Enhancement:
Filtering in the Frequency Domain

Course Website: http://www.comp.dit.ie/bmacnamee


2
of
41
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
3
of
41
Outline

• Introduction to the Fourier Transform and


Frequency Domain
– Magnitude of frequencies
– Phase of frequencies
– Fourier transform and DFT
• Filtering in the frequency domain
• Smoothing Frequency Domain Filters
• Sharpening Frequency Domain Filters
• Homomorphic Filtering
• Implementation of Fourier transform
4
of
41 Background
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).
5
of
41
The Big Idea
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

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
Frequency Weight
6
of f1 w1
41
f2 w2

f3 w3

f4 w4

Periodic function f
7
of
41
The Big Idea (cont…)
Also there is a common • The frequency domain
characteristics that a
Taken from www.tfh-berlin.de/~schwenk/hobby/fourier/Welcome.html

refers to the plane of the


function expressed either a
two dimensional discrete
Fourier series or transform
Fourier transform of an
can be reconstructed
image.
completely via an inverse
• The purpose of the Fourier
process.
transform is to represent a
signal as a linear
combination of sinusoidal
signals of various
frequencies.
8
of
41
The Big Idea (cont…)
Frequency
domain signal
processing
example in
Excel
9
of
41
Frequency Domain Methods

Spatial Domain Frequency Domain


12 Introduction
Introduction to
to the
the Fourier
Fourier Transform
Transform
of and
and the
the Frequency
Frequency Domain
Domain
41
• The one-dimensional Fourier transform and its
inverse
– Fourier transform (continuous case)

F (u )   f ( x)e  j 2ux dx where j   1

– Inverse Fourier transform: e j  cos   j sin 

f ( x)   F (u )e j 2ux du


• The two-dimensional Fourier transform and its


inverse
 
– Fourier transform
F (u , v)    (continuous
f ( x, y )e  j 2 (uxcase)
vy )
dxdy
 

– Inverse Fourier  transform:


f ( x, y )    F (u, v)e j 2 (ux vy ) dudv
 
13
of Introduction
Introduction to
to the
the Fourier
Fourier Transform
Transform
41 and
and the
the Frequency
Frequency Domain
Domain

• The one-dimensional Fourier transform and its


inverse
– Fourier transform (discrete case) DTC
M 1
F (u )   f ( x)e  j 2ux / M for u  0,1,2,..., M  1
x 0

– Inverse Fourier transform:


M 1
1
f ( x) 
M
 F (u )e
u 0
j 2ux / M
for x  0,1,2,..., M  1
14
of Introduction
Introduction to
to the
the Fourier
Fourier Transform
Transform
41 and
and the
the Frequency
Frequency Domain
Domain

• Since e j  cos   j sin  and the fact cos(  )  cos 


then discrete Fourier transform can be redefined
M 1
F (u )   f ( x)[cos 2ux / M  j sin 2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).
15
of
41
The Discrete Fourier Transform (DFT)

The Discrete 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

for u = 0, 1, 2…M-1 and v = 0, 1, 2…N-1.


and
j=(-1)1/2
16
of
41
DFT & Images
The DFT of a two dimensional image can be visualised by
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

showing the spectrum of the images component


frequencies spectrum.

DFT

• The fourier transform converts an image into a corresponding energy spectrum.


• Each frequency component is associated to a particular band in the energy
spectrum.
• Therefore, by maintaining or eliminating certain frequency components, we can get
a new energy spectrum.
• When this new spectrum is brought back to the spatial domain, we get a processed
image.
17
of
41
DFT & Images (cont…)
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

DFT

Scanning electron microscope Fourier spectrum of the image


image of an integrated circuit
magnified ~2500 times
18
of
41
The Inverse DFT
It is really important to note that the Fourier
transform is completely reversible
The inverse DFT is given by:
M 1 N 1
1
f ( x, y ) 
MN
 F (u, v)e
u 0 v 0
j 2 ( ux / M vy / N )

for x = 0, 1, 2…M-1 and y = 0, 1, 2…N-1


Introduction
Introduction to
to the
the Fourier
Fourier Transform
Transform
19
and
and the
the Frequency
Frequency Domain
Domain
of
41
• The two-dimensional Fourier transform and its
inverse
– Fourier transform (discrete case) DTC
M 1 N 1
F (u , v)   f ( x, y )e  j 2 ( ux / M  vy / N )
x 0 y 0

for u  0,1,2,..., M  1, v  0,1,2,..., N  1


– Inverse Fourier transform:
1 M 1 N 1
f ( x, y )  
MN u 0 v 0
F (u , v)e j 2 (ux / M  vy / N )

for x  0,1,2,..., M  1, y  0,1,2,..., N  1

• u, v : the transform or frequency variables


20
of
41
The DFT and Image Processing

To filter an image in the frequency domain:


Images taken from Gonzalez & Woods, Digital Image Processing (2002)

1. Compute F(u,v) the DFT of the image


2. Multiply F(u,v) by a filter function H(u,v) or filter
transfer function.
3. Compute the inverse DFT of the result
21
of
41
Representation of Fourier Domain
• H(u,v) F(u,v) is formed using array
multiplication.
• The filter function modifies the transform of
the input image to yield a processed
output g(x,y).
g(x,y)=IDFT(H(u,v)F(u,v))
22
of
41 The
The Two-Dimensional
Two-Dimensional DFT
DFT and
and Its
Its Inverse
Inverse

shift
23
of
The
The Property
Property of
of Two-Dimensional
Two-Dimensional DFT
DFT
41
Rotation
Rotation

DFT

DFT
24
of
The
The Property
Property of
of Two-Dimensional
Two-Dimensional DFT
DFT
41
Linear
Linear Combination
Combination

A
DFT

B
DFT

0.25 * A
+ 0.75 * B DFT
25
of
41 Filtering
Filtering in
in the
the Frequency
Frequency Domain
Domain
26
of
41
Some Basic Frequency Domain Filters

Low Pass Filter


Images taken from Gonzalez & Woods, Digital Image Processing (2002)

High Pass Filter


27
of
General Perception about Frequency
41
Filters
- Low frequencies in the transform are related to slowly
varying intensity components in an image such as walls of
the room or cloudless sky.

- High frequencies are caused by sharp transitions in


intensity such as edges and noise.

- Filter H(u,v) attenuates high frequencies while passing low


frequencies would blur the image.

- Filter H(u,v) attenuates low frequencies while high


frequencies would enhance sharp details but cause a
reduction in contrast in the image.
28
of
41
Description about Linear Filters

• Low-pass filter – low frequencies are passed, high


frequencies are attenuated.
• High-pass filter – high frequencies are passed,
low frequencies are attenuated.
• Band-pass filter – only frequencies in a frequency
band are passed.
• Band-stop filter or band-reject filter – only
frequencies in a frequency band are attenuated.
29
of
41
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 transform
function
Low pass filters – only pass the low frequencies,
drop the high ones
- It is used, in general, to smooth an image.
30
of
41
Ideal Low Pass Filter( ILPF)
A 2-D lowpass filter that passes without attenuation all frequencies within
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

a circle of radius D0 from the origin simply cut off all high frequency
components that are at a specified distance D0 from the origin
changing the distance changes the behaviour of the filter

Frequency Response Functional Form


31
of
41
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)  
Where
0 if D(u , v)  D0
D0 is a positive constant threshold frequency and = and D(u,v) is the
distance between a point (u,v) in the frequency domain and the centre
of the frequency rectangle.
D(u,v) is given as:

D (u, v)  [(u  M / 2)  (v  N / 2) ]
2 2 1/ 2
32
of
41
Ideal Low Pass Filter (cont…)
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

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
33
of
41
Ideal Low Pass Filter (cont…)
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

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
34
of
41
Butterworth Lowpass Filters
Butterworth is ILPF has a parameter called filter
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

order, n. 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
35
of
41
Butterworth Lowpass Filter (cont…)
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

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
36
of
41
Butterworth Lowpass Filter (cont…)

• Butterworth uses a sharp cut-off that


imply hard filtering.

• If we want to make the filter to allow a


part of the energy spectrum at higher
frequencies, we may use the
Butterworth Filter.
37
of
41
Gaussian Lowpass Filters (GLPF)
The transfer function of a Gaussian lowpass
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

filter is defined as:


 D 2 ( u ,v ) / 2 D0 2
H (u , v)  e

When D(u,v)= D0, the GLPF is down to 0.607 of its maximum value.
38
of
41
Gaussian Lowpass Filters (cont…)
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Result of filtering
Original with Gaussian
image filter with cutoff
radius 5

Result of filtering Result of filtering


with Gaussian with Gaussian filter
filter with cutoff with cutoff radius
radius 15 30

Result of Result of filtering


filtering with with Gaussian
Gaussian filter filter with cutoff
with cutoff radius 230
radius 85
39
of
41
Lowpass Filters Compared
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

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
40
of
41
Lowpass Filtering Examples
A low pass Gaussian filter is used to connect
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

broken text
41
of
41
Lowpass Filtering Examples (cont…)
Different lowpass Gaussian filters used to
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

remove blemishes in a photograph


42
of
41
Lowpass Filtering Examples (cont…)
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Original Gaussian
image lowpass filter

Spectrum of Processed
original image image
43
of
41
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)
44
of
41
Ideal High Pass Filters
The ideal high pass filter is given as:
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

0 if D(u , v)  D0
H (u , v)  
1 if D(u , v)  D0
where D0 is the cut off distance as before
45
of
41
Ideal High Pass Filters (cont…)
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

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
46
of
41
Butterworth High Pass Filters
The Butterworth high pass filter is given as:
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

1
H (u , v) 
1  [ D0 / D(u, v)] 2n

where n is the order and D0 is the cut off


distance as before
47
of
41
Butterworth High Pass Filters (cont…)
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

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
48
of
41
Gaussian High Pass Filters
The Gaussian high pass filter is given as:
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

 D 2 ( u ,v ) / 2 D0 2
H (u , v)  1  e
where D0 is the cut off distance as before
49
of
41
Gaussian High Pass Filters (cont…)
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

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
50
of
41
Highpass Filter Comparison
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Results of ideal Results of Butterworth Results of Gaussian


high pass filtering high pass filtering of high pass filtering with
with D0 = 15 order 2 with D0 = 15 D0 = 15
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

of
41
High frequency 51
emphasis result Original image

equalisation Highpass filtering result


After histogram
Highpass Filtering Example
52
of
41
Laplacian In The Frequency Domain
 Laplacian in frequency domain yields the equivalent
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

results as spatial domain.

H(u,v)= ( or w.r.t. centre of frequency


H(u,v)=

The Laplacian image is obtained as

g(x,y)= f(x,y) + c f(x,y)

Here c=-1 and

f(x,y) = IDFT (H(u,v)F(u,v))


Images taken from Gonzalez & Woods, Digital Image Processing (2002)

of
41
Inverse DFT of 53
Laplacian in the Laplacian in the
frequency domain frequency domain

domain
in the frequency
2-D image of Laplacian
to spatial filter
of the image on
Zoomed section
Laplacian In The Frequency Domain

the left compared


54
of
41
Frequency Domain Laplacian Example

Original Laplacian
image filtered
image

Laplacian
Enhanced
image
image
scaled
55
of
41
Frequency Domain Steps Revisited
56
of
41
Fast Fourier Transform
The reason that Fourier based techniques
have become so popular is the development
of the Fast Fourier Transform (FFT)
algorithm
Allows the Fourier transform to be carried
out in a reasonable amount of time
Reduces the amount of time required to
perform a Fourier transform by a factor of
100 – 600 times!
57
of
41
FFT Continues
• FFT computes the DFT of sequence.
Converts a signal from its original domain
to frequency domain rapidly.
• Reduces the computation in order of
MNlog2 MN multiplications and additions.
• DFT is a mathematical operation. FFT is
an efficient algorithm for the evaluation of
that operation. It is the faster version of
DFT that can be applied when the number
of samples in the signal is a power of two.
58
of
Frequency Domain Filtering & Spatial
41 Domain Filtering
Similar jobs can be done in the spatial and
frequency domains
Filtering in the spatial domain can be easier
to understand
Filtering in the frequency domain can be
much faster – especially for large images
59
of
41
Summary
In this lecture we examined 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
Next time we will begin to examine image
restoration using the spatial and frequency
based techniques we have been looking at
60
of
41
Questions?

?
61
of
41
Different enhancement approaches
Lowpass filter
Highpass filter
Homomorphic filter

61
62
of
41
Lowpass filtering
 Ideal filter
– D(u, v): distance from point (u, v) to the origin
– cutoff frequency (D0) ì1 if D (u , v )£D0
H (u , v )=í
– nonphysical î0 if D(u , v )> D0
– radially symmetric about the origin
 Butterworth filter
1
H (u, v )= 2n
1 + [D(u, v )/ D0 ]
 Gaussian lowpass filter

- D 2 (u ,v )/ 2 D0 2
H (u , v )=e

62
63
of
41

63
64
of
Power ratio
41
99.9699.6599.0497.84

é ù
b =100 êå
ëu
å
v
P(u, v )/ PT (u , v )ú
û

64
65
of
41
Highpass filter
Ideal filter
ì0 if D(u , v )£D0
H (u , v )=í
î1 if D(u , v )> D0
Butterworth filter

1
H (u , v )= 2n
1 + [D0 / D(u, v )]
Gaussian highpass filter

- D 2 (u ,v )/ 2 D0 2
H (u , v )=1 - e
65
66
of
41

66
67
of
41

67
68
of
41
Example

68
69
of Laplacian frequency-domain
41
filters
• Spatial-domain Laplacian (2nd derivative)

• Fourier transform 2 f 2 f
 f  2  2
2

x y

  n f ( x) 
   ( ju ) n
F (u )
 x
n

  2 f ( x, y )  2 f ( x , y ) 
    ( ju ) 2
F (u , v )  ( jv ) 2
F (u , v)
 x y
2 2

 (u 2  v 2 ) F (u , v)
69
70
of Laplacian frequency-domain
41
filters

Input
F(u,v)
f(x,y) F
Laplacian -(u2+v2)

 2
f  2
f
2 f  2  2
x y -(u2+v2)F(u,v)
F

The Laplacian filter in the frequency domain is


H(u,v) = -(u2+v2)
70
71 0
of
41

H(u,v) = -(u2+v2) frequency

71
spatial
72
of
41

original Laplacian

Scaled original+
Laplacian Laplacian

72
73
of
41 Image Enhancement - 3
Frequency vs. spatial domain

73
74
of
41
Homomorphic filtering
A simple image model
– f(x,y): the intensity is called the gray level for
monochrome image
– f(x, y) = i(x, y).r(x, y)
– 0 < i(x, y) < inf, the illumination
– 0< r(x, y) < 1, the reflectance

74
75
of
41
Image Enhancement - 3

Homomorphic filters (cont’)

75
76
of
41
Homomorphic filter (cont’)
f (x, y )=i (x, y )×r (x, y )
z (x, y )=ln f (x, y ) =ln i(x, y )+ ln r (x, y )
F {z (x, y )} =F {ln i (x, y )}+ F {ln r (x, y )}
Z (u, v) =Fi (u , v) + Fr (u , v)

S (u , v )=H (u , v )Fi (u , v )+ H (u , v )Fr (u , v )

s (x, y ) =i¢(x, y )+ r ¢(x, y )

g (x, y ) =exp[s (x, y )] =exp[i¢(x, y )]exp[r ¢(x, y )] 76


77
of
41
Homomorphic filter (cont’)

 The illumination component


– Slow spatial variations
– Low frequency
 The reflectance component
– Vary abruptly, particularly at the junctions of
dissimilar objects
– High frequency
 Homomorphic filters
– Affect low and high frequencies differently
– Compress the low frequency dynamic range
– Enhance the contrast in high frequency
77
78
of
41
Homomorphic Filter (cont’)
This filter function tends
to attenuate the
contribution made by the
low frequencies
(illumination) and amplify
the contribution made by
high frequencies
(reflectance). Net result is
simultaneous dynamic
range compression and
contrast enhancement.

gH > 1 - c ( D 2 ( u ,v ) / D02 )
H (u, v) =(gH - gL )[1 - e ] + gL
gL <1
78
80
of
41

80
81
of
41
Homomorphic filter - example

81
 Point processing  Mask processing • Frequency domain
82
of filters
(spatial filters)
41Simple gray level
transformations  Smoothing filters (blur • Smoothing filters (blur
– Image negatives details) details)
– Log transformations – Average, weighted • Ideal lowpass filter
– Power-law average • Butterworth lowpass
transformations – Order statistics • Gaussian lowpass
– Contrast stretching • Sharpening filters
(e.g. median)
– Gray-level slicing (highlight details)
– Bit-plane slicing – Unsharp masking
 Histogram processing  Sharpening filters – High-boost filters
– Histogram (highlight details) – Derivative filters - The
equalization – Unsharp masking Laplacian
– *Histogram matching – Ideal highpass filter
– High-boost filters
(specification) – Butterworth highpass
 Arithmetic/logic – Derivative filters filter
• The Laplacian – Gaussian highpass
operations
– Image averaging • The Gradient filter
• Homomorphic filtering

82
83
of
41
FFT and IFFT

83
84
of
41

END
(FREQUENCY DOMAIN FILTERING)

You might also like