Untitled
unknown
python
a year ago
460 B
12
Indexable
Never
# open segmentation and grayscale it seg_im = Image.open(image_path) seg_im = seg_im.convert('L') seg_np = np.array(seg_im, dtype=np.uint8) # create contours thresh = 170 _, thresh = cv2.threshold(seg_np,thresh,255,0) contours, _ = cv2.findContours(thresh,cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_NONE) cont_im = np.zeros(seg_np.shape) for contour in contours: cv2.drawContours(cont_im,contour.astype('int'),-1,(255,255,255),2) cv2.imwrite(cont_path, cont_im)