Hi,
 
I have the following code to do fft2d on my 158x158 png image (imx):
 
----------------------------------------------------
typedef vcl_complex<float> Complx
 
...
   
    vnl_matrix<Complx> FFT2D(vnl_matrix<float> imx)
    {
         int r=imx.rows();
         int c=imx.cols();
         int imsize=160;

         vnl_matrix<Complx> A(imsize,imsize,0);

         for (int i=1; i < imsize-1; i++) 
          for (int j=1; j <imsize-1; j++)
          {      
               A(i,j)=imx(i-1,j-1);
          }
 
         vnl_fft_2d<float> fft2d(imsize,imsize);
         fft2d.fwd_transform(A);
        /*B = A without padding*/
         vnl_matrix<Complx> B = A.extract(r,c,1,1);
         return B;
    }
 
...
 
vil_image img = vil_load(filename);
img = vil_image_as<float>(img, (float*)0);
vil_memory_image_of<float> buf(img);
 
vnl_matrix<float> imx(buf.cols(),buf.rows(),0);
imx = MemImageToMatrix(buf);//A = transpose of buf. Vil image gets indexed as column,row and a vnl matrix gets indexed as row,column.
vnl_matrix<Complx> A(imx.rows(),imx.cols(),0);
A = FFT2D(imx);
 
------------------------------------------------------
When I do the same in Matlab :

A = fft2(double(imread(['filename'])));

I get a different result for matrix A.What am I doing wrong?
 
Thank you
Wouter (student)