File Exchange

image thumbnail

Efficient Graph based image segmentation

version 1.1.0.0 (172 KB) by Su Dongcai
A new version of previous program, support color image.

8 Downloads

Updated 06 Dec 2010

View License

This is an implementation of [1]. The result is slightly different from website[1], because we apply adjacent neighborhood rather than K nearest neighborhood. The following is an example usage:
%complie:(only once)
GraphSeg_complie
%Read an image
img = imread('images\rice.jpg');
%segmentation
[L, contour] = graph_segment(img, 1, 3, 100);
%display result
subplot(2, 1, 1), imshow(img), title('original image'); subplot(2, 1, 2), imshow(label2rgb(L)),title('segmented result');

[1]Efficient Graph-Based Image Segmentation
Pedro F. Felzenszwalb and Daniel P. Huttenlocher
International Journal of Computer Vision, Volume 59, Number 2, September 2004
http://people.cs.uchicago.edu/~pff/segment/

Cite As

Su Dongcai (2020). Efficient Graph based image segmentation (https://www.mathworks.com/matlabcentral/fileexchange/29299-efficient-graph-based-image-segmentation), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (15)

Avik Das

The function does not compile

vivian wang

Ji Deng

It seems that this code is fault

Ka Ho Tam

I'm trying to get this function to work with a 3D matrix. I can see that there are some functions to deal with 3D matrices, but can't get them to work. Can you please show me an example? This is the message I get if I just put a 3D matrix into graph_segment(img,1,3,100):

Attempt to execute SCRIPT CoherenceFilterStep3D as a function:
PATH_TO_Graph_seg\CoherenceFilter\functions3D\CoherenceFilterStep3D.m

Error in CoherenceFilter (line 185)
u=CoherenceFilterStep3D(u,Options)

zhengjun123

编译失败,有木有解决办法或者最新版的代码呢?

Leox91

Does not compile.

How can i get output like in the screenshot? Anyone?

IITH

Error using mex (line 206)
Unable to complete successfully.

Error in GraphSeg_complie (line 1)
mex Graph_seg_gray.cpp c_GraphSeg_gray.cpp public_functions_lib.cpp
extract_edges.cpp c_GraphSeg.cpp Disjoint_set.cpp disjoint_elt.cpp.
please help me how to run the code

Can I get all pixels within each closed contour?

what exactly is the output 'contour'?Am actually trying to access each patch separately (i.e.) all pixels within a patch. Is it possible?

add "int" before num_pixels in "public_functions_lib.cpp" and "public_functions_lib.h"

Su Dongcai

Sorry folks:
I made a mistake.This code is compiled on msvc6++, windows xp system.

bailjung

i have the same problem

Sara

Hello,

You write on the updates that your version on 06 Dec 2010
"supply compling m-file make it independent to the operating systems". I work with a macos operating system and i tried to compile GraphSeg_complie, but it doesn't work:

>> GraphSeg_complie
In file included from Graph_seg_gray.cpp:4:
stdafx.h:17:21: error: windows.h: No such file or directory
public_functions_lib.h:19: error: ISO C++ forbids declaration of 'num_pixels' with no type
public_functions_lib.h:22: error: ISO C++ forbids declaration of 'num_pixels' with no type
Graph_seg_gray.h:15: error: expected initializer before 'CGraph_seg_gray'
Graph_seg_gray.h:21: error: expected initializer before 'int'
Graph_seg_gray.h:23: error: expected initializer before 'int'

mex: compile of ' "Graph_seg_gray.cpp"' failed.

??? Error using ==> mex at 221
Unable to complete successfully.

Error in ==> GraphSeg_complie at 1
mex Graph_seg_gray.cpp c_GraphSeg_gray.cpp public_functions_lib.cpp extract_edges.cpp c_GraphSeg.cpp
Disjoint_set.cpp disjoint_elt.cpp

What i have to do to do it works?
Your work would be a great help to me if i could run it...

Thanks a lot,

Sara

Updates

1.1.0.0

supply compling m-file make it independent to the operating systems

MATLAB Release Compatibility
Created with R14SP1
Compatible with any release
Platform Compatibility
Windows macOS Linux