I would suggest that you invert the thresholded image so that the contours are white and the background is black ( cv2.threshold(cv2.THRESH_BINARY_INV)
). Then you search for contours with cv2.findContours()
. To select your desirable contour you can make some filters to eliminate other contours from the contour you are hoping to find. You can use the filters in a For loop ( for i in contours:
) and with some conditional statements for the filters. For filters you can try the size of contours ( size = cv2.contourArea(i)
) or height and width ( x, y, w, h = cv2.boundingRect(i)
). Then you can make the statements like if size > 100 and h > 100 and w < 50: cv2.drawContours()
. Hope it gives you an idea on how to proceed. Cheers!