Fourier transforms & fft algorithm (paul heckbert, 1998) by tantanoid

Notes 3, Computer Graphics 2, 15-463
Fourier Transforms and the
Fast Fourier Transform (FFT) Algorithm
Paul Heckbert
Feb. 1995
Revised 27 Jan. 1998
We start in the continuous world; then we get discrete.
Definition of the Fourier Transform
The Fourier transform (FT) of the function f (x) is the function F(ω), where:
F(ω) =
∞
−∞
f (x)e−iωx
dx
and the inverse Fourier transform is
f (x) =
1
2π
∞
−∞
F(ω)eiωx
dω
Recall that i =
√
−1 and eiθ
= cos θ + i sinθ.
Think of it as a transformation into a different set of basis functions. The Fourier trans-
form uses complex exponentials (sinusoids) of various frequencies as its basis functions.
(Other transforms, such as Z, Laplace, Cosine, Wavelet, and Hartley, use different basis
functions).
A Fourier transform pair is often written f (x) ↔ F(ω), or F ( f (x)) = F(ω) where F
is the Fourier transform operator.
If f (x) is thought of as a signal (i.e. input data) then we call F(ω) the signal’s spectrum.
If f is thought of as the impulse response of a filter (which operates on input data to produce
output data) then we call F the filter’s frequency response. (Occasionally the line between
what’s signal and what’s filter becomes blurry).
1
Example of a Fourier Transform
Suppose we want to create a filter that eliminates high frequencies but retains low frequen-
cies (this is very useful in antialiasing). In signal processing terminology, this is called an
ideal low pass filter. So we’ll specify a box-shaped frequency response with cutoff fre-
quency ωc:
F(ω) =
1 |ω| ≤ ωc
0 |ω| > ωc
What is its impulse response?
We know that the impulse response is the inverse Fourier transform of the frequency
response, so taking off our signal processing hat and putting on our mathematics hat, all we
need to do is evaluate:
f (x) =
1
2π
∞
−∞
F(ω)eiωx
dω
for this particular F(ω):
f (x) =
1
2π
ωc
−ωc
eiωx
dω
=
1
2π
eiωx
ix
ωc
ω=−ωc
=
1
πx
eiωcx
− e−iωcx
2i
=
sinωcx
πx
since sinθ =
eiθ
− e−iθ
2i
=
ωc
π
sinc(
ωc
π
x)
where sinc(x) = sin(πx)/(πx). For antialiasing with unit-spaced samples, you want the
cutoff frequency to equal the Nyquist frequency, so ωc = π.
Fourier Transform Properties
Rather than write “the Fourier transform of an X function is a Y function”, we write the
shorthand: X ↔ Y. If z is a complex number and z = x + iy where x and y are its real and
imaginary parts, then the complex conjugate of z is z∗
= x − iy. A function f (u) is even if
f (u) = f (−u), it is odd if f (u) = − f (−u), it is conjugate symmetric if f (u) = f ∗
(−u),
and it is conjugate antisymmetric if f (u) = − f ∗
(−u).
2
discrete ↔ periodic
periodic ↔ discrete
discrete, periodic ↔ discrete, periodic
real ↔ conjugate symmetric
imaginary ↔ conjugate antisymmetric
box ↔ sinc
sinc ↔ box
Gaussian ↔ Gaussian
impulse ↔ constant
impulse train ↔ impulse train
(can you prove the above?)
When a signal is scaled up spatially, its spectrum is scaled down in frequency, and vice
versa: f (ax) ↔ F(ω/a) for any real, nonzero a.
Convolution Theorem
The Fourier transform of a convolution of two signals is the product of their Fourier trans-
forms: f ∗ g ↔ FG. The convolution of two continuous signals f and g is
( f ∗ g)(x) =
+∞
−∞
f (t)g(x − t)dt
So
+∞
−∞
f (t)g(x − t)dt ↔ F(ω)G(ω).
The Fourier transform of a product of two signals is the convolution of their Fourier
transforms: fg ↔ F ∗ G/2π.
Delta Functions
The (Dirac) delta function δ(x) is defined such that δ(x) = 0 for all x = 0,
+∞
−∞
δ(t)dt = 1,
and for any f (x):
( f ∗ δ)(x) =
+∞
−∞
f (t)δ(x − t)dt = f (x)
The latter is called the sifting property of delta functions. Because convolution with a delta
is linear shift-invariant filtering, translating the delta by a will translate the output by a:
f (x) ∗ δ(x − a) (x) = f (x − a)
3
Discrete Fourier Transform (DFT)
When a signal is discrete and periodic, we don’t need the continuous Fourier transform.
Instead we use the discrete Fourier transform, or DFT. Suppose our signal is an for n =
0. . . N − 1, and an = an+ jN for all n and j. The discrete Fourier transform of a, also known
as the spectrum of a, is:
Ak =
N−1
n=0
e−i 2π
N kn
an
This is more commonly written:
Ak =
N−1
n=0
Wkn
N an (1)
where
WN = e−i 2π
N
and Wk
N for k = 0. . . N − 1 are called the Nth roots of unity. They’re called this because, in
complex arithmetic, (Wk
N )N
= 1 for all k. They’re vertices of a regular polygon inscribed
in the unit circle of the complex plane, with one vertex at (1,0). Below are roots of unity
for N = 2, N = 4, and N = 8, graphed in the complex plane.
W4
2
Re
Im
N=2
W2
0
W2
1
N=4
W4
0
W4
3
W4
1
1
−1 −1
1
i
-i
W8
4
N=8
W8
0
W8
6
W8
2
−1
1
i
-i
W8
7
W8
5
W8
3
W8
1
Powers of roots of unity are periodic with period N, since the Nth roots of unity are
points on the complex unit circle every 2π/N radians apart, and multiplying by WN is equiv-
alent to rotation clockwise by this angle. Multiplication by WN
N is rotation by 2π radians,
that is, no rotation at all. In general, Wk
N = Wk+ jN
N for all integer j. Thus, when raising WN
to a power, the exponent can be taken modulo N.
The sequence Ak is the discrete Fourier transform of the sequence an. Each is a sequence
of N complex numbers.
The sequence an is the inverse discrete Fourier transform of the sequence Ak. The for-
mula for the inverse DFT is
an =
1
N
N−1
k=0
W−kn
N Ak
4
The formula is identical except that a and A have exchanged roles, as have k and n. Also,
the exponent of W is negated, and there is a 1/N normalization in front.
Two-point DFT (N=2)
W2 = e−iπ
= −1, and
Ak =
1
n=0
(−1)kn
an = (−1)k·0
a0 + (−1)k·1
a1 = a0 + (−1)k
a1
so
A0 = a0 + a1
A1 = a0 − a1
Four-point DFT (N=4)
W4 = e−iπ/2
= −i, and
Ak =
3
n=0
(−i)kn
an = a0 + (−i)k
a1 + (−i)2k
a2 + (−i)3k
a3 = a0 + (−i)k
a1 + (−1)k
a2 +ik
a3
so
A0 = a0 + a1 + a2 + a3
A1 = a0 − ia1 − a2 + ia3
A2 = a0 − a1 + a2 − a3
A3 = a0 + ia1 − a2 − ia3
This can also be written as a matrix multiply:


A0
A1
A2
A3


=


1 1 1 1
1 −i −1 i
1 −1 1 −1
1 i −1 −i




a0
a1
a2
a3


