0% found this document useful (0 votes)
17 views72 pages

Chapter 04

The document discusses Fourier transforms and their application to digital image processing. It provides background on Fourier series and how they can represent periodic signals as weighted sums of sinusoids. It then covers 1D and 2D discrete Fourier transforms, including their properties and computational advantages. It also discusses how to compute 2D DFTs using 1D DFTs and conventions for displaying DFT results.

Uploaded by

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

Chapter 04

The document discusses Fourier transforms and their application to digital image processing. It provides background on Fourier series and how they can represent periodic signals as weighted sums of sinusoids. It then covers 1D and 2D discrete Fourier transforms, including their properties and computational advantages. It also discusses how to compute 2D DFTs using 1D DFTs and conventions for displaying DFT results.

Uploaded by

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

Digital Image Processing

Chapter 4:
Image Enhancement in the
Frequency Domain
Background: Fourier Series

Fourier series:
Any periodic signals can be
viewed as weighted sum
of sinusoidal signals with
different frequencies

Frequency Domain:
view frequency as an
independent variable
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Fourier Tr. and Frequency Domain

Fourier Tr.
Time, spatial Frequency
Domain Domain
Signals Inv Fourier Tr. Signals

1-D, Continuous case


 f ( x )e
 j 2ux
Fourier Tr.: F (u )  dx


 F (u )e
j 2ux
Inv. Fourier Tr.: f ( x)  du

Fourier Tr. and Frequency Domain (cont.)
1-D, Discrete case
M 1
1
Fourier Tr.: F (u ) 
M
 f ( x )e
x 0
 j 2ux / M
u = 0,…,M-1
M 1
Inv. Fourier Tr.: f ( x)   F
u 0
( u ) e j 2ux / M
x = 0,…,M-1

F(u) can be written as


F (u )  R (u )  jI (u ) or F (u )  F (u ) e  j ( u )
where
 I (u ) 
F (u )  R (u )  I (u )
2 2  (u )  tan 1

 R (u ) 
Example of 1-D Fourier Transforms

Notice that the longer


the time domain signal,
The shorter its Fourier
transform

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Relation Between x and u
For a signal f(x) with M points, let spatial resolution x be space
between samples in f(x) and let frequency resolution u be space
between frequencies components in F(u), we have
1
u 
M x
Example: for a signal f(x) with sampling period 0.5 sec, 100 point,
we will get frequency resolution equal to

1
u   0.02 Hz
100  0.5

This means that in F(u) we can distinguish 2 frequencies that are


apart by 0.02 Hertz or more.
2-Dimensional Discrete Fourier Transform

For an image of size MxN pixels


2-D DFT
M 1 N 1
1
F ( u, v ) 
MN

x 0 y 0
f ( x, y )e  j 2 ( ux / M  vy / N )

u = frequency in x direction, u = 0 ,…, M-1


v = frequency in y direction, v = 0 ,…, N-1

2-D IDFT
M 1 N 1
f ( x, y )   F (u, v )e
u 0 v 0
j 2 ( ux / M  vy / N )

x = 0 ,…, M-1
y = 0 ,…, N-1
2-Dimensional Discrete Fourier Transform (cont.)

F(u,v) can be written as


 j ( u ,v )
F (u, v )  R (u, v )  jI (u, v ) or F ( u, v )  F ( u, v ) e
where
 I ( u, v ) 
F ( u, v )  R ( u, v )  I ( u, v )
2 2
 (u, v )  tan 
1

 R ( u, v ) 

For the purpose of viewing, we usually display only the


Magnitude part of F(u,v)
2-D DFT Properties

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
2-D DFT Properties (cont.)

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
2-D DFT Properties (cont.)

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
2-D DFT Properties (cont.)

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Computational Advantage of FFT Compared to DFT

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Relation Between Spatial and Frequency Resolutions

1 1
u  v 
M x Ny

where
x = spatial resolution in x direction
y = spatial resolution in y direction

x and y are pixel width and height. )


u = frequency resolution in x direction
v = frequency resolution in y direction
N,M = image width and height
How to Perform 2-D DFT by Using 1-D DFT

1-D
DFT
f(x,y) by row F(u,y)
1-D DFT
by column

F(u,v)
How to Perform 2-D DFT by Using 1-D DFT (cont.)

Alternative method

f(x,y)
1-D DFT
by column

1-D
DFT
F(x,v) by row F(u,v)
Periodicity of 1-D DFT
M 1
1
From DFT: F (u ) 
M
 f ( x )e
x 0
 j 2ux / M

-N 0 N 2N

We display only in this range

DFT repeats itself every N points (Period = N) but we usually


display it for n = 0 ,…, N-1
Conventional Display for 1-D DFT

F (u )
f(x)
DFT

0 N-1 0 N-1

Time Domain Signal


High frequency
area
Low frequency
area

The graph F(u) is not


easy to understand !
Conventional Display for DFT : FFT Shift
F (u )
FFT Shift: Shift center of the
graph F(u) to 0 to get better
Display which is easier to
understand.

