Autumn 2025 Department of AI, IIT Kharagpur
AI61201: Visual Computing With AI/ML
Module 4: Frequency Domain Image Analysis and Filtering
Dr. Somdyuti Paul
1
Spatial (2D) Frequency
• Just as a 1D signal can be represented in terms of its constituent
frequencies, a 2D signal could be represented in terms of its
constituent spatial frequencies.
• A 2D discrete space sinusoid has the following functional form:
Asin[2π(Ux + Vy)]
where U and V are the spatial frequencies along the horizontal and u = 4, v = 1 u = 5, v = 10
vertical directions in cycles per pixel.
• The frequency and direction of fastest oscillation is given by:
2 2 V
Ω = U + V (radial frequency) and θ = tan−1 .
U
• It is often convenient to represent the spatial frequencies in the units u = 35, v = 15 u = 35, v = 65
of cycles/image by scaling U and V with the image dimensions:
u v 2D sinusoids at di erent spatial frequencies
Asin[2π( x + y)]
M N
2
ff
Discrete Space Fourier Transform
• The discrete space Fourier transform (DSFT) is a continuous function that describes the frequency composition of a
discrete spatial signal.
• The DSFT is given
∞
by:
∞
f(x, y)e −j2π(Ux+Vy)
∑ ∑
F(U, V) =
x=−∞ y=−∞
• The DSFT is complex valued: F(U, V) = R(U, V) + jI(U, V)
2 2
• Magnitude spectrum: | F(U, V) | = R (U, V) + I (U, V)
−1
I(U, V)
Phase spectrum: ∠F(U, V) = tan
• R(U, V)
3
Discrete Space Fourier Transform
• The Fourier transform of the discrete space signal is continuous and periodic.
• The discrete space signal can be recovered using the inverse DSFT (IDSFT) as follows:
0.5 0.5
∫−0.5 ∫−0.5
j2π(Ux+Vy)
f(x, y) = F(U, V)e dUdV
ℱ
• f and F constitute a Fourier transform pair and is represented as f F.
4
Properties of DSFT
• Linearity
ℱ
af1(x, y) + bf2(x, y) aF1(U, V) + bF2(U, V)
• Symmetry: if f(x, y) is real (e.g. natural images) the DSFT F(U, V) is conjugate symmetric:
F(U, V) = F*(−U, − V)
the magnitude spectrum is even symmetric while the phase spectrum is odd symmetric.
• Translation:
j2π(U0 x+V0 y) ℱ
• In the spatial domain: f(x, y)e F(U − U0, V − V0)
ℱ
• In the frequency domain: f(x − x0, y − y0) F(U, V)e −j2π(Ux0+Vy0)
• Convolution Theorem:
ℱ
f(x, y) * h(x, y) F(U, V)H(U, V)
5
Discrete Fourier Transform
• Since the DSFT is a continuous function of spatial frequency, it is not useful for analyzing and processing
digital images.
• A more convenient discrete representation of the DSFT exists in the form of discrete Fourier transform (DFT).
• The DFT is derived by sampling the DSFT at discrete frequencies.
• For signals having a nite spatial dimension of M × N (such as images), the DSFT becomes:
M−1 N−1
−j2π(Ux+Vy)
∑∑
F(U, V) = f(x, y)e
x=0 y=0
• This nite extent spatial signal can be represented by a weighted sum of a nite number of frequency
components by sampling frequencies at:
u v
for u = 0,1,⋯, M − 1 and for v = 0,1,⋯, N − 1, over one period of the DSFT.
M N
• So, the DFT is given by:
M−1 N−1
−j2π( Mu x+ Nv y)
∑∑
F(u, v) = f(x, y)e
x=0 y=0 6
fi
fi
fi
Discrete Fourier Transform
• Thus, the DFT of a M × N image f(x, y) is a nite extent, complex valued matrix F(u, v) of size M × N.
• The spatial signal f(x, y) could be uniquely recovered by performing the inverse DFT (IDFT) as follows:
M−1 N−1
1 j2π( Mu x+ Nv y)
MN ∑ ∑
f(x, y) = F(u, v)e
u=0 v=0
DFT visualization:
• The magnitude spectrum and the phase spectrum of DFT can be visualized as images.
• A logarithmic transformation is often applied to the magnitude spectrum to highlight high frequency
components.
• The origin of the DFT is usually shifted from the top left corner to the center of the image in order to display it
in the conventional manner, i.e. instead of displaying F(u, v), we display F(u − M/2,v − N/2).
7
fi
DFT Visualization
8
DFT Visualization
9
DFT Visualization
Image Magnitude Spectrum Magnitude Spectrum Phase Spectrum
after log transformation
10
Importance of DFT Phase
• The magnitude spectrum provides
information about the strength of various
frequency components,
• the phase spectrum provides critical
information about the spatial arrangement
and interaction of the frequency components
• The DFT phase contains information about
the image structure
• Although visually uninformative, the phase
information is vital for image reconstruction.
11
DFT Properties
• The DFT is linear, invertible and conjugate symmetric (same as DSFT).
• Periodicity in the Frequency Domain: the DFT is periodic with periods of M and N along the u and v
dimensions, respectively.
F(u + kM, v + lN) = F(u, v) for 0 ≤ u ≤ M − 1 and 0 ≤ v ≤ N − 1
• Periodicity in the Spatial Domain: similarly, the IDFT implies that the image is periodic in the spatial domain
(a counterintuitive e ect that arises due to sampling the DSFT).
f(x + kM, y + lN) = f(x, y) for 0 ≤ x ≤ M − 1 and 0 ≤ y ≤ N − 1
• Duality: The duality property of DFT can be stated as follows:
If f(x, y) ↔ F(u, v) then F(x, y) ↔ MNf((−u)M, (−v)N )
12
ff
Circular Convolution
j j
(0,0)
(0,0) (0,0)
(0,0)
Circular Convolution
The multiplication of the DFTs of two images correspond to the circular
convolution of the images in the spatial domain, i.e. i i
ℱ−1 f(x,I 1y)
I1 h(x, y)
I 2I 2
F(u, v)H(u, v) f(x, y) ⊛ h(x, y), where Image
Image Image
Image
Image I 1Image I 2 mage I 1
M−1 N−1
Image I 2
j
∑∑
f(x, y) ⊛ h(x, y) = f(p, q)h[(x − p)M, (y − q)N )] (Circular convolution) (0,0) i
(0,0) (0,0)
p=0 q=0
where (z)N = z mod N.
Image I 2 Image I 1Image I 2 mage I 1
(0,0) (0,0) (0,0)
i (x, y) i
(M − 1, N − 1)
j j
Image I 1 Image I 2
(0,0) (0,0) (0,0)
j j
13
Circular Convolution
• In most applications, the linear convolution output is desired.
• The linear convolution result can be recovered from the product of the two 0 0
DFTs by appropriately padding the inputs in the spatial domain.
Image I1
(zero padded) Image I2
(zero padded)
(zero padded) (zero padded)
(zero padded)
Image I2 (zero padded)
Image I1Image I2 Image I1
• The size of the full linear convolution of two images of sizes M × N and
P × Q is (M + P − 1) × (N + Q − 1) 0 0
0 0 0 0
(zero padded) (zero padded)
(zero padded) (zero padded)
•
Image I2 Image I1Image I2
Thus, to make the size of the circular convolution correspond to that of the
Image I1
linear convolution, both the images must be zero padded to a size of
0 0 0
0 0 0 0
(M + P − 1) × (N + Q − 1), before multiplying their DFTs. 0
Image I1 Image I2
(zero padded) (zero padded)
Linear Convolution Using Zero-
Padded Circular Convolution
14
Important DFT Pairs
Function f(x, y) F(u, v)
Delta δ(x, y) 1
MN
Cosine cos(2π(u0 x + v0y))
2 [δ(u − u0 M, v − v0 N) + δ(u + u0 M, v + v0 N)]
πua πvb
sin( ) sin( )
Rectangle
rec(a, b) ab πua M N
e jπ( Mu + Nv )
πvb
M N
x 2 + y2
2 −2π 2σ 2(u 2+v 2)
Gaussian e −( 2 )
2σ 2πσ e
15
Image Filtering in the Frequency Domain
• A digital lter can be characterized by its impulse response h(m, n) or its
frequency response H(u, v).
• The frequency response of a system speci es how the system a ects
each frequency component of its input.
• The link between ltering in the spatial and frequency domains is
established by the convolution theorem.
• Frequency domain ltering consists of modifying the DFT of an image
F(u, v) using a lter transfer function H(u, v) that selectively attenuates or
ampli es the contribution of some frequencies, to alter the appearance of
the image f(x, y) in the spatial domain.
Ideal Low Pass, High Pass and
Band Pass and Band Reject
Filter Responses.
16
fi
fi
fi
fi
fi
fi
ff
Frequency Domain Filtering Steps
1. Padding: Given an input image f(x, y) of size M × N, and lter kernel get padded image fp(x, y) of size
2M × 2N.
x+y
2. Shifting: Multiply fp(x, y) with (−1) to center its DFT.
x+y ℱ
3. DFT of image: (−1) f(x, y) Fp(u, v)
4. Filter design: construct the symmetric lter transfer function H(u, v) of size 2M × 2N.
5. Filtering: obtain the element-wise product G(u, v) = Fp(u, v)H(u, v).
6. IDFT: gp(m, n) = Real(ℱ (G(u, v)))(−1)
−1 (x+y)
7. Padding removal: obtain the unpadded ltered image g(m, n) by extracting the top M × N region from
gp(m, n).
17
fi
fi
fi
Low Pass, High Pass and Bandpass Filtering
• An image can be processed using ideal low pass, high-pass and bandpass lters.
Ideal low Pass Filter Ideal High Pass Filter Ideal Bandpass Filter
{0 otherwise
2 2
2 2 H(u, v) = 1 if D1 ≤ u + v ≤ D2
1 if u 2 + v 2 ≤ D0 0 if u + v ≤ D0
H(u, v) = H(u, v) =
2 2
0 if 2 2
u + v > D0 1 if u + v > D0
18
fi
Low Pass, High Pass and Bandpass Filtering
19
Low Pass, High Pass and Bandpass Filtering
20
Low Pass, High Pass and Bandpass Filtering
21
Limitations of Ideal Filters
• Ideal lters that have sharp cut-o frequencies lead to
oscillations in the spatial domain which produces unpleasant
“ringing” artifacts.
• The inverse Fourier transform of the ideal low pass lter (LPF)
resembles a sinc function.
• Convolution of an input image with the sinc-like function in
the spatial domain causes ringing due to interference
between the minor lobes of the sinc-like spatial pattern.
• The ringing e ect is more pronounced when the cut-o Frequency domain (left) and spatial domain (right)
frequency of the frequency domain lter is lower. representation of the ideal LPF.
• Ideal lters are also hard to implement (practically
impossible).
22
fi
fi
ff
ff
fi
fi
ff
Gaussian Filters
• As an alternative to ideal lters, Gaussian lters could be applied to lter images.
Gaussian low pass lter Gaussian high pass lter Gaussian band pass lter
(u − μu)2 + (v − μv)2 (u − μu)2 + (v − μv)2
− −
H(u, v) = e 2σ2 H(u, v) = 1 − e 2σ2
23
fi
fi
fi
fi
fi
fi
Gaussian Filters
24
Gaussian Filters
25
Gaussian Filters
26
Sampling and Aliasing: A Frequency Domain Perspective
• A 2D signal f(x, y) could be sampled by multiplying it with a 2D periodic impulse train:
∞ ∞
∑ ∑
fs(x, y) = f(x, y) ⋅ δ(x − mΔTx, y − nΔTy), where ΔTx and ΔTy are the sampling periods along
m=−∞ n=−∞
the horizontal and vertical directions.
• At each sample location, the value of the sampled function is the impulse weighted by the value of f(x, y) at
that location:
∞ ∞
∫−∞ ∫−∞
f(x, y)δ(x − k1ΔTx, y − k2ΔTy)dxdy = f(k1ΔTx, k2ΔTy) (Sifting property of impulse function)
27
Sampling and Aliasing: A Frequency Domain Perspective
• The Fourier transform of the sampled signal is given by:
∞ ∞
ℱ( fs(x, y) = ℱ(f(x, y) ⋅ δ(x − mΔTx, y − nΔTy))
∑ ∑
m=−∞ n=−∞
∞ ∞
= ℱ(f(x, y)) * ℱ( δ(x − mΔTx, y − nΔTy)) (Using duality)
∑ ∑
m=−∞ n=−∞
∞ ∞
1 m n
∑ ∑
= F(U, V) * δ(U − ,V − )
ΔTxΔTy m=−∞ n=−∞
ΔT x ΔT y
∞ ∞
1 m n
∑ ∑
= F(U − ,V − ) (Using sifting property of the impulse function)
ΔTxΔTy m=−∞ n=−∞
ΔT x ΔT y
28
Sampling and Aliasing: A Frequency Domain Perspective
m n
Thus, sampling causes shifted versions of F(U, V) i.e. F(U − ,V − ) to be in nitely repeated in the
• ΔTx ΔTy
1 1
frequency domain, at intervals of ( , ) along the two frequency dimensions.
ΔTx ΔTy
• Aliasing occurs when the repetitions overlap.
• Let the maximum frequencies present in the signal along the horizontal and vertical directions be Umax and
Vmax. Then to avoid aliasing, we must have:
1 1
− Umax > Umax and − Vmax > Vmax.
ΔTx ΔTy
1 1
Let fsx = and fsy = be the sampling frequencies in the horizontal and vertical directions.
• ΔTx ΔTy
• Thus, by analyzing the spectrum of the sampled signal in the frequency domain, we derived the result of the
Nyquist Theorem, i.e to avoid aliasing, fsx ≥ 2Umax and fsy ≥ 2Vmax.
29
fi