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

Lode's Computer Graphics Tutorial Fourier Transform

There is also another way to calculate the FT of color images however, by using quaternions instead ofcomplex numbers, which can convert an image of 4 channels to another image with 4 channels.Before beginning with the **Fourier** **Transform** on images, which is the 2D version of the FT, we'll startwith the easier 1D FT, which is often used for audio and electromagnetical signals.To fully understand this tutorial, it'd be interesting to know about complex numbers, their magnitude(amplitude), and argument (phase). If you'd like to learn more about these, there's an appendix aboutcomplex numbers (one of the other html files), or find a tutorial with google.The following two source files can be downloaded to have all the code described:fourier2d.cppfourier1d.cppSignals and SpectraBefore starting with the **Fourier** **Transform**, an introduction about Signals and Spectra is in place. Assignals, for now consider signals in the time, like audio and electromagnetic signals. If you plot such asignal in function of time, a simple signal could look like this:This is a sine wave, so if this'd be an audio signal, you'd hear a pure tone with only 1 frequency (likethe beep of a PC speaker, or a very pure flute). The grey curve behind the red curve represents theamplitude of the signal, which is always positive.The spectrum of a signal contains for every frequency, how much of this frequency is in the signal.Since the signal above is a sine, it has only one frequency, so the spectrum would be very simple: onlyone value will be positive (= the frequency of the sine curve), and all others are zero. So the spectrum

would have a single peak. A spectrum has two sides however: the negative side on the left, and thepositive side on the right. The negative side contains negative frequencies. For real signals (with noimaginary part), like audio signals are, the negative side of the spectrum is always a mirrored version ofthe positive side. So for the sine signal above, the positive side will have a single peak, and this peakwill be mirrored in the negative side. This is what it's spectrum looks like:The white curve represents the amplitude of the signal. The red and green curve represent the real andimaginary part of the spectrum, respectively, but a spectrum is raraly represented that way. Normally,both the amplitude and phase of a spectrum are given, but since there's not that much interesting infofor us in it now, the phase isn't included.Let's study another example now: the same sine, but with a DC component added: sin(x)+C. The nameDC component comes from electronics, where it stands for Direct Current (as opposed to AlternatingCurrent). The DC component in any signal, is the time average of it. A sine signal has time average 0,but if however, you add a constant to the sine, the signals time average will become that constant. Thisadding of the constant, results in the sine signal being raised higher above the horizontal axis:Such a constant, or DC component, has frequency 0. So we can expect that the spectrum will get anextra peak at the origin, and indeed, it has:So, if the spectrum of a signal is non-zero at the origin, you know that it's time average isn't zero and it

- Page 1: Lode's Computer Graphics TutorialFo
- Page 5 and 6: The spectrum is positive everywhere
- Page 7 and 8: This looks already much more progra
- 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