简体   繁体   中英

fft visualization using fftw and opencv

Im using the following code to generate the visualization of fourier transform using FFTW and OpenCV. However, I'm only getting the upper part of the image correctly. Can anyone explain if there is something wrong with the code?

fft stores the fftw_execute data.

int nl= fftvis->height; // number of lines
// total number of element per line
int nc= fftvis->width * fftvis->nChannels;

// get the pointer to the image buffer
unsigned char *data= reinterpret_cast<unsigned char *>
(fftvis->imageData);
k =0;
for (int x=1; x<nl; x++) {
    for (int y=0; y<nc; y+= fftvis->nChannels) {
        data[y] = 10*log(sqrt((pow(fft[k++][0],2) + pow(fft[k++][1],2))));
        //k+=1;
    } // end of line

    data+= step;
    // next line
}

You need to fill each channel's RGB, but you are stepping over channel data when y+= fftvis->nChannels is executed.
Also, data+= step; would skip step bytes of your data, this is not necessary if you align the processing properly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM