Download as pdf or txt
Download as pdf or txt
You are on page 1of 72

5/30/2022 102

5/30/2022 103
5/30/2022 104
The Basic Filtering in the Frequency Domain

Why is the spectrum at


almost ±45 degree stronger
than the spectrum at other
directions?

5/30/2022 105
The Basic Filtering in the Frequency Domain

► Modifying the Fourier transform of an image

► Computing the inverse transform to obtain the processed


result

g ( x, y )  1{H (u , v) F (u , v)}

F (u , v) is the DFT of the input image


H (u , v) is a filter function.

5/30/2022 106
The Basic Filtering in the Frequency Domain

► In a filter H(u,v) that is 0 at the center of the transform


and 1 elsewhere, what’s the output image?

5/30/2022 107
The Basic Filtering in the Frequency Domain

5/30/2022 108
The Basic Filtering in the Frequency Domain

5/30/2022 109
Zero-Phase-Shift Filters
1
g ( x, y )   {H (u, v) F (u, v)}
F (u, v)  R(u, v)  jI (u, v)
1
g ( x, y )    H (u, v) R(u, v)  jH (u, v) I (u, v)
Filters affect the real and imaginary parts equally,
and thus no effect on the phase.
These filters are called zero-phase-shift filters

5/30/2022 110
Examples: Nonzero-Phase-Shift Filters

Even small
Phasechanges
angle is in the phase angle can ishave
Phase angle
dramaticmultiplied
(usually by undesirable) effects on the
multiplied by filtered
output 0.5 0.25

5/30/2022 111
Summary:
Steps for Filtering in the Frequency Domain
1. Given an input image f(x,y) of size MxN, obtain the
padding parameters P and Q. Typically, P = 2M and Q = 2N.

2. Form a padded image, fp(x,y) of size PxQ by


appending the necessary number of zeros to f(x,y)

3. Multiply fp(x,y) by (-1)x+y to center its transform

4. Compute the DFT, F(u,v) of the image from step 3

5. Generate a real, symmetric filter function*, H(u,v), of


size PxQ with center at coordinates (P/2, Q/2)
*generate from a given spatial filter, we pad the spatial filter, multiply the expadded
array by (-1)x+y, and compute the DFT of the result to obtain a centered H(u,v).
5/30/2022 112
Summary:
Steps for Filtering in the Frequency Domain
6. Form the product G(u,v) = H(u,v)F(u,v) using array
multiplication

7. Obtain the processed image

 
g p ( x, y )  real 1 G (u , v )  ( 1) x y

8. Obtain the final processed result, g(x,y), by extracting


the MxN region from the top, left quadrant of gp(x,y)

5/30/2022 113
An Example:
Steps for Filtering in the Frequency Domain

5/30/2022 114
Correspondence Between Filtering in the
Spatial and Frequency Domains (1)

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 x 2
h ( x )  2 Ae

1. Both components are Gaussian and real


2. The functions behave reciprocally

5/30/2022 115
Correspondence Between Filtering in the
Spatial and Frequency Domains (2)
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 x 2 2 2 2 2 x 2
h( x )  2 1 Ae  2 2 Ae

High-pass filter or low-pass filter ?

5/30/2022 116
Correspondence Between Filtering in the
Spatial and Frequency Domains (3)

5/30/2022 117
Correspondence Between Filtering in the
Spatial and Frequency Domains: Example

600x600

5/30/2022 118
Correspondence Between Filtering in the
Spatial and Frequency Domains: Example

5/30/2022 119
Image Smoothing Using Filter Domain Filters:
ILPF

Ideal Lowpass Filters (ILPF)


1 if D (u , v )  D0
H (u , v )  
0 if D (u , v )  D0

D0 is a positive constant and D (u , v) is the distance between a point (u , v )


in the frequency domain and the center of the frequency rectangle
2 2 1/2
D(u, v)  (u  P / 2)  (v  Q / 2) 

5/30/2022 120
Image Smoothing Using Filter Domain Filters:
ILPF

5/30/2022 121
ILPF Filtering Example

5/30/2022 122
ILPF ringing and
blurring
Filtering
Example
Ideal in frequency
domain means
non-ideal in
spatial domain,
vice versa.
5/30/2022 123
The Spatial Representation of ILPF

5/30/2022 124
Image Smoothing Using Filter Domain Filters:
BLPF
Butterworth Lowpass Filters (BLPF) of order n and
with cutoff frequency D0 • Smooth transfer
1 function, no sharp
H (u , v )  discontinuity, no
1   D (u , v ) / D0 
2n
clear cutoff
frequency.

5/30/2022 125
The Spatial Representation of BLPF

