2D CUFFT problem


I’m tring to draw out the output from a 2d R2C CUFFT as a bitmap but I’m getting a strange result. I know that to get the full output I need to reconstruct the redundant coefficients, but even the basic output from cufftExecR2C() is displaying incorrectly. As you can see it’s getting skewed by two pixels on each row (the points should form vertical columns). The data is thresholded which is why there are no grey tones, but other than that there is no processing being done.

The function FFT() opens the input image, does the FFT and takes the magnitude of the (complex) result, and returns that.

float *FFT_out;

	FFT_out = FFT(512, 512);

	int array_size = 512*512;

	int *FFT_out_int; //new FFT output data which will all be between 0 and 255

	FFT_out_int = (int*)malloc(array_size * sizeof(int));

	for (int i = 0; i < array_size; i++)


		if (FFT_out[i] < 500)

			FFT_out_int[i] = 0;


			FFT_out_int[i] = 255;


	//create bitmap from FFT output data:

	Bitmap^ FFT_out_bmp = gcnew Bitmap(512,512);

	int i = 0;

	Color pixel_colour;

	for (int r = 0; r < 512 ; r++)


		for (int c = 0; c < 512; c++)


			pixel_colour = Color::FromArgb(FFT_out_int[i], FFT_out_int[i], FFT_out_int[i]);






I have no idea what is going wrong, but if anyone else has any thoughts or has ever seen this before I’d really appreciate hearing from you.

Many thanks,


The R2C transform takes an array of floats size(lx,ly) and gives an output of (lx,ly/2+1) of complex numbers with real and imaginary part interleaved. If you do an inplace transform than the input must be an array of (lx,ly+2) where the elements where the extra elements (1:lx,ly+1:ly+2) are just put to 0.

I apologize I do not understand you code. I do not see the place where the transform is done and how are you defining the matrices and how you get the cufft plans. I used the cufft both 2D and 3D with both R2C and C2C in both single precision and double precision.