image processing fourier transform 1d efficient data representation discrete fourier transform - 1d...
TRANSCRIPT
Image Processing
Fourier Transform 1D
• Efficient Data Representation
• Discrete Fourier Transform - 1D
• Continuous Fourier Transform - 1D
• Examples
2
The Fourier Transform
Jean Baptiste Joseph Fourier
3
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
4
Problem in Frequency
Space
Original Problem
Solution in Frequency
Space
Solution of Original Problem
Relatively easy solution
Difficult solution
Fourier Transform
Inverse Fourier
Transform
Why do we need representation in the frequency domain?
5
How can we enhance such an image?
6
Solution: Image Representation
2 1 3
5 8 7
0 3 5
= 1 0 0
0 0 0
0 0 0
2 + 1
0 1 0
0 0 0
0 0 0
0 0 1
0 0 0
0 0 0
+ 3 + 5
0 0 0
1 0 0
0 0 0
+
+ ...
= 3 + 23 +
+ 10 + 7 + ...
7
Transforms
1. Basis Functions.
2. Method for finding the image given the transform coefficients.
3. Method for finding the transform coefficients given the image.
U Coordinates
V C
oord
inat
es
X Coordinate
Y C
oord
inat
e
Grayscale Image
TransformedImage
8
Representation in different bases
• It is possible to go back and forth between representations:
v1
v2
a
u1
u2
ivu u,aia
ii
uv uiaa
9
The Inner Product
• Discrete vectors (real numbers):
• Discrete vectors (complex numbers):
The vector aH denotes the conjugate
transpose of a.
• Continuous functions:
ibiabab,ai
T
ibiabab,ai
*H
x
* dxxgxfxg,xf
10
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+)
11
3 sin(x)
+ 1 sin(3x)
+ 0.8 sin(5x)
+ 0.4 sin(7x)
=
A
B
C
D
A+B
A+B+C
A+B+C+D
Every function equals a sum of sines and cosines
12
Sum of cosines only symmetric functions
Sum of sines only antisymmetric functions
{ {
13
Using Complex Numbers:
cos(kx) , sin(kx)
Ckcos(kx) + Sksin(kx) = Rk sin(kx + k)
f(x) = C0 + C1cos(x) + S1sin(x) + ... + Ckcos(kx) + Sksin(kx) + ...
Fourier Coefficients
eikx
Terms are considered in pairs:
k
kkkkk C
SSCR 122 tanandwhere
Ckcos(kx) + Sksin(kx) R ei eikx
Amplitude+phase
14
• The inverse Continuous Fourier Transform composes a signal f(x) given F():
deF)x(fk
xi2
The 1D Continues Fourier Transform
• The Continuous Fourier Transform finds the F() given the (cont.) signal f(x):
B(x)=ei2x is a complex wave function for
each (continues) given
dxxi x
2ef(x)F
• F() and f(x) are continues.
15
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+x), f(x0+2x), .... , f(x0+[n-1]x),
Given N samples at equal intervals, we redefine f as:
f(j) = f(x0+jx) j = 0, 1, 2, ... , N-1
4
3
2
1
4
3
2
1
0 0.25 0.5 0.75 1.0 1.25 0 1 2 3
f(x)
f(x0)
f(x0+x)
f(x0+2x)f(x0+3x)
f(j) = f(x0 + jx)
f(0)
f(3)f(2)
f(1)
16
• The discrete basis functions are
• For frequency k the Fourier coefficient is:
1..0
21 NkN
ikx
k eN
xb
N/kx2iikkk eeR
Nkx2
sinSNkx2
cosC k
kikeRkF
1..0 Nx
17
k = 0, 1, 2, ..., N-1
1
0
2
)(,)(N
x
N
ikx
exfxbxfkFk
1
0
21 )()(N
k
N
ikx
NekFxf
x = 0, 1, 2, ..., N-1
The Inverse Discrete Fourier Transform (IDFT) is defined as:
Matlab: F=fft(f);
Matlab: F=ifft(f);
The Discrete Fourier Transform (DFT)
Remark: Normalization constant might be different!
18
Discrete Fourier Transform - Example
F(0) = f(x) e = f(x) 13
x=0
-2i0x4
= (f(0) + f(1) + f(2) + f(3)) = (2+3+4+4) = 13
3
x=0
F(1) = f(x) e = [2e0+3e-i/2+4ei+4e-i3/2] = [-2+i]3
x=0
-2ix4
F(3) = f(x) e = [2e0+3e-i3/2+4ei+4e-i9/2] = [-2-i]3
x=0
-6ix4
F(2) = f(x) e = [2e0+3e-i+4ei+4e-3i] = [-1-0i]= -13
x=0
-4ix4
DFT of [2 3 4 4] is [ 13 (-2+i) -1 (-2-i) ]
f(x) = [2 3 4 4]
19
• F(k) is the Fourier transform of f(x):
• f(x) is the inverse Fourier transform of F(k):
• 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.
kFxfF~
xfkFF~ 1
The Fourier Transform - Summary
20
• The Fourier transform F(k) is a function over the complex numbers:
– Rk tells us how much of frequency k is needed.
k tells us the shift of the Sine wave with frequency k.
• Alternatively:
– ak tells us how much of cos with frequency k is needed.
– bk tells us how much of sin with frequency k is needed.
kikeRkF
kk ibakF
21
x
f(x)
k
Rk
k
k
kikeRkF
The signal f(x)
k
Real
k
Imag
kk ibakF
Amplitude (spectrum) and Phase
Real and Imaginary
The Frequency Domain
22
• Rk - is the amplitude of F(k).
k - 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)
=
DEMO
23
24
Examples:
• Let xxf δ)(
1dxexF x2i
Fourier
x
f(x)
R
Real
Imag
The Delta Function:
0
00
0
1
xgdxxxxg
dxxxx
)(
)(;)(lim
25
• Let 1)( xf
dxeF x2i
Fourier
x
f(x)
R
Real
Imag
The Constant Function:
0
0
0
26
• Letx2i 0e)x(f
dxeeF x2ix2i 0
Fourier
x
f(x)
R
Real
Imag
A Basis Function:
0
0dxe x)(2i 0
00
27
• Let xxf 02cos)(
dxeeeF xixixi 222 00
2
1
x
R
002
1
f(x)
Fourier
0-0
Real
Imag
0-0
The Cosine wave:
28
• Let xxf 02sin)(
dxeeei
F xixixi 222 00
2
x
R
002
i
f(x)
Fourier
0-0
/2
Real
Imag
0
-0
The Sine wave:
-/2
29
• Let
otherwise021if1)(
21
xxrect
sinc
sin5.0
5.0
2
dxeF xi
x
f(x)
Fourier
R
The Window Function (rect):
-0.5 0.5
30
Proof:
f(x) = rect1/2(x) ={ 1 |x| 1/2
0 otherwise1
-1/2 1/2
dxedxexfF xixi
2/1
2/1
22)()(
2/1
2/12
2
1
xie
i
ii ee
i
2
1
)sin(i)cos()sin(i)cos(i
21
)(SINC)sin(
sinc()
F()
31
• Let2
)( xexf
2 eF
x
f(x)
Fourier
R
The Gaussian:
32
• Let kmodx)x(ck
ω1modωδ~1
kk C
kcF
x
f(x)
Fourier
R
k
1/k
The Comb Function:
ck(x)
C1/k()
33
Properties of The Fourier Transform
• Linearity:
• Distributive (additivity):
• DC (average):
• Symmetric: If f(x) is real then,
2121 fF~
fF~
ffF~
fF~
fF~
FFthusFF *
dxexfF 00
34
x
f(x)
|F()|
x
g(x)
|G()|
x
f+g
|F()+G()|
Distributive: gFfFgfF ~~~
35
Transformations
• Translation:
The Fourier Spectrum remains unchanged under translation:
• Scaling:
020
xieFxxfF ~
02 xieFF
a
Fa
xafF1~
0 50 1000
0.2
0.4
0.6
0.8
1
0 50 1000
0.2
0.4
0.6
0.8
1
0 50 100-15
-10
-5
0
5
10
0 50 100-15
-10
-5
0
5
10
0 50 100-15
-10
-5
0
5
10
0 50 100-15
-10
-5
0
5
10
0 50 1000
2
4
6
8
10
0 50 1000
2
4
6
8
10
0 50 100-15
-10
-5
0
5
10
0 50 100-15
-10
-5
0
5
10
0 50 100-15
-10
-5
0
5
10
Example - Translation
1D Image
Translated
real(F(u)) imag(F(u)) |F(u)|
Differences:
37
x
f(x)
|F()|
x
f(x)
|F()|
Change of Scale- 1D:
x
f(x)
|F()|
a
ωF
a
1axfF
~thenωFxfF
~if
38
x
f(x)
F()
x
f(2x)
0.5 F(/2)
Change of Scale
x
f(x/2)
2 F(2)