1、http://www.cs.cmu.edu/~mohitg/segmentation.htm
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 themaxflow code [4]by Vladimimr Kolmogorov.
Source Code
SegTool.zip
Requires MATLAB and mex (C++) compiler. You will need kmeans on MATLAB to run the code. Refer the README file for compilation instructions.
PASCAL Data-Set
Our Segmentation Tool can be used to perform segmentation on huge image databases. As an example, we provideresults 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-shedsuper-pixels instead of pixels, for efficiency purposes. Using super-pixels, we achieve a significant speed-up at the cost of slight loss of accuracy.
References
[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]
[4] http://www.adastral.ucl.ac.uk/~vladkolm/software.html
[5] http://www.pascal-network.org/challenges/VOC/voc2005/index.html
/***********************************************************/
代码测试结果win7 64bit+matlab 2012a+vs2010 编译通不过,没细研究
win7 64bit/32bit+matlab 2012a+vs2008编译没问题,程序运行结果异常终止
winxp+matlab7.1+vc6.0编译没问题,运行时matlab报错: too many input arguments,可能和版本有关,data.ui.push_bg = uicontrol(hfig, 'Style','pushbutton', 'Units', 'Normalized','Position',[.7 .4 .1 .05], ...
'String','Graph Cuts','Callback', ['Segment ',longfilename]);
其中:longfilename = strcat(pathname,filename); longfilename由绝对路径和文件名组成,改成相对路径就不会报错了
longfilename = strcat('images\',filename);
测试了两幅图片,一张是原图,一张是标记了前景和背景的图片,测试代码如下:
global sopt fgpixels bgpixels; sopt = mksopt; img_name='images\kid2.bmp'; scribs_img_name='images\kid2_m.bmp'; I=double(imread(img_name))/255; mI=double(imread(scribs_img_name))/255; consts_map=sum(abs(I-mI),3)>0.001; if (size(I,3)==3) consts_vals=rgb2gray(mI).*consts_map; end if (size(I,3)==1) consts_vals=mI.*consts_map; end fgpixels=[]; [fgpixels(:,2),fgpixels(:,1)]=find(consts_vals>0); bg=consts_map-consts_vals; bgpixels=[]; [bgpixels(:,2),bgpixels(:,1)]=find(bg>0); Segment('images\kid2.bmp');
测试结果可以对图像进行抠图,由于是01年的文章,抠图效果肯定没有现在的matting算法效果好
2、http://masterravi.wordpress.com/2011/05/24/interactive-segmentation-using-graph-cutsmatlab-code/
3、http://cs.brown.edu/~pff/segment/
4、http://research.microsoft.com/en-us/um/cambridge/projects/visionimagevideoediting/segmentation/grabcut.htm
5、http://www.360doc.com/content/11/0426/21/6408986_112560226.shtml
6、https://mywebspace.wisc.edu/pwang6/personal/
7、http://research.microsoft.com/en-us/um/cambridge/projects/visionimagevideoediting/segmentation/grabcut.htm
8、https://developer.nvidia.com/content/graphcuts-using-npp
9、http://docs.nvidia.com/cuda/cuda-samples/index.html