Ch 7

advertisement
Chapter 7: Fourier Analysis
Fourier analysis = Series + Transform
◎ Fourier Series
-- A periodic (T) function f(x) can be written
as the sum of sines and cosines of varying
amplitudes and frequencies

f ( x)  a0 / 2   an cos n x  bn sin n x
n 1
1 T /2
2 T /2
a0  
f ( x)dx, an  
f ( x)cos n xdx
T T / 2
T T / 2
2
2 T /2

,
bn  
f ( x)sin n xdx
T
T T / 2
7-1
○ Some function is formed by a finite number
of sinuous functions
f ( x)  sin x  (1/ 3)sin 2 x  (1/ 5)sin 4 x
7-2
Some function requires an infinite number
of sinuous functions to compose
1
1
1
1
f ( x)  sin x  sin 3x  sin 5 x  sin 7 x  sin 9 x  
3
5
7
9
7-3
• Spectrum
The spectrum of a
periodic function is
discrete, consisting
of components at dc,
1/T, and its multiples,
e.g., f ( x)  sin x  (1/ 3)sin 2 x  (1/ 5)sin 4 x
For non-periodic
functions, i.e.,
T   or   0
The spectrum of the
function is continuous
7-4
○ In complex form: f ( x) 

 cn exp( jn x)
n 
1 T /2
cn  
f ( x) exp( jn x)dx
T T / 2
2


, T : period
Compare with
T

f ( x)  a0 / 2   an cos n x  bn sin n x
n 1
1
c0  a0 , cn  (an  jbn ) / 2
2
an  2 Re [cn ], bn  2 I m [cn ]
7-5
Continuous case

f ( x)   [a( )cos  x  b( )sin  x]d 
0

 c()e
j x
d

1 
1 
a( )   f ( x)cos  xdx, b( )   f ( x)sin  xdx
 
 
1
c( )  ( a ( )  jb( ))
2
1 

 f ( x)[cos  x  j sin  x]dx
2 
1 
 j x

f
(
x
)
e
dx

2 
7-6
◎ Fourier Transform
1
F ( ) 
2

 f ( x)exp( j x)dx

f ( x)   F ( )exp( j x)d

Discrete case:
1
Fu 
N
N 1

x 0
 j 2 xu
f x exp(
), u  0,1, , N  1
N
N 1
j 2 xu
f x   Fu exp(
), x  0,1, , N  1
N
u 0
7-7
Matrix form
Input sequence: f  { f0 , f1 , , f N 1}
DFT sequence: F  {F0 , F1 , , FN 1}
1
Fu 
N
N 1

x 0
 j 2 xu
