djs22
djs22

Reputation: 1156

Two Dimensional FFTW Help

I'm currently trying to compute the fft of an image via fftw_plan_dft_2d.

To use this function, I'm linearizing the image data into an in array and calling the function mentioned above (and detailed below)

ftw_plan fftw_plan_dft_2d(int n0, int n1,
                            fftw_complex *in, fftw_complex *out,
                            int sign, unsigned flags);

The func modifies a complex array, out, with a size equal to the number of pixels in the original image.

Do you know if this is the proper way of computing the 2D FFT of an image? If so, what does the data within out represent? IE Where are the high and low frequency values in the array?

Thanks, djs22

Upvotes: 4

Views: 2897

Answers (2)

Paul R
Paul R

Reputation: 213170

A 2D FFT is equivalent to applying a 1D FFT to each row of the image in one pass, followed by 1D FFTs on all the columns of the output from the first pass.

The output of a 2D FFT is just like the output of a 1D FFT, except that you have complex magnitudes in x, y dimensions rather just a single dimension. Spatial frequency increases with the x and y index as expected.

There's a section in the FFTW manual (here) which covers the organisation of the real-to-complex 2D FFT output data, assuming that's what you're using.

Upvotes: 6

João Faria
João Faria

Reputation: 1

It is. Try to compute 2 plans:

plan1 = fftw_plan_dft_2d(image->rows, image->cols, in, fft, FFTW_FORWARD, FFTW_ESTIMATE); 
plan2 = fftw_plan_dft_2d(image->rows, image->cols, fft, ifft, FFTW_BACKWARD, FFTW_ESTIMATE);

You'll obtain the original data in ifft.

Hope it helps :)

Upvotes: 0

Related Questions