Lode's Computer Graphics Tutorial Fourier Transform
The Fourier TransformSo how do you calculate the spectrum of a given signal? With the Fourier Transform!The Continuous Fourier Transform, for use on continuous signals, is defined as follows:And the Inverse Continuous Fourier Transform, which allows you to go from the spectrum back to thesignal, is defined as:F(w) is the spectrum, where w represents the frequency, and f(x) is the signal in the time where xrepresents the time. i is sqrt(-1), see complex number theory.Note the similarity between both transforms, which explains the duality between a signal and it'sspectrum.A computer can't work with continuous signals, only with finite discrete signals. Those are finite intime, and have only a discrete set of points (i.e. the signal is sampled). One of the properties of theFourier Transform and it's inverse is, that the FT of a discrete signal is periodic. Since for a computerboth the signal and the specrum must be discrete, both the signal and spectrum will be periodic. But bytaking only one period of it, we get our finite signal. So if you're taking the DFT of a signal or an imageon the computer, mathematicaly speaking, that signal is infinitely repeated, or the image infinitely tiled,and so is the spectrum. A nice property is that both the signal and the spectrum will have the samenumber of discrete points, so the DFT of an image of 128*128 pixels will also have 128*128 pixels.Since the signal is finite in time, the infinite borders of the integrals can be replaced by finite ones, andthe integral symbol can be replaced by a sum. So the DFT is defined as:And the inverse as:
This looks already much more programmable on a computer, to program the FT, you have to do thecalculation for every n, so you get a double for loop (one for every n, and one for every k, which is thesum). The exponential of the imaginary number can be replaced by a cos and a sin by using the famousformuma e^ix = cosx + isinx. More on programming it follows further in this tutorial.There are multiple definitions of the DFT, for example you can also do the division through N in theforward DFT instead of the inverse one, or divide through sqrt(N) in both. To plot it on a computer, thebest result is gotten by dividing through N in the forward DFT.Properties of The Fourier TransformA signal is often denoted with a small letter, and it's fourier transform or spectrum with a capital letter.The relatoin between a signal and it's spectrum is often denoted with f(x) F(w), with thesignal on the left and it's spectrum on the right.The Fourier Transform has some interesting properties, some of which make it easier to understandwhy spectra of certain signals have a certain shape.Don't take this as a proper list however, some scaling factors like 2*pi are left away, they're not thatimportant and can be left away or depending if you use frequency or pulsation. Handbooks of SigalProcessing and sites like Wikipedia and Mathworld contain much more complete and mathematicallycorrect tables of FT properties. We're most interested in the shape of the functions and not the scale.Linearityf(x)+g(x) F(w)+G(w)a*f(x) a*F(w)This means that if you add/substract two signals, their spectra are added/substracted as wall, and if youincrease/decrease the amplitude of the signal, the amplitude of it's spectrum will be increased/decreasedwith the same factor.Scalingf(a*x) (1/a) * F(w/a)This means that if you make the function wider in the x-direction, it's spectrum will become smaller inthe x-direction, and vica versa. The amplitude will also be changed.Time Shiftingf(x-x0) (exp(-i*w*x0)) * F(w)Since the only thing that happens if you shift the time, is a multiplication of the Fourier Transform withthe exponential of an imaginary number, you won't see the difference of a time shift in the amplitude ofthe spectrum, only in the phase.