【发布时间】:2019-01-12 03:55:23
【问题描述】:
我正在使用 drawContours 制作用于提取 ROI 的蒙版。
我已经定义了四个点和一个用于绘制轮廓的零掩码。
drawContours 函数的输出掩码有点像梯形,这正是我想要的。
但是,当我使用此掩码对图像进行 bitwise_and 处理时, 结果与面具的形状并不完全相同。
形状的边缘明显是锯齿状的。
这是我的python代码sn-p:
hull2 = cv2.convexHull(crop1)
mask10 = np.zeros(image.shape[:2], dtype = "uint8")
print(len(hull2))
cv2.drawContours(mask10, [hull2], -1,255, -1,cv2.LINE_AA)
cv2.imshow("mask10",mask10)
cv2.waitKey(0)
crop = cv2.bitwise_and(image, image, mask=mask10)
cv2.imshow("crop",crop)
cv2.waitKey(0)
cv2.drawContours(image, [hull2], -1, (0, 255, 0), -1,cv2.LINE_AA)
cv2.imshow("mask+img",image)
cv2.waitKey(0)
这是显示结果的图片: "crop" is the ROI result image
感谢任何试图提供帮助的人。
【问题讨论】: