we've compiled the KissFFT library and it appears to be running fine, but we're not sure how we use it to get the frequency domain of a 2d image. Any help would be fantastic.
PS. We're running it in the After Effects SDK.
I haven't used KissFFT
with images (only with audio) but here's my attempt based on what I've read in the docs. You should create 3 arrays for the individual colour components (i.e. create img1/img2/img3).
//(I can't test this code now because I don't have kiss_fft)
kiss_fft_scalar img1[M][N]; //array containing red pixels
kiss_fft_scalar img2[M][N]; //array containing green pixels
kiss_fft_scalar img3[M][N];//array containing blue pixels
int mDim[2] = { N, M };
const int numDim = 2; //number of dimensions
kiss_fft_cpx *cinRed = new kiss_fft_cpx[N * M];
kiss_fft_cpx *coutRed = new kiss_fft_cpx[N * M];
kiss_fft_cpx *cinGreen = new kiss_fft_cpx[N * M];
kiss_fft_cpx *coutGreen = new kiss_fft_cpx[N * M];
kiss_fft_cpx *cinBlue = new kiss_fft_cpx[N * M];
kiss_fft_cpx *coutBlue = new kiss_fft_cpx[N * M];
kiss_fftnd_cfg state = kiss_fftnd_alloc (mDim, numDim, 0, 0, 0);
int k=0;
for (int i=0;i<M;++i) {
for(int j=0;j<N;j++){
cinRed[k].r = img1[i][j];
cinRed[k].i = 0;
cinGreen[k].r = img2[i][j];
cinGreen[k].i = 0;
cinBlue[k].r = img3[i][j];
cinBlue[k].i = 0;
k++;
}
}
kiss_fftnd(state,cinRed,coutRed);//coutRed contains 2D fft results for img1 (red channel)
kiss_fftnd(state,cinGreen,coutGreen);
kiss_fftnd(state,cinBlue,coutBlue);
//for inverse 2D FFT just use
state = kiss_fftnd_alloc (mDim, numDim, 1, 0, 0);//1 sets inverse to true
kiss_fftnd(state,coutRed,cinRed); //note that cin and cout have switched positions
kiss_fftnd(state,coutGreen,cinGreen);
kiss_fftnd(state,coutRed,cinGreen);
Thank you Cris for letting me know that I should use kiss_fftnd
(I've deleted the old code and procedure)