topic_7_rev

advertisement
Department of Physics and Astronomy
DIGITAL IMAGE PROCESSING
Course 3624
Topic 7 - Fourier Transforms
Professor Bob Warwick
7.1 Review of The Fourier Transform
• Many DIP techniques rely on the application of an image
transform of which the Fourier Transform is the most popular.
• The Fourier domain provides very important insight into the
information content of the data.
Outline of this Topic
7.1 Introduction to the Fourier Transform (FT)
7.2 The Discrete Fourier Transform (DFT)
7.3 The Properties of the DFT
7.4 Computation of the DFT (via the FFT)
7.1 Introduction to the FT
In 1-d, assuming continuous variables:
f (x) Û F(u)
f (x)
Fourier Transform Pair
F(u) =
f (x) =
¥
ò
f (x)e- j2p ux dx
ò
F(u)e j2 p ux du
-¥
¥
-¥
may often be real, whereas F(u)
is generally complex, ie
F(u) = R(u)+ j I(u) = F(u) e jq (u)
Spatial Frequency
The spatial frequency of this signal
would be:
u=l
-1
with units of either:
cycles per m (physical space)
cycles per pixel (image space)
F(u) is a two-side function of u
(i.e. extends to +ve and –ve frequencies)
If f(x) is real:
F(u) = F * (-u)
\ F(u) = F(-u)
Fourier Transform of a Rectangular Function
f (x) Û F(u)
sin(p uX)
® sinc(p uX)
p uX
Amplitude = F(u) = AX sinc(p uX)
Phase = q (u) = -p uX
Fourier Transform of a Gaussian
f (x)
F(u)
f (x) Û F(u)
sx
su
x
f (x) µ e
-x 2 /2s x2
Û F(u) µ e
u
-u2 /2s u2
where s u = 1/ 2ps x
Notes:
•The Inverse Relationship – narrow
function in the spatial domain results in
a wide function in the Fourier Domain.
•In this case F(u) is not complex ie
q (u) = 0
The Impulse or Delta Function
A Table of FT Pairs
f (x) Û F(u)
RECTANGULAR FUNCTION
GAUSSIAN FUNCTION
DELTA FUNCTION
COSINE FUNCTION
SINE FUNCTION
SHAH FUNCTION
The 2-D Fourier Transform
F(u, v) =
f (x, y) =
¥ ¥
ò ò
f (x, y)e
ò ò
F(u, v)e j2 p (ux+vy)du dv
-¥ -¥
¥ ¥
- j2 p (ux+vy)
-¥ -¥
Example: The "Box Car" Function
y
dx dy
x
v
u
More on Convolution Integrals
f (x)* h(x) =
¥
ò
f (a )h(x - a )da
-¥
f (x, y)* h(x, y) =
¥ ¥
ò ò
f (a, b )h(x - a, y - b )da d b
-¥ -¥
Example: Convolution of a Shah Function with a Rectangular Function
The CONVOLUTION THEOREM: the Fourier Transform of the
product of two functions equals the convolution of the Fourier
transforms of the individual functions.
f (x) ´ h(x) Û F(u)* H (u)
Conversely:
f (x)* h(x) Û F(u) ´ H (u)
7.2 The Discrete Fourier Transform (DFT)
Consider a 1-d sampled dataset of dimension N:
f0 f1 f2 f3
fx¢
f
x¢ index
N-1
0 ® N -1
x continuous variable 0 ® X
X
N
x = (x¢ + 0.5)Dx » x¢Dx
Dx =
x=0
F(u) =
F(u) =
x=X
¥
ò
f (x)e- j2p ux dx @
-¥
N -1
X
ò f (x)e- j2p ux dx
0
å fx'e- j2p ux¢Dx Dx
x¢ index, u continuous variable
x¢=0
We need to evaluate F(u) on a grid of N points (in u space). A good choice for the
spacing is Δu=1/X (=1 cycle across the full extent of the image)
F0 F1 F2 F3
u=0
Fu¢
F
N-1
Du =
Fu¢ = Dx å fx' e- j 2 p u¢x¢ Dx Du Also:
x¢=0
0 ® N -1
u continuous variable 0 ®U
u =U
N -1
u¢ index
1
1
\U = NDu =
X
Dx
fx¢ = Du
N -1
(ie 1 cycle per pixel)
å Fu' e j 2p u¢x¢ Dx Du
u¢=0
The DFT continued
Finally we set
DuDx =
1
N
1
Fu =
N
fx =
, we redistribute the normalization term and drop the dashes:
N -1
åf
x
e
-
j 2 p ux
N
u = 0 ® N -1
x=0
N -1
åF
u
e
+
j 2 p ux
N
x = 0 ® N -1
u=0
EXAMPLE: Determine the DFT of a 4-point dataset with input values:
f0 = 1
f1 = 1
f2 = 0
f3 = 0
Fu =
1 3
fx e
å
4 x=0
j 2 p ux
4
u=0®3
1
F0 = (f0 + f1 + f2 + f3 )
4
1
F1 = (f0 - jf1 - f2 + jf3 )
4
1
F2 = (f0 - f1 + f2 - f3 )
4
1
F3 = (f0 + jf1 - f2 - jf3 )
4
1
=
2
1
j
= 4
4
=0
=
1
j
+
4 4
|Fu|
X
X
X
X
X
X
X
X
X
-4 -3 -2 -1 0 1 2 3 4
Why the periodicity?
X
X
5 6
X
7
u
7.3 Some Properties of the DFT
(a) SAMPLING THEORY
Input data stream
(continuous variables)
Represent sampling by a
comb of delta functions
s(x) [a Shah Function]
The sampled version of
f(x) can be represented
by s(x)f(x)
Assume F(u) is zero
outside range -w<u<w
S(u) is a Shah Function
with spacing Δu=1/Δx
In the Fourier domain we
have the convolution
S(u)*F(u)
This explains the periodic nature of the DFT ie it repeats at a rate (in u) of 1/Δx
However, if the bandwidth of the
input signal w is too high , such that
w > 1/2Δx, then the result will be 
The overlap of the repeating functions
results in information loss 
ALIASING
Some Properties of the DFT cont.
(b) SHANNON’S SAMPLING THEOREM
To avoid information loss it is necessary to sample a signal at a rate equivalent
to at least twice the maximum frequency component present in the signal.
That is we need w < 1/2Δx, where 1/2Δx is known as the Nyquist frequency.
✖
✔
To avoid aliasing
sample at a higher
rate
(or alternatively filter
the input data stream
to remove signals
above the Nyquist
frequency)
The process
to recover
the original
data stream!
Some Properties of the DFT cont.
(c) CHARACTER OF THE DFT
Example: 1-d 8-point transform.
1´ Du =
fx