5/30/2022 126
No
serious
ringing
artifacts

5/30/2022 127
Image Smoothing Using Filter Domain Filters:
GLPF

Gaussian Lowpass Filters (GLPF) in two dimensions is given


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

By letting   D0
 D 2 ( u ,v )/2 D02
H ( u , v)  e

• Smooth transfer function,


smooth impulse
5/30/2022
response, no ringing 128
Image Smoothing Using Filter Domain Filters:
GLPF

5/30/2022 129
GLPF

Frequency
domain

Gaussian lowpass filter

Spatial
domain

130
No
ringing
artifacts

5/30/2022 131
Examples of smoothing by GLPF (1)

5/30/2022 132
Examples of smoothing by GLPF (2)

5/30/2022 133
Examples of smoothing by GLPF (3)

5/30/2022 134
Examples of Lowpass Filtering

Low-pass filter H(u,v)

Original image and its FT Filtered image and its FT

135
Image Sharpening Using Frequency Domain
Filters

A highpass filter is obtained from a given lowpass filter


using

H HP (u, v)  1  H LP (u, v)

A 2-D ideal highpass filter (IHPL) is defined as


0 if D (u , v )  D0
H (u , v )  
1 if D (u , v )  D0

5/30/2022 136
Image Sharpening Using Frequency Domain
Filters

A 2-D Butterworth highpass filter (BHPL) is defined as


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

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


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

5/30/2022 137
5/30/2022 138
The Spatial Representation of Highpass
Filters

5/30/2022 139
Filtering Results by IHPF
ringing artifacts

5/30/2022 140
Filtering Results by BHPF

5/30/2022 141
Filtering Results by GHPF

5/30/2022 142
Gaussian High-pass Filtering

Gaussian filter H(u,v)


Original image

Filtered image and its FT

143
Using Highpass Filtering and Threshold for
Image Enhancement

BHPF
(order 4 with a cutoff
frequency 50)

5/30/2022 144
Laplacian in Frequency Domain

¶ 2 f (x, y) ¶ 2 f (x, y)
[  ]   (u 2
 v 2
)F (u, v)
¶x 2
¶y 2

H 1(u, v)  (u2  v2 )
Frequency
2 2
Spatial domain
2 ¶ f ¶ f domain
 f  2  2 Laplacian operator
¶x ¶y
The Laplacian in the Frequency Domain

H (u , v)  4 2 (u 2  v 2 )

H (u , v)  4 2 (u  P / 2) 2  (v  Q / 2) 2 ) 
 4 2 D 2 (u, v)
The Laplacian image
 2 f ( x, y )  1  H (u , v) F (u , v)

Enhancement is obtained
g ( x, y )  f ( x, y )  c 2 f ( x, y ) c  -1
5/30/2022 146
The Laplacian in the Frequency Domain

The enhanced image


1
g ( x, y )   F (u, v)  H (u, v) F (u, v)
 1 1  H (u, v)  F (u, v)


 1 1  4 2 D 2 (u, v)  F (u, v) 

5/30/2022 147
148
The Laplacian in the Frequency Domain

5/30/2022 149
Subtract Laplacian from the Original
Image to Enhance It
enhanced Original Laplacian
image image output

Spatial g(x, y)  f (x, y)   2 f (x, y)


domain

Frequency
G (u, v)  F (u, v)  (u2  v2 )F (u, v)
domain
new operator H 2 (u, v)  1  (u2  v2 )  1  H 1 (u, v)

Laplacian

150
2 f
f

f  2 f

151
Unsharp Masking, Highboost Filtering and
High-Frequency-Emphasis Fitering

g mask ( x, y )  f ( x, y )  f LP ( x, y )

f LP ( x, y )  1  H LP (u , v) F (u , v) 

Unsharp masking and highboost filtering


g ( x, y )  f ( x, y )  k * g mask ( x, y )


g ( x, y )  1 1  k *1  H LP (u, v) F (u, v) 
 1 1  k * H HP (u , v ) F (u , v )

5/30/2022 152
Unsharp Masking, Highboost Filtering and
High-Frequency-Emphasis Fitering

1
g ( x, y )   k
1  k 2 * H HP (u , v)  F (u , v)
k1  0 and k2  0

5/30/2022 153
154
5/30/2022 155
An image formation model

• We can view an image f(x, y) as a product of two components:

f  x, y   i  x, y   r  x, y 
0  i ( x, y )  
0  r ( x, y )  1
• i (x, y): illumination. It is determined by the illumination source.
• r (x, y): reflectance (or transmissivity). It is determined by the
characteristics of imaged objects.

156
Homomorphic Filtering

