我试图实现谱方法来计算图像的显着性地图,但我似乎无法使逆FFT工作。
int main(int argc, char * argv[]) {
const char * input_file = "img/pic.png";
CImg<unsigned char> * input = new CImg<unsigned char>(input_file);
resize_fft(*input); //Resize the image for the FFT
CImg<unsigned char> gray = any2gray(*input); //to single-channel grayscale image
free(input);
CImgList<unsigned char> fft = gray.get_FFT();
CImg<unsigned char>::FFT(fft[0], fft[1], true);
fft[0].save("img/fft.png");
return 1;
}最后,fft.png只是一个黑色的图像文件。我找不到任何人用CImg计算逆fft的例子.有人有线索吗?
非常感谢!罗宾
发布于 2016-01-27 04:11:59
对于广泛的图像来说,一个常见的问题是,在有限的unsigned char范围内,图像的快速傅立叶变换不能被表示(或者松散太多的信息而无法实际使用)。您可以通过使用中间float图像执行FFT计算来避免这种情况:
// convert from unsigned char to float to support larger range of values
CImg<float> fft_in = gray;
// Forward transform
CImgList<float> fft = fft_in .get_FFT();
// Inverse transform
CImg<float>::FFT(fft[0], fft[1], true);
// Normalize back to unsigned char range (0,255) and save
fft[0].normalize(0,255).save("img/fft.png");https://stackoverflow.com/questions/35019666
复制相似问题