0% found this document useful (0 votes)
69 views110 pages

Lec5 Frequency Filtering

Here is the mathematical expression for generating a square wave using Fourier series: ≈ 4/π * (1/1 * sin(πt) + 1/3 * sin(3πt) + 1/5 * sin(5πt) + ...) The square wave can be approximated as an infinite sum of sine waves with frequencies that are odd multiples of the fundamental frequency. The coefficients follow the pattern 1/odd number.

Uploaded by

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

Lec5 Frequency Filtering

Here is the mathematical expression for generating a square wave using Fourier series: ≈ 4/π * (1/1 * sin(πt) + 1/3 * sin(3πt) + 1/5 * sin(5πt) + ...) The square wave can be approximated as an infinite sum of sine waves with frequencies that are odd multiples of the fundamental frequency. The coefficients follow the pattern 1/odd number.

Uploaded by

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

Image Processing

COMP4421
Dr. Hao CHEN
Dept. of CSE, HKUST
Filtering in the Frequency Domain

• Top row: Frequency domain


filter transfer functions of
(a) a lowpass filter,
(b) a highpass filter,
(c) an offset highpass filter.
• Bottom row:
Corresponding filtered images.
• Efficient computation for convolution
• Frequency domain analysis of filters
2
Filtering in Frequency Domain
• We will cover:
• Fourier Series and Transform
• Basics
• Fourier series
• Fourier transform
• Discrete Fourier Transform
• Discrete Fourier transform
• 2D discrete Fourier transform for images
• Filtering in Frequency Domain
• Basics
• Smoothing (Lowpass) filters in frequency domain
• Sharpening (Highpass) filters in frequency domain

3
Basics about Fourier Transform

4
Fourier Transform
• Jean-Baptiste Joseph Fourier, French
mathematician and physicist (1768-
1830)
• He was orphaned at the age of nine.
• Egyptian expedition with Napoleon I: 1798
Governor of Lower Egypt
• Permanent Secretary of the French
Academy of Sciences: 1822
• Théorie analytique de la chaleur : 1822
(The Analytic Theory of Heat)

5
https://en.wikipedia.org/wiki/Joseph_Fourier
Fourier Transform

Fourier’s idea in 1807 that periodic functions could be represented as a


weighted sum of sines and cosines was met with skepticism.

6
Digital Image Processing, by Gonzalez and Woods, Pearson, 2018.
Fourier Transform

https://www.youtube.com/watch?v=spUNpyF58BY
7
Fourier Transform
• Why we need Fourier Transform?
• Different views will make it easy to
understand problems
• Transform to frequency from
spatial may decrease the
complexity of problems.
• For some tasks, operation in
frequency domain is much easier.

https://kinder-chen.medium.com/denoising-data-with-fast-fourier-transform-a81d9f38cc4c 8
Fourier Series and Transform
• Fourier Series and Fourier Transform

o Fourier Series: any periodic function can be represented by a discrete


weighted sum of sines and cosines

o Fourier Transform: an arbitrary function with finite duration (non-periodic


function) can be expressed by a weighted integrals of sines and cosines

Fourier transform is more general!

9
Recalling some basics
Complex numbers have two parts:

rectangular
coordinates what‘s this? what‘s this?

10
Recalling some basics
Complex numbers have two parts:

rectangular
coordinates real imaginary

11
Recalling some basics
Complex numbers have two parts:

rectangular
coordinates real imaginary

Alternative reparameterization:
polar transform
polar
coordinates
how do we compute these?

12
Recalling some basics
Complex numbers have two parts:

rectangular
coordinates real imaginary

Alternative reparameterization:
polar transform
polar
coordinates
polar transform

13
Recalling some basics
Complex numbers have two parts:

rectangular
coordinates real imaginary

Alternative reparameterization:
polar transform
polar
How do you write
coordinates
polar transform these in exponential
form?

14
Recalling some basics
Complex numbers have two parts:

rectangular
coordinates real imaginary

Alternative reparameterization:

polar exponential
coordinates or form
polar transform equivalently how did we get this?

15
Recalling some basics
Complex numbers have two parts:

rectangular
coordinates real imaginary

Alternative reparameterization:

polar exponential
coordinates or form
polar transform equivalently Euler’s formula

This will help us understand the Fourier transform equations


