2.0

2.0 | 3 ratings Rate this file 217 Downloads (last 30 days) File Size: 1.77 KB File ID: #40669
image thumbnail

Graph Cut for image Segmentation

by

 

07 Mar 2013 (Updated )

The code segments the grayscale image using graph cuts.

| Watch this File

File Information
Description

Running the Code:
% Maximum Image size 128 by 128

I=imread('Lenna.jpg');
pad=3;
MAXVAL=255;
[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

Required Products Image Processing Toolbox
MATLAB release MATLAB 7.6 (R2008a)
MATLAB Search Path
/
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (10)
08 Dec 2014 suji

Thank you for sharing!

04 Dec 2014 Amarjot

@chandra Please use the image size 128 by 128

04 Dec 2014 Chandra Shaker Balure

I am getting an error at line:18, which has the instruction WM = zeros(H*W,H*W);... I am using an image of 256x320, so the zero matrix forming is giving the problem. Is it that I have to use some smaller sized image? I have tried generating zeros(256*256), it also give error. What is the workaround to solve this problem?

17 Nov 2014 joy angel

good

05 Jun 2014 Amarjot

@matlabuser1 I assume you are passing the to the function.In that case you should not get any error. Can you send me the file in which you are calling the function at asa168@sfu.ca. I can look into the error.

05 Jun 2014 matlabuser1

Firstly, I am getting an error:

??? Input argument "I" is undefined.

Error in ==> graphcuts at 7
I = double(I); [H,W] = size(I);

------

Also, I am getting the same graph cut for ever image. Please help me out.

Thanks.

05 Sep 2013 Wouter

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.

13 May 2013 abbad

:::

12 May 2013 Zhao

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;

15 Apr 2013 Anton Semechko

This is a very poor and extremely inefficient implementation of the normalized graph cut algorithm.

Updates
04 Dec 2014

I added the maximum image size for which the code runs without error.

Contact us