• In some images, the quality of the image has reduced because of


non-uniform illumination.
• Homomorphic filtering can be used to perform illumination
correction.

f  x, y   i  x, y   r  x, y 

• The above equation cannot be used directly in order to operate


separately on the frequency components of illumination and
reflectance.

157
Homomorphic Filtering

f ( x, y )  i ( x, y ) r ( x, y )
  f ( x, y )  
=  i ( x, y )    r ( x, y )  ?
Not
separable

z ( x, y )  ln f ( x, y )  ln i ( x, y )  ln r ( x, y )

 z ( x, y )   ln f ( x, y )   ln i ( x, y )   ln r ( x, y )

Z (u , v)  Fi (u , v)  Fr (u , v)

5/30/2022 158
Homomorphic Filtering

S (u , v)  H (u , v) Z (u , v)
 H (u, v) Fi (u, v)  H (u, v) Fr (u, v)
s ( x, y )  1 S (u , v)
 1  H (u, v) Fi (u, v)  H (u, v) Fr (u, v) 
 1  H (u, v) Fi (u, v)  1 H (u, v) Fr (u, v) 
 i '( x, y)  r '( x, y)

g ( x, y )  e s ( x , y )  ei '( x , y ) e r '( x , y )  i0 ( x, y )r0 ( x, y )

5/30/2022 159
Homomorphic Filtering

ln : z x, y   ln f x, y   ln ix, y   ln r x, y 


DFT : Z u , v   Fi u , v   Fr u , v 
H(u,v) S (u , v)  H (u , v) Z u , v 
: ' '
(DFT)-1 : s ( x, y )  i ( x, y )  r ( x, y )
exp : g ( x, y )  e s ( x , y )  i0 ( x, y )r0 ( x, y )

160
Homomorphic Filtering

The illumination component of an image generally is


characterized by slow spatial variations, while the
reflectance component tends to vary abruptly

These characteristics lead to associating the low


frequencies of the Fourier transform of the logarithm of an
image with illumination the high frequencies with
reflectance.
5/30/2022 161
Homomorphic Filtering

• By separating the illumination and reflectance


components, homomorphic filter can then operate on
them separately.
• Illumination component of an image generally has slow
variations, while the reflectance component vary abruptly.
• By removing the low frequencies (highpass filtering) the
effects of illumination can be removed .

162
Homomorphic Filtering


H (u, v)  ( H   L ) 1  e
 c  D 2 ( u , v )/ D02 
   
  L

Attenuate the contribution


made by illumination and
amplify the contribution made
by reflectance

5/30/2022 163
 L  0.25
Homomorphic
H  2
Filtering
c 1
D0  80

5/30/2022 164
Homomorphic Filtering

5/30/2022 165
Selective Filtering

Non-Selective Filters:
operate over the entire frequency rectangle

Selective Filters
operate over some part, not entire frequency rectangle
• bandreject or bandpass: process specific bands
• notch filters: process small regions of the frequency
rectangle

5/30/2022 166
Selective Filtering:
Bandreject and Bandpass Filters

H BP (u, v)  1  H BR (u, v)

5/30/2022 167
Selective Filtering:
Bandreject and Bandpass Filters

5/30/2022 168
Selective Filtering:
Notch Filters
Zero-phase-shift filters must be symmetric about the origin.
A notch with center at (u0, v0) must have a corresponding
notch at location (-u0,-v0).

Notch reject filters are constructed as products of highpass


filters whose centers have been translated to the centers of
the notches.
Q
H NR (u , v )   H k (u , v )H k (u , v )
k 1

where H k (u , v ) and H - k (u , v ) are highpass filters whose centers are


at (uk , vk ) and (-uk , -vk ), respectively.
5/30/2022 169
Selective Filtering:
Notch Filters
Q
H NR (u , v )   H k (u , v )H k (u , v )
k 1

where H k (u , v ) and H - k (u , v ) are highpass filters whose centers are


at (uk , vk ) and (-uk , -vk ), respectively.

A Butterworth notch reject filter of order n


3  1  1 
H NR (u, v)    2n   2n 
k 1 1   D0 k / Dk (u , v )   1   D0 k / D k (u , v ) 
  
2 1/2
Dk (u, v)   (u  M / 2  uk )  (v  N / 2  vk ) 
2

2 1/2
D k (u, v)   (u  M / 2  uk )  (v  N / 2  vk ) 
2

5/30/2022 170
Examples:
Notch
Filters (1)

A Butterworth notch
reject filter D 0 =3
and n=4 for all
notch pairs

5/30/2022 171
Examples:
Notch Filters
(2)

5/30/2022 172
5/30/2022 173

You might also like