I'm trying to segment the hand out of the image using OpenCV python. One of the images contains a ring on one of the fingers as shown here
After thresholding I get this result:
How can I reconnect the finger after thresholding?
CodePudding user response:
Don't know how you thresholded your image, but if we use it and morphological closing we can close some gaps:
morph = cv2.morphologyEx(threshold_img, cv2.MORPH_CLOSE, cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (31, 31)))
One problem you can notice is it closes in all directions. If you know there are more likely gaps in vertical direction you can change the structuring element accordingly:
morph = cv2.morphologyEx(threshold_img, cv2.MORPH_CLOSE, cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (11, 31)))