You are on page 1of 73

DIGITAL IMAGE PROCESSING

Filtering in the
Frequency Domain
by
Dr. K. M. Bhurchandi
The DFT of One - Variable
• Obtaining the DFT from the Continuous Transform of a Sampled
Function

sampled, continuous,
band-limited function FT periodic function
extending from -∞ to ∞ extending from -∞ to ∞

• Equation of transform of sampled data in terms of sampled function is


given by:

2
• And we know
The DFT of One - Variable

• Although fn is a discrete function, its Fourier is continuous and infinitely periodic 3


with period 1/ ΔT.

• Sampling one period is the basis for the DFT.


The DFT of One - Variable
• To have M equally spaced samples of the transform taken over the period
μ = 0 to 1/ ΔT, consider following frequencies,

where, m = 0, 1, 2, ….., M-1


Substituting it in previous equation, we get DFT equation:

Conversely, IDFT can be obtained by:

where, n = 0, 1, 2, …, N-1
The DFT of One - Variable
• In a more intuitive approach, notations used will be
x & y - image coordinates variables
u & v – frequency variables
Thus, the above equations become:

where, u = 0, 1, 2, …., M-1

where, x = 0, 1, 2, …, M-1
5
• Both the forward & inverse discrete transforms are infinitely periodic with
period M.
Extension to Functions of Two Variables
• The 2-D Impulse and Its Sifting Property:
• The impulse of 2 continuous variables t & z is given by:
• &

• As in the 1D case, the 2D impulse exhibits the sifting property


under integration,

• More generally for an impulse located at coordinates (to, zo) 6


Extension to Functions of Two Variables

• For discrete variables x & y, the 2D discrete impulse is defined


as:

• Its sifting property is:

• For an impulse located at coordinates (xo, yo)


7
Extension to Functions of Two Variables
• Two-dimensional unit discrete impulse.

8
The 2-D Continuous Fourier Transform
Pair

• f(t, z) – continuous function of two variables, t & z.


• μ & γ – frequency variables define continuous frequency
domain.

9
• A 2-D function & its spectrum

10
2-D Sampling and the 2-D Sampling
Theorem
• 2-D impulse train is given by:

where, ΔT & ΔZ are separations between samples along t


& z axis.

11
2-D Sampling and the 2-D Sampling
Theorem
• Function f(t, z) is said to be band-limited if its Fourier
Transform is 0 outside a rectangle established by the intervals
[-μmax, μmax] and [-γmax, γmax].

• 2-Dimesional sampling theorem states that a continuous, band


limited function f(t, z) can be recovered with no error from a
set of its samples if the sampling intervals are

12

and
Aliasing in Images
• 2-D Fourier Transform of oversampled & under-sampled band
limited function

13
Aliasing in Images
• Two manifestations of aliasing in images:
• Spatial Aliasing & Temporal Aliasing

• Spatial Aliasing: It is due to under-sampling

• Temporal Aliasing: It is related to time intervals between


images in a sequence of images.
• E.g. wagon wheel effect (wheel appear to rotate backwards)

14
• Effects of Aliasing

15
The 2-D DFT and Its Inverse
• 2-D Discrete Fourier Transform Pairs:

where, f(x, y) – digital image of size M x N.


u – 0, 1, 2, ….., M-1
v – 0, 1, 2, ….., N-1

where, F(u, v) – transform of f(x, y). 16


x – 0, 1, 2, ….., M-1
y – 0, 1, 2, …., N-1
Properties
•   of 2-D DFT
1) Relationships between Spatial & Frequency Intervals

• If a continuous function f(t, z) is sampled to form a digital


image, f(x, y) consisting of M x N samples in t& z resp.

• If ΔT&ΔZ denote the separations between samples, then,


separations between the corresponding discrete, frequency
domain variables are given by:

&
17
Properties of 2-D DFT
2) Translation and Rotation
• Fourier transform pair satisfies translation properties

Multiplying f(x,y) by exponential shown shifts the origin of DFT


to (u0,v0) and conversely, multiplying F(u,v) by negative of that
exponential shifts the origin of f(x,y) to (x0,y0).

18
Properties of 2-D DFT
2) Translation and Rotation

Using Polar coordinates

Results in transform pair

Rotating f(x,y) with rotates F(u,v) by same angle and viceversa. 19


Properties of 2-D DFT
3) Periodicity
2D Fourier transform and its inverse are infinitely periodic in u
and v directions