16
Recalling some basics
• Preliminary Concepts Im(𝐶)
𝐼
𝐶 = 𝑅 + 𝑗𝐼
Complex number: 𝐶 = 𝑅 + 𝑗𝐼, 𝑗 = −1
|𝐶|

The conjugate: 𝐶 ∗ = 𝑅 − 𝑗𝐼 𝑅
Re(𝐶)

Polar coordinate representation: 𝐶 = |𝐶|(cos 𝜃 + 𝑗 sin 𝜃)


Image source:
|𝐶| = 𝑅2 + 𝐼 2 and 𝜃 = arctan( 𝐼/𝑅)
https://oer.physics.manchester
𝐶 = |𝐶|𝑒 𝑗𝜃 .ac.uk/Math2/Notes/Notes/No
tesse2.xht

17
Fourier series

18
Fourier Series
𝑓(𝑡) is a periodic continuous function with period 𝑇, we have:
Euler’s formula
𝑛=+∞
2𝜋𝑛 2𝜋𝑛 2𝜋𝑛
cos 𝑡 + 𝑗sin( 𝑡)
𝑓 𝑡 = ෍ 𝑐𝑛 𝑒 𝑇 𝑡
𝑗
𝑇 𝑇
𝑛=−∞
Where
Coefficient Discrete frequency

1 𝑇/2 2𝜋𝑛
−𝑗 𝑇 𝑡
𝑐𝑛 = න 𝑓 𝑡 𝑒 𝑑𝑡 , 𝑛 = 0, ±1, ±2, …
𝑇 −𝑇/2

19
Basic building block

amplitude phase
sinusoid variable
angular
frequency

Fourier’s claim: Add enough of these to get any periodic signal you want!
20
Examples
How would you generate this function?

= ? + ?

21
Examples
How would you generate this function?

= ? + ?

22
Examples
How would you generate this function?

= ? + ?

23
Examples
How would you generate this function?

= ? + ?

square wave

24
Examples
How would you generate this function?

≈ ? + ?

square wave

=
25
Examples
How would you generate this function?

≈ ? + ?

square wave

=
26
Examples
How would you generate this function?

≈ ? + ?

square wave

=
27
Examples
How would you generate this function?

≈ ? + ?

square wave

=
28
Examples
How would you generate this function?

≈ ? + ?

square wave

How would you express


= this mathematically?

29
Examples

square wave infinite sum of sine waves

How would could you visualize this in the frequency domain?

30
Examples

square wave infinite sum of sine waves

magnitude

frequency 31
Fourier transform

32
Fourier Transform
• Fourier Transform Pair in 1D

• From spatial domain to frequency domain



𝐹(𝜇) = ℑ{𝑓(𝑡)} = න 𝑓(𝑡)𝑒 −𝑗2𝜋𝜇𝑡 𝑑𝑡
−∞

• From frequency domain to spatial domain



𝑓(𝑡) = ℑ−1 {𝐹(𝜇)} = න 𝐹(𝜇)𝑒 𝑗2𝜋𝜇𝑡 𝑑𝜇
−∞
Coefficient
Continuous frequency
33
Fourier Transform
• Basic Properties of Fourier Transform for reference
Name Equation Description

Linearity ℎ 𝑡 = 𝑎𝑓 𝑡 + 𝑏𝑔 𝑡 ⟷ 𝐻 𝑢 = 𝑎𝐹 𝑢 + 𝑏𝐺(𝑢)

Time Shift ℎ 𝑡 = 𝑓(𝑡 − 𝑡0 ) ⟷ 𝐻 𝑢 = 𝑒 −𝑗2𝜋𝑡0 𝜇 𝐹(𝑢)

Frequency Shift ℎ 𝑡 = 𝑒 𝑗2𝜋𝑡𝜇0 𝑓 𝑡 ⟷ 𝐻 𝑢 = 𝐹 𝑢 − 𝑢0

1 𝑢
Scaling ℎ 𝑡 = 𝑓(𝑎𝑡) ⟷ 𝐻 𝑢 = 𝐹( )
𝑎 𝑎

Conjugation ℎ 𝑡 = 𝑓 ∗ 𝑡 ⟷ 𝐻 𝑢 = 𝐹 ∗ (−𝑢)

Duality 𝑓(𝑡) ⟷ 𝐹 𝑢 ⇒ 𝐹(𝑡) ⟷ 𝑓(−𝑢)

Convolution 𝑓(𝑡) ⋆ ℎ(𝑡) ⟷ 𝐻(𝜇)𝐹(𝜇)


