rlft3 and 2-D image?


dennisnguy
08-11-2002, 09:47 AM
Hello,

I'm trying to implement rlft3 routine into my program to process an 2-D real data image. Unfortunate, my result does not come out right.
Here is my code:

int fft_proc (int Width, int Height, double **ImageData)
{
int nn1,nn2,nn3;

nn1 = 1;
nn2 = Width;
nn3 = Height;
Mat_DP speq1(nn1,nn2<<1);
Mat3D_DP data1(nn1,nn2,nn3);

for (int i=0;i<nn1;i++)
for (int j=0;j<nn2;j++)
for (int k=0;k<nn3;k++)
data1[i][j][k] = ImageData[j][k];

NR::rlft3(data1,speq1,1);
NR::rlft3(data1,speq1,-1);

for (int i=0;i<nn1;i++)
for (int j=0;j<nn2;j++)
for (int k=0;k<nn3;k++)
ImageData[j][k] = data1[i][j][k];
}

What did I do wrong?

I'm try to do something like Figure 12.5.2: filter an 2-D image using rlft3.
Could anyone help please?

Thank you,
Dennis

zarnska
10-27-2004, 08:42 PM
This may just be a matter of scaling the output.
ie:my input ranged from 0 to 255, the output ranged from 0 to 3*10^7, however I scaled that back down to fit into the original range for display purposes.

achand
09-08-2005, 08:37 AM
Hi,

I was encountering the same problems. In the case of a 2d input matrix is is sufficient to normalize the output matrix you obtain by dividing it by data1[1][1][1].
I don't know if a more recent version of rlft3 exists but note that in order to use correctly the routine I suppose, following the discussion of NR' authors in the introduction, that all the array in input must have the first element with index 1 and not 0 as in ANSI C.


let me know.

A

achand
09-08-2005, 11:27 AM
to be rigorous, it is necessary to divide the output matrix by (N1*N2*N3/2) since the inerse transform is given with the factor N1*N2*N3/2 multiplicative factor. Just try it.


A.