and

where k1 and k2 are integers


20
Properties of 2-D DFT
3) Periodicity

21
Problems on DFT
1)•   Let f(x, y) = is image matrix. Then DFT(F) = ?
Sol:- y
f(x, y) = x =>

Generally, F(v) =

Thus, F1(0, v) =

22
•   F1(0, v) =
F1(0, v) = + +

For, v = 0: F1(0, 0) = + +
=1x1 + 1x1 + 1x1 = 3
For, v = 1: F1(0, 1) = + +
= 1 x 1 + 1 x (-0.5000 - 0.8660i) + 1 x (-0.5000 + 0.8660i)
=0
For, v = 2: F1(0, 2) = + +
= 1 x 1 + 1 x (-0.5000 + 0.8660i) + 1 x (-0.5000 - 0.8660i)
=0
So, F1(0, v) = [3 0 0];
Similarly, F1(1, v) = [3 0 0]; & F1(2, v) = [3 0 0];
Thus, F1=
23
Now, applying transformation column-wise.
•Generally,
 
Thus,
+
For u=0: +
=3 x 1 +3 x 1+ 3 x 1
=9
For u=1: +
=3 x 1 +3 x (-0.5000-0.8660i)+ 3 x (-0.5000+0.8660i)
=0
For u=2: +
=3 x 1 +3 x (-0.5000+0.8660i)+ 3 x (-0.5000-0.8660i)
=0
So, F(u,0)=
Similarly, F(u,1)=; & F(u,2)=
Thus, F=
24
Problems on DFT
2)• Let
  f(x, y) = is image matrix. Then DFT(F) = ?
Sol:- y
f(x, y) = x =>

Generally, F(v) =

Thus, F1(0, v) =

25
•   F1(0, v) =
F1(0, v) = + +

For, v = 0: F1(0, 0) = + +
=1x1 + 2x1 + 3x1 = 6
For, v = 1: F1(0, 1) = + +
= 1 x 1 + 2 x (-0.5000 - 0.8660i) + 3 x (-0.5000 + 0.8660i)
= -1.5000 + 0.8660i
For, v = 2: F1(0, 2) = + +
= 1 x 1 + 2 x (-0.5000 + 0.8660i) + 3 x (-0.5000 - 0.8660i)
= -1.5000 - 0.8660i

So, F1(0, v) = [6 -1.5000 + 0.8660i -1.5000 - 0.8660i];


Similarly, F1(1, v) = [15 -1.5000 + 0.8660i -1.5000 - 0.8660i];
&F1(2, v) = [24 -1.5000 + 0.8660i -1.5000 - 0.8660i]; 26
Thus, F1=
•  
Generally, F(u) =
Thus, F(u, 0) =
F(u, 0) = F1 + +F1
For, u = 0: F(0, 0) = F1 +F1 +F1
= 6 x 1 + 15 x 1 + 24 x 1 = 45
For, u = 1: F(1, 0) = F1 +F1 +F1
= 6x 1 + 15 x (-0.5000 - 0.8660i) + 24 x (-0.5000 + 0.8660i)
= -13.5000 + 7.7940i
For, u = 2: F(2, 0) = F1 +F1 +F1
= 6 x 1 + 15 x (-0.5000 + 0.8660i) + 24 x (-0.5000 - 0.8660i)
= -13.5000 - 7.7940i
So, F(u,0)=
Similarly, F(u,1) =
& F(u,2) =
Thus, F=

27
3)• Let
  f(x, y) = is image matrix. Then DFT(F) = ?
Sol:- y
f(x, y) = x

Generally, F(v) =

Thus, F1(-1, v) =

28
•   wise calculation
Row
F1(-1, v) = + +
F1(0, v) = + +
F1(1, v) = + +
&
Column wise calulation
F(u, -1) = F1 + +F1
F(u, 0) = F1 + +F1
F(u, 1) = F1 + +F1

Then,
F=

F=

29
Symmetry Properties of 2D-DFT

30
Summary of DFT definitions

31
Summary of DFT definitions

32
Summary of DFT Pairs

33
Summary of DFT Pairs

34
DFT of an image

35
Spectrum is insensitive to translation. But
rotates by the same angle as the rotated
image

36
Translation affects the phase

37
Reconstruction using either
spectrum or phase

38
Frequency Domain Filtering
Fundamentals
• Given a digital image f(x,y) of size MxN, the basic filtering
equation is

