Code covered by the BSD License
07 Mar 2013
The code segments the grayscale image using graph cuts.
Watch this File
Running the Code:
[Ncut] = graphcuts(I,pad,MAXVAL)
% function [Ncut] = graphcuts(I)
% Input: I image
% pad: spatial connectivity; eg. 3
% MAXVAL: maximum image value
% Output: Ncut: Binary map 0 or 1 corresponding to image segmentation
You might want to add a input check / limitation to the max. input size of an image.
For a 400x400 image, this code requires approximately 200Gb of memory...
The code is quite compact though. Thanks for sharing.
Why there is a problem when I run this program!!!
Out of memory. Type HELP MEMORY for your options.
Error in graphcuts (line 18)
WM = zeros(H*W,H*W); countWM = 0;
This is a very poor and extremely inefficient implementation of the normalized graph cut algorithm.