Mat findpeeks(Mat I,Mat J)
{
queue<Point> que;
/*最大值滤波*/
J = regionalmaximaImg(J);
/*对满足条件的点入队列,初始化队列*/
for(int i=0;i<I.rows;i++)
for(int j=0;j<I.cols;j++)
if(J.at<uchar>(i,j) && isexistNBzero(J,Point(j,i)))
que.push(Point(j,i));
/*循环队列,直至队列为空*/
while(que.empty())
{
Point p = que.front();
que.pop();
for(int i=0;i<NEGHTBOR;i++)
{
/*get the neighbor point*/
Point q;
q.x = p.x+x_offset[i];
q.y = p.y+y_offset[i];
if(q.x>I.cols-1) q.x = I.cols-1;
if(q.x<0) q.x = 0;
if(q.y>I.rows-1) q.y = I.rows-1;
if(q.y<0) q.y = 0;
if(J.at<uchar>(p.y,p.x)<J.at<uchar>(q.y,q.x) &&
I.at<uchar>(q.y,q.x)!=I.at<uchar>(q.y,q.x))
{
J.at<uchar>(p.y,p.x)=min(J.at<uchar>(p.y,p.x),
I.at<uchar>(q.y,q.x));
que.push(p);
}
}
}
return (I-J)>0;
}
【图像处理】灰度图、亮度峰值极值查找
最新推荐文章于 2024-07-24 22:13:06 发布