开发者

How to batch FFT in C

I am trying to do a batch FFT on 50 images using the following snippet:

pix3 = n*pix1*pix2;
fftwf_complex *in2, *f2h; //input for FFT2
in2 = (fftwf_complex*)fftwf_malloc(sizeof(fftwf_complex) * pix3);
f2h = (fftwf_complex*)fftwf_malloc(sizeof(fftwf_complex) * pix3);

for (i = 0; i < pix3; i++)
{
in2[i][0] = ref20[i]; //ref20 is an array of real values 
in2[i][1] = 0;
}    

for(i = 0; i < n; ++i)
{
  plan_forward2 = fftwf_plan_dft_2d (pix1, pix2, in2, f2h, FFTW_FORWARD, FFTW_ESTIMATE);
  fftwf_execute (plan_forward2);
  in2 += pix1*pix2;
  f2h +开发者_如何学Go= pix1*pix2;
}

However, I am only able to get the FFT of the 1st image (i.e. first pix1*pix2 elements). Any suggestions on how to get this right?

Thanks in advance


You should read the manual 4.6 New-array Execute Functions carefully

You only need to create the plan once outside the loop, and then use it as:

fftwf_execute_dft(plan_forward2, in2, f2h);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