34
Fourier Transform
• Fourier Transform: One Continuous Variable Example

∞ 𝑊/2
𝐹(𝜇) = න 𝑓(𝑡)𝑒 −𝑗2𝜋𝜇𝑡 𝑑𝑡 = න 𝐴 𝑒 −𝑗2𝜋𝜇𝑡 𝑑𝑡
−∞ −𝑊/2
−𝐴 −𝑗2𝜋𝜇𝑡 𝑊/2 𝐴 𝑗𝜋𝜇𝑊 −𝑗𝜋𝜇𝑊
= 𝑒 = 𝑒 − 𝑒
𝑗2𝜋𝜇 −𝑊/2 𝑗2𝜋𝑊
sin( 𝜋𝜇𝑊)
= 𝐴𝑊
(𝜋𝜇𝑊)

35
Fourier Transform
• Fourier Transform: One Continuous Variable Example

36
Fourier Transform
• Convolution • When consider Fourier Transform:
∞ ∞
• The convolution is denoted by ⋆:
ℑ 𝑓(𝑡) ⋆ ℎ(𝑡) = න න 𝑓(𝜏)ℎ(𝑡 − 𝜏)𝑑𝜏 𝑒 −𝑗2𝜋𝜇𝑡 𝑑𝑡
−∞ −∞

𝑓(𝑡) ⋆ ℎ(𝑡) = න 𝑓(𝜏)ℎ(𝑡 − 𝜏)𝑑𝜏 ∞ ∞
−∞ =න 𝑓(𝜏) න ℎ(𝑡 − 𝜏)𝑒 −𝑗2𝜋𝜇𝑡 𝑑𝑡 𝑑𝜏
−∞ −∞


= න 𝑓(𝜏) 𝐻(𝜇)𝑒 −𝑗2𝜋𝜇𝜏 𝑑𝜏
𝑓(𝑡 − 𝑡0 ) ⟷ 𝑒 −𝑗2𝜋𝑡0 𝜇 𝐹(𝜇) −∞


Spatial domain filter convolution is equivalent to =𝐻(𝜇) න 𝑓(𝜏)𝑒 −𝑗2𝜋𝜇𝜏 𝑑𝜏 =𝐻(𝜇)𝐹(𝜇)
frequency domain multiplication! −∞

37
Fourier Transform
• Convolution Theorem of Continuous Functions

𝑓(𝑡) ⋆ ℎ(𝑡) ⇔ 𝐻(𝜇)𝐹(𝜇)

𝑓(𝑡)ℎ(𝑡) ⇔ 𝐻(𝜇) ⋆ 𝐹(𝜇)

38
Filtering in Frequency Domain
• We will cover:
• Fourier Series and Transform
• Basics
• Fourier series
• Fourier transform
• Discrete Fourier Transform
• Discrete Fourier transform
• 2D discrete Fourier transform for images
• Filtering in Frequency Domain
• Basics
• Smoothing (Lowpass) filters in frequency domain
• Sharpening (Highpass) filters in frequency domain

39
Discrete Fourier Transform (DFT)

40
Discrete Fourier Transform
• Discrete Fourier Transform Pair in 1D

• From spatial domain to frequency domain 1/𝑀 is sampling


𝑀−1 interval
𝑗2𝜋𝑢𝑥

𝐹 𝑢 = ෍𝑓 𝑥 𝑒 𝑀 , 𝑢 = 0,1, . . . , 𝑀 − 1
𝑥=0 𝑢 is an integer
• From frequency domain to spatial domain
Both input and output
1
𝑀−1
𝑗2𝜋𝑢𝑥
are finite
𝑓 𝑥 = ෍ 𝐹 𝑢 𝑒 𝑀 , 𝑥 = 0,1,2, . . . , 𝑀 − 1
𝑀
𝑢=0

• 𝐹 𝑢 = 𝐹(𝑢 + 𝑛𝑀) and 𝑓 𝑥 = 𝑓(𝑥 + 𝑛𝑀)

41
Discrete Fourier transform
Where is the connection to the ‘summation of sine waves’ idea?

𝑀−1
1 𝑗2𝜋𝑢𝑥
𝑓 𝑥 = ෍ 𝐹 𝑢 𝑒 𝑀 , 𝑥 = 0,1,2, … , 𝑀 − 1
𝑀
𝑢=0
Euler’s formula