More on this later.
To compute A quickly, we can pre-compute common subexpressions:
A0 = (a0 + a2) + (a1 + a3)
A1 = (a0 − a2) − i(a1 − a3)
A2 = (a0 + a2) − (a1 + a3)
A3 = (a0 − a2) + i(a1 − a3)
5
This saves a lot of adds. (Note that each add and multiply here is a complex (not real) op-
eration.)
If we use the following diagram for a complex multiply and add:
p
q
α
p+αq
then we can diagram the 4-point DFT like so:
a0
1
a0+a2
a2
−1
a0−a2
a1
1
a1
+a3
a3
−1
a1
−a3
1
A0
−1
A2
−i
A1
i
A3
If we carry on to N = 8, N = 16, and other power-of-two discrete Fourier transforms,
we get...
The Fast Fourier Transform (FFT) Algorithm
The FFT is a fast algorithm for computing the DFT. If we take the 2-point DFT and 4-point
DFT and generalize them to 8-point, 16-point, ..., 2r
-point, we get the FFT algorithm.
To compute the DFT of an N-point sequence using equation (1) would take O(N2
) mul-
tiplies and adds. The FFT algorithm computes the DFT using O(N log N) multiplies and
adds.
There are many variants of the FFT algorithm. We’ll discuss one of them, the “decimation-
in-time” FFT algorithm for sequences whose length is a power of two (N = 2r
for some
integer r).
Below is a diagram of an 8-point FFT, where W = W8 = e−iπ/4
= (1 − i)/
√
2:
6
a0
1
a4
−1
a2
1
a6
−1
W 0
A0
W 2
W 4
W 6
a1
1
a5
−1
a3
1
a7
−1
W 0
W 2
W 4
W 6
W 0
W 4
W 1
W 5
W 2
W 6
W 3
W 7
A1
A2
A3
A4
A5
A6
A7
Butterflies and Bit-Reversal. The FFT algorithm decomposes the DFT into log2 N stages,
each of which consists of N/2 butterfly computations. Each butterfly takes two complex
numbers p and q and computes from them two other numbers, p + αq and p − αq, where
α is a complex number. Below is a diagram of a butterfly operation.
p
α
p+αq
q
−α
p−αq
In the diagram of the 8-point FFT above, note that the inputs aren’t in normal order:
a0, a1, a2, a3, a4, a5, a6, a7, they’re in the bizarre order: a0, a4, a2, a6, a1, a5, a3, a7. Why
this sequence?
Below is a table of j and the index of the jth input sample, nj:
j 0 1 2 3 4 5 6 7
nj 0 4 2 6 1 5 3 7
j base 2 000 001 010 011 100 101 110 111
nj base 2 000 100 010 110 001 101 011 111
The pattern is obvious if j and nj are written in binary (last two rows of the table). Observe
that each nj is the bit-reversal of j. The sequence is also related to breadth-first traversal of
a binary tree.
It turns out that this FFT algorithm is simplest if the input array is rearranged to be in
bit-reversed order. The re-ordering can be done in one pass through the array a:
7
for j = 0 to N-1
nj = bit_reverse(j)
if (j<nj) swap a[j] and a[nj]
General FFT and IFFT Algorithm for N = 2r
. The previously diagrammed algorithm
for the 8-point FFT is easily generalized to any power of two. The input array is bit-reversed,
and the butterfly coefficients can be seen to have exponents in arithmetic sequence modulo
N. For example, for N = 8, the butterfly coefficients on the last stage in the diagram are
W0
, W1
, W2
, W3
, W4
, W5
, W6
, W7
. That is, powers of W in sequence. The coefficients
in the previous stage have exponents 0,2,4,6,0,2,4,6, which is equivalent to the sequence
0,2,4,6,8,10,12,14 modulo 8. And the exponents in the first stage are 1,-1,1,-1,1,-1,1,-1,
which is equivalent to W raised to the powers 0,4,0,4,0,4,0,4, and this is equivalent to the
exponent sequence 0,4,8,12,16,20,24,28 when taken modulo 8. The width of the butterflies
(the height of the ”X’s” in the diagram) can be seen to be 1, 2, 4, ... in successive stages, and
the butterflies are seen to be isolated in the first stage (groups of 1), then clustered into over-
lapping groups of 2 in the second stage, groups of 4 in the 3rd stage, etc. The generalization
to other powers of two should be evident from the diagrams for N = 4 and N = 8.
The inverse FFT (IFFT) is identical to the FFT, except one exchanges the roles of a and
A, the signs of all the exponents of W are negated, and there’s a division by N at the end.
Note that the fast way to compute mod( j, N) in the C programming language, for N a power
of two, is with bit-wise AND: “j&(N-1)”. This is faster than “j%N”, and it works for
positive or negative j, while the latter does not.
FFT Explained Using Matrix Factorization
The 8-point DFT can be written as a matrix product, where we let W = W8 = e−iπ/4
= (1 −
i)/
√
2: 

A0
A1
A2
A3
A4
A5
A6
A7


=


W0 W0 W0 W0 W0 W0 W0 W0
W0 W1 W2 W3 W4 W5 W6 W7
W0 W2 W4 W6 W0 W2 W4 W6
W0 W3 W6 W1 W4 W7 W2 W5
W0 W4 W0 W4 W0 W4 W0 W4
W0 W5 W2 W7 W4 W1 W6 W3
W0 W6 W4 W2 W0 W6 W4 W2
W0 W7 W6 W5 W4 W3 W2 W1




a0
a1
a2
a3
a4
a5
a6
a7


8
Rearranging so that the input array a is bit-reversed and factoring the 8 × 8 matrix:


A0
A1
A2
A3
A4
A5
A6
A7


=


W0
W0
W0
W0
W0
W0
W0
W0
W0 W4 W2 W6 W1 W5 W3 W7
W0 W0 W4 W4 W2 W2 W6 W6
W0 W4 W6 W2 W3 W7 W1 W5
W0 W0 W0 W0 W4 W4 W4 W4
W0 W4 W2 W6 W5 W1 W7 W3
W0
W0
W4
W4
W6
W6
W2
W2
W0 W4 W6 W2 W7 W3 W5 W1




a0
a4
a2
a6
a1
a5
a3
a7


=


1 · · · W0
· · ·
· 1 · · · W1 · ·
· · 1 · · · W2 ·
· · · 1 · · · W3
1 · · · W4 · · ·
· 1 · · · W5 · ·
· · 1 · · · W6 ·
· · · 1 · · · W7




1 · W0
· · · · ·
· 1 · W2 · · · ·
1 · W4 · · · · ·
· 1 · W6 · · · ·
· · · · 1 · W0 ·
· · · · · 1 · W2
· · · · 1 · W4 ·
· · · · · 1 · W6




1 W0
· · · · · ·
1 W4 · · · · · ·
· · 1 W0 · · · ·
· · 1 W4 · · · ·
· · · · 1 W0 · ·
· · · · 1 W4 · ·
· · · · · · 1 W0
· · · · · · 1 W4




a0
a4
a2
a6
a1
a5
a3
a7


