Java 泛光填充算法填充超出指定边界的区域

Java 泛光填充算法填充超出指定边界的区域,java,opencv,image-processing,edge-detection,flood-fill,Java,Opencv,Image Processing,Edge Detection,Flood Fill,我想用泛光填充下面图片的某个区域“左边的矩形”。为了填充该区域,我在该矩形内指定了一个点,以了解像素值,如下所示: Log.D(TAG, "", "PixVal: "+gsMat.get(100, 240)[0]);//at that position the pixVal is 91 up ok Log.D(TAG, "", "PixVal: "+gsMat.get(250, 60)[0]);//at that position the pixVal is 217 l ??pe

我想用泛光填充下面图片的某个区域“左边的矩形”。为了填充该区域,我在该矩形内指定了一个点,以了解像素值,如下所示:

    Log.D(TAG, "", "PixVal: "+gsMat.get(100, 240)[0]);//at that position the pixVal is 91 up ok
    Log.D(TAG, "", "PixVal: "+gsMat.get(250, 60)[0]);//at that position the pixVal is 217 l ??peoblem
    Log.D(TAG, "", "PixVal: "+gsMat.get(330, 310)[0]);//at that position the pixVal is 123 down ok
    Log.D(TAG, "", "PixVal: "+gsMat.get(330, 580)[0]);//at that position the pixVal is 84 r ok
我确信点(x=60,y=250)位于左边的矩形内。我写了下面的代码来填充这个区域。但是我得到了下面的图片作为结果

"Mat subbed = gsRawMat.submat(r)" shows the whole orignal image as if the the whole pixel values in the image lays within the range of 216 to 218?

"ImageUtils.showMat(subbed, "subbed");" shows a white image as if the the whole pixel values in the image lays within the range of 216 to 218, hence, the whole area painted in white (255)?
请让我知道为什么会发生这种行为

代码

    Mat m = new Mat();
    Rect r = new Rect();
    Imgproc.floodFill(gsMat,
            m,
            new Point(60, 250),
            new Scalar(255),//to fill the designated area with color(255)
            r,//the rect that will encompass the designated area
            new Scalar(216),//lower bound
            new Scalar(218),//upper bound
            Imgproc.FLOODFILL_FIXED_RANGE);

    Mat subbed = gsRawMat.submat(r);// to extract the rectangle contains the flooded area from the main image
    ImageUtils.showMat(gsMat, "gsMat");//to show the gsmat
    ImageUtils.showMat(subbed, "subbed");//to show the subbed area from the gsMat
结果gsMat

结果子床垫

我没有使用此函数,但根据(C++)文档,参数不是“下限”和“上限”,而是“下限差”和“上限差”。它们的亮度/颜色值相对于种子点x=60,y=250。我还没来得及想清楚,但这有责任吗


如果你把结果包括进来,那会有很大帮助,因为我觉得你的描述有点模糊。@runDOSrun请看一下任务。我更新了整个问题