Sei sulla pagina 1di 55

Frequency Domain Filtering

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 spatial domain

Example:
High-pass filters
(i.e., sharpening filters)
• Preserves high frequencies - useful for edge detection

spatial
domain
frequency
domain

Example:
Band-pass filters

• Preserves frequencies within a certain band

frequency spatial
domain domain

Example:
Band-stop filters

• How do they look like?

Band-pass Band-stop
Frequency Domain Methods

Case 1: H(u,v) is specified in


the frequency domain.

Case 2: h(x,y) is specified in


the spatial domain.
Frequency domain filtering: steps

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


Frequency domain filtering: steps (cont’d)
(Case 1)

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


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)

gp(x,y) g(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)


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

600 x 600

frequency
spatial

Sobel

frequency 602 x 602


Results of Filtering in the
Spatial and Frequency Domains
spatial domain frequency domain
filtering filtering
Important: Preserving even/odd symmetry
when padding with zeroes
• Since h(x,y) is real and odd, H(u,v) should be imaginary and odd
• Need to explicitly preserve the odd symmetry of h(x,y) when padding
with zeroes (read details on pages 290-291 and 318-319)

Example: 6 x 6
g(x,y)= -g(6-x,6-y)
0 0 0 0 0 0
0 0 0 0 0 0
Sobel 0 0 -1 0 1 0
0 0 -2 0 2 0
0 0 -1 0 1 0
0 0 0 0 0 0
Recall the following FT properties:
Low Pass (LP) Filters

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


Ideal
In 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.
original r=8 (90% power) r=18 (93% power)

r: radius
r=43 (95%) r=78 (99%) r=152 (99.5%)
How does D0 (cut-off frequency) control
smoothing?
• Reminder: multiplication in the frequency domain implies
convolution in the time domain
time domain freq. domain

sinc

*
=
How does D0 (cut-off frequency) control
smoothing?
Recall the following result:

magnitude

rect(x) function sinc(x)=sin(x)/x


How does D0 (cut-off frequency) control
smoothing? (cont’d)
• D0 controls the amount of blurring
r=78 (99%)

r=8 (90%)
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 BLPF
ILPF BLPF

D0=10, 30,
60, 160,
460
D0=10, 30,
60, 160, n=2
460
Gaussian LP filter (GLPF)
Gaussian Lowpass Filters (GLPF) in two dimensions is given
 ( u 2  v2 )/2 2
H (u, v)  e

By letting   D0
 ( u 2  v2 )/2 D02
H (u, v)  e
Gaussian: Frequency – Spatial Domains
Let H(u) denote the 1-D frequency domain Gaussian filter
-u 2 /2 2
H (u)  Ae

The corresponding filter in the spatial domain


2 2 2 x2
h( x)  2 Ae

spatial
frequency domain
domain
Example: smoothing by GLPF (1)
Examples of smoothing by GLPF (2)

D0=100
D0=80
10/28/2019 32
High Pass (LP) Filters

• Common HO 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:

H HP (u, v)  1  H LP (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 ringing
effect

1-
Spatial Representation of High-pass Filters
IHPF BHPF GHPF
Comparison: IHPF and BHPF

IHPF D0=30,60,160

D0=30,60,160

BHPF n=2
Gaussian HP filter
A 2-D Gaussian highpass filter (GHPL) is defined as
 ( u 2  v 2 )/2 D02
H (u, v)  1  e

GHPF

BHPF
Comparison: BHPF and GHPF

BHPF D0=30,60,160
n=2

D0=30,60,160
GHPF
Example: High-pass Filtering and Thresholding
for Fingerprint Image Enhancement

BHPF
(order 4 with a cutoff
frequency 50)
Difference of Gaussians (DoG) filter

Let H (u ) denote the difference of Gaussian filter


-u 2 /212 -u 2 /2 22
H (u)  Ae  Be
with A  B and  1   2

The corresponding filter in the spatial domain


2 212 x2 2 2 22 x2
h( x)  21 Ae  2 2 Ae

This is a high-pass filter!


Highboost Filtering (revisited)

Unsharp Masking:
gmask ( x, y)  f ( x, y)  f LP ( x, y)

g ( x, y)  ( A 1) f ( x, y)  f HP ( x, y)

Highboost filtering:
(previous formulation) g ( x, y)  ( A 1) f ( x, y)  f HP ( x, y)

Highboost filtering: g ( x, y)  f ( x, y)  kgmask ( x, y)  f ( x, y)  k ( f ( x


(textbook’s formulation)
 f ( x, y)  kf HP ( x, y)
Highboost Filtering (revisited)

g ( x, y)  f ( x, y)  kgmask ( x, y)  f ( x, y)  k ( f ( x, y)  f LP ( x, y))

FT

G (u, v)  F{ f ( x, y )  k ( f ( x, y )  f LP ( x, y ))}
 F (u, v)  k ( F (u, v)  H LP (u, v) F (u, v)) 
 [1  k (1  H LP (u, v))]F (u, v)  [1  kH HP (u, v)]F (u, v)

1
Highboost Filter
so : g ( x, y )  F {[1  kH HP (u, v)]F (u, v)}
Highboost and High-Frequency-Emphasis Filters

g ( x, y )  F 1 ((1  kH HP (u , v)) F (u , v)) g ( x, y )  F 1 (( k1  k2 H HP (u, v)) F (u, v))


k 0 k1  0, k2  0

1+k k1+k2

1 k1
High-emphasis
Highboost
Example

GHPF
D0=40

High-emphasis High-emphasis
and hist. equal.
High-Frequency
Emphasis filtering
Using Gaussian filter
k1=0.5, k2=0.75
Homomorphic filtering
• Can be used to remove shading effects in 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:

i(x,y): illumination component


r(x,y): reflection component

• In general, the illumination component i(x,y) varies slowly


and affects low frequencies mostly.

• In general, the reflection component r(x,y) varies faster


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

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

• When applying filtering, it is difficult to handle


low/high frequencies separately.

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


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 g ( x, y)  i0 ( x, y)r0 ( x, y)


Homomorphic Filtering Example using
high-frequency emphasis
H (u, v)  ( H   L ) 1  e  
 c ( u 2  v2 )/ D02 
 
  L

Attenuate the contribution


made by illumination and
amplify the contribution made
by reflectance
Homomorphic Filtering: Example 1
Homomorphic Filtering: Example 2

 L  0.25
H  2
c 1
D0  80

Potrebbero piacerti anche