其中h和w是图像的长和宽
for i in range(h):
for j in range(w):
cv2.floodFill(copyImg,mask,(i,j),tuple(copyImg[i][j]*1.0),(5,5,5),(5,5,5),cv2.FLOODFILL_FIXED_RANGE)
error: OpenCV(4.3.0) C:\projects\opencv-python\opencv\modules\imgproc\src\floodfill.cpp:509: error: (-211:One of the arguments' values is out of range) Seed point is outside of image in function 'cv::floodFill'
在C++程序中,这样却是没有问题的
Mat mask(dst.rows + 2, dst.cols + 2, CV_8UC1, Scalar::all(0));
for (int i = 0; i<dst.rows; i++)
for (int j = 0; j<dst.cols; j++)
if (mask.at<uchar>(i + 1, j + 1) == 0)
{
Scalar newcolor(rng(256), rng(256), rng(256));
floodFill(dst, mask, Point(j, i), newcolor, 0, Scalar::all(5), Scalar::all(5));
}