Input image Frequency


Spectrum 39
Result of Filtering an image
More Results on Filtering
High Pass Filter
Low Pass Filter

40
Top row: Frequency domain Filters, Bottom Row: Corresponding Filtered Images
Gaussian Low pass Filtering
Gaussian Low
Gaussian Low
Pass Filter
Pass Filter with
without padding
padding

41
Summary of steps for filtering in Frequency
domain
1) Given an input image f(x, y) of size M x N, obtain the padding parameters P & Q
as 2M & 2N respectively.

2) Form a padded image, fp(x, y), of size P x Q be 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 P x Q with center at
coordinates (P/2, Q/2). Form the product G(u, v) = H(u, v)F(u, v) using array
multiplication; that is, G(i, k) = H(i, k)F(i, k).

6) Obtain the processed image: gp(x, y) = {real[Ṫ-1[G(u, v)]]}(-1)x+y where the real
part is selected in order to ignore parasitic complex components resulting from
computational inaccuracies, and the subscript p indicates that we are dealing
with padded arrays. 42

7) Obtain the final processed result, g(x, y), by extracting the M x N region from the
top, left quadrant of gp(x, y).
• Steps for Filtering in the Frequency Domain

43
Image smoothing using Frequency domain
filters
• Ideal
  Low-pass Filters (ILPF):
• A 2-D low-pass filter that passes without attenuation all
frequencies within a circle of radius D0 from the origin and
“cut off” all frequencies outside this circle is called an ideal
low-pass filter (ILPF).
H
Where, D0 - a positive constant
D(u, v) – distance between (u, v) in the frequency domain and
the center of the frequency rectangle; i.e.
D(u, v) = [(u – P/2)2 + (v – Q/2)2]1/2
44

Where P & Q are 2M & 2N respectively.


Image smoothing using Frequency domain
filters
Perspective plot
of an Ideal LPF
Transfer function

45

Filter displayed as an image Filter radial cross section


• Ideal Low Pass Filtering

46
Results of
Ideal LPF
Original Result of filtering
Image with ideal low pass
filter of radius 10

Result of filtering Result of filtering


with ideal low pass with ideal low pass
filter of radius 30 filter of radius 60

Result of filtering
with ideal low pass Result of filtering
with ideal low pass 47
filter of radius 160
filter of radius 460
The blurring and “ringing” properties
of Ideal LPFs

Intensity profile of a horizontal


line passing through the
center of the image.

48
Representation in the spatial
domain of an ILPF of radius 5
and size 1000x1000.
Image smoothing using Frequency domain
filters
• Butterworth
  Low-pass Filters (BLPF):
• The transfer function of a Butterworth low-pass filter (BLPF) of
order n, and with cutoff frequency at a distance D0 from the
origin, is defined as,

H
where, D(u, v) = [(u – P/2)2 + (v – Q/2)2]1/2

49
Image smoothing using Frequency domain
filters
Perspective
from order 1 - 4 plot of BLPF transfer
function

50

Filter displayed as an image Filter Radial cross section of


orders 1 through 4
Image smoothing using Frequency domain
filters
• Spatial representation of BLPF of order 1, 2, 5 & 20 and
corresponding intensity profiles through the center of the
filter.
• Ringing increases as a function of filter order.

51
Results of Butterworth LPF
Result of filtering
Original with BLPF with
Image cutoff radius 10

Result of Result of filtering


filtering with with BLPF with
BLPF with cutoff cutoff radius 60
radius 30

Result of Result of filtering


filtering with with BLPF with 52
BLPF with cutoff cutoff radius 460
radius 160
Image smoothing using Frequency domain
filters
• Gaussian
  Low-pass Filters (GLPF):
• Gaussian low-pass filters(GLPF) in two dimensions is given by

where, σ – is measure of spread about the center.

• Let σ = D0, thus the filter can be expressed as:

53
where D0 is the cutoff frequency
Image smoothing using Frequency domain
filters
Perspective
Plot of Gaussian LPF
transfer function

54

Filter displayed as Filter radial cross section


an image for various values of D0
Results of Gaussian Low pass Filters

Input Image Result of filtering


with GLPF with cut
off radius 10

Result of
filtering with Result of filtering
GLPF with cut with GLPF with cut
off radius 30 off radius 60

Result of
Result of filtering 55
filtering with
with GLPF with cut
GLPF with cut
off radius 460
off radius 160
Low Pass Filters

