OpenCV:区域生长法实现( 四 )


        while(!Q.empty())
        {
            now = Q.front();
            Q.pop();
            curr=texture.at<Vec4b>(now.y, now.x);
            for(int p=-1; p<=1; p++)
            {
                for(int q=-1; q<=1; q++)
                {
                    if(0<=now.x+p && now.x+p<texture.cols && 0<=now.y+q && now.y+q<texture.rows)
                    {
                        next=texture.at<Vec4b>(now.y+q, now.x+p);
                        if(mark.at<uchar>(now.y+q, now.x+p)==0 &&
                                (textureDifference(next, seed)==1 || farTextureDifference(next, curr)==2))
                        {
                            Q.push(Point(now.x+p, now.y+q));
                            mark.at<uchar>(now.y+q, now.x+p)=i;
                            //segm.at<Vec3b>(now.y, now.x)=image.at<Vec3b>(seedPoint.y, seedPoint.x);
                        }
                    }
                }
            }
        }
    }
    ///namedWindow("texture segment",2);
    ///imshow("texture segment",mark);
    imwrite("textureSegment.bmp",mark);
}

注重事项在每一个区域内起首要指定一个种子点作为发展的起点;
然后将种子点四周邻域的像素点与种子点进行比力 ,
对具有相似性质的点归并之后继续标的目的外发展 , 直到没有知足前提的像素被包罗进来为止;

以上内容就是OpenCV:区域生长法实现的内容啦 , 希望对你有所帮助哦!

推荐阅读