0% found this document useful (0 votes)
7 views59 pages

Unit 5 Freq Filtering

The document discusses image enhancement techniques, specifically focusing on frequency domain filtering and its applications. It explains the differences between spatial and frequency domain filtering, detailing how convolution in spatial domain translates to multiplication in frequency domain. Additionally, it covers lowpass and highpass filters, their effects on images, and the process of homomorphic filtering to improve image quality under poor illumination conditions.

Uploaded by

gipalaj384
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views59 pages

Unit 5 Freq Filtering

The document discusses image enhancement techniques, specifically focusing on frequency domain filtering and its applications. It explains the differences between spatial and frequency domain filtering, detailing how convolution in spatial domain translates to multiplication in frequency domain. Additionally, it covers lowpass and highpass filters, their effects on images, and the process of homomorphic filtering to improve image quality under poor illumination conditions.

Uploaded by

gipalaj384
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 59

Image Enhancement

Frequency Domain
Filtering
*Frequency Domain and
Spatial Domain Filtering

*Filtering can be done in Spatial domain or


in Frequency domain

*Filteringin spatial domain is easier to


understand

*However, Filtering in frequency domain is


much faster – especially for large images
*Filtering in Spatial
Domain

Image
Convolutio
n
Filter Mask
Ex.
Averaging,
Laplacian
*Filtering in Frequency
Domain

DFT DFT DFT

Convolution in spatial domain


becomes multiplying in frequency
domain
IDFT After applying Filter
H(u,v) to the image
Tranform F(u,v) we
g (x,y) get the response
G(u,v)
Filtered
Image To recover the
original image we
* Correspondence between
Frequency domain and Spatial
domain transform
*Spatial Domain : Filtering is given by
CONVOLUTION

*Frequency Domain : Convolution in FD is


equivalent to MULTIPLICATION

*Filtering can be done in either domain


Applications of Frequency Selective
Filters

* Lowpass filters (achieve


smoothing/blurring)
* Low frequency in transform relates to slowly
varying intensity components in an image such
as walls of a room or a cloudeless sky
* Highpass filters (enhance sharp
details, removes dc term)
* High frequency are due to sharp transition in
intensity such as edges and noise
* Low frequency and High Frequency
components in an image
* Mask H(u,v) used for filtering

Transform of
an image

Low pass filter mask High pass filter mask


*2D mask for Filter
H(u,v)

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

Low pass filtering


smoothes / blurs the
image
Image in frequency domain

IDFT
X =

F(u,v) x H(u,v) =
G(u,v)
*LPF and HPF
Low Pass Filter

• The edge content is reduced (blurs the image)


• As the size of the mask grow, more smoothing effect will
take place

High Pass Filter

• The edge content (sharpness) is increased


• As the size of the mask grows , more edge content is
increased
Low Pass Filtering

High Pass Filtering


*Ideal Low Pass
Filter
Ideal Lowpass filter Mask
• Transfer Function , H(u,v) of a ideal LPF

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=

2. Multiply by to center DFT


f’=

f’=

f’=
f’=

4. Pad the image if DFT is of order 4


New image matrix
fnew=

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=

We retain the outer coefficients


F=

And find the inverse DFT to recover the filtered image


*Effect of cutoff
frequency (Do)
Do controls the amount of bluring of the image

D0
Power spectrum of DFT of image/filter

* F(u,v)  DFT/FFT of image


* H(u,v)  DFT/FFT of filter

* Power spectrum for each value of u,v

P (u , v) Re{H (u , v)}2  Im{H (u , v)}2


image Preprocess image to center DFT
2 4 1 6  2  4 1  6
3 2 1 4  3 2  1 4 
f ( x , y )  f ' ( x, y ) ( 1) ( x y ) f ( x , y )  
6 5 3 2  6  5 3  2
   
1 2 4 3  1  2 4  3 
 3 54 j 9 5 4 j 
 9 2 j 1  3  3  10 j 
DFT of f’(x,y) F ' (u , v) 
 7 3 2 j 49 32 j 
 
 9  2 j  3  10 j  3 1 

 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 

• Total power= 9+40.96+81+…+ 9+1 = 3056

• Power contained in 2x2 within the center


= 1+9+12.96+2401 =2423.96

• Percentage of total power within 2x2 in the center


=100 (2423.96)/3056
=79%

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%

Image representation D0=5,


Image of magnitude of DFT 92.0%
of Image
27
Effect Original
500x500 Do = 10

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.

• Uses unsharp masking which uses


blurring as first step

• Cosmetic processing for smoother


and soft looking instead of sharp
original image

