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

Lode's Computer Graphics Tutorial Fourier Transform

has a DC component! The further away from the origin to the left or right a peak is, the higher thefrequency it represents, so a peak far to the right (and left) means that the signal contains a highfrequency component. Note that an audio signal never has a DC component, since nobody can produceor hear it. Electrical signals can have it however.Now let's look at a signal which is the sum of two sine functions: the second sine function has thedouble frequency of the first, so the curve has the shape sin(x)+sin(2*x):Since there are now two sines with two different frequencies, we can expect two peaks on the positiveside of the spectrum (and two more on the negative side since it's the mirrored version):If the two sines both have a different phase (i.e. one of the two sines is shifted horizontally), theamplitude of the spectum will still be the same, only the phase will be different, but the phase isn'tshown here.Arbitrary sound signals, such as a spoken word, consist of an infinite sum (or integral) of infinitelymuch sine functions, all with a different frequency, and all with their own amplitude and phase, and thespectrum is the perfect plot to view how much of each frequency is in the signal. Such a spectrumwon't just have a few peaks, but will be a continuous function.There are a few special functions with a special spectrum:The Dirac impuls is a signal that is zero everywhere, except at the origin, where it's infinite. That is theideal version for continuous functions, for a discrete function on a computer it can as well berepresented as a single peak with finite height at the origin.Such a peak sounds like a popping sound in an audio signal, and contains ALL frequencies. That's whyit's spectrum looks like this (the horizontal black line):

The spectrum is positive everywhere, so every frequency is contained in the signal. This also meansthat, to get such a peak as a sum of sine functions, you have to add infinitely much elementary sinefunctions all with the same amplitude, and all shifted with a certain phase, they'll cancel each other out,except at the origin, hence the peak.Note that it's possible to intepret the spectrum as a time signal (a constant DC signal), and that then thered function can be seen as it's spectrum (a peak at zero, since a DC signal has frequency 0). Thisduality is one of the interesting properties of the **Fourier** **Transform** as we'll see later.Finally, another special signal is the sinc(x) function; sinc(x) = sin(x)/x:It's spectrum is a rectangular pulse (here only an approximation of it because the spectrum wascalculated using only 128 points):Again because of the duality between a signal and it's spectrum, a rectangular time signal will have asinc function as it's spectrum.Spectra are also used to study the color of light. These are exactly the same thing, since light too is a 1-dimensional signal containing different frequencies, some of which the eye happens to be sensitive to.The spectrum shows for every frequency, how much of it is in the light, just the same as the audiospectrum does for audio signals.An MP3 player like Winamp also shows the spectrum of the audio signal it's playing (but it varies withtime because they calculate the spectrum each time again for the last few milliseconds), and spectra ofaudio signals can be used to detect bass, treble and vocals in music, for speach recognition, audiofilters, etc... Since this is a tutorial about computer graphics, I won't go any deeper in this however.Often, the spectrum is drawn on a logarithmical scale instead of a linear one like here, then theamplitude is expressed in decibels (dB).

- Page 1 and 2: Lode's Computer Graphics TutorialFo
- Page 3: would have a single peak. A spectru
- 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