Professional Documents
Culture Documents
Fourier Transform 2D
Discrete Fourier Transform - 2D Continues Fourier Transform - 2D Fourier Properties Convolution Theorem Examples
+ + +
Definitions
Image Processing
Frequencies in an Image
Any spatial or temporal signal has an equivalent frequency representation What do frequencies mean in an image ?
High frequencies correspond to pixel values that change rapidly across the image (e.g. text, texture, leaves, etc.) Strong low frequency components correspond to large scale features in the image (e.g. a single, homogenous object that dominates the image)
F (u ) =
Fourier Synthesis
f ( x )e
j 2ux
dx
Fourier Analysis
f ( x) =
F (u )e
j 2ux
du
f ( x, y )e F (u, v)e
j 2 ( ux + vy )
dxdy
f ( x, y ) =
j 2 ( ux + vy )
dudv
F (af + bg ) = aF ( f ) + bF ( g )
Some other useful properties include Discrete Real f+g f*g Periodic Symmetric F+G FG
F (u ) =
j 2xu dx f ( x )e j 2xu dx = e 1
1 j 2u j 2u e e j 2u sin 2u = u =
1 Bu,v (x, y ) = e MN
ux v y 2 i + N M
u=0..N-1, M=0..M-1
The inner product of 2 functions (in 2D) is defined similarly to the 1D case :
F (u , v ) = f (x , y ), B u , v (x , y ) = =
N 1 M 1 x =0 y =0
* f (x , y )B u , v (x , y )
u=-2, v=2
u=-1, v=2
u=0, v=2
u=1, v=2
u=2, v=2
u=-2, v=1
u=-1, v=1
u=0, v=1
u=1, v=1
u=2, v=1
U
u=-2, v=0 u=-1, v=0 u=0, v=0 u=1, v=0 u=2, v=0
u=-2, v=-1
u=-1, v=-1
u=0, v=-1
u=1, v=-1
u=2, v=-1
u=-2, v=-2
u=-1, v=-2
u=0, v=-2
u=1, v=-2
u=2, v=-2
Aliasing Examples
75 dpi Scan
* Wikipedia
DFT (Continued)
Since the values of the FT are complex numbers, it is sometimes more convenient to express F(u) in terms of polar coordinates
F (u , v ) = F (u , v ) e j ( u , v )
where the magnitude or spectrum is denoted by
F (u , v ) = R 2 (u , v ) + I 2 (u, v)
1 2
(u, v) = tan 1
I (u , v) R (u , v)
11
DFT (Continued)
F (u , v) =
1 MN
M 1 N 1 x =0 y = 0
f ( x, y)e
j 2 ( ux / M + vy / N )
f ( x, y)
This is nothing more than the average grayscale level of the image This is often referred to as the DC Component (0 frequency)
DFT (Continued)
The FT has the following translation property
f ( x, y )e j 2 (u0 x / M +v0 y / N ) F (u u0 , v v0 )
which for u0=M/2 and v0=N/2 we see that
F ( f ( x, y )(1) x + y ) = F (u M / 2, v N / 2)
In image processing, it is common to multiply the input image by (-1)x+y prior to computing F(u,v) This has the effect of centering the transform since F(0,0) is now located at u=M/2, v=N/2
12
F(k) = f ( x),e
2 ikx N
= f (x) e
x =0
N1
2ikx N
k = 0, 1, 2, ..., N-1
Matlab: F=fft(f);
1 f ( x) = N
N 1 k =0
F (k ) e
2ikx N
x = 0, 1, 2, ..., N-1
Matlab: F=ifft(f);
F(0) = =
x=0
f(x) e
-2i0x
4
x=0
f(x) 1
F(1) =
f(x) e x=0
3
-2ix
4
[2e0+3e-i/2+4ei+4e-i3/2] = [-2+i]
F(2) =
-4ix
4
= [2e0+3e-i+4e2i+4e-3i] = [-1-0i]= -1
F(3) =
-6ix
4
= [2e0+3e-i3/2+4e3i+4e-i9/2] = [-2-i]
DFT of [2 3 4 4] is
[ 13 (-2+i) -1 (-2-i) ]
17
Sampling Limits
Shannons Sampling Theorem states that if a function f is sampled at a rate twice its highest frequency, f can be completely recovered from its samples This is known as the Nyquist Frequency Limit The sampling rate in images is the pixels/unit distance
er
Aliasing
For an image sampled spatially, the shortest wavelength that be represented is 2 pixels When a signal is under-sampled, aliasing can result Aliasing is when a high frequency signal masquerades as a lower frequency signal
10
Sampling
When we sample, we lose information When is sampling adequate? Consider sampling of a checkerboard image Top row: 2 and one samples per feature Will that be enough? Bottom row
Sampling
occurs when your sampling rate is not high enough to capture the amount of detail in your image formally, the image contains structure at different scales
called frequencies in the Fourier domain
the sampling rate must be high enough to capture the highest frequency in the image
To avoid aliasing:
sampling rate > 2 * max frequency in the image
i.e., need more than two samples per period
F = fft2(f);
In order to display the Fourier Spectrum |F(u,v)| Reduce dynamic range of |F(u,v)| by displaying the log:
D = log(1+abs(F));
Cyclically rotate the image so that F(0,0) is in the center:
Example:
D = fftshift(D);
2 1 0 0 1 2 4
|F(u)| = 100 4
Display in Range([0..10]): log(1+|F(u)|) = 4.62 1.61 1.01 0.69 0 0 0.69 1.01 1.61 log(1+|F(u)|)/0.0462 = 10 4 2 1 0 fftshift(log(1+|F(u)|) = 0 1 2 4 2 1 0
6
0 1 2 4 10 4
Original
|F(u,v)|
log(1 + |F(u,v)|)
fftshift(log(1 + |F(u,v)|))
Original
Example - Rotation
2D Image 2D Image - Rotated
Fourier Spectrum
Fourier Spectrum
17
18
19
20
21
Fourier Transform
Original Problem
Difficult solution
22
Filtering Example Smooth an Image with a Gaussian Kernel Traditionally, we would just convolve the image with the a gaussian kernel
1 4 6 4 1 4 16 24 16 4 6 24 36 24 6 / 256 4 16 24 16 4 1 4 6 4 1
Instead, we will perform multiplication in the frequency domain to achieve the same effect
15
Filtering Example Smooth an Image with a Gaussian Kernel 1. Multiply the input image by (-1)x+y to center the transform
Filtering Example Smooth an Image with a Gaussian Kernel 2. Compute the DFT F(u,v) of the resulting image
log transform
16
Filtering Example Smooth an Image with a Gaussian Kernel 3. Multiply F(u,v) by a filter G(u,v)
1 4 6 4 1 4 16 24 16 4 6 24 36 24 6 / 256 4 16 24 16 4 1 4 6 4 1
g(x,y) G(u,v)
Filtering Example Smooth an Image with a Gaussian Kernel 3. Multiply F(u,v) by a filter G(u,v)
17
Filtering Example Smooth an Image with a Gaussian Kernel 4. 5. 6. Computer the inverse DFT transform h*(x,y) Obtain the real part h(x,y) of 4 Multiply the result by (-1)x+y
f ( x, y ) g ( x, y )
F (u , v)G (u , v)
18
f(x,y)
filter
g(x,y)
G(u,v)
f(x,y)
F(u,v)
g(x,y)
H(u,v)
14
H(u,v) =
1 0
H(u,v) H(u,v) v u 1 0 D0
D(u,v)
15
99.7%
99.37%
98.65%
16
96.6%
98.0%
99.0%
99.4%
99.6%
99.7%
17
H(u,v)
H(u,v) 1
1/ e
u v 0 D0
D(u,v)
H(u,v) =
-D2(u,v)/(2D20)
D(u,v) = u2 + v2
Softer Blurring
20
99.11%
98.74%
96.44%
Freq. domain
Spatial domain
50
100
150
200
250
300
22
H(u,v)
H(u,v) 1 0.5 v
D0
D(u,v)
H(u,v) =
1 1 + (D(u,v)/D0)2n
D(u,v) = u2 + v2
23
97.48%
95.95%
93.70%
24
Freq. domain
Spatial domain
250
200
150
100
50
50
100
150
200
250
25
26
Smoothed Image
28
H(u,v) v 1 0 D0 D(u,v)
29
H(u,v) H(u,v) 1 v u
11/ e
0 D0 D(u,v)
H(u,v) = 1 - e
-D2(u,v)/(2D20)
D(u,v) = u2 + v2
30
D(u,v)
H(u,v) =
1 1 + (D0/D(u,v))2n
D(u,v) = u2 + v2
31
Butterworth
Gaussian
32
Original
33
Original
34
H'(u,v) 1 0 D0 D(u,v)
35
Original
w
2
D(u,v) D0 +
w
2
w
2
D(u,v) > D0 +
H(u,v)
H(u,v)
v u
1
D(u,v)
D0- w
2
D0 D0+w
2
38
w
2
D(u,v) D0 +
w
2
w
2
D(u,v) > D0 +
H(u,v)
H(u,v)
v u
1
D(u,v)
D0- w
2
D0 D0+w
2
39