import numpy as np
import cv2
from matplotlib import pyplot as plt

from sys import argv

if len(argv) ==  2:
    file_name = argv[1]
else:
    file_name = '/home/d3athmast3r/Pictures/livia.jpg'
    
img = cv2.imread(file_name)
mask = np.zeros(img.shape[:2],np.uint8)

bgdModel = np.zeros((1,65),np.float64)
fgdModel = np.zeros((1,65),np.float64)

rect = (0,250,2422,1920)
cv2.grabCut(img,mask,rect,bgdModel,fgdModel,5,cv2.GC_INIT_WITH_RECT)

mask2 = np.where((mask==2)|(mask==0),0,1).astype('uint8')
img = img*mask2[:,:,np.newaxis]

plt.imshow(img, cmap = "gray"),plt.colorbar(),plt.show()
import numpy as np
import cv2
from matplotlib import pyplot as plt

from sys import argv

if len(argv) ==  2:
    file_name = argv[1]
else:
    file_name = '/home/d3athmast3r/Pictures/livia.jpg'
    
img = cv2.imread(file_name)
mask = np.zeros(img.shape[:2],np.uint8)

bgdModel = np.zeros((1,65),np.float64)
fgdModel = np.zeros((1,65),np.float64)

rect = (0,250,2422,1920)
cv2.grabCut(img,mask,rect,bgdModel,fgdModel,5,cv2.GC_INIT_WITH_RECT)

mask2 = np.where((mask==2)|(mask==0),0,1).astype('uint8')
img = img*mask2[:,:,np.newaxis]

plt.imshow(img, cmap = "gray"),plt.colorbar(),plt.show()