You are on page 1of 56

EIE4512 - Digital Image Processing

Frequency Domain Operations

Zhen Li
lizhen@cuhk.edu.cn
School of Science and Engineering
The Chinese University of Hong Kong, Shen Zhen
February 19-21, 2019
Basics of Frequency
Domain

1
Outline
• Preliminary:
• Complex Numbers
• Fourier Series & Fourier Transform
• Impulses
• Convolution
• Sampling
• Sampled Function
• Sampling Theorem

2
Revisit of Complex Numbers
• Definition
• ! = # + % '
• Conjugate: ! ∗ = # − % '

• Polar Coordinates '


! = # + %'
• ! = ! (cos . + % sin .)
|!|
• ! = #2 + '2
• tan . = '/# .
#
• Euler’s Formula
• 6 78 = cos . +jsin .
• ! = |!|6 78
3
Fourier Series
• Any periodic function !(#) with period % can be
represented as a Fourier Series
1
X
j 2⇡n
f (t) = cn e T

n= 1

• With
Z T /2
1 j 2⇡n
cn = f (t)e T t dt
T T /2
Fourier Series for real value function and conplex value function 4
https://www.youtube.com/watch?v=kP02nBNtjrU
Chapter 4
Filtering in the Frequency Domain

Unit Impulse
4.2.3 Impulses and their Shifting Property

Unit impulse of a continuous variable t located at t=0 :

and

Sifting property :

(if f(t) continuous at t=0 )

© 1992–2008 R. C. Gonzalez & R. E. Woods


5
Digital Image Processing

Discrete Unit Impulse


T. Peynot

Chapter 4
Filtering in the Frequency Domain

Unit discrete impulse located at x=0 :

Sifting property :

© 1992–2008 R. C. Gonzalez & R. E. Woods

6
T. Peynot

Chapter 4

Impulse Train Filtering in the Frequency Domain

Impulse train : sum of infinitely many periodic impulses ΔT units apart:

© 1992–2008 R. C. Gonzalez & R. E. Woods

7
Chapter 4

Fourier Transform (FT) of Filtering in the Frequency Domain

Continuous Functions
4.2.4 The Fourier Transform of Functions of One Continuous Variable

Fourier Transform of a continuous function f(t) of a continuous variable t :

Inverse Fourier Transform:

© 1992–2008 R. C. Gonzalez & R. E. Woods

8
Digital Image Processing
T. Peynot

FT Example
Chapter 4
Filtering in the Frequency Domain

Example :

© 1992–2008 R. C. Gonzalez & R. E. Woods


9
Digital Image Processing
T. Peynot

FT of Unit Impulse Chapter 4


Filtering in the Frequency Domain

Example 2 : Fourier Transform of a unit impulse located at the origin:

Fourier Transform of a unit impulse located at t = t0 :

10
Digital Image Processing
T. Peynot

FT of Impulse Train Chapter 4


Filtering in the Frequency Domain

Example 2 : Fourier Transform S(µ) of an impulse train with period ΔT :


Periodic function with period ΔT =>

Where :

=>

Also an impulse train, with period 1/ΔT

© 1992–2008 R. C. Gonzalez & R. E. Woods 11


T. Peynot

Chapter 4

Continuous-Time Convolution Filtering in the Frequency Domain

4.2.5 Convolution
Convolution of functions f(t) and h(t), of one continuous variable t :

Fourier Transform pairs:

Spatial Domain Conv <=> Frequency Domain Multiplication

Spatial Domain Multiplication <=> Frequency Domain Conv


12
© 1992–2008 R. C. Gonzalez & R. E. Woods
Commonly used continuous Fourier transform
T. Peynot
Chapter 4
Filtering in the Frequency Domain
Chapter 4

Sampling
4.3 Sampling and the Filtering in the Frequency
Fourier Transform Domain
of Sampled Functions

4.3.1 Sampling
4.3 Sampling and the Fourier Transform of Sampled Functions
Model of the sampled function:
4.3.1 Sampling of f(t) by a sampling
multiplication
function equal to a train of impulses ΔT
units apart
Model of the sampled function:
multiplication of f(t) by a sampling
function equal to a train of impulses ΔT
units apart

© 1992–2008 R. C. Gonzalez & R. E. Woods

1992–2008 R. C. Gonzalez & R. E. Woods


13
Digital Image Processing
T. Peynot

FT of Sampled Function Chapter 4


Filtering in the Frequency Domain
h i
F̃ (µ) = F T f (t)4.3.3 The
˜ Sampling Theorem
= F T [f (t) · s T (t)]
= F (µ) ? S(µ)
Z 1
= F (⌧ )S(µ ⌧ )d⌧
1
Z ⇣ n ⌘
1 1
X
1
= F (⌧ ) µ ⌧ d⌧
T 1 n= 1
T
Z ⇣ n ⌘
1
X 1
1
= F (⌧ ) µ ⌧ d⌧
T n= 1 1 T

1 X1 ⇣ n ⌘
= F µ
T n= 1
T

Superposition of infinitely many


copies of ! " with an interval 1/∆&

© 1992–2008 R. C. Gonzalez & R. E. Woods

14
Digital Image Processing
T. Peynot

Sampling Theorem Chapter 4


Filtering in the Frequency Domain

A function f(t) whose Fourier transform is zero


for values of frequencies outside a finite
interval (band) [- µmax, µmax] about the origin is
called a band-limited function
Sufficient separation guaranteed if:

Sampling Theorem:
A continuous, band-limited function can be recovered completely
from a set of its samples if the samples are acquired at a rate
exceeding twice the highest frequency content of the function

NB: Sampling at:


Nyquist rate
© 1992–2008 R. C. Gonzalez & R. E. Woods

15
Digital Image Processing
T. Peynot

Recovery with Low-pass Filter Chapter 4


Filtering in the Frequency Domain

=> Recover f(t) using the inverse FT:

Example: ideal lowpass filter

© 1992–2008 R. C. Gonzalez & R. E. Woods

16
Digital Image Processing
T. Peynot

Aliasing
Chapter 4
Filtering in the Frequency Domain

4.3.4 Aliasing

Effect of under-sampling a function


Transform corrupted by frequencies
from adjacent periods

NB: the effect of aliasing can be reduced


by smoothing the input function to
attenuate its higher frequencies: anti-
aliasing.
Has to be done before the sampling

© 1992–2008 R. C. Gonzalez & R. E. Woods

17
Chapter 4
Filtering in the Frequency Domain

Aliasing (Illustration)
4.3.4 Aliasing

Illustration: sampling a sine wave of period 2s

18
Function Reconstruction
h i
1
f (t) = F T F̃ (µ)H(µ)
1
X 
1
= f (n T ) · sinc (t n T)
n= 1
T

https://blog.csdn.net/u010592995/article/details/73555425
https://blog.csdn.net/liyuanbhu/article/details/42061089

19
Discrete Fourier Transform
FT of a sampled function
Z 1
F̃ (µ) = f˜(t)e j2⇡µt
dt
1
Z 1 1
X
j2⇡µt
= f (t) (t n T )e dt
1 n= 1
1 Z 1
X
j2⇡µt
= f (t) (t n T )e dt
n= 1 1

X1
j2⇡µn T
= fn e
n= 1

Consider a finite sequence of samples

⇣ m ⌘
M
X1
j2⇡unm/M
DFT: Fm = F̃ = fne
M T n=0

20
DFT and IDFT
Discrete Fourier Transform (DFT)

M
X1
j2⇡mn/M
Fm = fn e
n=0

Inverse Discrete Fourier Transform (IDFT)

M
X1
1
fn = Fm ej2⇡mn/M
M m=0

21
Relation between Sampling &
Frequency Interval
• Consider ! samples of ", with interval ∆$

• The duration of the record is


• T = ! ( ∆$

• The entire frequency range is


)
• ∆*

• The spacing in the frequency domain


) )
• ∆+ = , ∆* = *

