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

Lode's Computer Graphics Tutorial Fourier Transform

An image can be blurred by, for each pixel, calculating the weighed average of that pixel and it'sneighbours, using a convolution matrix: that's the way Photoshop and Paint Shop Pro do it, forexample, you can create such a convolution matrix with the "User Defined" filter in these programs.But, since the convolution in the spatial domain is the same as a multiplication in the frequencydomain, we can also blur an image, by multiplying the spectrum with the transfer function of a lowpass filter. The transfer function of a low pass filter makes all high frequency components zero or atleast weakens them, while keeping or amplifying the low frequency ones.For very blurry blurs, a very large convolution matrix is required, and this would require a lot ofcalculations. Taking the Fast **Fourier** **Transform**, then multiplying the spectrum, and then taking theInverse FFT, goes much faster for heavy blurs. You can also create much nicers blurs easier and moreintuitively by using the spectrum.The more high frequencies you remove of the spectrum, the blurrier the image, and the morecalculations would be needed in the spatial domain:

In the above images, a circular section of the spectrum is left. You can also, for example, keep a squareone, but round ones should give nicer blurs:High Pass FiltersA high pass filter on an image keeps only the high frequency components. Since, by applying a highpass filter, the DC component of the spectrum is removed too, the resulting image can have negativepixel values that can't get drawn. To overcome this, the high pass filter of Photoshop adds 128 (half ofthe maximum value 255) to each color component the resulting pixels, so grey represents zero. Here,we'll look at the positive part of the image, the amplitude (revealing the negative values), and the imagewith the DC component added again instead.A high pass filter is exactly the opposite of the low pass filters, so now a circular section in the centerof the spectrum is removed. On the left is the resulting positive real part of the image, in the center thespectrum with the circle removed, and on the right the amplitude of the image:To see much better what's going on, add the DC component to it again:

- Page 1 and 2: Lode's Computer Graphics TutorialFo
- Page 3 and 4: would have a single peak. A spectru
- 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: component back.This is the original
- Page 39 and 40: It looks pretty ugly, because there
- Page 41 and 42: And here's the result of a much thi