0% found this document useful (0 votes)
3 views

Lecture 7

The document covers the fundamentals of image filtering in the frequency domain, including techniques for image smoothing and sharpening using various lowpass and highpass filters. It details the steps for filtering using the Fast Fourier Transform (FFT) and discusses the characteristics of different filters such as Ideal, Gaussian, and Butterworth filters. Additionally, it addresses selective filtering methods and the application of the Laplacian operator for image sharpening.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Lecture 7

The document covers the fundamentals of image filtering in the frequency domain, including techniques for image smoothing and sharpening using various lowpass and highpass filters. It details the steps for filtering using the Fast Fourier Transform (FFT) and discusses the characteristics of different filters such as Ideal, Gaussian, and Butterworth filters. Additionally, it addresses selective filtering methods and the application of the Laplacian operator for image sharpening.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 40

EENG 860 Special Topics: Digital Image Processing

Lecture 7: Image Filtering in Frequency


Domain

Dr. Ahmadreza Baghaie


Department of Electrical and Computer Engineering
New York Institute of Technology

Spring 2020

Readings: Chapter 4 (sections 4.7-4.9)


1 / 40
How to read: more relaxed than before.
Table of Content

● Basics of Filtering in the Frequency Domain


● Image Smoothing Using Lowpass Frequency Domain Filters
● Image Sharpening Using Highpass Frequency Domain Filters
● Selective Filtering
● The Fast Fourier Transform (FFT)

2 / 40
2D Sampling and 2D Sampling Theorem

● Function f(t,z) is said to be band limited, if its 2D FT is 0 outside a rectangle


in the frequency domain, by the limits [-umax, umax] and [-vmax, vmax]:
F (u , v)=0 for |u|≥u max and |v|≥v max
● The 2D 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
rates are:

1
>2u max
ΔT
1
>2 v max
ΔZ

3 / 40
2D Aliasing – Example

● Aliasing occurs in image re-sampling as well.


● Image smoothing before re-sampling can be used to reduce the aliasing.

4 / 40
Summary of DFT Definitions

5 / 40
Summary of DFT Pairs

6 / 40
Fourier Spectrum and Phase Angle – Example

● Spectrum or phase angles; which one is more important?

7 / 40
Basics of Filtering in the Frequency Domain

● The Fourier transform is computed by combination of the values of the signal


in the spatial domain, modified by the values of the exponential terms.
● In general, it is impossible to make direct correspondence between specific
components of an image and its Fourier transform.
● Since frequency is directly related to spatial rates of change, we can
associate frequencies in the Fourier transform with patterns of intensity
variations in an image.
● Filtering in the Fourier domain is based on modification of the Fourier
transform to achieve a specific objective, followed by inverse Fourier
transform to obtain the spatial domain representation of the processed result.

g (x , y)=Real {IDFT [ H (u , v) F (u , v)]}

8 / 40
Steps for Filtering in the Frequency Domain

1) Input image, f(x,y) of size MxN; zero-, mirror- or replicate-pad it to form


fp(x,y) with size PxQ, for P=2M and Q=2N;

2) Multiply fp(x,y) by (-1)(x+y) to center the Fourier transform

3) Compute the DFT, F(u,v), of the image from last step;


4) Construct a real, symmetric filter transfer function, H(u,v), of size PxQ with
center at (P/2, Q/2);
5) Form the product G(u,v)=H(u,v)F(u,v) using element-wise multiplication;

6) Obtain the filtered image of size PxQ by computing IDFT of G(u,v):


(x+ y)
g p ( x , y)=(Real {IDFT [G(u , v)]})(−1)
7) Obtain the final filtered result g(x,y) of the same size as the input image, by
extracting the MxN regions from the top, left quadrant of gp(x,y).

9 / 40
Steps for Filtering in the Frequency Domain

10 / 40
Filtering in the Frequency Domain - Examples

11 / 40
Filtering in the Frequency Domain - Examples

● Two ways to design filters:


– Specify the filter in the spatial domain
– Specify the filter in the frequency domain
● Two ways for implementation:
– Use spatial convolution
– Use DFT and IDFT

12 / 40
Filtering in the Frequency Domain - Examples

13 / 40
Image Smoothing Using Lowpass Frequency
Domain Filters
● Edges and sharp intensity transitions such as noise, contribute to high
frequency components in the frequency domain.
● Smoothing (blurring) is achieved by high-frequency attenuation, or lowpass
filtering.
● Three types of filters will be discussed here:
– Ideal lowpass filter (ILPF)
– Gaussian lowpass filter (GLPF)
– Butterworth lowpass filter (BLPF)
● Butterworth filters are controlled by a parameter called the filter order.
● Large values of the filter order, results in shapes similar to the ideal lowpass
filter, while smaller values result in shapes similar to a Gaussian lowpass
filter.