22
Chapter 4
Filtering in the Frequency Domain

Circular Convolution
4.4 The Discrete Fourier Transform (DFT) of One Variable

4.4.1 Obtaining the DFT from the Continuous Transform of a Sampled Function

Both forward and inverse discrete transforms are infinitely periodic, with period M

Where k is an integer

Discrete equivalent of the convolution:

© 1992–2008 R. C. Gonzalez & R. E. Woods

23
Chapter 4
Filtering in the Frequency Domain

Extension to Function of Two Variables


4.5 Extension to Function of Two Variables

4.5.1 The 2-D impulse and its Sifting Property

Impulse of two continuous variables t and z :

Digital Image Processing


T. Peynot

Chapter 4
Filtering in the Frequency Domain
Impulse of two continuous variables t and z :

4.5 Extension to Function of Two Variables

4.5.1 The 2-D impulse and its Sifting Property

Sifting property:
© 1992–2008 R. C. Gonzalez & R. E. Woods

24
4.5 Extension to Function of Two Variables

Extension
4.5.1 The 2-D of Discrete
impulse and its SiftingImpulse
Property

2-D discrete impulse:

Sifting property:

© 1992–2008 R. C. Gonzalez & R. E. Woods 25


Chapter 4
Filtering in the Frequency Domain

