Lec012 Frequency

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 20

1

CSE397/497-011 Real-time Image Processing


for Autonomous Robot Systems
Department of
Computer Science & Engineering
P.C. Rossin
College of Engineering
and Applied Science
Lecture 12: Image Processing
in the Frequency Domain
CSE397/497 Real-time Image Processing
JR Spletzer
Class Objectives/Announcements
Review of RIP06 Grand Challenge Rules
Questions?
Objectives
Investigate image representation, analysis and processing
techniques in the frequency domain
Review of Fourier Transforms
Questions about homework assignment?
2
CSE397/497 Real-time Image Processing
JR Spletzer
References
Gonzalez and Woods, Digital Image Processing,
Chapter 4
HIPR2, Fourier Transform,
http://homepages.inf.ed.ac.uk/rbf/HIPR2/fourier.htm
CVOnline, Fourier Methods,
http://homepages.inf.ed.ac.uk/rbf/CVonline/LOCAL_COPIES/MARSHALL/node15.html
CSE397/497 Real-time Image Processing
JR Spletzer
Things weve forgotten from Calculus
Eulers Identity
) sin( ) cos( t i t e
t i

+ =
2
) cos(
t i t i
e e
t

+
=
i
e e
t
t i t i
2
) sin(

=
3
CSE397/497 Real-time Image Processing
JR Spletzer
Definitions
Spatial Domain (I)
Normal image space
Changes in pixel positions correspond to changes in the scene
Distances in I correspond to real distances
Frequency Domain (F)
Changes in image position correspond to changes in the spatial
frequency
This is the rate at which image intensity values are changing in
the spatial domain image I
CSE397/497 Real-time Image Processing
JR Spletzer
Image Processing
Spatial Domain (I)
Directly process the input image pixel array
Frequency Domain (F)
Transform the image to its frequency representation
Perform image processing
Compute inverse transform back to the spatial domain
4
CSE397/497 Real-time Image Processing
JR Spletzer
Frequencies in an Image
Any spatial or temporal signal has an equivalent
frequency representation
What do frequencies mean in an image ?
High frequencies correspond to pixel values that change
rapidly across the image (e.g. text, texture, leaves, etc.)
Strong low frequency components correspond to large scale
features in the image (e.g. a single, homogenous object that
dominates the image)
We will investigate Fourier transformations to obtain
frequency representations of an image
CSE397/497 Real-time Image Processing
JR Spletzer
The Fourier Series
Periodic functions can be expressed as the sum of sines
and/or cosines of different frequencies each multiplied
by a different coefficient
=
+ + +
5
CSE397/497 Real-time Image Processing
JR Spletzer
The Fourier Transform
Functions that are NOT periodic BUT with finite area under the
curve can be expressed as the integral of sines and/or cosines
multiplied by a weight function

= dx e x f u F
ux j 2
) ( ) (


= du e u F x f
ux j 2
) ( ) (
Fourier
Transform
Inverse
Fourier
Transform
Fourier
Analysis
Fourier
Synthesis
CSE397/497 Real-time Image Processing
JR Spletzer
The FT transforms can be easily extended to 2 (and n
dimensions)
The Fourier transform for f(x) exists iff
1. f(x) is piecewise continuous on every finite interval
2. f(x) is absolutely integrable


+
= dxdy e y x f v u F
vy ux j ) ( 2
) , ( ) , (


+
= dudv e v u F y x f
vy ux j ) ( 2
) , ( ) , (

The Fourier Transform
6
CSE397/497 Real-time Image Processing
JR Spletzer
) ( ) ( ) ( g bF f aF bg af F + = +
Properties of the Fourier Transform
The FT is a linear operator
Some other useful properties include
Discrete
Real
f+g
f*g
Periodic
Symmetric
F+G
FG
CSE397/497 Real-time Image Processing
JR Spletzer
Some Fundamental Transform Pairs
Box Sinc

= dx e x f u F
xu j 2
) ( ) (
( )
u
u
e e
u j
dx e
u j u j
xu j

2 sin
2
1
2 2
1
1
2
=

=
=

7
CSE397/497 Real-time Image Processing
JR Spletzer
Some Fundamental Transform Pairs
Gaussian Gaussian

= dx e x f u F
xu j 2
) ( ) (
( )
a u
ax ax
ax
e
a
dx ux e j dx ux e
dx ux j ux e
/
2 2
2 2
2
2 sin 2 cos
2 sin 2 cos

=
=
=

CSE397/497 Real-time Image Processing


JR Spletzer
The Discrete Fourier Transform
Since we are dealing with images, we will be more
interested in the discrete Fourier Transform (DFT)
For a function f(x), x=0,1,,M-1 we have
For discrete functions, the DFT and iDFT always exist
1 ,..., 0 , ) (
1
) (
1
0
/ 2
= =

M u e x f
M
u F
M
x
M ux j
1 ,..., 0 , ) ( ) (
1
0
/ 2
= =

=
M x e u F x f
M
x
M ux j
iDFT
8
CSE397/497 Real-time Image Processing
JR Spletzer
The Discrete Fourier Transform
Recall Eulers Formula
from which we obtain
for u = 0,,M-1
Each term is composed of ALL values of f(x)
The values of u are the frequency domain
Each F(u) is a frequency component of the transform

sin cos j e
j
+ =

=
|

\
|
=
1
0
2
sin
2
cos ) (
1
) (
M
x
M
ux
j
M
ux
x f
M
u F

CSE397/497 Real-time Image Processing
JR Spletzer
The 2-D Discrete Fourier Transform
Since our images are nothing more than 2-D discrete
functions, we are interested in the 2-D DFT
for u=0,,M-1 and v=0,,N-1 and the iDFT is defined
as

=
+
=
1
0
1
0
) / / ( 2
) , (
1
) , (
M
x
N
y
N vy M ux j
e y x f
MN
v u F

=
+
=
1
0
1
0
) / / ( 2
) , ( ) , (
M
x
N
y
N vy M ux j
e v u F y x f

9
CSE397/497 Real-time Image Processing
JR Spletzer
Some Fundamental Transform Pairs
Comb Comb
w
2/w
CSE397/497 Real-time Image Processing
JR Spletzer
Sampling
Sampling is equivalent to multiplying with a comb
filter in the spatial domain
This corresponds to convolving with a comb filter in
the frequency domain
Fine sampling in spatial Spread out filter in the
frequency domain
Coarse sampling in Spatial Close filter in the
frequency domain
10
CSE397/497 Real-time Image Processing
JR Spletzer
Sampling Limits
Shannons Sampling Theorem states that if a function
f is sampled at a rate twice its highest frequency, f
can be completely recovered from its samples
This is known as the Nyquist Frequency Limit
The sampling rate in images is the pixels/unit distance
CSE397/497 Real-time Image Processing
JR Spletzer
Aliasing
For an image sampled spatially, the shortest
wavelength that be represented is 2 pixels
When a signal is under-sampled, aliasing can result
Aliasing is when a high frequency signal masquerades
as a lower frequency signal
11
CSE397/497 Real-time Image Processing
JR Spletzer
Aliasing Examples
600 dpi
Scan
Moire
Pattern
* Wikipedia
How might we
handle this effect?
75 dpi
Scan
CSE397/497 Real-time Image Processing
JR Spletzer
Since the values of the FT are complex numbers, it is
sometimes more convenient to express F(u) in terms of
polar coordinates
where the magnitude or spectrum is denoted by
and the phase angle by
DFT (Continued)
[ ]
2
1
2 2
) , ( ) , ( ) , ( v u I v u R v u F + =

=

) , (
) , (
tan ) , (
1
v u R
v u I
v u
) , (
) , ( ) , (
v u j
e v u F v u F

=
12
CSE397/497 Real-time Image Processing
JR Spletzer
At u=v=0, the FDT reduces to
This is nothing more than the average grayscale level
of the image
This is often referred to as the DC Component (0
frequency)

=
=
1
0
1
0
) , (
1
) 0 , 0 (
M
x
N
y
y x f
MN
F

=
+
=
1
0
1
0
) / / ( 2
) , (
1
) , (
M
x
N
y
N vy M ux j
e y x f
MN
v u F

DFT (Continued)
CSE397/497 Real-time Image Processing
JR Spletzer
The FT has the following translation property
which for u
0
=M/2 and v
0
=N/2 we see that
In image processing, it is common to multiply the input
image by (-1)
x+y
prior to computing F(u,v)
This has the effect of centering the transform since
F(0,0) is now located at u=M/2, v=N/2
) 2 / , 2 / ( ) ) 1 )( , ( ( N v M u F y x f F
y x
=
+
y x y x j N vy M ux j
e e
+ + +
= = ) 1 (
) ( ) / / ( 2
) , ( ) , (
0 0
) / / ( 2
0 0
v v u u F e y x f
N y v M x u j

+
DFT (Continued)
13
CSE397/497 Real-time Image Processing
JR Spletzer
For an image sampled spatially, the highest frequency
that can be represented is image size/2
To demonstrate this, we look at an image with 1 pixel
wide vertical bars
Note that the dominant frequency component in the
FT is at the max frequency 100/2 = 50 Hz
FFT Example
CSE397/497 Real-time Image Processing
JR Spletzer
If the bars are twice as wide, then we should expect
that the dominant frequency will drop off accordingly
Again, looking at the FT we see (as expected) that the
dominant harmonic component is at 25
FFT Example
14
CSE397/497 Real-time Image Processing
JR Spletzer
Now lets look at a checkerboard pattern
We now pick up the horizontal, vertical and diagonal
frequency components
FFT Example
CSE397/497 Real-time Image Processing
JR Spletzer
) ( ) ( ) ( g bF f aF bg af F + = +
Properties of the Fourier Transform
The FT is a linear operator
Some other useful properties include
Discrete
Real
f+g
f*g
Periodic
Symmetric
F+G
FG
Basis for
filtering in the
frequency domain!
15
CSE397/497 Real-time Image Processing
JR Spletzer
Procedure for Filtering in the Frequency Domain
1. Multiply the input image by (-1)
x+y
to center the
transform
2. Compute the DFT F(u,v) of the resulting image
3. Multiply F(u,v) by a filter G(u,v)
4. Computer the inverse DFT transform h*(x,y)
5. Obtain the real part h(x,y) of 4
6. Multiply the result by (-1)
x+y
CSE397/497 Real-time Image Processing
JR Spletzer
Traditionally, we would just convolve the image
with the a gaussian kernel
Instead, we will perform multiplication in the
frequency domain to achieve the same effect
Filtering Example
Smooth an Image with a Gaussian Kernel
256 /
1 4 6 4 1
4 16 24 16 4
6 24 36 24 6
4 16 24 16 4
1 4 6 4 1

* =
16
CSE397/497 Real-time Image Processing
JR Spletzer
1. Multiply the input image by (-1)
x+y
to center the
transform
Filtering Example
Smooth an Image with a Gaussian Kernel
CSE397/497 Real-time Image Processing
JR Spletzer
2. Compute the DFT F(u,v) of the resulting image
log transform
Filtering Example
Smooth an Image with a Gaussian Kernel
17
CSE397/497 Real-time Image Processing
JR Spletzer
3. Multiply F(u,v) by a filter G(u,v)
256 /
1 4 6 4 1
4 16 24 16 4
6 24 36 24 6
4 16 24 16 4
1 4 6 4 1

g(x,y)
G(u,v)
Filtering Example
Smooth an Image with a Gaussian Kernel
CSE397/497 Real-time Image Processing
JR Spletzer
x
3. Multiply F(u,v) by a filter G(u,v)
Filtering Example
Smooth an Image with a Gaussian Kernel
18
CSE397/497 Real-time Image Processing
JR Spletzer
4. Computer the inverse DFT transform h*(x,y)
5. Obtain the real part h(x,y) of 4
6. Multiply the result by (-1)
x+y
Filtering Example
Smooth an Image with a Gaussian Kernel
CSE397/497 Real-time Image Processing
JR Spletzer
) , ( ) , ( y x g y x f ) , ( ) , ( v u G v u F
Filtering Example
Smooth an Image with a Gaussian Kernel
19
CSE397/497 Real-time Image Processing
JR Spletzer
Other Applications of the DFT
Geometrical Information
At times, we can also infer geometric information
about the image from the DFT
The DFT (and its log transform) show after thresholding
the vertical orientation of the banding in this image
* HIPR2
CSE397/497 Real-time Image Processing
JR Spletzer
Geometrical Information
If we rotate the image, the primary frequency
components are similarly aligned
The secondary axis is the result of the black triangles
in the image
* HIPR2
20
CSE397/497 Real-time Image Processing
JR Spletzer
Summary
Images have both spatial and frequency representations
We use the DFT to obtain the latter
High texture results in high frequency components, while solid,
homogenous objects correspond to low frequency components
Aliasing is when high frequency components masquerade as low
frequency ones, and can result from improper image sampling
The effect can be eliminated by filtering out high frequency
components of the signal
Convolution and multiplication are duals in the spatial/frequency
domains
Although multiplication is MUCH more efficient than convolution,
there is a high cost in computing the DFT and iDFT
As such, most convolutions are carried out in the spatial domain
(unless the kernel is sufficiently large)

You might also like