Sum over frequencies


𝑀−1
1 2𝜋𝑢𝑥 2𝜋𝑢𝑥
𝑓 𝑥 = ෍ 𝐹 𝑢 {cos + 𝑗sin }
𝑀 𝑀 𝑀
𝑢=0

scaling parameter wave components


42
Discrete Fourier Transform
• DFT Computation Example

43
Digital Image Processing, by Gonzalez and Woods, Pearson, 2018.
Discrete Fourier Transform
• DFT Computation Example
• The first value of 𝐹(𝑢) is
3

𝐹 0 = ෍𝑓 𝑥 = 𝑓 0 +𝑓 1 +𝑓 2 +𝑓 3 = 11
𝑥=0

• The next value of 𝐹(𝑢) is


3

𝐹 1 = ෍ 𝑓 𝑥 𝑒 −2𝜋 1 𝑥/4
= 1𝑒 0 + 2𝑒 −𝑗𝜋/2 + 4𝑒 −𝑗𝜋 + 4𝑒 −𝑗3𝜋/2
𝑥=0

= −3 + 2𝑗

• What’s the value of 𝐹(2) and 𝐹(3)? 𝐹 2 = − 1 + 0𝑗 and 𝐹 3 = −(3 + 2𝑗)

• Given 𝐹(𝑢) , how to compute 𝑓(0) ? 1


𝑓 0 = 𝐹 0 +𝐹 1 +𝐹 2 +𝐹 4 =1
4
44
Digital Image Processing, by Gonzalez and Woods, Pearson, 2018.
2D Discrete Fourier transform
(DFT)

45
2D Discrete Fourier Transform
• 2-D Discrete Fourier Transform Pair

• Discrete Fourier Transform:


𝑀−1 𝑁−1
𝑀−1 𝑁−1
𝑢𝑥 𝜈𝑦 𝐹 0,0 = ෍ ෍ 𝑓 𝑥, 𝑦 = 𝑀𝑁𝑓 ҧ
−𝑗2𝜋( 𝑀 + 𝑁 )
𝐹(𝑢, 𝑣) = ෍ ෍ 𝑓 𝑥, 𝑦 𝑒 𝑥=0 𝑦=0
𝑥=0 𝑦=0

𝑢 = 0,1,2, … , 𝑀 − 1; 𝜈 = 0,1,2, … , 𝑁 − 1;
𝑓(𝑥, 𝑦) is a digital image of size 𝑀 × 𝑁 Periodicity:

• Inverse Discrete Fourier Transform: 𝐹 𝑢, 𝑣 = 𝐹(𝑢 + 𝑘1 𝑀, 𝑣 + 𝑘2 𝑁)

𝑀−1 𝑁−1 𝑓 𝑥, 𝑦 = 𝑓(𝑥 + 𝑘1 𝑀, 𝑦 + 𝑘2 𝑁)


1 𝑗2𝜋
𝑢𝑥 𝜈𝑦
𝑓(𝑥, 𝑦) = ෍ ෍ 𝐹 𝑢, 𝜈 𝑒 𝑀+𝑁
𝑀𝑁
𝑥=0 𝑦=0
46
2D Discrete Fourier Transform
• Properties of the 2-D DFT: Translation and Rotation

• Translation:
𝑢0 𝑥 𝜈0 𝑦
𝑗2𝜋 𝑀 + 𝑁
𝑓(𝑥, 𝑦)𝑒 ⇔ 𝐹(𝑢 − 𝑢0 , 𝜈 − 𝜈0 )
and 𝑢𝑥0 𝜈𝑦0
−𝑗2𝜋 +
𝑓(𝑥 − 𝑥0 , 𝑦 − 𝑦0 ) ⇔ 𝐹(𝑢, 𝜈)𝑒 𝑀 𝑁

• Rotation (Using the polar coordinates):


𝑥 = 𝑟 cos 𝜃 y=rsin𝜃 𝑢 = 𝜔cos𝜑 𝜈 = 𝜔 sin 𝜑
results in the following transform pair:
𝑓(𝑟, 𝜃 + 𝜃0 ) ⇔ 𝐹(𝜔, 𝜑 + 𝜃0 )

