frequency domain filtering (chapter 4)farid/teaching/dip/lecture - frequency filtering.pdf ·...

53
Frequency Domain Filtering (Chapter 4) CS474/674 - Prof. Bebis

Upload: others

Post on 12-May-2020

16 views

Category:

Documents


2 download

TRANSCRIPT

Frequency Domain Filtering (Chapter 4)

CS474/674 - Prof. Bebis

Frequency Domain Methods

Spatial Domain Frequency Domain

Major filter categories

• Typically, filters are classified by examining their properties in the frequency domain:

(1) Low-pass (2) High-pass (3) Band-pass (4) Band-stop

Example

Original signal

Low-pass filtered

High-pass filtered

Band-pass filtered

Band-stop filtered

Low-pass filters(i.e., smoothing filters)

• Preserve low frequencies - useful for noise suppression

frequency domain time domain

Example:

High-pass filters(i.e., sharpening filters)

• Preserves high frequencies - useful for edge detection

frequency domain

timedomain

Example:

Band-pass filters

• Preserves frequencies within a certain band

frequency domain

timedomain

Example:

Band-stop filters

• How do they look like?

Band-pass Band-stop

Frequency Domain Methods

Case 1: H(u,v) is specified inthe frequency domain.

Case 2: h(x,y) is specified inthe spatial domain.

(real)

Frequency domain filtering: steps

F(u,v) = R(u,v) + jI(u,v)

Frequency domain filtering: steps (cont’d)

G(u,v)= F(u,v)H(u,v) = H(u,v) R(u,v) + jH(u,v)I(u,v)

(Case 1)

Example

f(x,y) fp(x,y) fp(x,y)(-1)x+y

F(u,v)H(u,v) - centered G(u,v)=F(u,v)H(u,v)

g(x,y)gp(x,y)

(Case 2) h(x,y) specified in spatial domain

• If h(x,y) is given in the spatial domain, we can generate H(u,v) as follows:

1.Form hp(x,y) by padding with zeroes.

2. Multiply by (-1)x+y to center its spectrum.

3. Compute its DFT to obtain H(u,v)

Recall these properties:

Example: h(x,y) is specified in the spatial domain

600 x 600

Sobel

time

frequency

frequency

Warning: need to preserve odd symmetry when padding with zeroes H(u,v) should be imaginary and odd (read details on pages 241 and 268)

0 0 0 0 0 00 0 0 0 0 00 0 -1 0 1 00 0 -2 0 2 00 0 -1 0 1 00 0 0 0 0 0

Example: 6 x 6g(x,y)= -g(6-x,6-y)

602 x 602

Results of Filtering in the Spatial and Frequency Domains

spatial domainfiltering

frequency domainfiltering

Low Pass (LP) Filters

• Ideal low-pass filter (ILPF) • Butterworth low-pass filter (BLPF)• Gaussian low-pass filter (GLPF)

Low-pass (LP) filtering

• Preserves low frequencies, attenuates high frequencies.

IdealIn practice

D0: cut-off frequency

Lowpass (LP) filtering (cont’d)

• In 2D, the cutoff frequencies are specified by a circle.

Ideal

Specifying a 2D low-pass filter• Specify cutoff frequencies by specifying the radius of a circle

centered at point (N/2, N/2) in the frequency domain.• The radius is chosen by specifying the percentage of total

power enclosed by the circle.

Specifying a 2D low-pass filter (cont’d)• Typically, most frequencies are concentrated around the

center of the spectrum.r=8 (90% power) r=18 (93% power)

r=43 (95%) r=78 (99%) r=152 (99.5%)

original

r: radius

How does D0 control smoothing?

• Reminder: multiplication in the frequency domain implies convolution in the time domain

* =

freq. domaintime domain

sinc

How does D0 control smoothing? (cont’d)

• D0 controls the amount of blurring

r=8 (90%)

r=78 (99%)

Ringing Effect

• Sharp cutoff frequencies produce an overshoot of image features whose frequency is close to the cutoff frequencies (ringing effect).

h=f*g

Butterworth LP filter (BLPF)

• In practice, we use filters that attenuate high frequencies smoothly (e.g., Butterworth LP filter) less ringing effect

n=1 n=4 n=16

Spatial Representation of BLPFs

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

Comparison: Ideal LP and BLPFILPF BLPF

D0=10, 30,60, 160,460

n=2

D0=10, 30,60, 160,460

2 2 2( )/2

Gaussian Lowpass Filters (GLPF) in two dimensions is given

( , ) u vH u v e σ− +=

Gaussian LP filter (GLPF)

2 2 20

0

( )/2

By letting

( , ) u v D

D

H u v e

σ− +

=

=

Gaussian: Frequency – Spatial Domains

2 2- /2

Let H(u) denote the 1-D frequency domain Gaussian filter

( ) uH u Ae σ=

2 2 22

The corresponding filter in the spatial domain

( ) 2 xh x Ae π σπσ −=

frequencydomain

spatialdomain

Example: smoothing by GLPF (1)

14-May-18 30

Examples of smoothing by GLPF (2)

