24
Frequency Domain Filtering Lecture-5 Sankalp Kallakuri [email protected]

Frequency Domain Filtering Image Processing

Embed Size (px)

DESCRIPTION

Frequency domain filtering for image processing

Citation preview

Page 1: Frequency Domain Filtering Image Processing

Frequency Domain Filtering

Lecture-5

Sankalp Kallakuri

[email protected]

Page 2: Frequency Domain Filtering Image Processing

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.

Page 3: Frequency Domain Filtering Image Processing

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.

Page 4: Frequency Domain Filtering Image Processing

Basic Filters

• Low Pass Filter

• High Pass Filter

• Notch Filter

Page 5: Frequency Domain Filtering Image Processing

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.

Page 6: Frequency Domain Filtering Image Processing

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.

Page 7: Frequency Domain Filtering Image Processing

Example of Ideal LPF

Padded Input Image Result for Do = 50

10 25 100 200

Page 8: Frequency Domain Filtering Image Processing

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.

Page 9: Frequency Domain Filtering Image Processing

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),(

Page 10: Frequency Domain Filtering Image Processing

Butterworth LPF

5 25 50

70 100 200

Page 11: Frequency Domain Filtering Image Processing

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

Page 12: Frequency Domain Filtering Image Processing

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

Page 13: Frequency Domain Filtering Image Processing

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.

Page 14: Frequency Domain Filtering Image Processing

Example Gaussian LPF

Cutoff = 50 Gaussian LPF cutoff = 50

Page 15: Frequency Domain Filtering Image Processing

Examples Gaussian LPF

5 25 50

70 100 200

Page 16: Frequency Domain Filtering Image Processing

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?

Page 17: Frequency Domain Filtering Image Processing

Ideal HPF Example

Cutoff = 50 Cutoff = 100

Page 18: Frequency Domain Filtering Image Processing

Butterworth HPF

The Butterworth High Pass Filter transfer function is given by

nvuDD

vuH2

0 ),(/1

1),(

Cutoff = 100

50

100

Page 19: Frequency Domain Filtering Image Processing

Gaussian HPF

The Gaussian High Pass Filter transfer function is given by

Cutoff = 100

50

100

20

2 2/),(1),(

DvuDevuH

Page 20: Frequency Domain Filtering Image Processing

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

Page 21: Frequency Domain Filtering Image Processing

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

Page 22: Frequency Domain Filtering Image Processing

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.

Page 23: Frequency Domain Filtering Image Processing

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

Page 24: Frequency Domain Filtering Image Processing

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