/grabcut

A simple app for interactively removing the background from an image using the grab cut algorithm and 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]

Operation

At startup, two windows will appear, one for input and one for output.

To start, draw a rectangle around the object using mouse right button. For finer touch-ups, press any of the keys below and draw circles to mark the background and foreground. Finally, press 's' to save the result.

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