47
2D Discrete Fourier Transform
• Centering the DFT
• 1D case
𝑢 𝑥
0
𝑗2𝜋 𝑀
• 𝑓 𝑥 𝑒 ⇔ 𝐹 𝑢 − 𝑢0
• Let 𝑢0 = 𝑀/2, then
• 𝑓 𝑥 (−1)𝑥 ⇔ 𝐹 𝑢 − 𝑀/2

• 2D case, let 𝑢0 , 𝑣0 = (𝑀/2, 𝑁/2)


• 𝑓(𝑥, 𝑦) −1 𝑥+𝑦 ⇔ 𝐹(𝑢 − 𝑀/2, 𝜈 − 𝑁/2)

48
2D Discrete Fourier Transform
• Properties of the 2-D DFT: Fourier Spectrum and Phase
Angle
𝐹 𝑢, 𝑣 = 𝑅 𝑢, 𝑣 + 𝑗𝐼(𝑢, 𝑣)

• 2-D DFT in polar form


𝐹(𝑢, 𝑣) = |𝐹(𝑢, 𝑣)|𝑒 𝑗𝜙(𝑢,𝑣)
• Fourier spectrum
|𝐹(𝑢, 𝑣)| = 𝑅2 (𝑢, 𝑣) + 𝐼 2 (𝑢, 𝑣) 1/2

• Power spectrum
𝑃(𝑢, 𝑣) = |𝐹(𝑢, 𝑣)|2 = 𝑅2 (𝑢, 𝑣) + 𝐼 2 (𝑢, 𝑣)
• Phase angle 𝐼(𝑢, 𝑣)
𝜙(u,v)=arctan
𝑅(𝑢, 𝑣)
49
Power Spectrum

Fourier spectrum
|𝐹(𝑢, 𝑣)| = 𝑅2 (𝑢, 𝑣) + 𝐼2 (𝑢, 𝑣) 1/2

50
Digital Image Processing, by Gonzalez and Woods, Pearson, 2018.
Power Spectrum after Translation, Rotation

Fourier spectrum
|𝐹(𝑢, 𝑣)| = 𝑅2 (𝑢, 𝑣) + 𝐼2 (𝑢, 𝑣) 1/2

51
Digital Image Processing, by Gonzalez and Woods, Pearson, 2018.
Phase Angle after Translation Rotation
Phase angle
𝐼(𝑢, 𝑣)
𝜙(𝑢, 𝑣)=arctan
𝑅(𝑢, 𝑣)

The phase is a measure of displacement of the various sinusoids with respect to their origin.
Sensitive to translation and rotation.
52
Digital Image Processing, by Gonzalez and Woods, Pearson, 2018.
Analysis of Power Spectrum and Phase Angle
𝑀−1 𝑁−1
1 𝑗2𝜋
𝑢𝑥 𝜈𝑦
+
𝑓 𝑥, 𝑦 = ෍ ෍ 𝐹 𝑢, 𝜈 𝑒 𝑀 𝑁
𝑀𝑁
𝑥=0 𝑦=0

𝑢𝑥 𝜈𝑦
1 𝑗2𝜋 𝑀 + 𝑁
= σ𝑀−1
𝑥=0 σ𝑁−1
𝑦=0 𝐹 𝑢, 𝜈 𝑒 𝑗𝜙(𝑢,𝑣) 𝑒
𝑀𝑁
Weighted summation of sin waves
𝑢𝑥 𝜈𝑦
1 𝑗2𝜋 𝑀 + 𝑁 +𝜙(𝑢,𝑣)
= σ𝑀−1
𝑥=0 σ𝑁−1
𝑦=0 𝐹 𝑢, 𝜈 𝑒
𝑀𝑁

Power spectrum |𝐹 𝑢, 𝑣 | Phase angle 𝜙(𝑢, 𝑣)


• A large amplitude |𝐹 𝑢, 𝑣 | implies a greater prominence of • The phase is a displacement of the various sinusoids
a sinusoid of that frequency with respect to their origin
• A small amplitude |𝐹 𝑢, 𝑣 | implies less of that frequency • Carry much information about where the discernible
• Determine the intensities in the image objects are located at the image

53
Power Spectrum and Phase Angle

54
Digital Image Processing, by Gonzalez and Woods, Pearson, 2018.
Fourier transforms of natural images
original

Fourier spectrum Phase angle 55


Fourier transforms of natural images
Image phase matters!

cheetah phase with zebra amplitude zebra phase with cheetah amplitude 56
2D Discrete Fourier Transform
• 2D Discrete Convolution Theorem

