Discrete Fourier Transform
Ajit Rajwade
CS 663
Fourier Transform
2
Towards the Discrete Fourier Transform
3
The impulse functions here are Dirac delta functions.
Towards the Discrete Fourier Transform
4
This shows that the Fourier transform G(μ) of the sampled signal g(t) is an infinite periodic sequence of copies of F(μ) which is the Fourier transform of f(t). The periodicity of G(μ) is given by the sampling period ΔT. Also though g(t) is a sampled function, its Fourier transform is continuous.
Check the book for the derivation for this (see Appendix at the end of the slides)
5
G(μ)
G(μ)
G(μ)
Towards the Discrete Fourier Transform
6
f(t)δ(t-nΔT) is the sampled function (a Dirac impulse weighted by f(t)). To get the actual sample values (the strength of the impulse), we do an integration, i.e. of the following form:
Towards the Discrete Fourier Transform
7
Towards the Discrete Fourier Transform
8
This is the inverse Discrete Fourier Transform (IDFT).
Towards the Discrete Fourier Transform
9
Towards the Discrete Fourier Transform
10
Vectors of size M by 1
U turns out to be an orthonormal M by M matrix – called the discrete Fourier basis matrix or DFT matrix. The square root of M in the denominator is required for U to be orthonormal, else it would be proportional to an orthonormal matrix.
MATLAB does NOT follow this convention – it follows the one on the earlier slide.
11
Vectors of size M by 1
U is an orthonormal M by M matrix – called the discrete Fourier basis matrix or DFT matrix. The square root of M is required for U to be orthonormal, else it would be proportional to an orthonormal matrix.
Notice in the last equality how the signal f is being represented as a linear combination of column vectors of the DFT matrix. The coefficients of the linear combination are the discrete Fourier coefficients!
Sampling in time and frequency
1/ MΔT since μ = u/MΔT where u = 0,1,2…,M-1.
12
DFT properties
13
Clarification about DFT
14
Convolution of discrete signals
15
Convolution of discrete signals
16
Convolution of discrete signals
17
Convolution of discrete signals
18
19
Convolution of discrete signals
20
Convolution of discrete signals: 2 methods
21
Why convolution using Fourier transforms?
22
Why convolution using Fourier transforms?
23
Towards the Fast Fourier Transform
24
Even indices
Odd indices
Towards the Fast Fourier Transform
25
The M-point DFT computation for F is split up into two halves. The first half requires two M/2-point DFT computations – one for Feven, one for Fodd. The second half follows directly without any additional transform evaluations once Feven and Fodd are computed. Now Feven and Fodd can be further split up recursively.
Towards the Fast Fourier Transform
26
The M-point DFT computation for F is split up into two halves. The first half requires two M/2-point DFT computations – one for Feven, one for Fodd. The second half follows directly without any additional transform evaluations once Feven and Fodd are computed. Now Feven and Fodd can be further split up recursively.
This gives:
There is also a fast inverse Fourier transform which works quite similarly in O(M log M) time. The speedup achieved by the fast fourier transform over a naïve DFT computation is rather dramatic for large M!
M
T(M)
MATLAB implementation
27
2D-DFT
28
2D-DFT computation
29
Compute row-wise FFT, followed by a column-wise FFT. Overall complexity is W1W2 log(W1W2).
MATLAB implementation
30
2D-DFT properties
31
2D-DFT: Magnitude and phase
32
33
IFT (Magnitude of FT of Salman Khan times phase of P V Sindhu)
IFT (Magnitude of FT of P V Sindhu times phase of Salman Khan)
2D-DFT properties
34
2D-DFT properties
35
2D-DFT visualization in MATLAB
36
37
One full period
Two half periods – back to back
38
2D-DFT visualization in MATLAB
39
40
fim2 = fft2(im2);
absfim2 = log(abs(fim2)+1);
imshow(absfim1,[-1 18]);
colormap (jet); colorbar;
The (0,0) frequency lies at the
top left corner
Without centering the fft
fim2 = fftshift(fft2(im2));
absfim2 = log(abs(fim2)+1);
imshow(absfim1,[-1 18]);
colormap (jet); colorbar;
The (0,0) frequency lies in the
Center.
With centering the fft
u
v
u
v
“Viewing” the rotation property of the DFT
41
Visualizing DFT bases in 2D
42
Real part of DFT
Discrete cosine transform (for comparison only)
Each image represents a column of the 2D DFT matrix reshaped to form an image. Only the real component is displayed here. Our theory says that any discrete image can be accurately represented as a linear combination of such basis images. The coefficients of the linear combination may be positive, negative or zero, and real or complex in value. Note that pixel (x,y) of the image for frequency (u,v) represents: Exp(j 2*pi*(ux + vy)/N)
2D convolution
43
2D convolution
44
Image Filtering: Frequency domain
45
Image Filtering: Frequency domain
46
Low pass filters
47
Note: we are assuming (0,0) to be the center (lowest) frequency. Frequencies outside a radius of D from the center frequency are eliminated.
Low pass filters
48
Low pass filters
49
Low pass filters
50
Notice the ringing artifacts around the edges!
Low pass filters
51
52
An image can be regarded as a weighted sum of Kronecker delta functions (impulses). Convolving with a sinc function means placing copies of the sinc function at each impulse. The central lobe of the sinc function causes the blurring and the smaller lobes give rise to the “ripple artifacts” or ringing.
Low pass filters: other types
53
Butterworth filter:
D = cutoff frequency, n = order of the filter
Gaussian filter
54
Low pass filters: Butterworth
55
56
Low pass filters: Gaussian
57
Notice from the equations that a spatial domain Gaussian with high standard deviation corresponds to a frequency domain Gaussian with low cut off frequency! The extreme case of this is a constant intensity signal (Gaussian with very high standard deviation – infinite as such) whose Fourier transform is an impulse at the origin of the Frequency plane). Another extreme case is a spatial domain signal which is just an impulse – its Fourier transform has constant amplitude everywhere.
High pass filter
58
59
60
61
Ringing artifacts for an Ideal HPF!
Ringing artifacts gone!
62
Ringing artifacts for an Ideal HPF!
Ringing artifacts gone!
High pass filters
63
High pass filters
64
Boosting high frequencies
65
66
Notch filters
67
68
The yellow ellipses indicate unnatural peaks in the Fourier transform of the image with the superimposed interfering pattern. These are unnatural because typical images do not have such Fourier transforms. Therefore one can apply a notch filter to remove the interfering pattern.
69
70
71
Notch filters
72
Ideal notch reject filter
Gaussian notch reject filter
Algorithm for frequency domain filtering
73
74
Effect of Gaussian LPF with appropriate zero padding
Original image
Effect of Gaussian LPF without appropriate zero padding – zero the border artifacts!
Interpreting the DFT of Natural Images
75
76
There is a sinc function along the u axis!
77
Strong horizontal and vertical edges = strong responses along u and v axes in the Fourier plane!
A strong edge in direction θ in XY plane = a strong response in the direction perpendicular to θ in UV plane
Interpreting the DFT
78
DFT limitations
79
Fun with Fourier: Hybrid images
80
81
Tiger – when seen up-close, Cheetah – when seen from far
Einstein from nearby,
Marilyn Monroe from far away (or if you squint)!
Refer to:
http://cvcl.mit.edu/hybrid_gallery/monroe_einstein.html
http://cvcl.mit.edu/publications/OlivaTorralb_Hybrid_Siggraph06.pdf (paper from a graphics journal!)
Fourier in action: tomographic reconstruction
82
Radon transform
83
Imagine a line was drawn through the 2D image in a certain direction α, and you integrated the intensity values along that line.
Now you repeat this for lines parallel to the original one but at different offsets.
Each such summation produces a “bin” of the “tomographic projection”.
The collection of bins form a 1D array which is called the tomographic projection or the Radon transform of the object in the direction α.
Reconstruction from the Radon Transform
84
Fourier transform of the Radon Transform
85
G(μ, ϴ) is the Fourier transform of the projection of f(x,y) along some direction ϴ.
Fourier transform of the Radon Transform
86
The RHS of this equation is a slice of the 2D Fourier transform of f(x,y), i.e. F(u,v), along the angle ϴ in the frequency plane, and passing through the origin
This equation above is called the Projection Slice Theorem or the Fourier Slice Theorem. It states that the Fourier transform of a projection of the 2D object along some direction ϴ (i.e. G(μ, ϴ)) is equal to a slice of the 2D Fourier transform of the object along the same direction ϴ (in the frequency plane), passing through the origin.
Reconstruction from the Radon transfer
87
How does the Radon transform show up in tomographic acquisition?
88
Measured projection vector (many bins) at angle θ
Radon transform of object f at angle θ
Fourier transforms in actual acquisition
89
Applications of the Fourier transform in image processing
90
Appendix: Fourier transform of an impulse train
91
Appendix: Fourier transform of an impulse train
92
Thus the Fourier transform of an impulse train with period ∆T is also an impulse train with period 1/∆T. (Compare: The Fourier transform of a Gaussian is also a Gaussian with an inverted standard deviation). There are a few other functions that are their own Fourier transform.
Appendix: Sampling Theorem
93
Appendix: Sampling Theorem
94
Appendix: Sampling Theorem
95
f(t) is an underlying analog signal which is bandlimited, and whose equi-spaced time-domain samples we observe (second figure). The aim is to recover f(t) accurately from its sampled version. The gap between the samples is ∆T.
Appendix: Sampling Theorem
96
F(µ) is the Fourier transform of f(t) (observe the bandlimitedness). In the second row, we see the Fourier transform of its sampled version – we have earlier proved that it would be equal to the summation of infinitely many copies of F(µ). If ∆T is too large, then the different periods will merge and cause aliasing. Hence ∆T has to be “small enough”.
Appendix: Sampling Theorem
97
F(µ) is the Fourier transform of f(t) (observe the bandlimitedness). In the second row, we see the Fourier transform of its sampled version – we have earlier proved that it would be equal to the summation of infinitely many copies of F(µ). If ∆T is too large, then the different periods will merge and cause aliasing. Hence ∆T has to be “small enough”. As seen in sub-figure b here, we must have 1/ ∆T > 2µmax .
Appendix: Sampling Theorem
98
Appendix: Sampling Theorem
99
Sampled version of f
The inverse fourier transform of a rect is a sinc
Appendix: Sampling theorem in 2D
100
101
Appendix: Sampling Theorem and Aliasing
102
Appendix: Sampling Theorem and Aliasing in 1D
103
Analog signal (to be reconstructed from its samples) shown in solid line:
f(t) = sin (πt),
Time period = 2 second
As per the sampling theorem, we need to sample this signal at a rate strictly greater than twice the largest frequency, i.e. greater than 2 x ½ = 1 sample per second. Equivalently the sampling rate must be strictly less than 1/(2 x ½) = 1 second. If you sample at exactly twice the largest frequency, i.e. 1 sample per second, you will collect values of sin (πt) for integer t, i.e. all zeroes. This will not allow for good reconstruction.
Appendix: Sampling Theorem and Aliasing in 2D (example 1)
104
Consider a perfect imaging system that can faithfully capture images of size 96 x 96 pixels (one pixel is the resolution or sampling period of the system in both X and Y directions). Such a system can faithfully capture a checkerboard pattern in which each square has size 1 pixel or more. See top row where the square width is 16 and 6 pixels respectively. But there is a problem if the size of the squares is less than 1 pixel: see bottom row where the squares have width 0.9174 and 0.4798 respectively. These produce misleading patterns which can masquerade as normal images.
Appendix: Sampling Theorem and Aliasing in 2D (example 2)
105
“original” shirt texture
Aliased shirt texture (see appearance of slanting patterns from top right to bottom keft near the midde shirt button)
Appendix: Sampling Theorem and Aliasing in 2D (example 3)
106
Aliasing can be controlled by a small amount of blurring – this is of course not without loss of information, but at least it does not produce fake textures.
Appendix: Sampling Theorem and Aliasing in 2D (example 4)
107
Jagged edges due to aliasing