GrabCut: object extraction by separating the foreground and background of an image
GrabCut is an algorithm that is used to extract the foreground from an image. OpenCV has a python implementation of this algorithm which we can use for our purpose. GrabCut in OpenCV OpenCV provides the implementation of the GrabCut as a function cv2.grabCut() . The function takes seven parameters as arguments and returns three parameters. cv.grabCut(img, mask, rect, bgdModel, fgdModel, iterCount[, mode]) Parameters: img : take an image as input ( 8-bit 3-channel image). mask : input/output 8-bit single-channel mask. When we set parameter mode to cv2.GC_INIT_WITH_RECT , the mask will be initialized automatically. rect : coordinates of a rectangle or bounding box which includes the foreground object in the format (x, y, w, h) . The parameter is only used when the parameter mode==GC_INIT_WITH_RECT . bgdModel : temporary array for the backgro...