Unit 5 Freq Filtering
Unit 5 Freq Filtering
Frequency Domain
Filtering
*Frequency Domain and
Spatial Domain Filtering
Image
Convolutio
n
Filter Mask
Ex.
Averaging,
Laplacian
*Filtering in Frequency
Domain
Transform of
an image
Low pass filter mask Band pass filter mask High pass filter mask
*Example of LPF
let’s apply this filter to an actual image and let’s see what we got
Sample image
IDFT
X =
F(u,v) x H(u,v) =
G(u,v)
*LPF and HPF
Low Pass Filter
1, if D (u , v) D0
H (u , v)
0, if D(u , v) D0
D0
Image
representati u
on of filter
D>D0
v
Ideal Lowpass filter
• D(u,v) is a distance from the center to a point at (u,v)
• D(u,v)=(u2+v2)1/2
• D0 is cut off frequency in terms of distance from center
• Assuming coordinates of center as (0,0)
D0
D>D0
*Example Image Filters
1. Image matrix
f=
f’=
f’=
f’=
F=
5. DFT of image matrix
F=T. fnew .T’
*Example Image Filters
F=
H=
6. Choose a Low Pass filter for image
[ ]
000 0
F ′ ′ = F × 𝐻 = 0 1+3 𝑖 3+ 3𝑖 0
0 4 +2 𝑖 6 0
000 0
*Example Image Filters
7. Filtered Image
[ ]
0.87 0.87 0.25 0.25
IDFT ( F ¿¿ ′ ′ )= 𝑓 ′ ′ = − 1 0.62 − 0.12 0.50 ¿
0.37 − 0.12 0 − 0.25
− 0 .25 0 .37 − 0 .12 0
*For HPF
F=
D0
Power spectrum of DFT of image/filter
9 41 81 41
85 1 9 109
P (u , v) Re{H (u , v)}2 Im{H (u , v)}2 P (u , v)
49 13 2401 13
85 109 9 1
Power spectrum of an
9 41 81 41
85 1 9 109
P (u , v)
49 13 2401 13
85 109 9 1
Power contents of an
*What is the
Inference of the
power calculations
that we did
Percentage of total power contained
within D0 from center
D (u 2 v 2 )1 / 2 u and v are row and column numbers of
DFT D0=230
, 99.5%
D0=80,
98.0%
D0=30,
96.4%
D0=15
,
94.6%
of
lowpas
s filters
with D = 30
o
various Do = 60
values
of
cutoff D = o
freq, 160
Do =
Do 460
28
Original
500x500 Do = 10
Effect
of Do = 30
lowpas Do = 60
s filters
with
various Do =
values 160
Do =
of Do 460
29
Original
500x500 Do = 10
Do = 30
Do = 60
Do =
160
Do =
c 460
30
Do controls the amount of bluring of the image
Applications of low pass filtering
• LPF fills gaps of broken lines.
*Lowpass Filtering
Examples (cont…)
LPF fills gaps of broken lines
444 x 508, Low resolution After Guassian low pass filter
with cut off frequency = 80
*Lowpass Filtering
Examples
LPF fills gaps of broken lines
444 x 508, Low resolution After Guassian low pass filter
with cut off frequency = 80
*Lowpass Filtering
Examples
Highpass Filters
H hp (u , v) 1 H lp (u , v)
HBP(u,v)=1- HBR(u,v)
Band reject filter
* Pad the MxN image to PxQ and Multiply the input image by (-1)x+y
PREPROCESSING
* Compute F(u,v) DFT of f(x,y)
* Multiply F(u,v) with Filter transfer function H(u,v)
* Compute the Inverse DFT
* Obtain the real part, crop the image to MxN and multiply the real part by (-
1)x+y POSTPROCESSING
Padded image Multiply by (-1)x+y
image
256×256 Produc
t of
Spectru H and
m of F
image
Centered LPF
After IDFT
and
product Cropped image
image
Centered LPF
After IDFT
and
product Cropped image
image
Centered LPF
After IDFT
and
product Cropped image
image
511×511
Centered LPF
After IDFT
and
product Cropped image
image
After IDFT
and
product Cropped image
image
IDFT{T(u,v)
}
511×511 Cropped image
511×511
image
IDFT{T(u,v)
} Post processing,
Cropped and
511×511
filtered image
511×511 256×256
• An image is formed due to the fact that there is some amount of light
falling on the object and some amount of light that is reflected from the
object
*illumination – reflection
model
(IR model)
• Illumination I (x,y) : Light falling on the object
• Reflectance R(x,y) : light reflected by the object
𝐼 ( 𝑥 , 𝑦 )=𝐿 ( 𝑥 , 𝑦 ) × 𝑅 (𝑥 , 𝑦 )
Illumination Reflectance
*Low freq. and High Freq
in a IR model of an
𝑓 ( 𝑥 , 𝑦 ) =𝐼 ( 𝑥 , 𝑦 ) × 𝑅 ( 𝑥 , 𝑦 )
image
Illumination Reflectance
𝑖 . 𝑒 . 𝐹 [ 𝑓 ( 𝑥 , 𝑦 ) ]=𝐹 [ 𝑖 ( 𝑥 , 𝑦 ) × 𝑟 ( 𝑥 , 𝑦 ) ]
]]
*Procedure for applying
Homomorphic Filtering
STEP 1 :
Apply log function to the image , f(x,y)
STEP 2:
Apply fourier Transform to the Log of these components
𝑍 (𝑢 , 𝑣)= 𝐹 𝑖 (𝑢 , 𝑣)+ 𝐹 𝑟 (𝑢 , 𝑣)
Step 3: construct a frequency-domain high-pass
filter / Low pass filter [H(u,v)]
USE LPF
To extract the USE HPF
Low To extract
Frequency High
component Frequency
component
* Block Diagram of
Homomorphic Filtering
Step 4: Take inverse Fourier Transform to the filtered
component
𝑠(𝑥 , 𝑦)
𝑔 ( 𝑥 , 𝑦 )= 𝑒 =𝑖𝑜 ( 𝑥 , 𝑦 ) 𝑟 𝑜 ( 𝑥 , 𝑦)