Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.

The FFT adjusts only a half size.

siinii
Beginner
474 Views

I received below source code from Dima. I adjusted it to image.

--------------------------------------------------------------------------------------------------------------------------

You probably did the small size on a static array, defined as x[100][40]. The way the dynamic array is arranged in your example is incorrect and it demonstrates typical mistake. For static array '_complex x' expression 'x' has type '_complex *' whereas for dynamic array that one would use with double-subscript notation 'x' the type of 'x' is '_complex**' that is pointer to pointers. In other words, in this example when you call DftiComputeForward(..., x) the input data to the FFT routine is pointers, not the complex numbers!

I'd suggest you to refrain from the practice of using double-subscript notation for dynamic arrays, and adopt the following usage instead:

const int ROWS=3072, COLS=2560;

const int ROWSIZE=COLS, COLSIZE=ROWS;

_complex *x = new _complex[ROWS*COLS];

#define x(r,c) x[*ROWSIZE+(c)] /* explicit row-major indexing */

memset(x,0,sizeof(x[0])*ROWS*COLS); /* zero fill initialization */

for (r=0;r

The rest of this reply is duplicating your example in the above terms.

DftiCreateDescriptor(rowfft,DFTI_SINGLE,DFTI_COMPLEX,1,ROWSIZE); /* stride 1 by default */

DftiSetValue(rowfft,DFTI_NUMBER_OF_TRANSFORMS,(MKL_LONG)ROWS);

DftiSetValue(rowfft,DFTI_INPUT_DISTANCE,(MKL_LONG)ROWSIZE);

DftiSetValue(rowfft,DFTI_OUTPUT_DISTANCE,(MKL_LONG)ROWSIZE);

DftiCreateDescriptor(colfft,DFTI_SINGLE,DFTI_COMPLEX,1,COLSIZE); /* will set strides */

MKL_LONG colfft_strides[] = { 0, ROWSIZE };

DftiSetValue(colfft,DFTI_INPUT_STRIDES,colfft_strides);

DftiSetValue(colfft,DFTI_OUTPUT_STRIDES,colfft_strides);

DftiSetValue(colfft,DFTI_NUMBER_OF_TRANSFORMS,(MKL_LONG)COLS);

DftiSetValue(colfft,DFTI_INPUT_DISTANCE,(MKL_LONG)1);

DftiSetValue(colfft,DFTI_OUTPUT_DISTANCE,(MKL_LONG)1);

...

DftiComputeForward(rowfft,x);

DftiComputeForward(colfft,x);

Thanks

Dima

--------------------------------------------------------------------------------------------------------------------------

///FFT

DftiComputeForward(rowfft,x);

DftiComputeForward(colfft,x);

//Inverse FFT

DftiComputeBackward(rowfft,x);

DftiComputeBackward(colfft,x);

like this...

but The FFT adjusted only 2560*1536(original image size is 2560*3072)

Which code should I change?

0 Kudos
1 Reply
Dmitry_B_Intel
Employee
474 Views

The excerpt looks good, and it should process whole array.

Could you provide a self-contained example that shows your problem?

Thanks
Dima

0 Kudos
Reply