tags:

views:

60

answers:

1

Sorry this is the first time for me to ask question here, I've given a FFT function

void fft_1d(int n, float xr[256], float xi[256], int ntype)
{
  /* compute the FFT of a complex signal
     xr and xi are the real and imaginary parts respectively
     xr and xi contain the signal as input and the FT as output
     n is the number of points, it should be a power of 2
     ntype is set to 1 for forward transform and -1 for inverse transform
  */

And I have been told to extend this function to do the 2D (DFT) of the given image.

My problem is:

  1. I can get every itensity value of the given image but how can I deal with the complex components (real part /imaginary part) of the fft_1d? In other words, what should I put in the parameters float xr[256] and float xi[256] in order to do the 2D (DFT) of the image?

Thanks for your attention!

+2  A: 

An image is, generally, a real-only function. Therefore, you can set the real inputs to be the image values, and the imaginary inputs to zero when calling the FFT function.

However, in order to perform a 2D FFT, you must first call the 1D FFT on each row, and then call the 1D FFT on each column of the results. These intermediate results will be complex, and must be passed as such to the second set of FFTs.

Oli Charlesworth
Thanks for the answers~ But how can I actually use this function? I need to store the values after the 1st 1DFFT (which will be complex), but it seems that the function does not give any return values.
Nick Li
@Nick Li: I imagine from the function description that the FFT is *in-place*, i.e. the same arrays will also end up holding the results.
Oli Charlesworth
Yes, i think the function is in-place. So what I need to do is to feed in the function with all the intensity values which is in the form of a 2d array a[m][n](first by each row, and then for each column) ?
Nick Li
And one more, the data type I make use to store the intensity value is a character array, but the function's signature tells me to feed in a float array, is that mean I need to cast the char array first?
Nick Li
@Nick: You will need to create a new array of floats, and use a loop to convert each element in turn. You can't just cast the array on its way into the function.
Oli Charlesworth
What you mean is to loop through every single elements of the char array and to the casting for every single char value to float value?
Nick Li
@Nick Li: Yes...
Oli Charlesworth