作者:kalp_yp
来源:CSDN
原文:https://blog.csdn.net/u013539952/article/details/80702849
版权声明:本文为博主原创文章,转载请附上博文链接!
floodFill(image, mask, seedPoint, newVal, loDiff=None, upDiff=None, flags=None)
def fill_color_demo(image):
copyIma = image.copy()
h, w = image.shape[:2]
print(h, w)
mask = np.zeros([h+2, w+2], np.uint8)
cv.floodFill(copyIma, mask, (30, 30), (0, 255, 255), (100, 100, 100), (50, 50, 50), cv.FLOODFILL_FIXED_RANGE)
cv.imshow("fill_color", copyIma)
src = cv.imread("C:\\Users\\ZhouYu\\Desktop\\9.jpg")
cv.namedWindow("input image", cv.WINDOW_AUTOSIZE)
cv.imshow("input image", src)
fill_color_demo(src)
cv.waitKey(0)
cv.destroyAllWindows()
def fill_binary():
image = np.zeros([400, 400, 3], np.uint8)
image[100:300, 100:300, : ] = 255
cv.imshow("fill_binary", image)
mask = np.ones([402, 402, 1], np.uint8)
mask[101:301, 101:301] = 0
cv.floodFill(image, mask, (200, 200), (0, 0, 255), cv.FLOODFILL_MASK_ONLY)
cv.imshow("filled binary", image)
fill_fill_binary()
cv.waitKey(0)
cv.destroyAllWindows()