f x exp(
),
N
u  0,1, , N  1
F  f
1
j 2 mn
m,n  exp(
), m, n  0,1, , N  1
N
N
1 mn
j 2
)  m,n  
Let   exp(
N
N
7-8
1
1
1
1

1
2
3


1 
4
6
1  2


1

6
9
N 1  3





( N 1)
3( N 1)
2( N 1)


1 

( N 1) 


2( N 1) 


3( N 1) 



( N 1) 2 


1
。 Example: f = {1,2,3,4}. Then, N = 4,
j 2


  exp(
)  cos( )  j sin( )   j
4
2
2
7-9
1
1

1 1 ( j )
 
4 1 ( j )2

1 ( j )3
1
( j )
2
( j )
4
( j )
6
1 
1 1 1 1 
3
(  j )  1 1  j 1 j 



6
(  j )  4 1 1 1 1



9
j

1

j
1


( j ) 
1 1 1 1  1 
 10 

 


1 1  j 1 j   2  1  2  2 j 
F  f 

4 1 1 1 1  3  4  2 

 


1 j 1  j   4 
 2  2 j 
7-10
j 2 xu
○ Inverse DFT f x   Fu exp(
)
N
u 0
j 2
1
f   F Let   1/   exp(
)
N
N 1
1
1
1 1

1
2
3


1 
4
6
1  2


1 
 
6
9
1  3





( N 1)
3( N 1)
2( N 1)


1 
1 
( N 1) 


 2( N 1) 

3( N 1) 



( N 1) 2 


7-11
1
 j
。 Example:   1/  
j
1 1

1 ( j )
1
 
1 ( j )2

1 ( j )3
1
( j)
2
( j)4
( j )6
1  1 1 1 1 
3
( j )  1 j 1  j 



( j ) 6  1 1 1 1
 

9
1

j

1
j

( j)  
1 1 1 1   10  1 
1 j 1  j   2  2 j   2 
1
1


 
f  F 
1 1 1 1 4  2   3 

 
  
1

j

1
j

2

2
j

 
  4
7-12
◎ Properties
○ Linearity: ( f  g )  ( f )  ( g )
(kf )  k ( f )
。 Example: Noise removal
f’ = f + n, n: noise,
( f )  ( f  n)  ( f )  (n)
○ Scaling af ( x)  aF (u ),
1
u
f (ax)  F ( )
|a| a
7-13
○ Periodicity: Fu  FN u
FN u
N 1
 j 2 xu
 f x exp( N )
x 0
1 N 1
 j 2 x( N  u )
  f x exp(
)
N x 0
N
1
Fu 
N
1

N
1

N
1

N
N 1

f x e  j 2 x e

j 2 xu
N
x 0
N 1
 f x (cos 2 x  j sin 2 x)e

j 2 xu
N
x 0
N 1
 f xe
x 0

j 2 xu
N
 Fu
7-14
○ Shifting:
f ( x)exp( j 2 u0 x / N )  F (u  u0 )
f ( x  x0 )  F (u )exp( j 2 ux0 / N )
Let u0  N / 2  exp( j 2 u0 x / N )  exp( j x)
j x
 (e )  (cos   j sin  )  (1)
x
x
f  { f0 , f1 , , f N 1}, F  {F0 , F1, , FN 1}
x

f ( x)  f ( x)exp( j 2 u0 x / N )  (1) f ( x)
f   { f0 ,  f1 , f 2 ,  f3 , , f N 2 ,  f N 1}
F   {FN / 2 , , FN 1 , F0 , , FN / 21}
7-15
。 Example:
f  {2 3 4 5 6 7 8 1}
F  {36 - 9.6569  4i - 4 - 4i 1.6569 - 4i
4 1.6569  4i - 4  4i - 9.6569 - 4i}
f   {2 - 3 4 - 5 6 - 7 8 -1}
F   { 4 1.6569  4i - 4  4i - 9.6569 - 4i
36 - 9.6569  4i - 4 - 4i 1.6569 - 4i }
7-16
◎ Convolution: h  f  g  g  f

h( x ) 

f (  x) g ( x)d 



f ( x) g (  x)d

Convolution theorem:
f ( x)  g ( x)  F (u )G(u ), f ( x) g ( x)  F (u )  G(u )
7-17

◎ Correlation f ( x) g ( x)   f *( ) g ( x   )d

Correlation theorem
f ( x, y) g ( x, y)  F * (u, v)G(u, v)
f * ( x, y) g ( x, y)  F (u, v) G(u, v)
7-18
。Discrete Case:
N 1
h( k )  f e ( n)  g e ( k )   f e ( n) g e ( n  k )
n 0
N 1
h(k )  fe (k ) ge (k )   f e (n) ge (k  n)
n 0
e.g.,
N  A  B 1
A = 4, B = 5, A + B – 1 = 8, N  8
7-19
* Convolution can be defined in terms of
polynomial product
f  { f0 , f1 , , f N 1}, g  {g0 , g1 , , g N 1}
Extend f, g to fe , ge if f, g have different
numbers of sample points
Let P ( x)  f 0  f1 x  f 2 x    f N 1 x
2
N 1
Q ( x)  g 0  g1 x  g 2 x    g N 1 x
2
N 1
Compute P( x)Q( x)(1  x N )
to x 2 N 1 form
the result of convolution f  g
The coefficients of x
N
7-20
。Example: f  {1, 2, 3, 4}, g  {5, 6, 7, 8}
N  4
Let
P( x)  1  2 x  3x  4 x , Q( x)  5  6x  7 x  8x
2
3
2
3
P( x)Q( x)(1  x )  5  16 x  34 x  60 x  66 x
4
2
3
4
 68 x  66 x  60 x  61x  52 x  32 x
5
6
7
8
9
10
( N , 2 N  1)  (4, 7)
4
5
6
7
The coefficients of x , x , x , x form
the convolution f  g  {66, 68, 66, 60}
7-21
N 1
h( k )   f ( k  n) g ( n)
n 0
f  {1, 2, 3, 4}, g  {5, 6, 7, 8}
3
N  4, h(k )   f (k  n) g (n)
3
n 0
h(0)   f (n) g (n)
n 0
 f (0) g (0)  f ( 1) g (1)  f ( 2) g (2)  f ( 3) g (3)
 f (0) g (0)  f (3) g (1)  f (2) g (2)  f (1) g (3)
 1  5  4  6  3  7  2  8  5  24  21  16  66
h(1)  68, h(2)  66, h(3)  60
7-22
○ Fast Fourier Transform (FFT)
-- Successive doubling method
7-23
7-24
。 Time complexity
n
N  2 : the length of the input sequence
n 2
2n
n
FT: (2 )  2
FFT: n2
Times of speed increasing: 2n / n
N
FT
FFT
Ratio
4
8
16
32
64
128
256
512
1024
16
84
256
1024
4096
16384
65536
262144
1048576
8
24
64
160
384
896
2048
4608
10240
2.0
2.67
4.0
6.4
10.67
18.3
32.0
56.9
102.4
7-25
○ Inverse FFT
1
F (u ) 
N
N 1
 f ( x) exp[ j 2 ux / N ] ← Given
x 0
N 1
f ( x)   F (u ) exp[ j 2 ux / N ] ← compute
u 0
1 *
1 N 1 *
f ( x)   F (u ) exp[ j 2 ux / N ]
N
N u 0
i. Input F * (u) into FFT. The output is
f * ( x) / N
ii. Taking the complex conjugate and
multiplying by N , yields the f(x)
7-26
◎ 2D Fourier Transform
○ FT: F (u, v)  ( f ( x, y ))
1
F (u, v) 
MN
M 1 N 1

x 0 y 0
xu yv
f ( x, y )exp[ j 2 (  )]
M N
1
IFT: f ( x, y )   ( F (u, v))
M 1 N 1
xu yv
f ( x, y )    F (u , v) exp[ j 2 (  )]
M N
u 0 v 0
7-27
◎ Properties
○ Filtering: every F(u,v) is obtained by
multiplying every f(x,y) by a fixed
value and adding up the results. DFT
can be considered as a linear filtering
1
F (u, v) 
MN
M 1 N 1

x 0 y 0
xu yv
f ( x, y )exp[ j 2 (  )]
M N
○ DC coefficient:
1
F (0,0) 
MN
M 1 N 1

x 0 y 0
1
f ( x, y )exp(0) 
MN
M 1 N 1
  f ( x, y )
x 0 y 0
7-28
○ Separability:
xu yv
xu
yv
exp[ j 2 (  )]  exp( j 2 ) exp( j 2 )
M N
M
N
1
F (u , v) 
MN
1

M
1

M
M 1 N 1

x 0 y 0
M 1
xu yv
f ( x, y ) exp[  j 2 (  )]
M N
xu 1
 exp( j 2 M ) N
x 0
N 1

y 0
vy
f ( x, y ) exp(  j 2 )
N
M 1
xu
 F ( x, v) exp( j 2 M )
x 0
7-29
○ Conjugate Symmetry: F(u,v) = F*(-u,-v)
1 M 1 N 1
ux vy
F (u, v) 
f ( x, y )exp[ j 2 (  )]

MN x0 y 0
M N
1 M 1 N 1
ux vy
F (  u, v )=
f ( x, y )exp[ j 2 (  )]

MN x 0 y 0
M N
M 1 N 1
1
ux vy *
*
F (u, v) 
f ( x, y ){exp[ j 2 (  )]}

MN x0 y 0
M N
1 N 1 N 1
ux vy

f ( x, y )exp[ j 2 (  )]  F (u, v)

MN x 0 y 0
M N
7-30
○ Shifting
f ( x, y )exp[ j 2 (u0 x / M  v0 y / N )] 
F (u  u0 , v  v0 )
f ( x  x0 , y  y0 ) 
F (u, v)exp[ j 2 (ux0 / M  vy0 / N )]
7-31
○ Rotation
Polor coordinates: x  r cos , y  r sin 
u  w cos  , v  w sin 
f ( x, y )  f (r , ), F (u, v)  F ( w, )
f (r ,  0 )  F (w,  0 )
7-32
○ Display: effect of log
operation
F (u, v)
log(1  F (u, v) )
7-33
7-34
◎ Image Transform
7-35
◎ Filtering in Frequency Domain
○ Low pass filtering
1
m(u, v)  
0
(u, v)  D
(u, v)  D
1 (( I )  m)
I
FT
m
IFT
7-36
D=5
D = 30
○ High pass filtering
7-37
Different Ds
7-38
◎ Butterworth Filtering
○ Low pass filter
1
f ( x) 
2n
1  ( x / D)
○ High pass filter
1
f ( x) 
1  ( D / x) 2 n
When x: small; x/D : small; 1  ( x/D) : small;
2n
1/(1  ( x/D) ): large
2n
7-39
○ Low pass filter
○ High pass filter
7-40
◎ Homomorphic Filtering
-- Deals with images with large variation of
illumination, e.g., sunshine + shadows
-- Both reduces intensity range and increases local
contrast
○ Idea:
I = LR, L: illumination, R: Reflectance
logI = logL + logR
(log I )  (log L)  (log R)
7-41
(log L)
(log R)
low frequency
high frequency
H  (log I )  H  (log L)  H  (log R)
1
I    ( H  (log I ))
7-42
7-43
Euler’s formula: e  cos x  j sin x
jx
e
 jx
 cos x  j sin x
7-44
7-45
7-46
○ Fast Fourier Transform (FFT)
-- Successive doubling method
1 N 1
 j 2 xu
Fu 
f x exp(

N
x 0
N
)
 j 2
Let WN  exp(
)
N
1 N 1
ux
Fu   f xWN ,
N x 0
Assume N  2
n
n1
 M 2
Let N = 2M.
7-47
1 2 M 1
ux
F (u ) 
 f ( x)W2 M
2 M x 0
1
0
u
2u

[ f (0)W2 M  f (1)W2 M  f (2)W2 M   
2M
Mu
2M
f (M )W
(M 1)u
2M
 f (M  1)W
(2M -1)u
]
f
(2
M
-1)
W

2M
1 M -1
1 1 M -1
2
xu

 f (2x  1) W (2x1)u ]