Extension of Fourier
4.5 Extension to Function of Two VariablesTransform

4.5.2 The 2-D Continuous Fourier Transform Pair

f(t,z) continuous function of two continuous variables t and z, the 2-D continuous
Fourier transform pair is given by:

and

© 1992–2008 R. C. Gonzalez & R. E. Woods

26
Digital Image Processing
T. Peynot

2D FT: Example
Chapter 4
Filtering in the Frequency Domain

Example: Obtaining the 2-D Fourier transform of a simple function

© 1992–2008 R. C. Gonzalez & R. E. Woods

27
T. Peynot

Chapter 4
Filtering in the Frequency Domain
2D Sampling
4.5.3 Two-Dimensional Sampling and the 2-D Sampling Theorem

Sampling in 2-D can be modeled using the sampling function (2-D impulse train):

Multiplying f(t,z) by yields the sampled function

© 1992–2008 R. C. Gonzalez & R. E. Woods

28
Digital Image Processing
T. Peynot

2D Sampling Theorem Chapter 4


Filtering in the Frequency Domain

f(t,z) is said to be band-limited if its Fourier transform is 0 outside of a rectangle


[- µmax, µmax] and [- νmax, νmax]
2-D sampling theorem:
A continuous, band-limited function f(t,z) can be recovered with no error from a
set of its sample if the sampling intervals are

and

© 1992–2008 R. C. Gonzalez & R. E. Woods

29
T. Peynot

Chapter 4

2D Discrete Fourier Transform (DFT) Filtering in the Frequency Domain

4.5.5 The 2-D Discrete Fourier Transform and its Inverse

2-D Discrete Fourier Transform (DFT) of a digital image f(x,y) of size MxN:

Inverse Discrete Fourier Transform (IDFT):

© 1992–2008 R. C. Gonzalez & R. E. Woods 30


2D DFT example
2D DFT example

translation
insensitive,
but rotation
sensitive
Filtering in the Frequency Domain

4.6 Some Properties of the 2-D Discrete Fourier Transform


Relations between Spatial & Frequency Domains
4.6.1 Relationships between Spatial and Frequency Domains

If ΔT and ΔZ are the separations between samples, the separations between the
corresponding discrete, frequency domain variables are:
and

© 1992–2008 R. C. Gonzalez & R. E. Woods

31
Filtering
in Frequency Domain
Chapter 4
Filtering in the Frequency Domain

2D Convolution
4.6.6 The 2-D Convolution Theorem

2-D circular convolution :

2-D convolution theorem :

and conversely:

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing

Wraparound Error & Padding


T. Peynot

Chapter 4
Filtering in the Frequency Domain

Data from adjacent periods produce


