OpenCV对一张图片填充一个多边形 fillPoly

OpenCV对一张图片填充一个多边形 fillPoly 可视化一张图像,Python对内存numpy变量进行可视化

roiMask01Assis = cv.fillPoly(roiMask01Assis, line, color)

对一张图像进行可视化

cv.imshow("window_name", somaBackground), cv.waitKey(0)

points(list)和lines(array)是什么玩意

image-20221108225537443

points = value['polygon']

line = np.array([points], dtype=np.int32)

roiMask01Assis = np.zeros((self.imgsize[1], self.imgsize[0], 3), np.uint8)

cv.fillConvexPoly(roiMask01Assis, line, (255, 255, 255))

cv.imshow("window_name", roiMask01Assis), cv.waitKey(0)

结果如下图所示:

image-20221108225619267


来一个二值图像:

roiMask01 = np.zeros((self.imgsize[1], self.imgsize[0]), np.uint8)
cv.fillConvexPoly(roiMask01, line, (255, 255))
cv.imshow("window_name", roiMask01), cv.waitKey(0)

image-20221108225820017


posted @ 2022-11-11 00:46  bH1pJ  阅读(118)  评论(0编辑  收藏  举报