where “·” means 0.
These are sparse matrices (lots of zeros), so multiplying by the dense (no zeros) matrix
on top is more expensive than multiplying by the three sparse matrices on the bottom.
For N = 2r
, the factorization would involve r matrices of size N × N, each with 2 non-
zero entries in each row and column.
How Much Faster is the FFT?
To compute the DFT of an N-point sequence using the definition,
Ak =
N−1
n=0
Wkn
N an,
would require N2
complex multiplies and adds, which works out to 4N2
real multiplies and
4N2
real adds (you can easily check this, using the definition of complex multiplication).
The basic computational step of the FFT algorithm is a butterfly. Each butterfly com-
putes two complex numbers of the form p + αq and p − αq, so it requires one complex
multiply (α · q) and two complex adds. This works out to 4 real multiplies and 6 real adds
per butterfly.
9
There are N/2 butterflies per stage, and log2 N stages, so that means about 4 · N/2 ·
log2 N = 2N log2 N real multiplies and 3N log2 N real adds for an N-point FFT. (There are
ways to optimize further, but this is the basic FFT algorithm.)
Cost comparison:
BRUTE FORCE FFT
N r = log2 N 4N2
2N log2 N speedup
2 1 16 4 4
4 2 64 16 4
8 3 256 48 5
1,024 10 4,194,304 20,480 205
65,536 16 1.7 · 1010
2.1 · 106
˜104
The FFT algorithm is a LOT faster for big N.
There are also FFT algorithms for N not a power of two. The algorithms are generally
fastest when N has many factors, however.
An excellent book on the FFT is: E. Oran Brigham, The Fast Fourier Transform, Prentice-
Hall, Englewood Cliffs, NJ, 1974.
Why Would We Want to Compute Fourier Transforms, Any-
way?
The FFT algorithm is used for fast convolution(linear, shift-invariant filtering). If h = f ∗ g
then convolution of continuous signals involves an integral:
h(x) =
+∞
−∞
f (t)g(x − t)dt, but convolution of discrete signals involves a sum: h[x] =
∞
t=−∞ f [t]g[x − t]. We might think of f as the signal and g as the filter.
When working with finite sequences, the definition of convolution simplifies if we as-
sume that f and g have the same length N and we regard the signals as being periodic, so
that f and g “wrap around”. Then we get circular convolution:
h[x] =
N−1
t=0
f [t]g[x − t mod N] for x = 0. . . N − 1
The convolution theorem says that the Fourier transform of the convolution of two sig-
nals is the product of their Fourier transforms: f ∗ g ↔ FG. The corresponding theorem
10
for discrete signals is that the DFT of the circular convolution of two signals is the product
of their DFT’s.
Computing the convolution with a straightforward algorithm would require N2
(real)
multiplies and adds – too expensive!
We can do the same computation faster using discrete Fourier transforms. If we compute
the DFT of sequence f and the DFT of sequence g, multiply them point-by-point, and then
compute the inverse DFT, we’ll get the same answer. This is called Fourier Convolution:
f g
f⊕g
×
F G
FG
FFT − O(NlogN)
IFFT
O(NlogN)
convolve
O(N2)
multiply
O(N)
spatial
domain
frequency
domain
⊕⊗
⊗
If we use the FFT algorithm, then the two DFT’s and the one inverse DFT have a to-
tal cost of 6N log2 N real multiplies, and the multiplication of transforms in the frequency
domain has a negligible cost of 4N real multiplies. The straightforward algorithm, on the
other hand, required N2
real multiplies.
Fourier convolution wins big for large N.
Often, circular convolution isn’t what you want, but this algorithm can be modified to
do standard “linear” convolution by padding the sequences with zeros appropriately.
Fourier Transforms of Images
The two-dimensional discrete Fourier transform is a simple generalization of the standard
1-D DFT:
Ak,l =
M−1
m=0
N−1
n=0
Wkm
M Wln
N am,n
11
This is the general formula, good for rectangular images whose dimensions are not neces-
sarily powers of two. If you evaluate DFT’s of images with this formula, the cost is O(N4
)
– this is way too slow if N is large! But if you exploit the common subexpressions from row
to row, or from column to column, you get a speedup to O(N3
) (even without using FFT):
To compute the Fourier transform of an image, you
• Compute 1-D DFT of each row, in place.
• Compute 1-D DFT of each column, in place.
Most often, you see people assuming M = N = 2r
, but as mentioned previously, there
are FFT algorithms for other cases.
For an N × N picture, N a power of 2, the cost of a 2-D FFT is proportional to N2
log N.
( Can you derive this? ) Quite a speedup relative to O(N4
)!
Practical issues: For display purposes, you probably want to cyclically translate the pic-
ture so that pixel (0,0), which now contains frequency (ωx, ωy) = (0,0), moves to the center
of the image. And you probably want to display pixel values proportional to log(magnitude)
of each complex number (this looks more interesting than just magnitude). For color im-
ages, do the above to each of the three channels (R, G, and B) independently.
FFT’s are also used for synthesis of fractal textures and to create images with a given
spectrum.
Fourier Transforms and Arithmetic
The FFT is also used for fast extended precision arithmetic (e.g. computing π to a zillion
digits), and multiplication of high-degree polynomials, since they also involve convolution.
If polynomials p and q have the form: p(x) = N−1
n=0 fnxn
and q(x) = N−1
n=0 gnxn
then their
product is the polynomial
r(x) = p(x)q(x) =
N−1
n=0
fnxn
N−1
n=0
gnxn
= ( f0 + f1x + f2x2
+ ···)(g0 + g1x + g2x2
+ ···)
= f0g0 + ( f0g1 + f1g0)x + ( f0g2 + f1g1 + f2g0)x2
+ ···
=
2N−2
n=0
hnxn
12
where hn = N−1
j=0 f jgn− j, and h = f ∗ g. Thus, computing the product of two polynomials
involves the convolution of their coefficient sequences.
Extended precision numbers (numbers with hundreds or thousands of significant figures)
are typically stored with a fixed number of bits or digits per computer word. This is equiv-
alent to a polynomial where x has a fixed value. For storage of 32 bits per word or 9 digits
per word, one would use x = 232
or 109
, respectively. Multiplication of extended preci-
sion numbers thus involves the multiplication of high-degree polynomials, or convolution
of long sequences.
When N is small (< 100, say), then straightforward convolution is reasonable, but for
large N, it makes sense to compute convolutions using Fourier convolution.
13

Recomendados

Dsp U Lec10 DFT And FFT por
Dsp U   Lec10  DFT And  FFTDsp U   Lec10  DFT And  FFT
Dsp U Lec10 DFT And FFTtaha25
8.7K visualizações20 slides
Decimation in Time por
Decimation in TimeDecimation in Time
Decimation in TimeSURAJ KUMAR SAINI
672 visualizações13 slides
Radix-2 DIT FFT por
Radix-2 DIT FFT Radix-2 DIT FFT
Radix-2 DIT FFT Sarang Joshi
8.3K visualizações22 slides
Fast Fourier Transform por
Fast Fourier TransformFast Fourier Transform
Fast Fourier Transformop205
36.7K visualizações50 slides
fourier representation of signal and systems por
fourier representation of signal and systemsfourier representation of signal and systems
fourier representation of signal and systemsSugeng Widodo
3.3K visualizações135 slides
Discrete fourier transform por
Discrete fourier transformDiscrete fourier transform
Discrete fourier transformMOHAMMAD AKRAM
3K visualizações15 slides

Mais conteúdo relacionado

Mais procurados

Introduction to Fourier transform and signal analysis por
Introduction to Fourier transform and signal analysisIntroduction to Fourier transform and signal analysis
Introduction to Fourier transform and signal analysis宗翰 謝
7.1K visualizações49 slides
DSP_FOEHU - Lec 08 - The Discrete Fourier Transform por
DSP_FOEHU - Lec 08 - The Discrete Fourier TransformDSP_FOEHU - Lec 08 - The Discrete Fourier Transform
DSP_FOEHU - Lec 08 - The Discrete Fourier TransformAmr E. Mohamed
1.5K visualizações52 slides
Fourier transform por
Fourier transformFourier transform
Fourier transformSolo Hermelin
10.1K visualizações105 slides
Fourier Transform por
Fourier TransformFourier Transform
Fourier TransformNidhi Baranwal
5.1K visualizações14 slides
Chapter 9 computation of the dft por
Chapter 9 computation of the dftChapter 9 computation of the dft
Chapter 9 computation of the dftmikeproud
3.6K visualizações50 slides
Fft analysis por
Fft analysisFft analysis
Fft analysisSatrious
157 visualizações22 slides

Mais procurados(20)

