Professional Documents
Culture Documents
EECE/CS 253 Image Processing: Richard Alan Peters II
EECE/CS 253 Image Processing: Richard Alan Peters II
This work is licensed under the Creative Commons Attribution-Noncommercial 2.5 License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc/2.5/ or
send a letter to Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA.
Signal:
A measurable phenomenon that changes over time
or throughout space.
sound image
code
01101000101101110110010110001
string sound
pipe sound
1999-2007 by Richard Alan Peters
Saturday, April 23, 2022
202 6
II
2
Sound Waves: Emerge from the superposition of the modes.
string sound
pipe sound
The vibratory modes
add up to one complex
Even-order Odd-order
motion that pushes
harmonics harmonics
the air around the
vibrating object
a Frequency-Domain sq t
1 2
sin 2n 1 t
Representation n 2n 1
1 2
sin 2n 1 t
sq t
n 2n 1
1 2
sin 2n 1 t
sq t
n 2n 1
1 2
sin 2n 1 t
sq t
n 2n 1
1
the limit as n
approaches
infinity of the
sum of n sines.
8 sines 16 sines 32 sines
1024
1024
/2
/2
f t e i t dt
/2
/2
f,g t i sin t dt
f t cos 2
2
/2
/2 2
i t Complex number result
f t e
dt yields the amplitude and
/2
phase of that sinusoid in
/2
the function.
f t e i t dt
/2
2 n 2 n The representation of a
f t A0 An cos t Bn sin t function by its Fourier
n 1 Series is the sum of sinu-
soidal “basis functions”
periodic : such that f (t n ) f (t ). multiplied by coefficients.
/2
Fourier coefficients are
2 2 n dt for n 0
An f t cos t n
generated by taking the
inner product of the
/ 2 function with the basis.
/2
2 2 n
t n dt for n 0
The basis functions
Bn f t sin correspond to modes
/ 2 of vibration.
2 n 2 n
i t n
i 1
i t
f t Cn e Cn e
n n
2 n 2 n
Cn cos t n i Cn sin t n Cn Cn e i n
n
1
/2
i
2 n
t e i x cos x i sin x
Cn Cn e i n
/ 2
f t e dt
/2 f ( t n ) f ( t )
1 2 n 2 n
f t cos t n i sin t n dt for all intergers n
/ 2
1 /2 1 /2
f t f cos n n t d i f sin n n t d .
n / 2 n / 2
Cn represents the
amplitude, A=|Cn|,
and relative phase, f ,
of that part of the
original signal, f (t), 0
that is a sinusoid of
frequency wn = n / l.
Time-domain
signal
Fourier
magnitude
Fourier
phase
f t F e i 2 t d F e i 2 t d
F cos 2 t i sin 2 t d
F cos 2 t i sin 2 t d
1 N 1
Hn hk e i 2 k n /N
N k0
1999-2007 by Richard Alan Peters
Saturday, April 23, 2022
202 33
II
2
The Two-Dimensional Fourier Transform
and
N 1
1 discrete signals
Hn
N
he
n 0
k
i 2 k n / N
hk , e i 2 k n / N
with N terms or
samples.
, if 1 2
e i 2 1 t
, e i 2 2 t
e i 2 1 t e i 2 2 t dt The function
0 , if 1 2
sets are called
“orthogonal
e i 2 j n / N
, e i 2 k n / N
N 1
e i 2 j n /N e i 2 k n /N
n 0
c , if j k
0 , if j k , basis sets”
They are called “basis sets” since for any function1, f (t), of a real variable
there exists a complex-valued function F(w), and for any sequence1, hk , there
exist complex numbers, Hn , such that
f t
N 1
i 2 t
F e d hk H n e i 2 k n /N .
n 0
1
with finite energy.
e i 2 ( ux vy )
u, v , x , y and e jm
i 2 ( M knN )
j , m 0,..., M 1, k , n 0,..., N 1
, if u1 u2 and v1 v2
0 , otherwise ,
e
j m k n
i 2 1 1
M N
, e
j m k n
i 2 2 2
M N
M 1 N 1
e
i 2 j1 m k1 n
M
N
e
i 2
j2 m k 2 n
M
N
m 0 n 0
c , if j1 j2 and k1 k 2
0, otherwise .
e i 2 ( ux vy )
u, v, x, y and e
i 2
jm kn
M N
j, k , m, n, M integers
are orthogonal basis sets. This suggests that function f (x,y) defined on the
real plane, and sequence {{ hmn }} for integers m and n have analogous
Fourier representations,
jm kn
M 1N 1 i 2
f x, y F u , v e i 2 ( ux vy )
dudv and hmn H jk e M N
j0 k 0
I r, c I v, u e
i 2 ( vr uc )
dudv
I v, u Ir, c e
i 2 ( vr uc )
dcdr
vr uc
R 1C 1 i 2
I( r,c ) I v,u e R C
v 0 u 0
rv cu
R 1C 1 i 2
I v, u Ir,c e R C
r 0 c 0
vr uc
R 1C 1 i 2
I( r,c ) I v,u e R C
v 0 u 0
rv cu
R 1C 1 i 2
I v, u Ir,c e R C
r 0 c 0
cos 2 r sin θ c cos θ i sin 2 r sin θ c cos θ.
i 2 1 r sin θ c cos θ
e
Cont’d. on next page.
1999-2007 by Richard Alan Peters
Saturday, April 23, 2022
202 43
II
2
What are 2D sinusoids? (cont’d.)
Both the real part of this,
Re e i 2 1 r sin θ c cos θ
cos 2
r sin θ c cos θ
and the imaginary part,
Im e i 2 1 r sinθ c cos θ
sin 2
r sin θ c cos θ
are sinusoidal “gratings” of unit amplitude, period and direction .
2
Then is the radian frequency, and the frequency, of the wavefront
N N
N
and λ is the wavelength in pixels in the wavefront direction.
f = phase shift
on
e ntati
ori
c v v
u u
r
I Re[F{I}] Im[F{I}]
-θ direction
λ wf .
C 2 R 2
u direction
u v
ω wf 1
C 2
u
R 2
v
cycles.
If you represent
that number as a
magnitude, A, and
a phase, f, …
…represents a sinusoidal
grating of frequency
and orientation .
I log{|F{I}|2+1} Ð[F{I}]
I Re[F{I}] Im[F{I}]
We take the base-e logarithm of the PS in order to view it. Otherwise its dynamic range could be
too large to see everything at once. We add 1 to it first so that the minimum value of the result is
0 rather than –infinity, which it would be if there were any zeros in the PS. Recall that
log( f 2) = 2log( f ).
Multiplying by 2 is not necessary if you are generating a PS for viewing, since you'll probably
have to scale it into the range 0-255 anyway. It is much easier to see the structures in a Fourier
plane if the origin is in the center. Therefore we usually perform an fftshift on the PS before it is
displayed.
>> PS = fftshift(log(abs(fft2(I))+1));
>> M = max(PS(:));
>> image(uint8(255*(PS/M)));
If the PS is being calculated for later computational use -- for example the autocorrelation of a
function is the inverse FT of the PS of the function -- it should be calculated by
>> PS = abs(fft2(I)).^2;
large extent
small extent
frequency space
A symmetric pair of
small extent
large extent
Image Origin Image Origin Weight Matrix Origin Weight Matrix Origin
After FFT shift After FFT shift After IFFT shift After IFFT shift
origin origin
from FFT2
after fftshift
or ifftshift
J ( R/2 +1, C/2 +1) I (1,1) I (1,1) J ( R/2 +1, C/2 +1)
J = fftshift(I):
5 6 4
8 9 7 1 2 3
4 5 6
I (1,1) J ( R/2 +1, C/2 +1) 7 8 9
2 3 1
I = ifftshift(J):
5 6 4
1 2 3 8 9 7
4 5 6
J ( R/2 +1, C/2 +1) I (1,1) 7 8 9
2 3 1
po
sit decreasing rows
pe
iv
lo
es
(-r,-c) es (-r,+c) (-r,-c) lo (-r,+c)
tiv
pe
ga
ne
q<0 q>0
Since rows increase down and columns to the right, slopes and
angles are opposite those of a right-handed coordinate system.
θ wf tan 1 ,
vC
uR
-θ direction
λ wf .
C 2
u
R 2
v
u direction
The frequencies represent fractions of R & C,
(0,0)
ωu u
C
, ω v , and
v
R
ω wf 1
C 2
u
R 2
v
cycles.
fftshifted
fftshifted
fftshifted
fftshifted
fftshifted
fftshifted
fftshifted
512 columns
+u direction
384 rows
+v direction
512 columns
384 rows
λu = C / u
u = # of complete cycles
in the horizontal direction
512 columns
v = # of complete
cycles in the λv = R / v
384 rows
vertical direction
512 columns
384 rows
λu = C / u
u = # of complete cycles
in the horizontal direction
512 columns
v = # of complete
cycles in the λv = R / v
384 rows
vertical direction
512 columns
384 rows
λu = C / u
u = # of complete cycles
in the horizontal direction
512 columns
v = # of complete
cycles in the λv = R / v
384 rows
vertical direction
512 columns
384 rows
lwf
wf
384 rows
wf
512 columns
384 rows
frequencies: (u,v) = (3,3); wavelengths: (λu, λv) = (170 ⅔,128)
512 columns
384 rows
frequencies: (u,v) = (4,3); wavelengths: (λu, λv) = (128,128)
512 columns
lwf
wf
384 rows
wf
Lines in
the Power
Spectrum
are …
… perpen-
dicular to
lines in the
image.
log FI
FI
The combined brightness image shown above could have been produced by a pixel-for-pixel
adding of the two brightness images, or by a pixel-for-pixel addition of the corresponding Fourier
transforms, followed by an inverse transform to go back to the brightness domain. Either way the
result would be exactly identical. (Super Position – Linearity ?!)
1999-2007 by Richard Alan Peters
Saturday, April 23, 2022
202 99
II
2
Fourier Says:
any well-behaved function can be represented by a superposition of sinusoidal waves".
In other words by adding together a sufficient number of sine waves of just the right frequency
and amplitude