FFT: 1D signals

advertisement
Image Processing
Fourier Transform 1D
•
•
•
•
Efficient Data Representation
Discrete Fourier Transform - 1D
Continuous Fourier Transform - 1D
Examples
The Fourier Transform
Jean Baptiste Joseph Fourier
2
Efficient Data
Representation
• Data can be represented in many
ways.
• There is a great advantage using an
appropriate representation.
• Examples:
– Equalizers in Stereo systems.
– Noisy points along a line
– Color space red/green/blue v.s.
Hue/Brightness
3
Why do we need representation in
the frequency domain?
Problem in
Frequency
Space
Relatively
easy solution
Inverse
Fourier
Transform
Fourier
Transform
Original
Problem
Solution in
Frequency
Space
Difficult
solution
Solution of
Original
Problem
4
How can we enhance such an image?
5
Solution: Image Representation
2
1
3
5
8
7
0
3
5
=
2
+3
1
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
+1
+5
+
+ ...
= 3
+ 23
+
+ 10
+7
+ ...
6
Transforms
1. Basis Functions.
2. Method for finding the image given
the transform coefficients.
Grayscale
Image
X Coordinate
V Coordinates
Y Coordinate
3. Method for finding the transform
coefficients given the image.
Transformed
Image
U Coordinates
7
Representation in
different bases
• It is possible to go back and forth
between representations:
a u i   a v , u i
a v   a u i  u i
i
u1
v1
a
u2
v2
8
The Inner Product
• Discrete vectors (real numbers):
a, b  a b 
T
 a i  b i 
i
• Discrete vectors (complex numbers):
a, b  a b 
H

a i  b i 
*
i
The vector aH denotes the conjugate
transpose of a.
• Continuous functions:
f  x , g  x  
f
*
 x g  x  dx