Introduction to Fourier transform and signal analysis por 宗翰 謝
Introduction to Fourier transform and signal analysisIntroduction to Fourier transform and signal analysis
Introduction to Fourier transform and signal analysis
宗翰 謝7.1K visualizações
DSP_FOEHU - Lec 08 - The Discrete Fourier Transform por Amr E. Mohamed
DSP_FOEHU - Lec 08 - The Discrete Fourier TransformDSP_FOEHU - Lec 08 - The Discrete Fourier Transform
DSP_FOEHU - Lec 08 - The Discrete Fourier Transform
Amr E. Mohamed1.5K visualizações
Fourier transform por Solo Hermelin
Fourier transformFourier transform
Fourier transform
Solo Hermelin10.1K visualizações
Fourier Transform por Nidhi Baranwal
Fourier TransformFourier Transform
Fourier Transform
Nidhi Baranwal5.1K visualizações
Chapter 9 computation of the dft por mikeproud
Chapter 9 computation of the dftChapter 9 computation of the dft
Chapter 9 computation of the dft
mikeproud3.6K visualizações
Fft analysis por Satrious
Fft analysisFft analysis
Fft analysis
Satrious157 visualizações
Fourier series Introduction por Rizwan Kazi
Fourier series IntroductionFourier series Introduction
Fourier series Introduction
Rizwan Kazi2.3K visualizações
Fourier transform por auttaponsripradit
Fourier transformFourier transform
Fourier transform
auttaponsripradit113 visualizações
Fft por akliluw
FftFft
Fft
akliluw5.2K visualizações
DSP_2018_FOEHU - Lec 08 - The Discrete Fourier Transform por Amr E. Mohamed
DSP_2018_FOEHU - Lec 08 - The Discrete Fourier TransformDSP_2018_FOEHU - Lec 08 - The Discrete Fourier Transform
DSP_2018_FOEHU - Lec 08 - The Discrete Fourier Transform
Amr E. Mohamed4.4K visualizações
Digital Signal Processing Tutorial:Chapt 3 frequency analysis por Chandrashekhar Padole
Digital Signal Processing Tutorial:Chapt 3 frequency analysisDigital Signal Processing Tutorial:Chapt 3 frequency analysis
Digital Signal Processing Tutorial:Chapt 3 frequency analysis
Chandrashekhar Padole3.8K visualizações
Fft ppt por Puneet Gupta
Fft pptFft ppt
Fft ppt
Puneet Gupta14.1K visualizações
Properties of dft por tamil arasan
Properties of dftProperties of dft
Properties of dft
tamil arasan1.4K visualizações
Digital Signal Processing[ECEG-3171]-Ch1_L04 por Rediet Moges
Digital Signal Processing[ECEG-3171]-Ch1_L04Digital Signal Processing[ECEG-3171]-Ch1_L04
Digital Signal Processing[ECEG-3171]-Ch1_L04
Rediet Moges855 visualizações
The discrete fourier transform (dsp) 4 por HIMANSHU DIWAKAR
The discrete fourier transform  (dsp) 4The discrete fourier transform  (dsp) 4
The discrete fourier transform (dsp) 4
HIMANSHU DIWAKAR3.9K visualizações
Fourier transforms por Iffat Anjum
Fourier transformsFourier transforms
Fourier transforms
Iffat Anjum30.6K visualizações
Digital Signal Processing[ECEG-3171]-Ch1_L03 por Rediet Moges
Digital Signal Processing[ECEG-3171]-Ch1_L03Digital Signal Processing[ECEG-3171]-Ch1_L03
Digital Signal Processing[ECEG-3171]-Ch1_L03
Rediet Moges3.6K visualizações
Presentation on fourier transformation por Wasim Shah
Presentation on fourier transformationPresentation on fourier transformation
Presentation on fourier transformation
Wasim Shah1.5K visualizações
DSP_FOEHU - MATLAB 04 - The Discrete Fourier Transform (DFT) por Amr E. Mohamed
DSP_FOEHU - MATLAB 04 - The Discrete Fourier Transform (DFT)DSP_FOEHU - MATLAB 04 - The Discrete Fourier Transform (DFT)
DSP_FOEHU - MATLAB 04 - The Discrete Fourier Transform (DFT)
Amr E. Mohamed4.6K visualizações

Similar a Fourier transforms & fft algorithm (paul heckbert, 1998) by tantanoid

Image trnsformations por
Image trnsformationsImage trnsformations
Image trnsformationsJohn Williams
16.7K visualizações73 slides
z transforms por
z transformsz transforms
z transformsShahbaz Goshtasebi
24.3K visualizações73 slides
Fourier Analysis por
Fourier AnalysisFourier Analysis
Fourier AnalysisAli Osman Öncel
778 visualizações17 slides
Fourier Analysis por
Fourier AnalysisFourier Analysis
Fourier AnalysisAli Osman Öncel
600 visualizações17 slides
Optics Fourier Transform Ii por
Optics Fourier Transform IiOptics Fourier Transform Ii
Optics Fourier Transform Iidiarmseven
4.3K visualizações32 slides
Wave diffraction por
Wave diffractionWave diffraction
Wave diffractioneli priyatna laidan
663 visualizações64 slides

Similar a Fourier transforms & fft algorithm (paul heckbert, 1998) by tantanoid(20)

Image trnsformations por John Williams
Image trnsformationsImage trnsformations
Image trnsformations
John Williams16.7K visualizações
z transforms por Shahbaz Goshtasebi
z transformsz transforms
z transforms
Shahbaz Goshtasebi24.3K visualizações
Fourier Analysis por Ali Osman Öncel
Fourier AnalysisFourier Analysis
Fourier Analysis
Ali Osman Öncel778 visualizações
Fourier Analysis por Ali Osman Öncel
Fourier AnalysisFourier Analysis
Fourier Analysis
Ali Osman Öncel600 visualizações
Optics Fourier Transform Ii por diarmseven
Optics Fourier Transform IiOptics Fourier Transform Ii
Optics Fourier Transform Ii
diarmseven4.3K visualizações
Ch13 por douglaslyon
Ch13Ch13
Ch13
douglaslyon313 visualizações
Find the compact trigonometric Fourier series for the periodic signal.pdf por arihantelectronics
Find the compact trigonometric Fourier series for the periodic signal.pdfFind the compact trigonometric Fourier series for the periodic signal.pdf
Find the compact trigonometric Fourier series for the periodic signal.pdf
arihantelectronics13 visualizações
Lecture 9 por Wael Sharba
Lecture 9Lecture 9
Lecture 9
Wael Sharba623 visualizações
Time Series Analysis por Amit Ghosh
Time Series AnalysisTime Series Analysis
Time Series Analysis
Amit Ghosh951 visualizações
Low rank tensor approximation of probability density and characteristic funct... por Alexander Litvinenko
Low rank tensor approximation of probability density and characteristic funct...Low rank tensor approximation of probability density and characteristic funct...
Low rank tensor approximation of probability density and characteristic funct...
Alexander Litvinenko44 visualizações
Unit ii por Chetan Selukar
Unit iiUnit ii
Unit ii
Chetan Selukar8.7K visualizações
Fourier series of odd functions with period 2 l por Pepa Vidosa Serradilla
Fourier series of odd functions with period 2 lFourier series of odd functions with period 2 l
Fourier series of odd functions with period 2 l
Pepa Vidosa Serradilla6.3K visualizações
EC8553 Discrete time signal processing por ssuser2797e4
EC8553 Discrete time signal processing EC8553 Discrete time signal processing
EC8553 Discrete time signal processing
ssuser2797e4403 visualizações
Fourier Specturm via MATLAB por ZunAib Ali
Fourier Specturm via MATLABFourier Specturm via MATLAB
Fourier Specturm via MATLAB
ZunAib Ali1.4K visualizações
Properties of Fourier transform por Muhammed Afsal Villan
Properties of Fourier transformProperties of Fourier transform
Properties of Fourier transform
Muhammed Afsal Villan6.7K visualizações
21 5 ztransform por Mahyar Alzobaidy
21 5 ztransform21 5 ztransform
21 5 ztransform
Mahyar Alzobaidy621 visualizações
Unit vii por mrecedu
Unit viiUnit vii
Unit vii
mrecedu647 visualizações