0
1
2
3
4
5
6
7
x
1
1
=
1 cycle per 8 pixels
X NDx
1 cycle per 2 pixels
N
1
´ Du =
2
2Dx
Nyquist frequency
N ´ Du =
|Fu|
0
N=8
1
2
3
4
5
1
The sampling rate
Dx
6
7
x
N=8
(d) The 2-D DFT
N -1 N -1
j 2 p (ux+vy)
N
N -1 N -1
j 2 p (ux+vy)
N
1
Fuv =
fxy e
å
å
N x=0 y=0
+
1
fxy =
Fuv e
å
å
N u=0 v=0
(e) The Optical Transform
u = 0 ® N -1
v = 0 ® N -1
x = 0 ® N -1
y = 0 ® N -1
A trick to shift the (u,v) origin from the top left corner to the centre of the Fuv image is to multiply the
input image by alternate 1’s and -1’s before computing the DFT i.e.
fxy ´ (-1)x+y
The Optical Transform
7.4 Computation of the DFT
In DIP applications we need to compute the 2-d
DFT
j 2 p (ux+vy)
N -1 N -1
1
u = 0 ® N -1
N
Fuv =
f
e
xy
å
å
N x=0 y=0
v = 0 ® N -1
The “separability” property of the 2-d transform leads to a simplification:
N -1
Rearranging:
1
Fuv =
e
å
N x=0
j 2 p ux N -1
N
fxy
å
e
Writing:
Then:
1
Fuv =
Fxv e
å
N x=0
x
u = 0 ® N -1
v = 0 ® N -1
u = 0 ® N -1
v
1

Hence, the 2-d
DFT reduces to the
computation of a
series of 1-d
transforms.
v = 0 ® N -1
j 2 p ux
N
y
fxy
j 2 p vy
N
y=0
j 2 p vy ù
é
N -1
1
ê
Fxv = N
å fxy e N úú
ê N y=0
ë
û
N -1
-
Fxv
x
v
2

Fu
u
v
Step 1 involves N 1-d transforms along the rows of the original image (x N scaling)
Step 2 involves N 1-d transforms down the columns of the intermediate image
In total we require 2N 1-d transforms, each of which involves N x N
complex multiplies and adds ie
N4  2N3 calculations
The FFT Algorithm
Implementation of the FFT Algorithm
A Fortran FFT Routine
Re-ordering
Successive
doubling
Calculating the Inverse Fourier Transform
Fu =
fx =
N -1
1
fx e
å
N x=0
N -1
-
å Fu e
j 2 p ux
N
+
x = 0 ® N -1
j 2 p ux
N
u = 0 ® N -1
u=0
If we take the complex conjugate of the inverse transform and scale by 1/N:
1 *
1
fx =
N
N
N -1
*
F
å ue
-
j 2 p ux
N
u=0
To calculate the Inverse Transform with a software procedure that computes the 1-d
“forward” transform:
(i)Convert Fu  Fu*
(ii) Apply the forward transform
(iii) Scale the result by N
(iv) Convert fx*  fx
Example of a 2-d DFT calculation
fxy
|Fuv |
(-1)x+y
log |Fuv |
And the Inverse ….
(-1)x+y
Ignoring the phase!
Ignoring the amplitude!
Example of a 2-d DFT
log |Fuv|
Richard Alan Peters II
Magnitude-only Reconstruction
Phase-only Reconstruction
Download