SVJ
SVJ

Reputation: 31

How to get FFT values from Cimg FFT?

I am using Cimg to get FFT values of a (256 X 256)image. But FFT values for images are 3-dimesnional arrays of complex values i.e (256 X 256 X 3). i got two images using get_FFT() the real and imaginary part of the image. i also printed the values as fft0 + j fft1. I am not sure if this is the correct method to get values, but this still comes out to be (256 X 256). How do we get the third dimension value of FFT?

#include "CImg.h"
using namespace cimg_library;

int main(int argc, char * argv[]) {

    const char *input_file = "Lenna";
    CImg<unsigned char> input(input_file);
    CImgList<float> fft = input.get_FFT();
    fft[0].save("fft[0].jpg");
    fft[1].save("fft[1].jpg");

    int w0 = fft[0].width();
    printf("width of fft[0] %d \n",fft[0].width());
    int h0 = fft[0].height();
    printf("height of fft[0] %d \n",fft[0].height());
    printf("Spectrum of fft[0] %d \n",fft[0].spectrum());
    
    int count =1;
    for(int x=0;y<w0;y++){
    for(int y=0;x<h0;x++){
        count+=1;
        std::cout <<count <<","<< (int)fft[0](x,y) <<" "<< "+j"<< (int)fft[1](x,y)<<std::endl;
          }
       }   

    return 1;
}

Upvotes: 1

Views: 138

Answers (0)

Related Questions