Views
2 years ago

Lode's Computer Graphics Tutorial Fourier Transform

Lode's Computer Graphics Tutorial Fourier Transform

can be set to true to do

can be set to true to do the inverse calculations instead. Again *gRe and *gIm are the input arrays, and*GRe and *GIm the output arrays. In this 2D version, the values are divided through m for the normalDFT and through n for the inverse DFT. There are also definitions where you should divide throughm*n in one direction and through 1 in the other, or though sqrt(m*n) in both, but it doesn't really matterwhich one you pick, as long as the forward FT and the inverse together give the original image back.The version here gives the nicest results to draw.void DFT2D(int n, int m, bool inverse, double *gRe, double *gIm, double *GRe, double *GIm){std::vector Gr2(m * n * 3);std::vector Gi2(m * n * 3); //temporary buffers//calculate the fourier transform of the columnsfor(int x = 0; x < n; x++)for(int c = 0; c < 3; c++){print(" % done",8, 0, RGB_White, 1);print(50 * x / n, 0, 0, RGB_White, 1);if(done()) end();redraw();//This is the 1D DFT:for(int w = 0; w < m; w++){Gr2[m * 3 * x + 3 * w + c] = Gi2[m * 3 * x + 3 * w + c] = 0;for(int y = 0; y < m; y++){double a= 2 * pi * w * y / float(m);if(!inverse)a = -a;double ca = cos(a);double sa = sin(a);Gr2[m * 3 * x + 3 * w + c] += gRe[m * 3 * x + 3 * y + c] * ca - gIm[m * 3 * x + 3 * y + c] * sa;Gi2[m * 3 * x + 3 * w + c] += gRe[m * 3 * x + 3 * y + c] * sa + gIm[m * 3 * x + 3 * y + c] * ca;}}}//calculate the fourier transform of the rowsfor(int y = 0; y < m; y++)for(int c = 0; c < 3; c++){print(" % done",8, 0, RGB_White, 1);print(50 + 50 * y / m, 0, 0, RGB_White, 1);if(done()) end();redraw();//This is the 1D DFT:for(int w = 0; w < n; w++){GRe[m * 3 * w + 3 * y + c] = GIm[m * 3 * w + 3 * y + c] = 0;for(int x = 0; x < n; x++){double a = 2 * pi * w * x / float(n);if(!inverse)a = -a;double ca = cos(a);double sa = sin(a);GRe[m * 3 * w + 3 * y + c] += Gr2[m * 3 * x + 3 * y + c] * ca - Gi2[m * 3 * x + 3 * y + c] * sa;GIm[m * 3 * w + 3 * y + c] += Gr2[m * 3 * x + 3 * y + c] * sa + Gi2[m * 3 * x + 3 * y + c] * ca;}if(inverse){GRe[m * 3 * w + 3 * y + c] /= n;GIm[m * 3 * w + 3 * y + c] /= n;}else{GRe[m * 3 * w + 3 * y + c] /= m;GIm[m * 3 * w + 3 * y + c] /= m;}}}}

And here's the Fast Fourier Transform again, in 2D this time. The same can be said about this functionas for the DFT2D function. The explanation of the FFT was already done in an earlier section.void FFT2D(int n, int m, bool inverse, double *gRe, double *gIm, double *GRe, double *GIm){int l2n = 0, p = 1; //l2n will become log_2(n)while(p < n) {p *= 2; l2n++;}int l2m = 0; p = 1; //l2m will become log_2(m)while(p < m) {p *= 2; l2m++;}m = 1

Introduction to Fourier Transform Infrared ... - Nicolet CZ sro
Chapter 36 Fast Fourier Transform and N - Phase ... - E-Courses
SLEVES and SLEFES - Computer Graphics Laboratory
CSC418: Computer Graphics Tutorial 1 - CDF
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 ...
Tutorial : , & coherence with M 1 Fourier transform by Fast Fourier ...
Fast Clifford Fourier Transformation for - Computer Science and ...
Fundamentals of the Discrete Fourier Transform
Fourier transforms & the convolution theorem - UGAstro
Analysis/resynthesis with the short time Fourier transform
some notes on the Fourier transform - IGPP
Fast Fourier Transform and MATLAB Implementation
Chapter 8 Fourier Transforms
The Fast Fourier Transform - LOMONT.org
Exercises in MATLAB for convolution and Fourier transform These ...
Fourier Slice Photography - Computer Graphics Laboratory ...
Fourier Transform of a Gaussian and Convolution