PDA

View Full Version : fftw help

superutsav
10th April 2006, 10:33
Hi
I have a question regarding the way the data is stored in a 2d fourier transform. I am using a fftw_plan_dft_r2c_2d transform, and here is my question:

From what i understand of 2d fourier transforms, the dc component lies in the centre of the transform, i.e. for a transform of size (nx,ny), the dc component would be at value (nx/2,ny/2).

The fftw_plan_dft_r2c_2d transform returns a matrix of size (nx,ny/2+1). The dc component of this matrix is the value (0,0).

So my question is, which part of the complete 2d fourier transform is reflected in the matrix? In other words, how do I obtain the actual 2d fourier transform from the (nx,ny/2+1) sized matrix i am getting by using the plan? I want to know this so i can design a filter for the same.

With best regards,
superutsav

P.S. If anyone here could give me example code of image filter usage with fftw libraries i would be really grateful

wysota
10th April 2006, 11:29
You are probably getting just the (right -- positive) half of the transform as it should be (AFAIR) symmetric to the OY axis.

superutsav
10th April 2006, 12:14
You are probably getting just the (right -- positive) half of the transform as it should be (AFAIR) symmetric to the OY axis.

Yes, thats exactly what i intially thought... but in that case the dc component will not be the (0,0) value... it will be the (0,nx/2) element...

superutsav

wysota
10th April 2006, 13:51
If this is a 2D transform then the lowest frequencies are towards the middle of the transform, thus DC will be exactly in the middle (0,0). X axis gives you one dimension of FT and Y axis gives you the other one, so (0, nx/2) gives you the constant for one dimension interfered with "nx/2" frequency for the other. At least that's what I think I remember about FT :)

And all that of course means you only have the quarter of the result and not half of it.