我正在尝试对两个原始图像进行 FFT。但我得到了unhandled exception (access violation)
- 我不知道为什么。我正在使用 fftw 库。首先我正在阅读两个图像,然后我计算 FFT。但在它开始计算之前,它会产生访问冲突错误。
#include "stdafx.h"
#include <iostream>
#include <conio.h>
#include "fftw3.h"
#define Width 2280
#define Height 170
unsigned char im2[170*2280];
unsigned char im1[170*2280];
float image1[170*2280];
float image2[170*2280];
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
FILE* fp1, *fp2;
//Read two images
fp1 = fopen ("image1.raw" , "r");
fread(im1, sizeof(unsigned char), Width* Height, fp1);
fp2 = fopen ("image2.raw" , "r");
fread(im2, sizeof(unsigned char), Width* Height, fp2);
fclose(fp2);
fclose(fp1);
//Typecasting two images into float
for (int i = 0; i < Width* Height; i++)
{
image1[i]= (float)im1[i];
image2[i] = (float)im2[i];
}
fftwf_plan fplan1, fplan2;
fftwf_complex fft1[((Width/2)+1)*2];
fftwf_complex fft2[((Width/2)+1)*2];
fplan1 = fftwf_plan_dft_r2c_2d(Height, Width, (float*)image1, fft1, FFTW_ESTIMATE);
fftwf_execute(fplan1);
fftwf_destroy_plan(fplan1);
fplan2 = fftwf_plan_dft_r2c_2d(Height,Width, image2, (fftwf_complex*)fft2, FFTW_ESTIMATE);
fftwf_execute(fplan2);
fftwf_destroy_plan(fplan2);
_getch();
return 0;
}