Views
3 years ago

Lode's Computer Graphics Tutorial Fourier Transform

Lode's Computer Graphics Tutorial Fourier Transform

Calculates the amplitude

Calculates the amplitude of *gRe and *gIm and puts the result in *gAmpvoid calculateAmp(int n, double *gAmp, double *gRe, double *gIm){for(int x = 0; x < n; x++){gAmp[x] = sqrt(gRe[x] * gRe[x] + gIm[x] * gIm[x]);}}The output of this program is as follows:The red function is the input function, which is a sine, and the black funtion at the bottom is theamplitude of it's spectrum, which is calculated by the DFT function. The green curves are theimaginary parts.The Fast Fourier TransformThe above DFT function correctly calculates the Discrete Fourier Transform, but uses two for loops ofn times, so it takes O(n²) arithmetical operations. A faster algorithm is the Fast Fourier Transform or

FFT, which uses only O(n*logn) operations. This makes a big difference for very large n: if n would be1024, the DFT function would take 1048576 (about 1 million) loops, while the FFT would use only10240.The FFT works by splitting the signal into two halves: one halve contains all the values with evenindex, the other all the ones with odd index. Then, it splits up these two halves again, etc..., recursivily.Due to this, a requirement is that the size of the signal, n, must be a power of 2. There exist other FFTversions that can work on signals that can have length n*m where both n and m are primes, but thatgoes beyond the scope of this tutorial.Here's a new version of the DFT function, called FFT, which uses the Fast Fourier Transform instead.The FFT algorithm used here is called the Radix-2 algorithm, by Cooley-Tukey, developed 1965. Youcan add it to the previous program and change the function call of it to FFT to test it out.First, this function will calculate the logarithm of n, needed for the algorithm.void FFT(int n, bool inverse, double *gRe, double *gIm, double *GRe, double *GIm){//Calculate m=log_2(n)int m = 0;int p = 1;while(p < n){p *= 2;m++;}Next, Bit Reversal is performed. Because of the way the FFT works, by splitting the signal in it's evenand odd components every time, the algorithm requires that the input signal is already in the formwhere all odd components come first, then the even ones, and so on in each of the halves. This is thesame as reversing the bits of the index of each value (for example the second value, with index 0001will now get index 1000 and this go to the center), hence the name.//Bit reversalGRe[n - 1] = gRe[n - 1];GIm[n - 1] = gIm[n - 1];int j = 0;for(int i = 0; i < n - 1; i++){GRe[i] = gRe[j];GIm[i] = gIm[j];int k = n / 2;while(k

Introduction to Fourier Transform Infrared ... - Nicolet CZ sro
CSC418: Computer Graphics Tutorial 1 - CDF
Chapter 36 Fast Fourier Transform and N - Phase ... - E-Courses
SLEVES and SLEFES - Computer Graphics Laboratory
Real-Time Interaction Behavior - Computer Graphics and Visualization
THE WAVELET TUTORIAL PART II by ROBI POLIKAR
Fourier Transform Graphical Analysis: an Approach for Digital Image ...
Fundamentals of the Discrete Fourier Transform
Fast Clifford Fourier Transformation for - Computer Science and ...
Tutorial : , & coherence with M 1 Fourier transform by Fast Fourier ...
Analysis/resynthesis with the short time Fourier transform
some notes on the Fourier transform - IGPP
Fourier transforms & the convolution theorem - UGAstro
Exercises in MATLAB for convolution and Fourier transform These ...
Chapter 8 Fourier Transforms
Fast Fourier Transform and MATLAB Implementation
The Fast Fourier Transform - LOMONT.org
Lecture: Fourier Transform - biomachina.org
Fourier Transform of a Gaussian and Convolution