Why Frequency Domain?
.The idea of filtering in Frequency domain is more intuitive.
. It is possible to create a spatial domain filter by finding the IFT of
the frequency domain filter.
. In spatial domain the filter masks tend to be much smaller.
. In frequency domain the filter masks tend to be the same
size as the image.
. Frequency domain is more computationally intensive especially
for larger numbers.
Frequency Domain Filtering Process
• Multiply input image by (-1)x+y
• Compute DFT F(u,v) of input image.
• Multiply F(u,v) by a filter function H(u,v).
• Compute the inverse DFT of the product.
• Obtain the real part of IDFT.
• Multiply the result by (-1)x+y.
. The transform is a complex quantity and the filter will be
multiplied with both the real and imaginary parts.
. Calculations could be floating point.
. Scaling and quantising to grey levels.
Basic Filters
• Low Pass Filter
• High Pass Filter
• Notch Filter
Smoothing Frequency Domain Filters
),(),(),( vuFvuHvuG
Smoothing in the frequency domain is achieved by attenuating certain
high frequency components .
Ideal, Gaussian and Butterworth are some of the filters we shall study.
The basic filtering model is given by
Ideal Low Pass Filter
),( vuH {1 If
0 If
0),( DvuD
0),( DvuD
D(u,v) is the distance and D0 is a threshold beyond which all
frequencies are getting attenuated.
Smoothing Frequency Domain Filters
The Ideal Low Pass filter has very sharp transitions in frequency domain.
These sharp transitions can cause ringing in the spatial domain.
Example of Ideal LPF
Padded Input Image Result for Do = 50
10 25 100 200
Cutoff Frequency
1
0
1
0
),(M
u
N
v
T vuPP
The frequency in ILPF transfer function at which there is a sharp transition
The total power enclosed in the frequency spectrum is
The power that is enclosed within the circle is given by a fraction alpha
u v
TPvuP /),(100
The amount of ringing depends on the cut off frequency as well as
the spectrum of the underlying image.
Butterworth LPF
Why Butter worth compared to the ideal?
Reduced ringing.
Nth order Butterworth LPF
Example
Do = 200
N=2
In Frequency Domain
nDvuD
vuH2
0/),(1
1),(
Butterworth LPF
5 25 50
70 100 200
How can we obtain the spatial filter
components?
• The Frequency Domain filter is NxN
• The Spatial filter is nxn.
FT of nxn
FT of NxN
How can we obtain the spatial filter
components?
Reshape the matrices such that there is a matrix C
Contents of C are given by
The error between the nxn and NxN mask convolution filter
Equating the error term to zero and taking the derivative we get
Which could be solved for
http://www.mu.edu/~matthysd/web226/L0219.htm
Gaussian LPF
The Gaussian LPF is defined as
Gaussian LPF is smoother in the transition band as compared
to a Butterworth LPF.
Blurring effects show a smoother transition as cutoff frequency is
Increased.
IFT of such a Gaussian LPF will display no ringing.
20
2 2/),(),(
DvuDevuH
22 2/),(),( vuDevuH
Replacing standard deviation as cutoff.
The frequency when the filter value is 0.607 of the max value is
defined as the cutoff frequency.
Example Gaussian LPF
Cutoff = 50 Gaussian LPF cutoff = 50
Examples Gaussian LPF
5 25 50
70 100 200
High Pass Filters
Transfer function of Highpass Filters
HPF (u,v)= 1 – LPF(u,v)
Ideal High Pass Filter
),( vuH { 0 If
1 If
0),( DvuD
0),( DvuD
Why should the center pixel of a High Pass Filter be 255 on a gray
level image?
Ideal HPF Example
Cutoff = 50 Cutoff = 100
Butterworth HPF
The Butterworth High Pass Filter transfer function is given by
nvuDD
vuH2
0 ),(/1
1),(
Cutoff = 100
50
100
Gaussian HPF
The Gaussian High Pass Filter transfer function is given by
Cutoff = 100
50
100
20
2 2/),(1),(
DvuDevuH
Laplacian in Frequency Domain
),()(),(),( 22
22
2
22
2
vuFvuy
yxf
x
yxf
)()()(
uFjudx
xfd n
n
n
)(),( 22 vuvuH
),()()],([ 222 vuFvuyxf
Effect of differentiation in the space domain
The FT of Laplacian operator on an image f(x,y)
The FT of Laplacian operator
Laplacian in Frequency Domain
),(])2/()2/[(),( 2212 vuFNvMuyxf
),()])2/()2/([(1),( 221 vuFNvMuyxg
),(1),( vuHvuH lphp
The Laplacian operating on f(x,y) and its fourier transform
Laplacian HPF
The Laplacian for composite filtering
),()1(),( vuHAvuH hphb
The Laplacian for High Boost
High Frequency Emphasis
),(),( vubHavuH hphfe
0a ab
Homomorphic Filter
Ln DFT H(u,v) IDFT expf(x,y)
g(x,y)
Split the image into illumination and reflectance components
The low frequencies of the FT of the log would be related to illuminance
The high with reflectance.
Modeling of multiplicative noise.
HW-4
• Write a matlab script to find the histogram of an image. Plot the histogram (Figure A). Compare with Matlabs inbuilt function and comment.
• Write a matlab script to perform histogram equalization. Plot equalized histogram from your script (Figure B). Display equalized image obtained from your script (Figure C). Display equalized image and equalised histogram obtained by matlabs inbuilt functions (Figure D & Figure E). Compare results with matlabs inbuilt function and comment.
• Try to threshold Lena so that pixels that belong to her skin are thresholded high. Display thresholded image (Figure F).
• Write a matlab script to perform contrast stretching on an image given a certain stretch function.
DUE at 11:59 pm on the 8th of March 2007
HW -4
• Use your stretching script and your equalization script on the same original image. Display both output images (Figure G & Figure H). Compare the two images and comment.
• Take the difference of the equalized image with the original. Display the difference image (Figure J). Take the difference between contrast stretched script and the original. Display the difference image (Figure H). Compare the two images and comment.
• Display histograms of the two difference images (Figure K & Figure L). Compare and comment.
• Write a matlab script to perform Histogram matching. Given a PDF for the output image. Display matched image (Figure M). Compare with matlabs inbuilt function and comment.
*Figures are to be named as marked in red