Mais de Xavier Davias

Metodos numericos-3-1212530740013750-9 por
Metodos numericos-3-1212530740013750-9Metodos numericos-3-1212530740013750-9
Metodos numericos-3-1212530740013750-9Xavier Davias
15.9K visualizações45 slides
Heckbert p s__adaptive_radiosity_textures_for_bidirectional_r por
Heckbert p s__adaptive_radiosity_textures_for_bidirectional_rHeckbert p s__adaptive_radiosity_textures_for_bidirectional_r
Heckbert p s__adaptive_radiosity_textures_for_bidirectional_rXavier Davias
739 visualizações10 slides
03.problemas por
03.problemas03.problemas
03.problemasXavier Davias
235 visualizações3 slides
Systems interfacesanddeployment por
Systems interfacesanddeploymentSystems interfacesanddeployment
Systems interfacesanddeploymentXavier Davias
1.1K visualizações108 slides
Oracle b tree index internals - rebuilding the thruth por
Oracle b tree index internals - rebuilding the thruthOracle b tree index internals - rebuilding the thruth
Oracle b tree index internals - rebuilding the thruthXavier Davias
4.9K visualizações83 slides
Sistemas temaii 5 por
Sistemas temaii 5Sistemas temaii 5
Sistemas temaii 5Xavier Davias
257 visualizações4 slides

Mais de Xavier Davias(20)

Metodos numericos-3-1212530740013750-9 por Xavier Davias
Metodos numericos-3-1212530740013750-9Metodos numericos-3-1212530740013750-9
Metodos numericos-3-1212530740013750-9
Xavier Davias15.9K visualizações
Heckbert p s__adaptive_radiosity_textures_for_bidirectional_r por Xavier Davias
Heckbert p s__adaptive_radiosity_textures_for_bidirectional_rHeckbert p s__adaptive_radiosity_textures_for_bidirectional_r
Heckbert p s__adaptive_radiosity_textures_for_bidirectional_r
Xavier Davias739 visualizações
03.problemas por Xavier Davias
03.problemas03.problemas
03.problemas
Xavier Davias235 visualizações
Systems interfacesanddeployment por Xavier Davias
Systems interfacesanddeploymentSystems interfacesanddeployment
Systems interfacesanddeployment
Xavier Davias1.1K visualizações
Oracle b tree index internals - rebuilding the thruth por Xavier Davias
Oracle b tree index internals - rebuilding the thruthOracle b tree index internals - rebuilding the thruth
Oracle b tree index internals - rebuilding the thruth
Xavier Davias4.9K visualizações
Sistemas temaii 5 por Xavier Davias
Sistemas temaii 5Sistemas temaii 5
Sistemas temaii 5
Xavier Davias257 visualizações
Simulacion sistemas tema6pr-2 por Xavier Davias
Simulacion sistemas tema6pr-2Simulacion sistemas tema6pr-2
Simulacion sistemas tema6pr-2
Xavier Davias399 visualizações
El hombre anumerico john allen paulos por Xavier Davias
El hombre anumerico  john allen paulosEl hombre anumerico  john allen paulos
El hombre anumerico john allen paulos
Xavier Davias12.3K visualizações
Clase3 por Xavier Davias
Clase3Clase3
Clase3
Xavier Davias214 visualizações
Cap04 por Xavier Davias
Cap04Cap04
Cap04
Xavier Davias288 visualizações
Cap2 por Xavier Davias
Cap2Cap2
Cap2
Xavier Davias490 visualizações
Cap1 por Xavier Davias
Cap1Cap1
Cap1
Xavier Davias1.1K visualizações
Aic multiproc por Xavier Davias
Aic multiprocAic multiproc
Aic multiproc
Xavier Davias597 visualizações
Aa por Xavier Davias
AaAa
Aa
Xavier Davias698 visualizações
08 0300 cs por Xavier Davias
08 0300 cs08 0300 cs
08 0300 cs
Xavier Davias560 visualizações
Cp223 por Xavier Davias
Cp223Cp223
Cp223
Xavier Davias536 visualizações
Cap04 por Xavier Davias
Cap04Cap04
Cap04
Xavier Davias435 visualizações
Ejercicios tema7 por Xavier Davias
Ejercicios tema7Ejercicios tema7
Ejercicios tema7
Xavier Davias287 visualizações
Ejercicios tema6 por Xavier Davias
Ejercicios tema6Ejercicios tema6
Ejercicios tema6
Xavier Davias1.2K visualizações
Ejercicios tema5 por Xavier Davias
Ejercicios tema5Ejercicios tema5
Ejercicios tema5
Xavier Davias256 visualizações

Último

"Surviving highload with Node.js", Andrii Shumada por
"Surviving highload with Node.js", Andrii Shumada "Surviving highload with Node.js", Andrii Shumada
"Surviving highload with Node.js", Andrii Shumada Fwdays
53 visualizações29 slides
Digital Personal Data Protection (DPDP) Practical Approach For CISOs por
Digital Personal Data Protection (DPDP) Practical Approach For CISOsDigital Personal Data Protection (DPDP) Practical Approach For CISOs
Digital Personal Data Protection (DPDP) Practical Approach For CISOsPriyanka Aash
153 visualizações59 slides
CloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&T por
CloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&TCloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&T
CloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&TShapeBlue
112 visualizações34 slides
KVM Security Groups Under the Hood - Wido den Hollander - Your.Online por
KVM Security Groups Under the Hood - Wido den Hollander - Your.OnlineKVM Security Groups Under the Hood - Wido den Hollander - Your.Online
KVM Security Groups Under the Hood - Wido den Hollander - Your.OnlineShapeBlue
181 visualizações19 slides
What’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlue por
What’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlueWhat’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlue
What’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlueShapeBlue
222 visualizações23 slides
The Power of Heat Decarbonisation Plans in the Built Environment por
The Power of Heat Decarbonisation Plans in the Built EnvironmentThe Power of Heat Decarbonisation Plans in the Built Environment
The Power of Heat Decarbonisation Plans in the Built EnvironmentIES VE
69 visualizações20 slides

Último(20)

