1 | initial version |
you could simply overwrite the unwanted contour(s), with cv2.FILLED
to erase them
(untested) code:
# keep #0, erase #1
clone1 = im.copy()
cv2.drawContours(clone1, contours, 1, (0,0,0), cv2.FILLED) # paint it black
cv2.imwrite("contour_0.png", clone1)
# keep #1, erase #0
clone2 = im.copy()
cv2.drawContours(clone2, contours, 0, (0,0,0), cv2.FILLED) # paint it black
cv2.imwrite("contour_1.png", clone2)