漫水填充算法

    xiaoxiao2022-07-14  177

    漫水填充算法

    用一定颜色填充联通区域,通过射着可连通像素的上下限以及连通方式来达到不同的填充效果。

    漫水填充类似于连通域分析中种子填充法,区别在于漫水填充处理彩色或灰度图像,当邻域像素值和种子像素值的差值在一定范围内,则认为是同一连通区域。

    种子填充法:https://chaos.blog.csdn.net/article/details/90488626

    #include "opencv2/imgproc/imgproc.hpp" #include "opencv2/highgui/highgui.hpp" #include <iostream> using namespace cv; using namespace std; Mat src, mask; int g_nFillMode = 1;//漫水填充的模式 int g_nConnectivity = 4;//表示floodFill函数标识符低八位的连通值 int g_nNewMaskVal = 255;//新的重新绘制的像素值 static void onMouse( int event, int x, int y, int, void* ) {     if( event != CV_EVENT_LBUTTONDOWN )         return;     Point seed = Point(x,y);     int flags = g_nConnectivity   (g_nNewMaskVal <<
    最新回复(0)