我正在尝试创建我的个人 Blob 检测算法 据我所知,我首先必须创建具有不同 sigma 的不同高斯内核(我正在使用Mat kernel= getGaussianKernel(x,y);
)然后获取该内核的拉普拉斯算子,然后用它过滤图像,这样我就创建了我的尺度空间。现在我需要在尺度空间的每个结果图像中找到局部最大值。但我似乎找不到合适的方法来做到这一点......到目前为止我的代码是
vector <Point> GetLocalMaxima(const cv::Mat Src,int MatchingSize, int Threshold)
{
vector <Point> vMaxLoc(0);
if ((MatchingSize % 2 == 0) ) // MatchingSize has to be "odd" and > 0
{
return vMaxLoc;
}
vMaxLoc.reserve(100); // Reserve place for fast access
Mat ProcessImg = Src.clone();
int W = Src.cols;
int H = Src.rows;
int SearchWidth = W - MatchingSize;
int SearchHeight = H - MatchingSize;
int MatchingSquareCenter = MatchingSize/2;
uchar* pProcess = (uchar *) ProcessImg.data; // The pointer to image Data
int Shift = MatchingSquareCenter * ( W + 1);
int k = 0;
for(int y=0; y < SearchHeight; ++y)
{
int m = k + Shift;
for(int x=0;x < SearchWidth ; ++x)
{
if (pProcess[m++] >= Threshold)
{
Point LocMax;
Mat mROI(ProcessImg, Rect(x,y,MatchingSize,MatchingSize));
minMaxLoc(mROI,NULL,NULL,NULL,&LocMax);
if (LocMax.x == MatchingSquareCenter && LocMax.y == MatchingSquareCenter)
{
vMaxLoc.push_back(Point( x+LocMax.x,y + LocMax.y ));
// imshow("W1",mROI);cvWaitKey(0); //For gebug
}
}
}
k += W;
}
return vMaxLoc;
}
我在这里的这个线程中找到了它,它应该返回一个最大值所在的点向量。它确实返回了一个点向量,但每个点的所有 x 和 y 坐标始终为 -17891602 ......怎么办???如果您要带领我做一些其他事情而不是更正我的代码,请提供信息,因为我对 opencv 一无所知。我只是在学习