Sunteți pe pagina 1din 24

Frequency Domain Filtering

Lecture-5
Sankalp Kallakuri
elsanky@gmail.com
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
The basic filtering model is given by

G(u, v)  H (u, v) F (u, v)


Ideal, Gaussian and Butterworth are some of the filters we shall study.

Smoothing in the frequency domain is achieved by attenuating certain


high frequency components .

Ideal Low Pass Filter


D(u, v)  D0
H (u, v) 
{ 1

0
If

If D(u, v)  D0

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
The frequency in ILPF transfer function at which there is a sharp transition
The total power enclosed in the frequency spectrum is
M 1 N 1
PT   P(u, v)
u 0 v 0

The power that is enclosed within the circle is given by a fraction alpha

 
  100 P(u, v) / PT 
u v 

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.
1
H (u, v) 
1  D(u, v) / D0 
Nth order Butterworth LPF 2n

Example
Do = 200
N=2
In Frequency Domain
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
 D 2 ( u ,v ) / 2 2
H (u, v)  e
Blurring effects show a smoother transition as cutoff frequency is
Increased.

Gaussian LPF is smoother in the transition band as compared


to a Butterworth LPF.

IFT of such a Gaussian LPF will display no ringing.

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

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

Gaussian LPF cutoff = 50


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


D(u, v)  D0
H (u, v)  { 0

1
If

If D(u, v)  D0

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


1
H (u, v) 
1  D0 / D(u, v)
2n

50

100
Cutoff = 100
Gaussian HPF

The Gaussian High Pass Filter transfer function is given by


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

50

100
Cutoff = 100
Laplacian in Frequency Domain
Effect of differentiation in the space domain
 d n f ( x) 
 n   ( ju ) n
F (u )
 dx 

  2 f ( x, y )  2 f ( x, y ) 
     (u 2
 v 2
) F (u, v)
  x  y 
2 2 2 2

The FT of Laplacian operator on an image f(x,y)


 [2 f ( x, y)]  (u 2  v 2 ) F (u, v)
The FT of Laplacian operator

H (u, v)  (u 2  v 2 )
Laplacian in Frequency Domain
The Laplacian operating on f(x,y) and its fourier transform

2 f ( x, y)   1  [(u  M / 2) 2  (v  N / 2) 2 ]F (u, v) 
Laplacian HPF


g ( x, y)   1 1  ([(u  M / 2) 2  (v  N / 2) 2 )]F (u, v) 
The Laplacian for composite filtering
H hp (u, v)  1  H lp (u, v)

The Laplacian for High Boost


H hb (u, v)  ( A  1)  H hp (u, v)
High Frequency Emphasis
H hfe (u, v)  a  bH hp (u, v)
a0 ba
Homomorphic Filter

g(x,y)
f(x,y)
Ln DFT H(u,v) IDFT exp

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
DUE at 11:59 pm on the 8th of March 2007

• 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.
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

S-ar putea să vă placă și