14 / 40
Ideal Lowpass Filter (ILPF)

● A 2D filter which passes without attenuation all of the frequencies within a


circle of specified radius from the origin, and cuts off all of the frequencies
outside this circle.
● Mathematically, it is defined as:
1 if D(u , v) D0
H (u , v) 
0 if D (u , v)  D0
with D0 as the cutoff frequency and:
1
 2
D(u , v)  (u  P / 2)  (v  Q / 2) 
2 2

15 / 40
Ideal Lowpass Filter (ILPF)

● How to select the cutoff frequency? By specifying the percentage of the


image power that you want the filter to pass.
P−1 Q−1
● Total image power is calculated by: P (u , v )=|F (u , v )|2 ⇒ PT = ∑ ∑ P (u , v )
(u=0) v=0

P (u , v )
● The percentage is calculated as: α =100 ∑ PT
(u , v)∈D0

Fourier spectrum
Rings of radii 10, 30, 60,
160, 460 pixels,
corresponding to 87%,
93%, 96%, 98%, 99% of
the total image power.

16 / 40
Ideal Lowpass Filter (ILPF) - Examples

17 / 40
Ideal Lowpass Filter (ILPF) - Limitations

● The main issue with ILPF is the ringing artifacts.


● To see the spatial representation, we can calculate the IDFT of the ILPF.
● The profile of the IDFT of the ILPF is similar to a sinc function; although it is
actually a Bessel function.
● The inverse proportionality between the width of the filter function in the
frequency domain, and the spread of the width of the lobes in the spatial
function still holds.

18 / 40
Gaussian Lowpass Filter (GLPF)

● The transfer function of a Gaussian lowpass filter (GLPF), with cutoff


frequency at a distance D0 from the center of the frequency rectangle:
D 2 ( u ,v )

2 D02
H (u , v) e
1
 2
with D (u , v)  (u  P / 2)  (v  Q / 2) 
2 2

19 / 40
Gaussian Lowpass Filter (GLPF) - Examples

20 / 40
Butterworth Lowpass Filter (BLPF)

● The transfer function of a Butterworth lowpass filter (BLPF) of order n, with


cutoff frequency at a distance D0 from the center of the frequency rectangle:
1
H (u , v)  2n
 D(u , v) 
1  
 D 0 
1
 2
with D (u , v)  (u  P / 2)  (v  Q / 2) 
2 2

21 / 40
Butterworth Lowpass Filter (BLPF) - Examples

22 / 40
Butterworth Lowpass Filter (BLPF)

● Using higher values of the filter order n, BLPF’s characteristics approach to


that of ILPF.
● Using lower values of the filter order n, BLPF’s characteristics approach to
that of GLPF.
● What about ringing?

23 / 40
Lowpass Filtering – Additional Examples

● Text image processing: smoothing/blurring can be used to bridge small gaps


and repair the broken characters.

24 / 40
Lowpass Filtering – Additional Examples

● Printing and publishing industry: cosmetic processing for smoothing and


creating a softer-look, to reduce sharpness of fine skin lines and small
blemishes

25 / 40
Lowpass Filtering – Additional Examples

● To reduce machine-induced artifacts, such as scan lines in the images; for


example a very high resolution radiometer (VHRR) image.
● Also, it can smooth out small features less than certain sizes.

26 / 40
Image Sharpening Using Highpass Frequency
Domain Filters
● Edges and sharp intensity transitions contribute to high frequency
components in the frequency domain.
● Image sharpening can be achieved by highpass filtering, which attenuates
low-frequency components without disturbing high-frequency components.
● Here, we discuss:
– Ideal highpass filter (IHPF)
– Gaussian highpass filter (GHPF)
– Butterworth highpass filter (BHPF)
– Laplacian in Frequency Domain
– Unsharp Masking and High-Boost Filtering

27 / 40
Ideal, Gaussian and Butterworth Highpass Filters

● The transfer function of these highpass


filters can be computed by subtracting a
lowpass filter transfer function from 1:
H HP (u , v) 1  H LP (u , v)

0 if D (u , v) D0
● IHPF: H (u , v) 
1 if D(u, v)  D0

D 2 ( u ,v )

2 D02
● GHPF: H (u, v) 1  e
1
● BHPF: H (u , v)  2n
 D0 
1  
 D(u , v) 
28 / 40
Ideal, Gaussian and Butterworth Highpass Filters

● The spatial kernel can be derived by applying IDFT to the HHP:

h HP ( x , y)=IDFT [ H HP (u , v)]=IDFT [1−H LP (u , v)]= δ (x , y)−h LP ( x , y )

29 / 40
Ideal, Gaussian and Butterworth Highpass Filters -
Examples

30 / 40
Ideal, Gaussian and Butterworth Highpass Filters -
Examples

31 / 40
Laplacian in Frequency Domain

● Remember the Laplacian operator in the spatial domain:

2 2 f 2 f
 f  2  2
x y
● Its Fourier transform can be written as:
H (u , v)  4 2 (u 2  v 2 )
● Given that we center our FTs, we can rewrite it as:
H (u, v)  4 2 [(u  P / 2) 2  (v  Q / 2) 2 ]  4 2 D 2 (u, v)
with
1
 2
D(u , v)  (u  P / 2)  (v  Q / 2) 
2 2

● From the convolution theorem, we have:

2 f  1{H (u , v) F (u , v)}

32 / 40
Image Sharpening Using Laplacian Operator

● Remember image sharpening in the spatial domain:


g ( x, y )  f ( x, y )  c2 f ( x, y )
● In the frequency domain, with c=-1:
g ( x , y ) = IDFT {F (u , v )+cH (u , v ) F (u , v )}
= IDFT {[1+cH (u , v )] F (u , v )}
2 2
= IDFT {[1+4  D (u , v )] F (u , v )}
● Image f(x,y) should be normalized to range [0,1], and the Laplacian needs to
be divided by its maximum to bring its range to approximate [-1,1].

33 / 40
Unsharp Masking and High-Boost Filtering

● Remember the equations for unsharp masking (k=1) and high-boost filtering
(k>1):
g ( x, y )  f ( x, y )  k * g mask ( x, y )
g mask ( x, y )  f ( x, y )  f LP ( x, y )
),(yxfg

● We have:
f LP ( x , y)=IDFT {H LP (u , v ) F (u , v )}⇒ g mask ( x , y )=IDFT {F (u , v)−H LP (u , v ) F (u , v )}
● Therefore:
g ( x , y ) = IDFT {(1+k [1−H LP (u , v)]) F (u , v)}
= IDFT {[1+kH HP (u , v)] F (u , v)}

34 / 40
Selective Filtering

Filter Type Spatial Kernel Frequency Kernel


Lowpass lp( x , y)
),(yxfg
LP (u , v)
Highpass hp(x , y)=δ (x , y)−lp( x , y) HP(u , v)=1− LP(u , v )
Bandreject br (x , y)=lp1 ( x , y)+hp2 ( x , y) BR(u , v)= LP1 (u , v)+ HP2 (u , v)
Bandpass bp( x , y)=δ ( x , y)−br ( x , y) BP(u , v)=1−BR(u , v)

35 / 40
Selective Filtering: Notch Filters

● Notch filters reject (pass) frequencies in a


predefined neighborhood of the frequency
rectangle.
● Notch reject filters are constructed by
product of several highpass filter transfer
functions, with centers translated to the
centers of the notches:
Q
H NR (u , v)= ∏ H k (u , v ) H −k (u , v)
k=1

36 / 40
Fast Fourier Transform (FFT)

● We mentioned before that the 2D DFT is separable into 1D transforms:


M −1 N −1
DFT [f ( x , y )] = ∑ ∑ f ( x , y )e− j 2  (ux / M + vy / N )
x=0 y=0
M −1 N −1
− j 2  ux / M
= ∑e ∑ f ( x , y ) e− j 2  vy / N
x=0 y=0
M −1
= ∑ F ( x , v ) e− j 2  ux / M
x=0
= F (u , v )
● We also mentioned that inverse DFT can be calculated using a forward DFT
algorithm:
M −1 N −1
* * − j 2  (ux / M + vy / N )
MNf ( x , y)= ∑ ∑ F (u , v)e
u=0 v =0

37 / 40
Fast Fourier Transform

● Brute-force implementation of the DFT requires on the order of (MN)2


multiplications and additions; exponentials are only calculated once and
stored as a look-up table.
● For an image of 2048x2048 pixels, this means 17 trillion calculations.
● Fast Fourier Transform (FFT) brings this down to MN log2 MN
multiplications and additions.
● For an image of similar size as before, FFT requires 92 million calculations!
● For an image of size MxM with M=2p, the computational advantage of FFT
over a brute-force implementation of the 1D DFT is:

2p
C ( p)=
p

38 / 40
What is Next?

● Image Degradation/Restoration Process


● Noise Models
● Noise Reduction
● Degradation Function Estimation

39 / 40
Questions?
[email protected]

40 / 40

You might also like