x
9
The Fourier basis functions
Basis Functions are sines and cosines
sin(x)
cos(2x)
sin(4x)
The transform coefficients determine the amplitude and phase:
a sin(2x)
2a sin(2x)
-a sin(2x+)
10
Every function equals a sum of sines and cosines
=
3 sin(x)
A
+ 1 sin(3x)
B
+ 0.8 sin(5x)
C
A+B
A+B+C
+ 0.4 sin(7x)
D
A+B+C+D
11
symmetric functions
Sum of sines only
antisymmetric functions
{
{
Sum of cosines only
-D
D
12
Fourier Coefficients
f(x) = C0 + C1cos(x) + S1sin(x) + ... + Ckcos(kx) + Sksin(kx) + ...
Terms are considered in pairs:
Ckcos(kx) + Sksin(kx) = Rk sin(kx + qk)
where
Rk 
Ck
2
Sk
2
and q k  tan
-1
 Sk

C
 k




Using Complex Numbers:
cos(kx) , sin(kx)
Ckcos(kx) + Sksin(kx)
eikx
R eiq eikx
Amplitude+phase
13
The 1D Continues
Fourier Transform
• The Continuous Fourier Transform finds
the F() given the (cont.) signal f(x):
F 
 
f(x) e
- i 2  x
dx
x
B(x)=ei2x is a complex wave function for
each (continues) given  .
• The inverse Continuous Fourier Transform
composes a signal f(x) given F():
f(x) 
 F  
e
i 2  x
d
k
• F() and f(x) are continues.
14
Continuous vs sampled Signals
Sampling: Move from f(x) (x  R) to f(xj) (j Z)
by sampling at equal intervals.
f(x0), f(x0+Dx), f(x0+2Dx), .... , f(x0+[n-1]Dx),
Given N samples at equal intervals, we redefine f as:
f(j) = f(x0+jDx)
j = 0, 1, 2, ... , N-1
f(j) = f(x0 + jDx)
f(x)
f(x0+2Dx)
4
f(x0+3Dx)
f(x0+Dx)
3
f(x0)
2
1
f(2)
4
f(3)
f(1)
3
2
f(0)
1
0
0.25 0.5 0.75 1.0 1.25
0
1
2
3
15
• The discrete basis functions are
bk x  
1
2ikx
e
N
N
k  0.. N - 1
x  0.. N - 1
• For frequency k the Fourier coefficient is:


 2kx 
 2kx 
iq
i2 kx / N
Ck cos
  Sk sin
  Rk e k e
 N 
 N 
Fk   R k e
iq k
16
The Discrete Fourier Transform
(DFT)
F ( k )  f  x , b  x  
k
- 2 ikx
N -1

f ( x) e
N
x0
k = 0, 1, 2, ..., N-1
Matlab: F=fft(f);
The Inverse Discrete Fourier Transform (IDFT) is defined as:
f ( x) 
2 ikx
N -1
1
N

F (k ) e
N
k 0
x = 0, 1, 2, ..., N-1
Matlab: F=ifft(f);
Remark: Normalization constant might be different!
17
Discrete Fourier Transform - Example
f(x) = [2 3 4 4]
3
F(0) =
=
S f(x) e
-2ix
S f(x) e
x=0
4
-6ix
S f(x) e
x=0
4
-4ix
S f(x) e
x=0
3
F(3) =
x=0
(f(0) + f(1) + f(2) + f(3)) = (2+3+4+4) = 13
3
F(2) =
S f(x) 1
=
4
x=0
3
F(1) =
3
-2i0x
4
=
[2e0+3e-i/2+4e-i+4e-i3/2] = [-2+i]
= [2e0+3e-i+4e-2i+4e-3i] = [-1-0i]= -1
= [2e0+3e-i3/2+4e-3i+4e-i9/2] = [-2-i]
DFT of [2 3 4 4] is
[ 13 (-2+i) -1 (-2-i) ]
18
The Fourier Transform - Summary
• F(k) is the Fourier transform of f(x):
~
Ff x   Fk 
• f(x) is the inverse Fourier transform of
F(k):
~ -1
F Fk   f x 
• f(x) and F(k) are a Fourier pair.
• f(x) is a representation of the signal in
the Spatial Domain and F(k) is a
representation
in
the
Frequency
Domain.
19
• The Fourier transform F(k) is a
function over the complex numbers:
Fk   Rk e
iqk
– Rk tells us how much of frequency
k is needed.
– qk tells us the shift of the Sine wave
with frequency k.
• Alternatively:
Fk   ak  ibk
– ak tells us how much of cos with
frequency k is needed.
– bk tells us how much of sin with
frequency k is needed.
20
The Frequency Domain
f(x)
x
The signal f(x)
qk
Rk
F k   R k e
iq k
k
k
Amplitude (spectrum) and Phase
Real
Imag
F k   a k  ib k
k
k
Real and Imaginary
21
• Rk - is the amplitude of F(k).
• qk - is the phase of F(k).
• |Rk|2=F*(k) F(k) - is the power spectrum of
F(k) .
• If a signal f(x) has a lot of fine details |Rk|2
will be high for high k.
• If the signal f(x) is "smooth" |Rk|2 will be
low for high k.
=
3 sin(x)
+ 1 sin(3x)
+ 0.8 sin(5x)
+ 0.4 sin(7x)
22
DEMO
23
Examples:
The Delta Function:
• Let
f ( x )  δ x 
F   
 lim ( x )   ; ( x ) dx  1 

 x 0



 g  x ( x - x 0 )dx  g  x 0  
 


  x   e
- i 2  x
dx  1
-
f(x)
0
x
Fourier
R
q
Real


Imag


24
The Constant Function:
• Let
f ( x) 1
F   

e
- i 2  x
dx    
-
f(x)
0
x
Fourier
R
q
Real
0

Imag

0


25
A Basis Function:
• Let
f (x )  e

F     e
i 2  0 x
-

 e
i 2  0 x
e
- i 2  x
- i 2  ( -  0 ) x
-
dx
dx     -  0 
f(x)
0
x
Fourier
R
q
Real
0

Imag

0


26
The Cosine wave:
f ( x )  cos  2 0 x 
• Let
F   

 2 e
1
i 2  0 x
e
- i 2  0 x
 e
- i 2  x
dx 
-

1
2
  -  0       0 
f(x)
Fourier
R
Real
0
-0
x

q
-0
0

Imag


27
The Sine wave:
f ( x )  sin  2 0 x 
• Let
F   

 2 e
i
- i 2  0 x
-e
i 2  0 x
 e
- i 2  x
dx 
-

i
2
    0  -   -  0 
f(x)
x
Fourier
R
Real
0
-0

q

Imag
/2

-/2
0
-0

28
The Window Function (rect):
• Let
F   

1
rect 1 ( x )  
2

0
1
2
otherwise
if
0 .5
e
- i 2  x
dx 
x 
sin 
- 0 .5


 sinc 

f(x)
x
-0.5
0.5
Fourier
R

29
Proof:
1
f(x) = rect1/2(x) =
-1/2
{
1
|x|  1/2
0
otherwise
1/2

F ( ) 
1/ 2

f ( x )e
- 2  i x
dx 
-
1

- 2 i 



e
- 2 i 
- 2  i
- 2  i x
dx
-1 / 2
1
1
e

- 2  i x 1 / 2
-1 / 2
e
-
 i
-e
 i

cos(  ) - i sin(  ) - cos(  ) - i sin(  ) 
sin(  )

 SINC (  )
F()
sinc()

30
The Gaussian:
• Let
f (x)  e
-x
F    e
2
- 
2
f(x)
x
Fourier
R

31
The Comb Function:
• Let c k ( x )    x mod k 
~
F c k   δ  ω

1
  C 1 ω 
k
k
mod
f(x)
ck(x)
x
k
Fourier
R
C1/k()

1/k
32
Properties of The Fourier
Transform
• Linearity:
~
~
F f   Ff 
• Distributive (additivity):
~
~
~
Ff1  f2   Ff1   Ff2 
• DC (average):
F  0    f  x e dx
0
• Symmetric:
If f(x) is real then,
F    F -   thus F    F -  
*
33
Distributive:
~
~
~
F f  g   F f   F g 
f(x)
|F()|

x
g(x)
|G()|

x
f+g
|F()+G()|
x

34
Transformations
• Translation:
~
F f  x - x 0
  F  e
-2 ix 0
The Fourier Spectrum remains unchanged
under translation:
F    F  e
-2 ix 0
• Scaling:
1
~
 
F  f a x  
F 
a
a
35
Example - Translation
1D Image
real(F(u))
imag(F(u))
|F(u)|
1
10
10
10
0.8
5
5
8
0.6
0
0
6
0.4
-5
-5
4
0.2
-10
-10
2
0
0
50
100
-15
0
50
100
-15
0
50
100
0
0
50
100
0
50
100
0
50
100
Translated
1
10
10
10
0.8
5
5
8
0.6
0
0
6
0.4
-5
-5
4
0.2
-10
-10
2
0
0
50
100
Differences:
-15
0
50
100
-15
0
50
100
0
10
10
10
5
5
5
0
0
0
-5
-5
-5
-10
-10
-10
-15
0
50
100
-15
0
50
100
-15
Change of Scale- 1D:
1 ω
~
~
if F f  x   F ω  then F f ax   F  
a a 
f(x)
|F()|

x
|F()|
f(x)

x
f(x)
|F()|
x

37
Change of Scale
f(x)
F()

x
0.5 F(/2)
f(2x)

x
f(x/2)
2 F(2)
x

38
Download