𝑓 ⋆ ℎ 𝑥, 𝑦 ⇔ (𝐻 𝐹)(𝑢, 𝑣)

1
(𝑓 ℎ)(𝑥, 𝑦) ⇔

(𝐻 ⋆ 𝐹)(𝑢, 𝑣)
𝑀𝑁

57
Filtering in Frequency Domain
• We will cover:
• Fourier Series and Transform
• Basics
• Fourier series
• Fourier transform
• Discrete Fourier Transform
• Discrete Fourier transform
• 2D discrete Fourier transform for images
• Filtering in Frequency Domain
• Basics
• Smoothing (Lowpass) filters in frequency domain
• Sharpening (Highpass) filters in frequency domain

58
Spatial domain filtering

filter kernel
=
Fourier transform inverse Fourier transform

Frequency domain filtering


59
Basic Filtering
• The Basic Filtering in the Frequency Domain:

𝑓 𝑥, 𝑦 |𝐹 𝑢, 𝑣 |
Spatial Frequency

60
Digital Image Processing, by Gonzalez and Woods, Pearson, 2018.
Basic Filtering
• The Basic Filtering in the Frequency Domain:
• Modifying the Fourier transform of an image
• Computing the inverse transform to obtain the processed result

𝑔(𝑥, 𝑦) = ℑ−1 {𝐻(𝑢, 𝑣)𝐹(𝑢, 𝑣)}

𝐹(𝑢, 𝑣) is the DFT of the input image


𝐻(𝑢, 𝑣) is a filter function.

61
Basic Filtering
Fourier Filter Function Inverse Fourier
Transform 𝐻(𝑢, 𝑣) Transform

𝐹(𝑢, 𝑣) 𝐻 𝑢, 𝑣 𝐹(𝑢, 𝑣)

Pre-
processing 𝑓 𝑥, 𝑦 ⋆ ℎ(𝑥, 𝑦) ⇔ 𝐹 𝑢, 𝑣 𝐻(𝑢, 𝑣) Post-
processing
Convolution Element-by-element
Filtering Multiplication

𝑓(𝑥, 𝑦)
Input Image 𝑔(𝑥, 𝑦) Enhanced Image
62
Basic Filtering
• The Basic Filtering :
➢ Top row:
Frequency domain filter
transfer functions of
(a) a lowpass filter,
(b) a highpass filter
(c) an offset highpass filter.
➢ Bottom row:
Corresponding filtered
images.

63
Digital Image Processing, by Gonzalez and Woods, Pearson, 2018.
Revisiting blurring
Why does the Gaussian give a nice smooth image, but the box filter give edgy artifacts?

Gaussian Box
filter filter

64
Gaussian blur

65
Box blur

66
More filtering examples

?
filters shown
in frequency-
domain

67
More filtering examples
low-pass

filters shown
band-pass in frequency-
domain

68
More filtering examples
high-pass

69
More filtering examples
high-pass

70
More filtering examples
original image low-pass filter

?
frequency magnitude

71
More filtering examples
original image low-pass filter

frequency magnitude

72
More filtering examples
original image high-pass filter

?
frequency magnitude

73
More filtering examples
original image high-pass filter

frequency magnitude

74
More filtering examples
original image band-pass filter

frequency magnitude

75
More filtering examples
original image band-pass filter

frequency magnitude

76
More filtering examples
original image band-pass filter

frequency magnitude

77
More filtering examples
original image band-pass filter

frequency magnitude

78
Smoothing Filter in Frequency
Domain
ILPF: Ideal Lowpass Filters
GLPF: Gaussian Lowpass Filters
BLPF: Butterworth Lowpass Filter

79
Ideal Lowpass Filters
• Ideal Lowpass Filters (ILPF):
1 if 𝐷(𝑢, 𝑣) ≤ 𝐷0
𝐻(𝑢, 𝑣) = ቊ
0 if 𝐷(𝑢, 𝑣) > 𝐷0
𝐷0 is a positive constant (cutoff frequency) and 𝐷(𝑢, 𝑣) is the distance between
a point (𝑢, 𝑣) in the frequency domain and the center of the P x Q frequency
rectangle
1
2 2
𝑃 2 𝑄
𝐷(𝑢, 𝑣) = (𝑢 − ) + 𝑣 −
2 2

80
Ideal Lowpass Filters
• Ideal Lowpass Filters (ILPF):

