Fill the outside of contours OpenCV
问题 I am trying to color in black the outside region of a contours using openCV and python language. Here is my code : contours, hierarchy = cv2.findContours(copy.deepcopy(img_copy),cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE) areas = [cv2.contourArea(c) for c in contours] max_index = np.argmax(areas) cnt=contours[max_index] # how to fill of black the outside of the contours cnt please? ` 回答1: Here's how you can fill an image with black color outside of a set of contours: import cv2 import numpy img =