Untitled - PYTHON 0.50 KB
                                
                                    mask = np.zeros(img2.shape[:2], np.uint8)
  
backgroundModel = np.zeros((1, 65), np.float64)
foregroundModel = np.zeros((1, 65), np.float64)
  
rectangle = (220, 120, 850, 850)

cv2.grabCut(img2, mask, rectangle, 
            backgroundModel, foregroundModel,
            10, cv2.GC_INIT_WITH_RECT)
  
mask2 = np.where((mask == 2)|(mask == 0), 0, 1).astype('uint8')
image = img2 * mask2[:, :, np.newaxis]
blur = cv2.GaussianBlur(image,(10,10),0)
plt.imshow(cv2.Canny(image,100,150))
                                
                            

Paste Hosted With By Wklejamy.pl