• For human faces, it reduces sharp fine


lines and blemishes
LPF reduces sharp fine lines and blemishe

*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)

0, if D(u , v) D0


*Ideal filters : H (u, v) 
1, if D(u, v)  D0
Band pass filters

HBP(u,v)=1- HBR(u,v)
Band reject filter

Band reject filter Original Image Filtered Image


band pass filter

Band pass filter Original Image Filtered Image


*Steps for
Frequency
Domain Filtering

* 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

Steps for frequency domain


Padded image Multiply by (-1)x+y

image

256×256 511×511 Produc


t of
Spectru H and
m of F
image

Centered LPF
After IDFT
and
product Cropped image

Steps for frequency domain


Padded image Multiply by (-1)x+y

image

 

256×256 511×511 Produc


511×511
t of
Spectru H and
m of F
image

Centered LPF
After IDFT
and
product Cropped image

Steps for frequency domain


Padded image Multiply by (-1)x+y

image

 

256×256 511×511 Produc


511×511
t of
DFTof H and
image F

511×511
Centered LPF
After IDFT
and
product Cropped image

Steps for frequency domain


Padded image Multiply by (-1)x+y

image

  

256×256 511×511 511×511


H(u,v)x
DFT of F(u,v)
image=  
F(u,v) 

511×511 511×511LPF H(u,v) 511×511

After IDFT
and
product Cropped image

Steps for frequency domain


Padded image Multiply by (-1)x+y

image

 

256×256 511×511 511×511


H(u,v)x
Spectru
F(u,v),
m of  
image,  
F(u,v)
511×511 511×511 511×511LPF H(u,v) 511×511

IDFT{T(u,v)
} 
511×511 Cropped image

511×511

Steps for frequency domain


Padded image Multiply by (-1)x+y

image

 

256×256 511×511 511×511


H(u,v)x
Spectru
F(u,v),
m of  
image,  
F(u,v)
511×511 511×511 511×511LPF H(u,v) 511×511

IDFT{T(u,v)
} Post processing,
 Cropped and
511×511
filtered image
511×511 256×256

Steps for frequency domain


*Homomorphic
Filtering
*Homomorphic
Filtering
• Homomorphic Filtering is used to address the problem of improving
the quality of image that has been acquired under poor
illumination conditions

• Homomorphic filtering uses illumination – reflection model

• 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

• These two combine to form an image

• An image can be modeled as the product of an illumination function


and reflectance function at every point on the image.

𝐼 ( 𝑥 , 𝑦 )=𝐿 ( 𝑥 , 𝑦 ) × 𝑅 (𝑥 , 𝑦 )

Illumination Reflectance
*Low freq. and High Freq
in a IR model of an
𝑓 ( 𝑥 , 𝑦 ) =𝐼 ( 𝑥 , 𝑦 ) × 𝑅 ( 𝑥 , 𝑦 )
image
Illumination Reflectance

• Illumination is the primary contributor to the dynamic


range and varies slowly in space

• While reflector component represents the details of object


edges and varies rapidly in space

• These characteristics lead to associating the


• LOW FREQUENCIES of the Fourier Transform of an image
with illumination and HIGH FREQUENCIES with
reflectance
*Homomorphic Filtering
• The ideal of Homomorphic Filtering is to separate the
illumination (low frequency) and the reflectance
(high frequency) components
*Homomorphic Filtering
• Now to separate the LOW and HIGH Frequency
we have to convert the image f(x,y) in frequency
domain by applying Fourier Transform

𝑖 . 𝑒 . 𝐹 [ 𝑓 ( 𝑥 , 𝑦 ) ]=𝐹 [ 𝑖 ( 𝑥 , 𝑦 ) × 𝑟 ( 𝑥 , 𝑦 ) ]

• The problem with fourier transform is that the


product of two functions is not seperable

]]
*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)]

𝐹 {𝑙𝑛 [ 𝑓 ( 𝑥 , 𝑦 ) ] }=𝐹 {𝑙𝑛 [ 𝑖 ( 𝑥 , 𝑦 ) ] }+ F {ln [ 𝑟 ( 𝑥 , 𝑦 ) ] }

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

Step 5: To offset the logarithm applied in Step – 1 apply antilog


function to recover the filtered image

𝑠(𝑥 , 𝑦)
𝑔 ( 𝑥 , 𝑦 )= 𝑒 =𝑖𝑜 ( 𝑥 , 𝑦 ) 𝑟 𝑜 ( 𝑥 , 𝑦)

Here, io and ro are the illumination and the reflectance components of


the filtered output image.

You might also like