56
Applications of LPF
• Character Recognition

57
Result of filtering with GLPF
Sample text of low resolution
Note: broken character
Note: broken characters
segments are joined
Contd..
• Printing and publishing industry: “cosmetic” processing

58
Image sharpening using Frequency
domain filter
• A
  high-pass filter is obtained from a given low-pass filter using
the equation

HHP(u, v) = 1 – HLP(u, v)

Where, HLP(u, v) – transfer function of the LPF

• Ideal High-pass Filter (IHPF)


• A 2-D high-pass filter is given by
59
H
Image sharpening using Frequency
domain filter
• Butterworth
  High-pass Filter (BHPF)
• A 2-D Butterworth high-pass filter (BHPF) of order n and cutoff
frequency D0 is defined as
H

• Gaussian High-pass Filter (GHPF)


• The transfer function of the Gaussian high-pass filter (GHPF)
with cutoff frequency locus of at a distance D0 from the center
of the frequency rectangle is given by

60
Image sharpening using Frequency
domain filter

IHPF

BHPF

61
GHPF
Spatial Representation of High Pass Filter

62
Results of Ideal HPF

63
Results of BHPF of order 2
• Results are much smoother than ideal HPF

64
Results of GHPF
 𝐷 0= 30  𝐷 0= 60  𝐷 0= 160

65
Laplacian in the frequency domain
• The
  Laplacian can be implemented in the frequency domain
using the filter

Or with respect to the center of the frequency rectangle, using


the filter
]
=

Where, D(u, v) is the distance function. 66


Laplacian in the frequency domain
•   Laplacian image is obtained as:
The

Enhancement is achieved using the equation

• Here, c = -1, because, H(u, v) is negative


• In frequency domain the above equation is written as:
67
Homomorphic Filtering
• According to Illumination-Reflectance model:
• An image f(x, y) can be expressed as the product of its illumination,
i(x, y), and reflectance, r(x, y), components:
f(x, y) = i(x, y)r(x, y) (1)
• Since the Fourier Transform of a product is not the product of the
transforms:
• So, F[f(x, y)] ≠ F[i(x, y)] F[r(x, y)]

• However, if,
z(x, y) = ln f(x, y)
= ln i(x, y) + ln r(x, y) (2)
Then, 68
F{z(x, y)} = F{ln f(x, y)}
= F{ln i(x, y)} + F{ln r(x, y)} (3)
Homomorphic Filtering
or
Z(u, v) = Fi(u, v) + Fr(u, v)
Where, Fi(u, v) and Fr(u, v) are the Fourier transforms of ln i(x, y) & ln
r(x, y) respectively.

We can filter Z(u, v) using a filter H(u, v)


S(u, v) = H(u, v) Fi(u, v) + H(u, v) Fr(u, v) (4)

The filtered image in spatial domain is


s(x, y) = T-1{S(u, v)}
= T-1{H(u, v) Fi(u, v)} + T-1{H(u, v) Fr(u, v)} (5)
= i’(x, y) + r’(x, y)
69
where, i’(x, y) = T-1{H(u, v) Fi(u, v)}
r’(x, y) = T-1{H(u, v) Fr(u, v)}
Homomorphic Filtering
• In order to get the original image, we reverse the process,

g(x, y) = es(x, y)
= ei’(x, y)er’(x, y)
= i0(x, y)r0(x, y) (6)

where, i0(x, y) = ei’(x, y) & r0(x, y) = er’(x, y) are the illumination and
reflectance components of the output (processed) image.

70
Summary of steps in homomorphic
filtering

• The illumination component of an image is characterized by


slow spatial variations, while the reflectance components tend
to vary abruptly.

• The low frequencies of DFT of Logarithm of an image are


71
associated with illumination and high frequencies with
reflectance.
Homomorphic Filtering

• Radial cross section of such a homomorphic filter H(u, v) that


affects low and high frequency components differently. The vertical 72
axis is at the center of the frequency rectangle and D(u,v) is the
distance from the center.
Homomorphic Filtering
• If
  parameters γL&γH are chosen such that γL< 1 &γH> 1, the filter
attenuates low frequencies and amplifies high frequencies.

• It results in simultaneous dynamic range compression and


contrast enhancement. (High-pass filter)

• Slightly modified Gaussian high-pass filter yields the function

]+

where, constant ‘c’ controls the sharpness of the


slope of the function as it transitions between
73
γL&γH

You might also like