/GrabCut-OpenCV

An implementation of Grabcut using OpenCV

Primary LanguagePythonGNU General Public License v3.0GPL-3.0

grabcut

A simple program for interactively removing the background from an image using the grab cut algorithm and OpenCV.

This code was derived from the Grab Cut example from the OpenCV project but is hopefully more usable for day-to-day tasks.

See the OpenCV GrabCut Tutorial for more information.

Examples

Orignal Image Result Image Orignal Image Result Image

Usage

grabcut.py <input> [output]

Instructions

  1. After seeing the input and output windows, draw a rectangle arround the object using middle mouse button and wait for segmentation in output window.
  2. Press ctrl+P to see the control pannel with the options of Mark Forgeground / Background, Reset and Save.
  3. Click the relevant option and start marking the regions with the brush using the left mouse button, you may change the thickness of the brush, from input window.
  4. Reset or Save the final annotation.

Keys

  • 0 - Select areas of sure background
  • 1 - Select areas of sure foreground
  • 2 - Select areas of probable background
  • 3 - Select areas of probable foreground
  • n - Update the segmentation
  • r - Reset the setup
  • s - Save the result
  • q - Quit