81
Digital Image Processing, by Gonzalez and Woods, Pearson, 2018.
Ideal Lowpass Filters
• Image Power:
• We calculate the amount of power a filter “encloses” from the total power 𝑃𝑇 :

𝑃𝑇 = ෍ ෍ 𝑃(𝑢, 𝑣)
𝑢 𝑣
𝑃 𝑢, 𝑣 = 𝑅 𝑢, 𝑣 2 + 𝐼 𝑢, 𝑣 2

Real and Imaginary Components of DFT

82
Ideal Lowpass Filters
• Image Power:
• A filter, centered at the original of the frequency plane with radius 𝑟,
enclosed 𝛼 precent of power
𝑃 𝑢, 𝑣
𝛼 = ෍෍ × 100%
𝑃𝑇
𝑢 𝑣
Where 𝑢, 𝑣 are summed over the coordinates that lie within the circle or on
its boundary

83
Ideal Lowpass Filters
• Ideal Lowpass Filters (ILPF):

84
Digital Image Processing, by Gonzalez and Woods, Pearson, 2018.
Ideal Lowpass Filters Example

𝐷0 = 10 𝐷0 = 30

𝐷0 = 60 𝐷0 = 160 𝐷0 = 460

85
Digital Image Processing, by Gonzalez and Woods, Pearson, 2018.
Ideal Lowpass Filters
• Ideal Lowpass Filters (ILPF):

86
Digital Image Processing, by Gonzalez and Woods, Pearson, 2018.
Ideal Lowpass Filters

• Ideal Lowpass Filters (ILPF):

• The sharp cut off in the frequency domain can result in ripples appearing in

the image. It is called ringing artifact.

• Can we design a filter with a smooth cut off?

87
Gaussian Lowpass Filters
• Gaussian Lowpass Filters (GLPF):
−𝐷 2 (𝑢,𝑣)/2𝜎 2
𝐻(𝑢, 𝑣) = 𝑒
−𝐷 2 (𝑢,𝑣)/2𝐷 2
By letting 𝜎 = 𝐷0 , 𝐻(𝑢, 𝑣) = 𝑒 0

88
Gaussian Lowpass Filters
• Gaussian Lowpass Filters (GLPF) Examples:

89
Digital Image Processing, by Gonzalez and Woods, Pearson, 2018.
Gaussian Lowpass Filters
• Gaussian Lowpass Filters (GLPF) Examples:

90
Digital Image Processing, by Gonzalez and Woods, Pearson, 2018.
Gaussian Lowpass Filter
• Gaussian Lowpass Filters (GLPF) Examples:

91
Digital Image Processing, by Gonzalez and Woods, Pearson, 2018.
Gaussian Lowpass Filter

𝐷0 = 10 𝐷0 = 30

𝐷0 = 60 𝐷0 = 160 𝐷0 = 460

92
Butterworth Lowpass Filter
• Butterworth Lowpass Filter (BLPF):
• This filter does not have a sharp discontinuity
- Instead, it has a smooth transition
• Butterworth Lowpass Filters (BLPF) of order 𝑛 and with cutoff frequency 𝐷0
1
𝐻(𝑢, 𝑣) = 2𝑛
𝐷 𝑢, 𝑣
1+
𝐷0
- 𝐷(𝑢,𝑣) is the distance between a point (𝑢,𝑣) and the center of the frequency plane, and
𝐷0 is a positive constant

93
Butterworth Lowpass Filter
• Butterworth Lowpass Filter (BLPF):

94
Digital Image Processing, by Gonzalez and Woods, Pearson, 2018.
Butterworth Lowpass Filter Example

𝐷0 = 10 𝐷0 = 30

𝐷0 = 60 𝐷0 = 160 𝐷0 = 460

95
Digital Image Processing, by Gonzalez and Woods, Pearson, 2018.
Butterworth Lowpass Filter
• Butterworth Lowpass Filter (BLPF):

96
Digital Image Processing, by Gonzalez and Woods, Pearson, 2018.
Smoothing Filters in Frequency Domain
• ILPF vs. GLPF vs. BLPF:

97
Sharpening Filters in Frequency Domain
IHPF: Ideal Highpass Filters
GHPF: Gaussian Highpass Filters
BHPF: Butterworth Highpass Filter

