In the above image, I only need the following contours: 8, 7, 0, 2, 4.
Every other contour black empty boxes inside them. Is there a way to automatically extract only such contours using cv2.RETR_TREE?
cv2.RETR_EXTERNAL will ignore 2 and 4 which I actually need
>>heirarchy
>>array([[[ 7, -1, 1, -1],
[-1, -1, 2, 0],
[-1, -1, 3, 1],
[-1, -1, 4, 2],
[-1, -1, 5, 3],
[ 6, -1, -1, 4],
[-1, 5, -1, 4],
[ 8, 0, -1, -1],
[-1, 7, -1, -1]]])
How can I extract from the above heirarchy only the external contours but not exlcuding 2 and 4 and ignoring 1, 3, 5, 6 since those four contours contain just empty regions inside?
