- Text
- Spectrum,
- Fourier,
- Imaginary,
- Filter,
- Component,
- Frequency,
- Amplitude,
- Functions,
- Inverse,
- Transform,
- Graphics,
- Tutorial

Lode's Computer Graphics Tutorial Fourier Transform

The **Fourier** **Transform**So 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 the**Fourier** **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** **Transform**A 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.

- Page 1 and 2: Lode's Computer Graphics TutorialFo
- Page 3 and 4: would have a single peak. A spectru
- Page 5: The spectrum is positive everywhere
- Page 9 and 10: that remains at fixed position, whi
- Page 11 and 12: It takes 4 arrays as parameters: *g
- Page 13 and 14: FFT, which uses only O(n*logn) oper
- Page 15 and 16: FiltersIn the Fourier Domain, it's
- Page 17 and 18: Now the keys all change the spectru
- Page 19 and 20: A HP FilterHere, the same is done w
- Page 21 and 22: The main function first loads an im
- Page 23 and 24: And here's the Fast Fourier Transfo
- Page 25 and 26: left corner at xpos,yPos. The shift
- Page 27 and 28: would have only 2 color channels, o
- Page 29 and 30: The sloped lines in the spectrum he
- Page 31 and 32: shown here, the code for all keys i
- Page 33 and 34: }calculateAmp(N, M, fAmp[0][0], fRe
- Page 35 and 36: component back.This is the original
- Page 37 and 38: In the above images, a circular sec
- Page 39 and 40: It looks pretty ugly, because there
- Page 41 and 42: And here's the result of a much thi