【发布时间】:2011-09-30 14:19:22
【问题描述】:
我编写了使用 openCV api 创建一个高斯内核,然后将其传递给 Conv2ByDFT 函数进行卷积。但是程序崩溃了,我不知道为什么。这是代码。
void Conv2ByFFT(const Mat& f,const Mat& g,Mat& result)
{
result.create(abs(f.rows-g.rows+1),abs(f.cols-g.cols+1),f.type());
Size dftSize;
dftSize.width = getOptimalDFTSize(f.cols + g.cols - 1);
dftSize.height = getOptimalDFTSize(f.rows + g.cols -1);
Mat tmpF(dftSize,f.type(),Scalar::all(0));
Mat tmpG(dftSize,g.type(),Scalar::all(0));
dft(tmpF,tmpF,0,f.rows);
dft(tmpG,tmpG,0,g.rows);
mulSpectrums(tmpF,tmpG,tmpF,0);
dft(tmpF,tmpF,DFT_INVERSE+DFT_SCALE,result.rows);
tmpF(Rect(0,0,result.cols,result.rows)).copyTo(result);
}
这是 main() 中调用上述函数的一些代码
Mat gaussianFilter = getGaussianKernel(7,2.0,CV_64F); // create Gaussian kernel
Conv2ByFFT(src,gaussianFilter,result); // do the convolution
我不知道是 getGaussianKernel() 函数有问题还是我的 Conv2ByFFT() 函数有问题...谁能帮帮我?非常感谢!
【问题讨论】:
-
错误是什么?它在哪一行崩溃?
-
对不起,我没有说清楚:P。错误如下:“OPENCV ERROR: Assertion failed (type == CV_32FC1 || type == CV_32FC2 || type == CV_64FC1 || type == CV_64FC2) in unknown function,file..\..\..\ moduels\core\src\dxt.cpp,line 1483 "并且程序在 "dft(tmpF,tmpF,0,f.rows)" 行崩溃
标签: image-processing opencv gaussian