D0=100D0=80

High Pass (LP) Filters

• Ideal high-pass filter (IHPF) • Butterworth high-pass filter (BHPF)• Gaussian high-pass filter (GHPF)• Difference of Gaussians• Unsharp Masking and High Boost filtering

High-pass filtering

• Preserves high frequencies, attenuates low frequencies.

H(u)

High-Pass filtering (cont’d)

• A high-pass filter can be obtained from a low-pass filter as follows:

( , ) 1 ( , )HP LPH u v H u v= −

= 1 -D0

Butterworth high pass filter (BHPF)• In practice, we use filters that attenuate low frequencies

smoothly (e.g., Butterworth HP filter) less ringingeffect

Spatial Representation of High-pass FiltersIHPF BHPF GHPF

Comparison: IHPF and BHPF

IHPF

BHPF

D0=30,60,160

n=2

D0=30,60,160

Gaussian HP filter

2 2 20( )/2

A 2-D Gaussian highpass filter (GHPL) is defined as

( , ) 1 u v DH u v e− += −

GHPF

BHPF

Comparison: BHPF and GHPF

GHPF

BHPF D0=30,60,160

n=2

D0=30,60,160

Example: High-pass Filtering and Thresholding for Fingerprint Image Enhancement

BHPF (order 4 with a cutoff frequency 50)

Difference of Gaussians (DoG) filter

2 22 21 2/2 /2- -

1 2

Let ( ) denote the difference of Gaussian filter

( ) with and

u u

H u

H u Ae BeA B

σ σ

σ σ= −≥ ≥

2 2 2 2 2 21 22 2

1 2

The corresponding filter in the spatial domain

( ) 2 2x xh x Ae Aeπ σ π σπσ πσ− −= −

This is a high-pass filter!

Unsharp Masking and Highboost Filtering (revisited)

( , ) ( , ) ( , )mask LPg x y f x y f x y= −Unsharp Masking:

Highboost filtering:(textbook’s formulation) ),(),(

)),(),((),(),(),(),(yxkfyxf

yxfyxfkyxfyxkgyxfyxg

HP

LPmask

+=

−+=+=

),(),()1(),( yxfyxfAyxg HP+−=Previous definition:

Revisit: Unsharp Masking and Highboost Filtering

1

( , ) { ( , ) ( ( , ) ( , ))}( , ) ( ( , ) ( , ) ( , ))

[1 (1 ( , ))] ( , ) [1 ( , )] ( , )

: ( , ) {[1 ( , )] ( , )}

LP

LP

LP HP

HP

G u v f x y k f x y f x yF u v k F u v H u v F u v

k H u v F u v kH u v F u v

so g x y kH u v F u v−

= + −= + − == + − = +

= +

F

FHighboost Filter

FT

( , ) ( , ) ( , ) ( , ) ( ( , ) ( , ))mask LPg x y f x y kg x y f x y k f x y f x y= + = + −

Highboost and High-Frequency-Emphasis Filters

1

1+k

k1

k1+k2

HighboostHigh-emphasis

0)),()),(1((),( 1

≥+= −

kvuFvukHyxg HPF

0,0)),()),(((),(

21

211

≥≥+= −

kkvuFvuHkkyxg HPF

High-FrequencyEmphasis filteringUsing Gaussian filterk1=0.5, k2=0.75

D0=40

Example

GHPF

High-emphasis High-emphasisand hist. equal.

Homomorphic filtering

• Many times, we want to remove shading effects from an image (i.e., due to uneven illumination)– Enhance high frequencies– Attenuate low frequencies but preserve fine detail.

Homomorphic Filtering (cont’d)

• Consider the following model of image formation:

• In general, the illumination component i(x,y) varies slowlyand affects low frequencies mostly.

• In general, the reflection component r(x,y) varies fasterand affects high frequencies mostly.

i(x,y): illuminationr(x,y): reflection

IDEA: separate low frequencies due to i(x,y) from high frequencies due to r(x,y)

How are frequencies mixed together?

• When applying filtering, it is difficult to handle low/high frequencies separately.

( , ) ( , )* ( , )F u v I u v R u v=

( , ) ( , ) [ ( , )* ( , )] ( , )F u v H u v I u v R u v H u v=

• Low and high frequencies from i(x,y) and r(x,y)are mixed together.

Can we separate them?

• Idea:

Take the ln( ) of

Steps of Homomorphic Filtering

(1) Take

(2) Apply FT:

or

(3) Apply H(u,v)

Steps of Homomorphic Filtering (cont’d)

(4) Take Inverse FT:

or

(5) Take exp( ) or ),(),(),( 00 yxryxiyxg =

Example using high-frequency emphasis

2 2 20( )/( , ) ( ) 1 c u v D

H L LH u v eγ γ γ − + = − − +

Attenuate the contribution made by illumination and

amplify the contribution made by reflectance

Attenuate the contribution made by illumination and

amplify the contribution made by reflectance

Homomorphic Filtering: Example

Homomorphic Filtering: Example

0

0.252

180

L

H

cD

γγ

==

==