Interactive Segmentation Tool-Box


An implementation of ‘Lazy Snapping’ and ‘GrabCut’: Based on Interactive Graph Cuts


Lazy Snapping [2] and GrabCut [3] are 2D image segmentation tools based on the interactive graph-cuts technique proposed by Boykov and Jolly [1]. Lazy Snapping requires the user to specify foreground and background seeds, and performs 2D segmentation with the seeds as hard constraints. GrabCut makes the process more automatic by using iterated graph cuts – the only user interaction required is a bounding box of the foreground object.


We provide an implementation of both these tools, along with a third tool which combines both these methods. Our code uses the maxflow code [4] by Vladimimr Kolmogorov.








Source Code

Requires MATLAB and mex (C++) compiler. You will need kmeans on MATLAB to run the code. Refer the README file for compilation instructions.









Our Segmentation Tool can be used to perform segmentation on huge image databases. As an example, we provide results of using the Grab Cut Tool on a subset of the PASCAL data set [5] (a few different Object Classes). We use the Bounding Boxes available along with this set to seed our iterative graph cuts algorithm. The parameters given in the parameter file can be fine-tuned to achieve desirable segmentations.


Note: The coarseness around the boundary of the segmented results is due to the fact that the code runs segmentation on water-shed super-pixels instead of pixels, for efficiency purposes. Using super-pixels, we achieve a significant speed-up at the cost of slight loss of accuracy.






[1] Interactive Graph Cuts for Optimal Boundary & Region Segmentation of Objects in N-D Images. Boykov & Jolly, ICCV 2001    [PDF]

[2] Lazy Snapping. Yin Li, Jian Sun, Chi-Keung Tang, Heung-Yeung Shum, SIGGRAPH 2004                                                                 [PDF]

[3] GrabCut — Interactive Foreground Extraction using Iterated Graph Cuts. Rother, Kolmogorov & Blake, SIGGRAPH 2004      [PDF]






For questions/comments about the code, please contact:

Krishnan Ramnath




You can post your comments/questions here


This project was done as part of the Advanced perception class at the Robotics Institute, CMU. Class Instructor: Alexei Efros