[
 f (2x) W
2M
2M
M x 0
2 M x 0
=
∵ W
2xu
2M
= [e
 j 2
2 M 2 xu
]
 [e
 j 2
M
]  WMxu
xu
W2(2Mx +1)u  W22MxuW2uM  WMxuW2uM
7-48
1 1
 F (u )  [
2 M
M 1

x0
1
Let Feven (u ) 
M
f (2 x)WMux
M 1

x 0
f
1

M
M 1

x0
f (2 x  1)WMuxWMu ]
ux
(2 x)WM
1 M 1
ux
Fodd (u ) 
f
(2
x

1)
W

M
M x 0
1
 F (u )  [ Feven (u )  Fodd (u )W2uM ]--------- (B)
2
Consider
1
F (u  M )  [ Feven (u  M )  Fodd (u  M )W2uM M ]
2
7-49
 j 2
uM
uM
2
M
W2 M  (e
)
 j 2
 j 2
u
M
2
M
2
M
 (e
) (e
)
 W2uM (1)  W2uM
1
u
 F (u  M )  [ Feven (u  M )  Fodd (u  M )W2 M ]
2
 j 2
WMuM  (e M )u M
 j 2
 j 2
 (e M )u (e M ) M
 WMu (1)  WMu
7-50
1
 Feven (u  M ) 
M
1

M
1
Fodd (u  M ) 
M
M 1

f (2 x)WM(u  M ) x

f (2 x)WMux  Feven (u )
x 0
M 1
x 0
M 1

1

M
x 0
f (2 x  1)WM(u  M ) x
M 1

x 0
f (2 x  1)WMux  Fodd (u )
1
 F (u  M )  [ Feven (u )  Fodd (u )W2uM ] ---- (C)
2
7-51
○ Analysis :
The Fourier sequence F(u), u = 0 , … , N-1
of f(x), x = 0 , … , N-1 can be formed from
sequences
1
u
[
F
(
u
)

F
(
u
)
W
odd
2M ]
F(u) = 2 even
1
u
F(u+M) = [ Feven (u )  Fodd (u )W2 M ]
2
u = 0 , …… , M-1
Recursively divide F(u) and F(u+M),
Eventually, each contains one element
F(w), i.e., w = 0, and F(w) = f(x).
7-52
7-53
○ Example: Input { f(0), f(1), ……, f(7) }
1
Computing Feven (u ) 
M
M 1

x 0
f (2 x)WMux
needs { f(0), f(2), f(4), f(6) }
1
Computing Fodd (u ) 
M
M 1

x 0
f
ux
(2 x  1)WM
needs { f(1), f(3), f(5), f(7) }
Computing
7-54
Computing
Reorder the input sequence into
{f(0), f(4), f(2), f(6), f(1), f(5), f(3), f(7)}
* Bit-Reversal Rule
7-55
Download