wraparound error
=> Need to append zeros to both functions

In 2-D, padd the two images array of size


MxN by zeros
Padded images of size PxQ, with:
P ≥ 2M-1
and
Q ≥ 2N-1

More 2D
© 1992–2008 R. C.wraparound/padding
Gonzalez & R. E. Woods

example see Page 281 Figure 4.32


Digital Image Processing
T. Peynot

Chapter 4

Frequency Domain Filtering: Fundamentals


Filtering in the Frequency Domain

4.7.2 Frequency Domain Filtering Fundamentals

Given a digital image f(x,y) of size MxN, the basic filtering equation is:

NB: product = array multiplication

Filtered (output) image Filter function DFT if the input image


(or filter transfer
function)

NB: For simplification, use functions H(u,v)


that are centered symmetric about their
centre
+ centre F(u,v) multiplying f(x,y) by (-1)x+y

© 1992–2008 R. C. Gonzalez & R. E. Woods


Shifting 2D Frequency Spectrum

M
X1
j2⇡ux/M
f (x) , F (u) = f (x)e
x=0
M
X1
f (x)ej2⇡(u0 x/M ) , F (u u0 ) = f (x)e j2⇡(u u0 )x/M

x=0
M
X1
x j2⇡(u M/2)x/M
f (x)( 1) , F (u M/2) = f (x)e
x=0

Extension to 2D:

f (x, y)( 1)x+y , F (u M/2, v N/2)


Digital Image Processing
T. Peynot

Filtering in Frequency Domain


Chapter 4
Filtering in the Frequency Domain

Lowpass filter highpass filter

008 R. C. Gonzalez & R. E. Woods


Chapter 4
Filtering in the Frequency Domain
Steps for Frequency Domain Filtering
4.7.3 Steps for Filtering in the Frequency Domain

1. Given an input image f(x,y) of size MxN, obtain padding parameters P and
Q. Typically, P=2M and Q=2N.
2. Form a padded image fp(x,y) of size PxQ by appending the necessary number
of zeros to f(x,y).
3. Multiply fp(x,y) by (-1)x+y to centre 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 PxQ with centre at
coordinates (P/2,Q/2). Form the product G(u,v)=H(u,v)F(u,v) using array
multiplication.
6. Obtain the processed image:
7. Obtain the final processed result, g(x,y), by extracting the MxN region from
the top, left quadrant of gp(x,y)
© 1992–2008 R. C. Gonzalez & R. E. Woods
T. Peynot

Chapter 4

Steps for Frequency Domain Filtering


Filtering in the Frequency Domain

4.7.3 Steps for Filtering in the Frequency Domain


2) Padding 3) (-1)x+y

1)

4) DFT

5) Filter H

6) Filtered
image (IDFT) 7) Final
Result
© 1992–2008 R. C. Gonzalez & R. E. Woods
Filtering in the Frequency Domain

4.8 Image Smoothing using Frequency Domain Filters

Ideal Lowpass Filter


NB: all filter functions are assumed to be discrete functions of size PxQ
Digital Image Processing
4.8.1 Ideal Lowpass Filters T. Peynot

Ideal Lowpass Filter (ILPF) = 2-D lowpass filter that passes without attenuation all
Chapter 4
frequencies within a circle of radius D0 from the origin and “cuts off” all frequencies
Filtering in the Frequency Domain
outside this circle

4.8.1 Ideal Lowpass Filters


Where:
The point of transition between H(u,v) = 1 and H(u,v) = 0 is called the cutoff frequency
And D(u,v) is the distance between a point (u,v) and the centre of the frequency rectangle:
NB: an ILPF cannot be realized with real electronic components

© 1992–2008 R. C. Gonzalez & R. E. Woods

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing
T. Peynot

Ideal Lowpass Filter (Effect) Chapter 4


Filtering in the Frequency Domain
r = 10

4.8.1 Ideal Lowpass Filters

Example:
r = 30

r = 60

r = 160 r = 460

© 1992–2008 R. C. Gonzalez & R. E. Woods


