Unit - 2 - Part III
Unit - 2 - Part III
Domain
Module - 2 : Image Transforms
2
Let us try to attach
“meaning” to the frequency
domain with respect to Image
Processing
3
Spatial Domain Frequency Domain
In image processing:
Instead of time domain: spatial domain
(normal image space)
4
What is Spatial Frequency?
6
Revision of FT
FT decomposes a signal into a set of
sines/cosines of different characteristics like
frequency and phase
FT is perfectly reversible
9
Frequency Domain and Images
v
(-N/2, -N/2) (-N/2, N/2)
high high
low
u
high high
10
Frequency Domain and Images
protrusions
Higher frequencies
correspond to the
faster varying intensity
level changes in the
image. The edges of
objects or the other
components
characterized by the Notice the ±45°
abrupt changes in the components and the
intensity level vertical component
which is slightly off-
corresponds to higher
axis to the left! It
frequencies corresponds to
the protrusion caused
by thermal failure
above.
11
Image Filtering in Frequency
Domain
= G(u,v)
12
A simple Demonstration – Notch filter
Multiply all values of F(u,v) by the filter function (notch filter):
0 if (u , v) ( M / 2, N / 2)
H (u , v)
1 otherwise.
Set F(0,0) to zero (force the average value of an image to
zero) and leave all frequency components of the Fourier
transform untouched.
Low-pass Filtering in Frequency
Domain
14
Ideal Low-pass Filter
The simplest low-pass filter is a filter that “cuts off” all
high-frequency components of the Fourier transform that
are at a distance greater than a specified distance D0
from the origin of the transform (D0=cut-off frequency)
Transfer function of an ideal low-pass filter
1 if D(u , v) D0
H (u , v)
0 if D(u , v) D0
1
D(u , v) (u M / 2) 2 (v N / 2) 2 2
15
Ideal Low-pass Filter
16
Example Image and its FT
17
Ideal LPF
D0 = 5
Note :
Narrower the D0 = 15 D0 = 30
filter in the
frequency
domain, more
severe are the D0 = 80 D0 = 230
blurring and
ringing!
18
Butterworth Low-pass Filter (BLPF)
Transfer function is given by
1
H (u , v) 2n
D(u , v)
1
D 0
1
D(u , v) (u M / 2) 2 (v N / 2) 2 2
20
Butterworth Low-pass Filter (BLPF)
1
H (u , v ) 2n
D (u , v )
1
D 0
21
% This code is used to perform Butterworth low-pass filter
clc
im = imread('cameraman.tif');
D0=20; %cut-off frequency
n=1; %order
[M N] = size(im);
% find the centre of the image
cx = round(N/2);
cy = round (M/2);
imf = fftshift(fft2(im));
H = zeros (M, N);
for u = 1:N
for v = 1:M
d = sqrt((u - cx).^2 + (v - cy).^2);
H (u,v) = 1/(1+(d/D0).^(2*n));
end
end
outf = imf .* H;
out = abs (ifft2(outf));
subplot(2,1,1); imshow(im); title ('Original Image');
subplot(2,1,2); imshow(uint8(out)), title('Lowpass Filtered Image (BLPF)');
22
Butterworth Low-pass Filter (BLPF)
The smaller
the value of
D0, the greater
the number of
image
components
eliminated by
the filter
23
BLPF
Order, n=2
Cut-off frequency,
D0=5,15,30,80,and 230
24
BLPF
2 2
D
H (u , v) e ( u ,v ) / 2 D0
1
D(u , v) (u M / 2) 2 (v N / 2) 2 2
26
Gaussian Low-pass Filter (GLPF)
27
% This code is used to perform Gaussian low-pass filter
clc
im = imread('cameraman.tif');
D0=10; %cut-off frequency
[M N] = size(im);
% find the centre of the image
cx = round(N/2);
cy = round (M/2);
H = zeros (M, N);
imf = fftshift(fft2(im));
for u = 1:N
for v = 1:M
d = (u - cx).^2 + (v - cy).^2;
H (u,v) = exp(-d/D0.^2);
end
end
outf = imf .* H;
out = abs (ifft2(outf));
subplot(2,1,1); imshow(im); title ('Original Image');
subplot(2,1,2); imshow(uint8(out)), title('Low-pass Filtered Image (GLPF)');
28
GLPF
Cut-off frequency,
D0=5,15,30,80,and 230
No ringing
29
30
Additional Examples of GLPF
31
Additional Examples of GLPF
“Cosmetic” processing
LPF – to produce a
smoother, softer-looking
results from sharp originals
0 if D(u , v) D0
H (u , v)
1 if D(u , v) D0
D 2 ( u ,v ) / 2 D02
H (u , v) 1 e
33
Ideal High-pass Filter
0 if D(u , v) D0
H (u , v)
1 if D(u , v) D0
Ideal high-pass filters enhance edges but suffer from ringing artifacts,
just like Ideal LPF. 34
% This code is used to perform Butterworth high-pass filter
clc
im = imread('cameraman.tif');
D0=40; %cut-off frequency
n=1; %order
[M N] = size(im);
% find the centre of the image
cx = round(N/2);
cy = round (M/2);
imf = fftshift(fft2(im));
H = zeros (M, N);
for u = 1:N
for v = 1:M
d = sqrt((u - cx).^2 + (v - cy).^2);
H (u,v) = 1/(1+(D0/d).^(2*n));
end
end
outf = imf .* H;
out = abs (ifft2(outf));
subplot(2,1,1); imshow(im); title ('Original Image');
subplot(2,1,2); imshow(uint8(out)), title(‘High-pass Filtered Image (BHPF)');
35
Butterworth High-pass Filter
1
H (u , v)
1 D0 / D(u , v)
2n
38
Comments on LPFs
ILPF
The spatial filter
h (x, y) has two
major
characteristics
○ Dominant
component at
the origin
○ Concentric
circular
components
about center
component
43
The Laplacian in Frequency
Domain
Transfer function
where
1
D(u , v) (u M / 2) (v N / 2)
2 2 2
44
The Laplacian in Frequency
Domain
Laplacian-filtered image in spatial
domain
1
f ( x, y ) {H (u, v) F (u, v)}
2
in the frequency
Laplacian in the
domain
frequency domain
Laplacian in the
Inverse DFT of
Zoomed
section of
the image on
the left
compared to
spatial filter
The Laplacian in Frequency
Domain
47
Unsharp Masking
f hp ( x, y ) f ( x, y ) f lp ( x, y )
With
1
f lp ( x, y ) [ H lp (u , v) F (u , v)]
Low pass filter FT of f ( x, y)
High-boost Filtering
Generalization
f hb ( x, y ) Af ( x, y ) f lp ( x, y )
Where A ≥ 1
f hb ( x, y ) ( A 1) f ( x, y ) f hp ( x, y )
Unsharp masking and High-boost
filtering in Frequency Domain
Fhp (u , v) F (u , v) Flp (u , v)
but
Flp (u , v) H lp (u , v) F (u , v)
51
High-frequency Emphasis
Objective
To accentuate the contribution to
enhancement made by high-frequency
components of an image
52
High-Frequency Emphasis
Transfer function
H hfe a bH hp (u , v)
where a 0 and b a
Typical values of a 0.25 to 0.5
Typical values of b 1.5 to 2.0
a=0.5, b= 2.0
emphasis result
High frequency
After histogram
equalisation
Highpass Filtering Example
Highpass Filtering Example
Highpass Filtering Example
Highpass Filtering Example
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.
59
Homomorphic Filtering
Consider the following model of image formation:
( x, y ) i ( x, y ) r ( x, y )
fIn general, I (x,y): illumination
r(x, y): reflection
61
Homomorphic Filtering
c ( D 2 ( u ,v ) / D02 )
H (u , v) ( H L )[1 e ] L
63
Example - Homomorphic
Filtering
L 0.25
H 2
c 1
D0 80
A Final Comment
Similar jobs can be done in the spatial and
frequency domains
Filtering in the spatial domain can be
easier to understand
Filtering in the frequency domain can be
much faster – especially for large images
Why Frequency Domain?
-One Reason
66