DIP Chap 4 (Filtering in the Frequency Domain) Lect 11

Post on 23-Nov-2014

115 views 3 download

Tags:

transcript

1

Digital Image ProcessingDr. Basit Mughal

drmughal75@gmail.comLecture 11

Lowpass Filtering in the Frequency DomainThree types of low pass filters:

1. Ideal filters2. Butterworth filters (parameter: filter

order)3. Gaussian filters

Ideal Filter (Lowpass)

A 2-D ideal low-pass filter:

0

0

),( if 0

),( if 1),(

DvuD

DvuDvuH

where D0 is a specified nonnegative quantity and D(u,v) is the distance from point (u,v) to the center ofthe frequency rectangle.

• Center of frequency rectangle: (u,v)=(M/2,N/2)• Distance from any point to the center (origin) of the Fourier Transform:

2/122 ))2/()2/(),( NvMuvuD

Ideal Low pass filter

Ideal Low pass filter:

all frequencies inside a circle of radius D0 are passed with no attenuation

all frequencies outside this circle are completely attenuated.

Ideal Filter (Lowpass)Cutoff-frequency: the point of transition between

H(u,v)=1 and H(u,v)=0 (D0)

To establish cutoff frequency loci, we typically compute circles that enclose specified amounts of total image power PT.

1

0

1

0

),(M

u

N

vT vuPP

2),(),( vuFvuP where

Fourier Spectrum with different radiiFourier Spectrum with different radii

8% power removed

0.5% power removed

2% power removed

5.4% power removed

3.6% power removed

Blurring with little or no ringingButterworth low pass filter (BLPF)

Gaussian low pass filter (GLPF)

2

0

1( , )

( , )1

nH u v

D u v

D

where

2/122 ))2/()2/(),( NvMuvuD

The transfer function of a Buterworth low pass filter (BLPF) of order n, and with cutoff frequency at a distance D0 from the origin, is

Sharp Discontinuity

Does not have sharp Discontinuity

Butterworth Filter (Lowpass)To define a cutoff frequency locus: at points

for which H(u,v) is down to a certain fraction of its maximum value.

When D(u,v) = D0, H(u,v) = 0.5

i.e. down 50% from its maximum value of 1.

Smooth transition of blurring as a function of increasing cutoff frequency for n=2 and D0= 5, 15, 30, 80, 320

ILPF results BLPF results with n=2

A Butterworth filter of order 1 has no ringing. Ringing generally is imperceptible in filter of order 2 , but can become a significant factor in filter of higher order. (with cutoff frequency of 5 pixels)

n = 1 n = 2 n = 5 n = 20

Summary of BLPFBLPF of order 1 has no ringing at all.BLPF of order 2 shows mild ringing but

small as compared to ILPF.BLPF of higher order have significant

ringing effect.BLPF of order 20 = ILPF

BLPF of order 2 is a good compromise between effective low pass filtering and acceptable ringing characteristics.

Gaussian Low Pass Filter

2

2

2

),(

),( vuD

evuH

where sigma is a measure of the spread of the Gaussian curve . Let sigma = D0, then

20

2

2

),(

),( D

vuD

evuH

When D(u,v) = D0 , the filter is down to 0.607 of its maximum value

Gaussian low pass filters (GLPFs) in two dimensions is

D(u,v) is the distance from the origin of the Fourier Transform

Gaussian Low Pass Filters

Comparison of GLPF with BLPFSmooth transition in blurring as a function

of increasing cutoff frequency.GLPF did not achieve as much smoothing as

the BLPF of order 2 for the same value of cutoff frequency because the profile of GLPF is not as tight as that of BLPF.

It is assumed that no ringing in GLPF.BLPF is a suitable choice where tight

control of the transition between low and high frequencies about the cutoff frequency are needed.

The price of this additional control over the filter profile is the possibility of ringing

Example from machine perception GLPF with D0=80 (Application to Character Recognition )

Fax transmissionDuplicate materialHistorical records

Sharpening frequency domain filters• Image can be blurred by attenuating the high frequency components• Edges and other abrupt changes in gray levels are associated with high

frequency components • Image can be sharpened by attenuating low frequency components i.e.

HP filtering

( , ) 1 ( , )hp lpH u v H u v

Three types of High Pass Filters:1.Ideal High Pass Filters (IHPF)2.Butterworth filter (BHPF)3.Gaussian filter (GHPF)

Transfer function of LP filter

When LP filters attenuates frequencies HP filter passes them and vice versa

Sharpening frequency domain filtersB

HP

F r

epre

sen

ts a

tra

nsi

tion

bet

wee

n t

he

shar

pn

ess

of t

he

idea

l fil

ter

and

th

e to

tal

smoo

thn

ess

of t

he

Gau

ssia

n f

ilte

r

Spatial Representation of a frequency domain filter

Multiply H(u,v) by (-1)u+v for centeringComputing the inverse DFTMultiplying the real part of inverse DFT by (-1)x+y

Ideal Filter (Highpass)

A 2-D ideal low-pass filter:

0

0

),( if 1

),( if 0),(

DvuD

DvuDvuH

where D0 is a specified nonnegative quantity and D(u,v) is the distance from point (u,v) to the center of the frequency rectangle.

• Center of frequency rectangle: (u,v)=(M/2,N/2)• Distance from any point to the center (origin) of the FT:

2/122 ))2/()2/(),( NvMuvuD

Same ringing properties as ILPF

IHPF with D0=15, 30, 80

Butterworth Filter (Highpass)This filter does not have a sharp

discontinuity establishing a clear cutoff between passed and filtered frequencies.

nvuDDvuH

20 )],(/[1

1),(

BHPF with D0=15, 30, 80• BHPF behave smoother than IHPF• The boundaries are less distorted than the result of IHPF even for

smallest value of cutoff frequency• The transition into higher values of cutoff frequencies is mush smoother

with BHPF

Gaussian High Pass Filter2

2

2

),(

1),( vuD

evuH

Where sigma is a measure of the spread of the Gaussian curve . Let sigma = D0, then

20

2

2

),(

1),( D

vuD

evuH

GHPF GHPF

D0 = 15 D0 = 30 D0 = 80

Better results than IHPF and BHPF, even the filtering of the smaller objects and thin bars is cleaner with the Gaussian filter

The Laplacian in Frequency Domain

If the centre of the filter function is shifted to (M/2, N/2)

The Laplacian filtered image in the spatial domain is obtained by computing the inverse Fourier transform of

In Fourier Transform pair notation

The Laplacian in the frequency domainThe Laplacian in the frequency domain

We form an enhanced image g(x,y) by subtracting the Laplacian from the original image

As in the spatial domain, where we obtained the enhanced image with a single mask, it is possible to perform the entire operation in the frequency domain with only one filter

2 2

2 2

1 2 2

( , ) ( , ) ( / 2) ( / 2) ( , )

( , ) 1 ( / 2) ( / 2) ( , )

( , ) 1 ( / 2) ( / 2) ( , )

G u v F u v u M v N F u v

G u v u M v N F u v

g x y u M v N F u v

Scaled image

Operated in frequency domain

Operated in spatial domain

High boost filtering

),(),(),( yxfyxAfyxf lphb

),(),(),()1(),( yxfyxfyxfAyxf lphb

),(),()1(),( yxfyxfAyxf hphb

( , ) ( , ) ( , )mask lpg x y f x y f x y

High boost filtering generalized this by multiplying f(x,y) by a constant A ≥ 1

),(1),( vuHvuH lphp

hb hpH (u, v) (A 1) H (u, v)

In high pass filters average background intensity reduced to nearblack because of zero frequency component elimination

Highboost filtering in the frequency domainHighboost filtering in the frequency domain

Original Image High pass filtered(Laplacian)

),(),()1(),( yxfyxfAyxf hphb

A = 2A = 2.7

End Chapter 4

?

44

MATLABMATLAB functions

45

Questions /comments

drmughal75@gmail.com