"Surviving highload with Node.js", Andrii Shumada por Fwdays
"Surviving highload with Node.js", Andrii Shumada "Surviving highload with Node.js", Andrii Shumada
"Surviving highload with Node.js", Andrii Shumada
Fwdays53 visualizações
Digital Personal Data Protection (DPDP) Practical Approach For CISOs por Priyanka Aash
Digital Personal Data Protection (DPDP) Practical Approach For CISOsDigital Personal Data Protection (DPDP) Practical Approach For CISOs
Digital Personal Data Protection (DPDP) Practical Approach For CISOs
Priyanka Aash153 visualizações
CloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&T por ShapeBlue
CloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&TCloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&T
CloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&T
ShapeBlue112 visualizações
KVM Security Groups Under the Hood - Wido den Hollander - Your.Online por ShapeBlue
KVM Security Groups Under the Hood - Wido den Hollander - Your.OnlineKVM Security Groups Under the Hood - Wido den Hollander - Your.Online
KVM Security Groups Under the Hood - Wido den Hollander - Your.Online
ShapeBlue181 visualizações
What’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlue por ShapeBlue
What’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlueWhat’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlue
What’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlue
ShapeBlue222 visualizações
The Power of Heat Decarbonisation Plans in the Built Environment por IES VE
The Power of Heat Decarbonisation Plans in the Built EnvironmentThe Power of Heat Decarbonisation Plans in the Built Environment
The Power of Heat Decarbonisation Plans in the Built Environment
IES VE69 visualizações
How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ... por ShapeBlue
How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ...How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ...
How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ...
ShapeBlue123 visualizações
Backroll, News and Demo - Pierre Charton, Matthias Dhellin, Ousmane Diarra - ... por ShapeBlue
Backroll, News and Demo - Pierre Charton, Matthias Dhellin, Ousmane Diarra - ...Backroll, News and Demo - Pierre Charton, Matthias Dhellin, Ousmane Diarra - ...
Backroll, News and Demo - Pierre Charton, Matthias Dhellin, Ousmane Diarra - ...
ShapeBlue146 visualizações
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N... por James Anderson
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
James Anderson156 visualizações
Updates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBIT por ShapeBlue
Updates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBITUpdates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBIT
Updates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBIT
ShapeBlue166 visualizações
Extending KVM Host HA for Non-NFS Storage - Alex Ivanov - StorPool por ShapeBlue
Extending KVM Host HA for Non-NFS Storage -  Alex Ivanov - StorPoolExtending KVM Host HA for Non-NFS Storage -  Alex Ivanov - StorPool
Extending KVM Host HA for Non-NFS Storage - Alex Ivanov - StorPool
ShapeBlue84 visualizações
CloudStack Managed User Data and Demo - Harikrishna Patnala - ShapeBlue por ShapeBlue
CloudStack Managed User Data and Demo - Harikrishna Patnala - ShapeBlueCloudStack Managed User Data and Demo - Harikrishna Patnala - ShapeBlue
CloudStack Managed User Data and Demo - Harikrishna Patnala - ShapeBlue
ShapeBlue94 visualizações
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLive por Network Automation Forum
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLiveAutomating a World-Class Technology Conference; Behind the Scenes of CiscoLive
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLive
Network Automation Forum50 visualizações
Confidence in CloudStack - Aron Wagner, Nathan Gleason - Americ por ShapeBlue
Confidence in CloudStack - Aron Wagner, Nathan Gleason - AmericConfidence in CloudStack - Aron Wagner, Nathan Gleason - Americ
Confidence in CloudStack - Aron Wagner, Nathan Gleason - Americ
ShapeBlue88 visualizações
Why and How CloudStack at weSystems - Stephan Bienek - weSystems por ShapeBlue
Why and How CloudStack at weSystems - Stephan Bienek - weSystemsWhy and How CloudStack at weSystems - Stephan Bienek - weSystems
Why and How CloudStack at weSystems - Stephan Bienek - weSystems
ShapeBlue197 visualizações
The Role of Patterns in the Era of Large Language Models por Yunyao Li
The Role of Patterns in the Era of Large Language ModelsThe Role of Patterns in the Era of Large Language Models
The Role of Patterns in the Era of Large Language Models
Yunyao Li80 visualizações
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda... por ShapeBlue
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...
ShapeBlue120 visualizações
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue por ShapeBlue
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlueElevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue
ShapeBlue179 visualizações
Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ... por ShapeBlue
Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ...Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ...
Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ...
ShapeBlue85 visualizações

