【发布时间】:2016-01-28 15:33:07
【问题描述】:
我尝试从具有 fftw 和 qt 的图像列表中及时计算像素向量 fft,并对所有图像的所有像素重复此处理;向量包含 [pix1.1 of im1,pix1.1 of im2,...pix1.1 of imN],问题是当图像数量很大时程序崩溃
const int Npoints(widget.imagelistWidget->count());
fftw_complex *in, *out;
in = (fftw_complex*) fftw_malloc(sizeof(fftw_complex)*Npoints);
out = (fftw_complex*) fftw_malloc(sizeof(fftw_complex)*Npoints);
double resfft;
fftw_plan p;
QList<QImage*> imageList;
QImage *imagef ;
for(int k=0;k<liste.size();k++)
{
imagef = new QImage;
imagef->load(liste[k]);
imageList.append(imagef);
}
for(int i=0;i<imagef->width();i++)
{
for(int j=0;j<imagef->height();j++)
{
for(int k=0;k<liste.size();k++)
{
imagef =imageList.at(k);
QRgb pixelfft=imagef->pixel(i,j);
double moyp= qGray(pixelfft);
in[k][0] = moyp;
in[k][1] = 0.0;
}
p = fftw_plan_dft_1d(Npoints, in, out, FFTW_FORWARD, FFTW_ESTIMATE);
fftw_execute(p);
//resultat
QVector<qreal> realV;
QVector<qreal> imgV;
for (int s = 0; s < Npoints; s++)
{
realV.append(out[s][0]);
imgV.append(out[s][1]);
}
for(int l=0;l<liste.size();++l)
{
resfft = sqrt((realV[l] * realV[l]) + (imgV[l] * imgV[l]));
imagef=imageList.at(l);
imagef->setPixel(i,j,qGray(qRgb(resfft,resfft,resfft)));
}
}
}
【问题讨论】:
-
一些想法:你不需要每次都打电话给
fftw_plan_dft_1d。一个缺陷:imagef指针不断变化。你确定这是你想要的吗?您确定所有图像的大小都相同吗?你得到什么错误? -
哪条线路崩溃了?堆栈跟踪在哪里?