0 N-1 F (u )

High frequency area

Low frequency area


-N/2 0 N/2-1
Periodicity of 2-D DFT
M 1 N 1
1
2-D DFT: F ( u, v ) 
MN

x 0 y 0
f ( x, y )e  j 2 ( ux / M  vy / N )
g(x,y)

-M

For an image of size NxM


pixels, its 2-D DFT repeats
0 itself every N points in x-
direction and every M points
in y-direction.
M

We display only
2M in this range
-N 0 N 2N (Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Conventional Display for 2-D DFT

F(u,v) has low frequency areas


at corners of the image while high
frequency areas are at the center
of the image which is inconvenient
to interpret.

High frequency area

Low frequency area

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
2-D FFT Shift : Better Display of 2-D DFT
2-D FFT Shift is a MATLAB function: Shift the zero frequency
of F(u,v) to the center of an image.

2D FFTSHIFT

(Images from Rafael C. Gonzalez and Richard E. High frequency area Low frequency area
Wood, Digital Image Processing, 2nd Edition.
2-D FFT Shift (cont.) : How it works

-M

Display of 2D DFT
After FFT Shift
M

Original display
2M
of 2D DFT
-N 0 N 2N

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Example of 2-D DFT

Notice that the longer the time domain signal,


The shorter its Fourier transform
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Example of 2-D DFT

Notice that direction of an


object in spatial image and
Its Fourier transform are
orthogonal to each other.

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Example of 2-D DFT

2D DFT

Original image

2D FFT Shift
Example of 2-D DFT

2D DFT

Original image

2D FFT Shift
Basic Concept of Filtering in the Frequency Domain
From Fourier Transform Property:

g ( x , y )  f ( x , y )  h ( x , y )  F ( u, v )  H ( u, v )  G ( u, v )

We cam perform filtering process by using

Multiplication in the frequency domain


is easier than convolution in the spatial
Domain.

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Filtering in the Frequency Domain with FFT shift

H(u,v)
F(u,v) g(x,y)
(User defined)

FFT shift
X 2D IFFT

2D FFT
FFT shift

f(x,y) G(u,v)

In this case, F(u,v) and H(u,v) must have the same size and
have the zero frequency at the center.
Multiplication in Freq. Domain = Circular Convolution

f(x) DFT F(u)


G(u) = F(u)H(u) IDFT g(x)
h(x) DFT H(u)
Multiplication of 1

DFTs of 2 signals 0.5 f(x)


is equivalent to
0
perform circular 0 20 40 60 80 100 120
convolution 1
in the spatial domain.
0.5 h(x)
0
“Wrap around” effect 0 20 40 60 80 100 120

40

20
g(x)
0
0 20 40 60 80 100 120
Multiplication in Freq. Domain = Circular Convolution

Original H(u,v)
image Gaussian
Lowpass
Filter with
D0 = 5

Filtered image
(obtained using
circular convolution)

Incorrect areas at image rims


Linear Convolution by using Circular Convolution and Zero Padding

f(x) Zero padding DFT F(u)


G(u) = F(u)H(u)
h(x) Zero padding DFT H(u)
1
IDFT

0.5
Concatenation
0
0 50 100 150 200 250
1 g(x)
0.5

0 Padding zeros
0 50 100 150 200 250 Before DFT
40
Keep only this part
20

0
0 50 100 150 200 250
Linear Convolution by using Circular Convolution and Zero Padding

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Linear Convolution by using Circular Convolution and Zero Padding

Filtered image

Zero padding area in the spatial


Domain of the mask image Only this area is kept.
(the ideal lowpass filter)
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Filtering in the Frequency Domain : Example
In this example, we set F(0,0) to zero
which means that the zero frequency
component is removed.

Note: Zero frequency = average


intensity of an image (Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Filtering in the Frequency Domain : Example

Lowpass Filter

Highpass Filter

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Filtering in the Frequency Domain : Example (cont.)

Result of Sharpening Filter

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Filter Masks and Their Fourier Transforms

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Ideal Lowpass Filter
Ideal LPF Filter Transfer function

1 D (u, v )  D0
H ( u, v )  
0 D (u, v )  D0
where D(u,v) = Distance from (u,v) to the center of the mask.

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Examples of Ideal Lowpass Filters

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.

The smaller D0, the more high frequency components are removed.
Results of Ideal Lowpass Filters

Ringing effect can be


obviously seen!

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
How ringing effect happens

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

Surface Plot

0.8

0.6

Ideal Lowpass Filter 0.4

with D0 = 5 0.2

20
20
0
0
Abrupt change in the amplitude -20 -20
How ringing effect happens (cont.)

Surface Plot
-3
x 10

15

Spatial Response of Ideal 10

Lowpass Filter with D0 = 5 5

20
20
0
Ripples that cause ringing effect -20 -20
0
How ringing effect happens (cont.)

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Butterworth Lowpass Filter
Transfer function
1
H ( u, v ) 
1  D (u, v ) / D0 
2N

Where D0 = Cut off frequency, N = filter order.

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Results of Butterworth Lowpass Filters

There is less ringing


effect compared to
those of ideal lowpass
filters!
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Spatial Masks of the Butterworth Lowpass Filters

(Images from Rafael C. Gonzalez and Richard E.


Some ripples can be seen.
Wood, Digital Image Processing, 2nd Edition.
Gaussian Lowpass Filter
Transfer function
 D 2 ( u ,v ) / 2 D0 2
H ( u, v )  e
Where D0 = spread factor.

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.

Note: the Gaussian filter is the only filter that has no ripple and
hence no ringing effect.
Gaussian Lowpass Filter (cont.)
 D 2 ( u ,v ) / 2 D0 2
H ( u, v )  e
1

0.8

0.6
Gaussian lowpass
0.4 filter with D0 = 5
0.2

20
20
0
0
-20 -20

0.03

Spatial respones of the 0.02

Gaussian lowpass filter 0.01

with D0 = 5 0

20
20
0
0
-20 -20
Gaussian shape
Results of Gaussian Lowpass Filters

No ringing effect!

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Application of Gaussian Lowpass Filters

Original image Better Looking

The GLPF can be used to remove jagged edges


(Images from Rafael C. Gonzalez and Richard E.
and “repair” broken characters.
Wood, Digital Image Processing, 2nd Edition.
Application of Gaussian Lowpass Filters (cont.)
Remove wrinkles

Original image

Softer-Looking

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Application of Gaussian Lowpass Filters (cont.)

Original image : The gulf of Mexico and Filtered image


Florida from NOAA satellite. (Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.

Remove artifact lines: this is a simple but crude way to do it!


Highpass Filters

Hhp = 1 - Hlp

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Ideal Highpass Filters
Ideal LPF Filter Transfer function

0 D (u, v )  D0
H ( u, v )  
1 D (u, v )  D0
where D(u,v) = Distance from (u,v) to the center of the mask.

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Butterworth Highpass Filters
Transfer function
1
H ( u, v ) 
1  D0 / D (u, v )
2N

Where D0 = Cut off frequency, N = filter order.

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Gaussian Highpass Filters
Transfer function
 D 2 ( u ,v ) / 2 D0 2
H ( u, v )  1  e
Where D0 = spread factor.

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Gaussian Highpass Filters (cont.)

 D 2 ( u ,v ) / 2 D0 2
1 H ( u, v )  1  e
0.8

0.6 Gaussian highpass


0.4 filter with D0 = 5
0.2

0
60
60
40 50
40
20 30
20
10

3000

2000

Spatial respones of the 1000

Gaussian highpass filter 0

with D0 = 5 60
60
40 50
40
20 30
20
10
Spatial Responses of Highpass Filters

Ripples

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Results of Ideal Highpass Filters

Ringing effect can be


obviously seen!

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Results of Butterworth Highpass Filters

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Results of Gaussian Highpass Filters

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Laplacian Filter in the Frequency Domain
From Fourier Tr. Property: d n f ( x)
n
  ju n
F (u )
dx
Then for Laplacian operator
2 f 2 f
 f  2  2   u 2  v 2 F (u, v )
2

x y
We get
2   u 2  v 2 

Image of
–(u2+v2)

Surface plot (Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Laplacian Filter in the Frequency Domain (cont.)

Spatial response of –(u2+v2) Cross section

Laplacian mask in Chapter 3


Sharpening Filtering in the Frequency Domain
Spatial Domain
f hp ( x, y )  f ( x, y )  f lp ( x, y )

f hb ( x, y )  Af ( x, y )  f lp ( x, y )

f hb ( x, y )  ( A  1) f ( x, y )  f ( x, y )  f lp ( x, y )

f hb ( x, y )  ( A  1) f ( x, y )  f hp ( x, y )

Frequency Domain Filter

H hp (u, v )  1  H lp (u, v )

H hb (u, v )  ( A  1)  H hp (u, v )

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Sharpening Filtering in the Frequency Domain (cont.)

p 2 P

2 P P  2 P

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Sharpening Filtering in the Frequency Domain (cont.)
f hb ( x, y )  ( A  1) f ( x, y )  f hp ( x, y )

f f hp  2 P

A=2 A = 2.7

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
High Frequency Emphasis Filtering
H hfe (u, v )  a  bH hp (u, v )
Original Butterworth
highpass
filtered
image

High freq. emphasis After


filtered image Hist
Eq.

a = 0.5, b = 2
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Homomorphic Filtering
An image can be expressed as

f ( x, y )  i ( x, y ) r ( x, y )
i(x,y) = illumination component
r(x,y) = reflectance component

We need to suppress effect of illumination that cause image


Intensity changed slowly.
Homomorphic Filtering

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Homomorphic Filtering

More details in the room can be seen!

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Correlation Application: Object Detection

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.

You might also like