Fourier transforms & fft algorithm (paul heckbert, 1998) by tantanoid

  • 1. Notes 3, Computer Graphics 2, 15-463 Fourier Transforms and the Fast Fourier Transform (FFT) Algorithm Paul Heckbert Feb. 1995 Revised 27 Jan. 1998 We start in the continuous world; then we get discrete. Definition of the Fourier Transform The Fourier transform (FT) of the function f (x) is the function F(ω), where: F(ω) = ∞ −∞ f (x)e−iωx dx and the inverse Fourier transform is f (x) = 1 2π ∞ −∞ F(ω)eiωx dω Recall that i = √ −1 and eiθ = cos θ + i sinθ. Think of it as a transformation into a different set of basis functions. The Fourier trans- form uses complex exponentials (sinusoids) of various frequencies as its basis functions. (Other transforms, such as Z, Laplace, Cosine, Wavelet, and Hartley, use different basis functions). A Fourier transform pair is often written f (x) ↔ F(ω), or F ( f (x)) = F(ω) where F is the Fourier transform operator. If f (x) is thought of as a signal (i.e. input data) then we call F(ω) the signal’s spectrum. If f is thought of as the impulse response of a filter (which operates on input data to produce output data) then we call F the filter’s frequency response. (Occasionally the line between what’s signal and what’s filter becomes blurry). 1
  • 2. Example of a Fourier Transform Suppose we want to create a filter that eliminates high frequencies but retains low frequen- cies (this is very useful in antialiasing). In signal processing terminology, this is called an ideal low pass filter. So we’ll specify a box-shaped frequency response with cutoff fre- quency ωc: F(ω) = 1 |ω| ≤ ωc 0 |ω| > ωc What is its impulse response? We know that the impulse response is the inverse Fourier transform of the frequency response, so taking off our signal processing hat and putting on our mathematics hat, all we need to do is evaluate: f (x) = 1 2π ∞ −∞ F(ω)eiωx dω for this particular F(ω): f (x) = 1 2π ωc −ωc eiωx dω = 1 2π eiωx ix ωc ω=−ωc = 1 πx eiωcx − e−iωcx 2i = sinωcx πx since sinθ = eiθ − e−iθ 2i = ωc π sinc( ωc π x) where sinc(x) = sin(πx)/(πx). For antialiasing with unit-spaced samples, you want the cutoff frequency to equal the Nyquist frequency, so ωc = π. Fourier Transform Properties Rather than write “the Fourier transform of an X function is a Y function”, we write the shorthand: X ↔ Y. If z is a complex number and z = x + iy where x and y are its real and imaginary parts, then the complex conjugate of z is z∗ = x − iy. A function f (u) is even if f (u) = f (−u), it is odd if f (u) = − f (−u), it is conjugate symmetric if f (u) = f ∗ (−u), and it is conjugate antisymmetric if f (u) = − f ∗ (−u). 2
  • 3. discrete ↔ periodic periodic ↔ discrete discrete, periodic ↔ discrete, periodic real ↔ conjugate symmetric imaginary ↔ conjugate antisymmetric box ↔ sinc sinc ↔ box Gaussian ↔ Gaussian impulse ↔ constant impulse train ↔ impulse train (can you prove the above?) When a signal is scaled up spatially, its spectrum is scaled down in frequency, and vice versa: f (ax) ↔ F(ω/a) for any real, nonzero a. Convolution Theorem The Fourier transform of a convolution of two signals is the product of their Fourier trans- forms: f ∗ g ↔ FG. The convolution of two continuous signals f and g is ( f ∗ g)(x) = +∞ −∞ f (t)g(x − t)dt So +∞ −∞ f (t)g(x − t)dt ↔ F(ω)G(ω). The Fourier transform of a product of two signals is the convolution of their Fourier transforms: fg ↔ F ∗ G/2π. Delta Functions The (Dirac) delta function δ(x) is defined such that δ(x) = 0 for all x = 0, +∞ −∞ δ(t)dt = 1, and for any f (x): ( f ∗ δ)(x) = +∞ −∞ f (t)δ(x − t)dt = f (x) The latter is called the sifting property of delta functions. Because convolution with a delta is linear shift-invariant filtering, translating the delta by a will translate the output by a: f (x) ∗ δ(x − a) (x) = f (x − a) 3
  • 4. Discrete Fourier Transform (DFT) When a signal is discrete and periodic, we don’t need the continuous Fourier transform. Instead we use the discrete Fourier transform, or DFT. Suppose our signal is an for n = 0. . . N − 1, and an = an+ jN for all n and j. The discrete Fourier transform of a, also known as the spectrum of a, is: Ak = N−1 n=0 e−i 2π N kn an This is more commonly written: Ak = N−1 n=0 Wkn N an (1) where WN = e−i 2π N and Wk N for k = 0. . . N − 1 are called the Nth roots of unity. They’re called this because, in complex arithmetic, (Wk N )N = 1 for all k. They’re vertices of a regular polygon inscribed in the unit circle of the complex plane, with one vertex at (1,0). Below are roots of unity for N = 2, N = 4, and N = 8, graphed in the complex plane. W4 2 Re Im N=2 W2 0 W2 1 N=4 W4 0 W4 3 W4 1 1 −1 −1 1 i -i W8 4 N=8 W8 0 W8 6 W8 2 −1 1 i -i W8 7 W8 5 W8 3 W8 1 Powers of roots of unity are periodic with period N, since the Nth roots of unity are points on the complex unit circle every 2π/N radians apart, and multiplying by WN is equiv- alent to rotation clockwise by this angle. Multiplication by WN N is rotation by 2π radians, that is, no rotation at all. In general, Wk N = Wk+ jN N for all integer j. Thus, when raising WN to a power, the exponent can be taken modulo N. The sequence Ak is the discrete Fourier transform of the sequence an. Each is a sequence of N complex numbers. The sequence an is the inverse discrete Fourier transform of the sequence Ak. The for- mula for the inverse DFT is an = 1 N N−1 k=0 W−kn N Ak 4
  • 5. The formula is identical except that a and A have exchanged roles, as have k and n. Also, the exponent of W is negated, and there is a 1/N normalization in front. Two-point DFT (N=2) W2 = e−iπ = −1, and Ak = 1 n=0 (−1)kn an = (−1)k·0 a0 + (−1)k·1 a1 = a0 + (−1)k a1 so A0 = a0 + a1 A1 = a0 − a1 Four-point DFT (N=4) W4 = e−iπ/2 = −i, and Ak = 3 n=0 (−i)kn an = a0 + (−i)k a1 + (−i)2k a2 + (−i)3k a3 = a0 + (−i)k a1 + (−1)k a2 +ik a3 so A0 = a0 + a1 + a2 + a3 A1 = a0 − ia1 − a2 + ia3 A2 = a0 − a1 + a2 − a3 A3 = a0 + ia1 − a2 − ia3 This can also be written as a matrix multiply:   A0 A1 A2 A3   =   1 1 1 1 1 −i −1 i 1 −1 1 −1 1 i −1 −i     a0 a1 a2 a3   More on this later. To compute A quickly, we can pre-compute common subexpressions: A0 = (a0 + a2) + (a1 + a3) A1 = (a0 − a2) − i(a1 − a3) A2 = (a0 + a2) − (a1 + a3) A3 = (a0 − a2) + i(a1 − a3) 5
  • 6. This saves a lot of adds. (Note that each add and multiply here is a complex (not real) op- eration.) If we use the following diagram for a complex multiply and add: p q α p+αq then we can diagram the 4-point DFT like so: a0 1 a0+a2 a2 −1 a0−a2 a1 1 a1 +a3 a3 −1 a1 −a3 1 A0 −1 A2 −i A1 i A3 If we carry on to N = 8, N = 16, and other power-of-two discrete Fourier transforms, we get... The Fast Fourier Transform (FFT) Algorithm The FFT is a fast algorithm for computing the DFT. If we take the 2-point DFT and 4-point DFT and generalize them to 8-point, 16-point, ..., 2r -point, we get the FFT algorithm. To compute the DFT of an N-point sequence using equation (1) would take O(N2 ) mul- tiplies and adds. The FFT algorithm computes the DFT using O(N log N) multiplies and adds. There are many variants of the FFT algorithm. We’ll discuss one of them, the “decimation- in-time” FFT algorithm for sequences whose length is a power of two (N = 2r for some integer r). Below is a diagram of an 8-point FFT, where W = W8 = e−iπ/4 = (1 − i)/ √ 2: 6
  • 7. a0 1 a4 −1 a2 1 a6 −1 W 0 A0 W 2 W 4 W 6 a1 1 a5 −1 a3 1 a7 −1 W 0 W 2 W 4 W 6 W 0 W 4 W 1 W 5 W 2 W 6 W 3 W 7 A1 A2 A3 A4 A5 A6 A7 Butterflies and Bit-Reversal. The FFT algorithm decomposes the DFT into log2 N stages, each of which consists of N/2 butterfly computations. Each butterfly takes two complex numbers p and q and computes from them two other numbers, p + αq and p − αq, where α is a complex number. Below is a diagram of a butterfly operation. p α p+αq q −α p−αq In the diagram of the 8-point FFT above, note that the inputs aren’t in normal order: a0, a1, a2, a3, a4, a5, a6, a7, they’re in the bizarre order: a0, a4, a2, a6, a1, a5, a3, a7. Why this sequence? Below is a table of j and the index of the jth input sample, nj: j 0 1 2 3 4 5 6 7 nj 0 4 2 6 1 5 3 7 j base 2 000 001 010 011 100 101 110 111 nj base 2 000 100 010 110 001 101 011 111 The pattern is obvious if j and nj are written in binary (last two rows of the table). Observe that each nj is the bit-reversal of j. The sequence is also related to breadth-first traversal of a binary tree. It turns out that this FFT algorithm is simplest if the input array is rearranged to be in bit-reversed order. The re-ordering can be done in one pass through the array a: 7
  • 8. for j = 0 to N-1 nj = bit_reverse(j) if (j<nj) swap a[j] and a[nj] General FFT and IFFT Algorithm for N = 2r . The previously diagrammed algorithm for the 8-point FFT is easily generalized to any power of two. The input array is bit-reversed, and the butterfly coefficients can be seen to have exponents in arithmetic sequence modulo N. For example, for N = 8, the butterfly coefficients on the last stage in the diagram are W0 , W1 , W2 , W3 , W4 , W5 , W6 , W7 . That is, powers of W in sequence. The coefficients in the previous stage have exponents 0,2,4,6,0,2,4,6, which is equivalent to the sequence 0,2,4,6,8,10,12,14 modulo 8. And the exponents in the first stage are 1,-1,1,-1,1,-1,1,-1, which is equivalent to W raised to the powers 0,4,0,4,0,4,0,4, and this is equivalent to the exponent sequence 0,4,8,12,16,20,24,28 when taken modulo 8. The width of the butterflies (the height of the ”X’s” in the diagram) can be seen to be 1, 2, 4, ... in successive stages, and the butterflies are seen to be isolated in the first stage (groups of 1), then clustered into over- lapping groups of 2 in the second stage, groups of 4 in the 3rd stage, etc. The generalization to other powers of two should be evident from the diagrams for N = 4 and N = 8. The inverse FFT (IFFT) is identical to the FFT, except one exchanges the roles of a and A, the signs of all the exponents of W are negated, and there’s a division by N at the end. Note that the fast way to compute mod( j, N) in the C programming language, for N a power of two, is with bit-wise AND: “j&(N-1)”. This is faster than “j%N”, and it works for positive or negative j, while the latter does not. FFT Explained Using Matrix Factorization The 8-point DFT can be written as a matrix product, where we let W = W8 = e−iπ/4 = (1 − i)/ √ 2:   A0 A1 A2 A3 A4 A5 A6 A7   =   W0 W0 W0 W0 W0 W0 W0 W0 W0 W1 W2 W3 W4 W5 W6 W7 W0 W2 W4 W6 W0 W2 W4 W6 W0 W3 W6 W1 W4 W7 W2 W5 W0 W4 W0 W4 W0 W4 W0 W4 W0 W5 W2 W7 W4 W1 W6 W3 W0 W6 W4 W2 W0 W6 W4 W2 W0 W7 W6 W5 W4 W3 W2 W1     a0 a1 a2 a3 a4 a5 a6 a7   8
  • 9. Rearranging so that the input array a is bit-reversed and factoring the 8 × 8 matrix:   A0 A1 A2 A3 A4 A5 A6 A7   =   W0 W0 W0 W0 W0 W0 W0 W0 W0 W4 W2 W6 W1 W5 W3 W7 W0 W0 W4 W4 W2 W2 W6 W6 W0 W4 W6 W2 W3 W7 W1 W5 W0 W0 W0 W0 W4 W4 W4 W4 W0 W4 W2 W6 W5 W1 W7 W3 W0 W0 W4 W4 W6 W6 W2 W2 W0 W4 W6 W2 W7 W3 W5 W1     a0 a4 a2 a6 a1 a5 a3 a7   =   1 · · · W0 · · · · 1 · · · W1 · · · · 1 · · · W2 · · · · 1 · · · W3 1 · · · W4 · · · · 1 · · · W5 · · · · 1 · · · W6 · · · · 1 · · · W7     1 · W0 · · · · · · 1 · W2 · · · · 1 · W4 · · · · · · 1 · W6 · · · · · · · · 1 · W0 · · · · · · 1 · W2 · · · · 1 · W4 · · · · · · 1 · W6     1 W0 · · · · · · 1 W4 · · · · · · · · 1 W0 · · · · · · 1 W4 · · · · · · · · 1 W0 · · · · · · 1 W4 · · · · · · · · 1 W0 · · · · · · 1 W4     a0 a4 a2 a6 a1 a5 a3 a7   where “·” means 0. These are sparse matrices (lots of zeros), so multiplying by the dense (no zeros) matrix on top is more expensive than multiplying by the three sparse matrices on the bottom. For N = 2r , the factorization would involve r matrices of size N × N, each with 2 non- zero entries in each row and column. How Much Faster is the FFT? To compute the DFT of an N-point sequence using the definition, Ak = N−1 n=0 Wkn N an, would require N2 complex multiplies and adds, which works out to 4N2 real multiplies and 4N2 real adds (you can easily check this, using the definition of complex multiplication). The basic computational step of the FFT algorithm is a butterfly. Each butterfly com- putes two complex numbers of the form p + αq and p − αq, so it requires one complex multiply (α · q) and two complex adds. This works out to 4 real multiplies and 6 real adds per butterfly. 9
  • 10. There are N/2 butterflies per stage, and log2 N stages, so that means about 4 · N/2 · log2 N = 2N log2 N real multiplies and 3N log2 N real adds for an N-point FFT. (There are ways to optimize further, but this is the basic FFT algorithm.) Cost comparison: BRUTE FORCE FFT N r = log2 N 4N2 2N log2 N speedup 2 1 16 4 4 4 2 64 16 4 8 3 256 48 5 1,024 10 4,194,304 20,480 205 65,536 16 1.7 · 1010 2.1 · 106 ˜104 The FFT algorithm is a LOT faster for big N. There are also FFT algorithms for N not a power of two. The algorithms are generally fastest when N has many factors, however. An excellent book on the FFT is: E. Oran Brigham, The Fast Fourier Transform, Prentice- Hall, Englewood Cliffs, NJ, 1974. Why Would We Want to Compute Fourier Transforms, Any- way? The FFT algorithm is used for fast convolution(linear, shift-invariant filtering). If h = f ∗ g then convolution of continuous signals involves an integral: h(x) = +∞ −∞ f (t)g(x − t)dt, but convolution of discrete signals involves a sum: h[x] = ∞ t=−∞ f [t]g[x − t]. We might think of f as the signal and g as the filter. When working with finite sequences, the definition of convolution simplifies if we as- sume that f and g have the same length N and we regard the signals as being periodic, so that f and g “wrap around”. Then we get circular convolution: h[x] = N−1 t=0 f [t]g[x − t mod N] for x = 0. . . N − 1 The convolution theorem says that the Fourier transform of the convolution of two sig- nals is the product of their Fourier transforms: f ∗ g ↔ FG. The corresponding theorem 10
  • 11. for discrete signals is that the DFT of the circular convolution of two signals is the product of their DFT’s. Computing the convolution with a straightforward algorithm would require N2 (real) multiplies and adds – too expensive! We can do the same computation faster using discrete Fourier transforms. If we compute the DFT of sequence f and the DFT of sequence g, multiply them point-by-point, and then compute the inverse DFT, we’ll get the same answer. This is called Fourier Convolution: f g f⊕g × F G FG FFT − O(NlogN) IFFT O(NlogN) convolve O(N2) multiply O(N) spatial domain frequency domain ⊕⊗ ⊗ If we use the FFT algorithm, then the two DFT’s and the one inverse DFT have a to- tal cost of 6N log2 N real multiplies, and the multiplication of transforms in the frequency domain has a negligible cost of 4N real multiplies. The straightforward algorithm, on the other hand, required N2 real multiplies. Fourier convolution wins big for large N. Often, circular convolution isn’t what you want, but this algorithm can be modified to do standard “linear” convolution by padding the sequences with zeros appropriately. Fourier Transforms of Images The two-dimensional discrete Fourier transform is a simple generalization of the standard 1-D DFT: Ak,l = M−1 m=0 N−1 n=0 Wkm M Wln N am,n 11
  • 12. This is the general formula, good for rectangular images whose dimensions are not neces- sarily powers of two. If you evaluate DFT’s of images with this formula, the cost is O(N4 ) – this is way too slow if N is large! But if you exploit the common subexpressions from row to row, or from column to column, you get a speedup to O(N3 ) (even without using FFT): To compute the Fourier transform of an image, you • Compute 1-D DFT of each row, in place. • Compute 1-D DFT of each column, in place. Most often, you see people assuming M = N = 2r , but as mentioned previously, there are FFT algorithms for other cases. For an N × N picture, N a power of 2, the cost of a 2-D FFT is proportional to N2 log N. ( Can you derive this? ) Quite a speedup relative to O(N4 )! Practical issues: For display purposes, you probably want to cyclically translate the pic- ture so that pixel (0,0), which now contains frequency (ωx, ωy) = (0,0), moves to the center of the image. And you probably want to display pixel values proportional to log(magnitude) of each complex number (this looks more interesting than just magnitude). For color im- ages, do the above to each of the three channels (R, G, and B) independently. FFT’s are also used for synthesis of fractal textures and to create images with a given spectrum. Fourier Transforms and Arithmetic The FFT is also used for fast extended precision arithmetic (e.g. computing π to a zillion digits), and multiplication of high-degree polynomials, since they also involve convolution. If polynomials p and q have the form: p(x) = N−1 n=0 fnxn and q(x) = N−1 n=0 gnxn then their product is the polynomial r(x) = p(x)q(x) = N−1 n=0 fnxn N−1 n=0 gnxn = ( f0 + f1x + f2x2 + ···)(g0 + g1x + g2x2 + ···) = f0g0 + ( f0g1 + f1g0)x + ( f0g2 + f1g1 + f2g0)x2 + ··· = 2N−2 n=0 hnxn 12
  • 13. where hn = N−1 j=0 f jgn− j, and h = f ∗ g. Thus, computing the product of two polynomials involves the convolution of their coefficient sequences. Extended precision numbers (numbers with hundreds or thousands of significant figures) are typically stored with a fixed number of bits or digits per computer word. This is equiv- alent to a polynomial where x has a fixed value. For storage of 32 bits per word or 9 digits per word, one would use x = 232 or 109 , respectively. Multiplication of extended preci- sion numbers thus involves the multiplication of high-degree polynomials, or convolution of long sequences. When N is small (< 100, say), then straightforward convolution is reasonable, but for large N, it makes sense to compute convolutions using Fourier convolution. 13