Morphology connected image to contour mask image, error?

352 views Asked by At

Here is my Morphology connected image and I want to do mask and get this asOutput

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)

So..Please tell how can I get this output? how do I remove this black patch ?

0

There are 0 answers