0

这是我的形态连接图像,我想做面具并将其作为输出

thresh = cv2.threshold(gray, 0, 255, cv2.THRESH_BINARY)[1]

# use morphology to close figure
kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (35,35))
morph = cv2.morphologyEx(thresh, cv2.MORPH_CLOSE, kernel, )

# find contours and bounding boxes
mask = np.zeros_like(thresh)
cv2.waitKey(0)
contours = cv2.findContours(morph, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
contours = contours[0] if len(contours) == 2 else contours[1]
for count in contours:
    cv2.drawContours(mask, [count], 0, 255, -1)

所以..请告诉我怎样才能得到这个输出?如何去除这个黑色补丁?

4

0 回答 0