98
Sharpening Filter in Frequency Domain
• Basic Concept
• Because edges and other abrupt changes in grey levels are associated with
high-frequency components, image sharpening can be achieved by using the
high-pass frequency filtering process.
• The high-pass filter attenuates (suppresses) the low frequency components
without disturbing high-frequency information in the frequency domain.
• Relation between low-pass and high-pass filters:
𝐻ℎ𝑝 𝑢, 𝑣 = 1 − 𝐻𝑙𝑝 (𝑢, 𝑣)
(𝑢, 𝑣) represents position variables in the frequency domain

99
Ideal Highpass Filter
• Ideal High Pass Filter (IHPF):
• A 2-D ideal highpass filter (IHPL) is defined as
0 if 𝐷(𝑢, 𝑣) ≤ 𝐷0
𝐻(𝑢, 𝑣) = ቊ
1 if 𝐷(𝑢, 𝑣) > 𝐷0
where 𝐷(𝑢, 𝑣) is the distance from point (𝑢, 𝑣) to the center of the
frequency plane; 𝐷0 is a non-negative quantity, cutoff frequency

100
Gaussian and Butterworth Highpass Filter
• Gaussian Highpass Filter (GHPL) and Butterworth Highpass Filter
(BHPL)

• A 2-D Gaussian highpass filter (GHPL) is defined as:


𝐷2 𝑢,𝑣
− 2
𝐻 𝑢, 𝑣 = 1 − 𝑒 2𝐷0
• A 2-D Butterworth highpass filter (BHPL) is defined as:
1
𝐻 𝑢, 𝑣 = 2𝑛
𝐷0
1+
𝐷 𝑢, 𝑣

101
Sharpening Filter in Frequency Domain

102
Sharpening Filter in Frequency Domain
• In Spatial Domain

103
IHPF, GHPF and BHPF
• IHPF vs. GHPF vs. BHPF:

104
IHPF, GHPF and BHPF
• Apply Result

105
IHPF, GHPF and BHPF
• Application with Butterworth Highpass Filter

106
Digital Image Processing, by Gonzalez and Woods, Pearson, 2018.
Sharpening Filter in Frequency Domain
• Unsharp Masking, Highboost Filtering and High-Frequency-Emphasis:
𝑔𝑚𝑎𝑠𝑘 (𝑥, 𝑦) = 𝑓(𝑥, 𝑦) − 𝑓𝐿𝑃 (𝑥, 𝑦)

𝑓𝐿𝑃 (𝑥, 𝑦) = ℑ−1 𝐻𝐿𝑃 (𝑢, 𝑣)𝐹(𝑢, 𝑣)

𝑔 𝑥, 𝑦 = 𝑓 𝑥, 𝑦 + 𝑘𝑔𝑚𝑎𝑠𝑘 𝑥, 𝑦
This expression defines unsharp masking when k = 1 and high-boost filtering when k > 1.

𝑔(𝑥, 𝑦) = ℑ−1 1 + 𝑘 1 − 𝐻𝐿𝑃 (𝑢, 𝑣) 𝐹(𝑢, 𝑣)


= ℑ−1 1 + 𝑘𝐻𝐻𝑃 (𝑢, 𝑣) 𝐹(𝑢, 𝑣)
107
Sharpening Filter in Frequency Domain
• Unsharp Masking, Highboost Filtering and High-Frequency-Emphasis:
• A slightly more general formulation of high-frequency-emphasis
filtering is the expression:
𝑔(𝑥, 𝑦) = ℑ−1 𝑘1 + 𝑘2 𝐻𝐻𝑃 (𝑢, 𝑣) 𝐹(𝑢, 𝑣)
where 𝑘1 ≥ 0 offsets the value of the transfer function so as not to zero-
out the average intensity
𝑘2 ≥ 0 controls the contribution of high frequencies

108
Sharpening Filter in Frequency Domain
• Image enhancement using high-frequency-emphasis filtering

GHPF with D0=40


scaled as the image

High-Frequency-
Emphasis Filtering
k1=0.5, k2=0.75

109
Digital Image Processing, by Gonzalez and Woods, Pearson, 2018.
Filtering in Frequency Domain
• We have covered:
• Fourier Series and Transform
• Basics
• Fourier series
• Fourier transform
• Discrete Fourier Transform
• Discrete Fourier transform
• 2D discrete Fourier transform for images
• Filtering in Frequency Domain
• Basics
• Smoothing (Lowpass) filters in frequency domain
• Sharpening (Highpass) filters in frequency domain

110

You might also like