Filtering in the Frequency Domain

Ideal Lowpass: Blurring and Ringing


ng the blurring and “ringing” properties of ILPFs
T. Peynot

Chapter 4
Filtering in the Frequency Domain
Butterworth Lowpass Filter
4.8.2 Butterworth Lowpass Filters

Transfer function of a Butterworth lowpass filter (BLPF) of order n and with


cutoff frequency at a distance D0 from the origin:

© 1992–2008 R. C. Gonzalez & R. E. Woods


Chapter 4
Butterworth Lowpass
Filtering in Filter
the Frequency Domain

4.8.2 (Spatial)
Butterworth Lowpass Filters
Digital Image Processing

Butterworth Lowpass Filter (Effect)


T. Peynot

Chapter 4
Filtering in the Frequency Domain

4.8.2 Butterworth Lowpass Filters

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing
T. Peynot

Gaussian Lowpass Filter


Chapter 4
Filtering in the Frequency Domain

4.8.3 Gaussian Lowpass Filters

Gaussian Lowpass Filters (GLPFs) in two-dimensions:

(σ = measure of spread about the centre)

(D0 = cutoff frequency)

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing

Gaussian Lowpass Filter (Effect)


T. Peynot

Chapter 4
Filtering in the Frequency Domain

4.8.3 Gaussian Lowpass Filters

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing
T. Peynot

Chapter 4

Highpass Filter
Filtering in the Frequency Domain

4.9 Image Sharpening using Frequency Domain Filters

Highpass filtering: attenuation of the high-frequency components of the Fourier


transform of the image
As before :
•  Radially symmetric filters
Digital Image Processing
•  All filter functions are assumed to be discrete functions of size PxQ
T. Peynot

A highpass HHP filter can be obtainedChapter


from a given
4 lowpass HLP filter by:
Filtering in the Frequency Domain

4.9.1 Ideal Highpass Filters

A 2-D Ideal Highpass Filter (IHPF) is defined as:

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing
T. Peynot

Highpass Filters (in Frequency Domain) Chapter 4


Filtering in the Frequency Domain

Ideal Highpass Filter:

Butterworth Highpass Filter:

Gaussian Highpass Filter:

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing
T. Peynot

Highpass Filters (in Spatial Domain) Chapter 4


Filtering in the Frequency Domain

Ideal Butterworth Gaussian


Highpass Filter Highpass Filter Highpass Filter

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing
T. Peynot

Highpass Filters (Effect)


Chapter 4
Filtering in the Frequency Domain

4.9.1 Ideal Highpass Filters

Do = 30 Do = 60 Do = 160
Digital Image Processing
T. Peynot

Chapter 4
Ideal HPF Filtering in the Frequency Domain

4.9.2 Butterworth Highpass Filters

Do = 30 Do = 60Processing
Digital Image Do = 160
T. Peynot

Chapter 4

Butterfly HPF
© 1992–2008 R. C. Gonzalez & R. E. Woods
Filtering in the Frequency Domain

4.9.3 Gaussian Highpass Filters

Do = 30 Do = 60 Do = 160

Gaussian HPF
© 1992–2008 R. C. Gonzalez & R. E. Woods

© 1992–2008 R. C. Gonzalez & R. E. Woods


9.5 Unsharp Masking, Highboost Filtering and High-Frequency-Emphasis Filtering

High Frequency Emphasis Filter


Expressed in terms of frequency domain computations:
Digital Image Processing
Lowpass filter: T. Peynot

Highpass filter: Chapter 4


Filtering in the Frequency Domain
High-frequency-emphasis filter
4.9.5 Unsharp Masking, Highboost Filtering and High-Frequency-Emphasis Filtering

More general formulation:


Gaussian highpass
filtering

Where: gives controls of the offset from the origin


controls the contribution of high frequencies
High-frequency Histogram
emphasis filtering Equalisation
R. C. Gonzalez & R. E. Woods

© 1992–2008 R. C. Gonzalez & R. E. Woods

You might also like