File Exchange

image thumbnail

Segment images interactively, and generate MATLAB code

version 1.7 (699 KB) by Brett Shoelson
An interactive app and function for segmenting images.


Updated 11 Nov 2020

View Version History

View License

Interactive UI for segmenting images. Explore different approaches, then export segmentation mask and reproduction code.
Supports all tunable parameters for EDGE detection, THRESHOLDING (including MULTITHRESH/IMQUANTIZE), HOUGH (line and circle detection), regional and extended minima and maxima, and COLOR thresholding.
PLEASE NOTE: From R2014b forward, this is intended as a REPLACEMENT for SegmentTool. This version will not work prior to R2014b, but SegmentTool will not work in R2014b.

Comments, suggestions appreciated!

Cite As

Brett Shoelson (2021). Segment images interactively, and generate MATLAB code (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (28)

Brett Shoelson

I can't reproduce that, but I think it has to do with installation as an app , and not with the functionality itself. Try running at the command line instead:
(Make sure that all of the relevant files are on your MATLAB path.)
Let me know if that works. If it does, I will steer you in debugging the app installation part.

Arshiya Khan


I am getting below error. Please help me fix this:
Error in SegmentImageApp (line 48)

Error in appinstall.internal.runapp>execute (line 116)
out = evalin('caller', [script ';']);

Error in appinstall.internal.runapp>runapp13a (line 95)
outobj = execute(fullfile(appinstalldir, [wrapperfile 'App.m']));

Error in appinstall.internal.runapp>preamble18b (line 60)
appobj = runapp13a(appinstalldir);

Error in appinstall.internal.runapp (line 13)
out = preamble18b(appinstalldir);

Error in (line 45)
appinstall.internal.runapp(appName, appLocation);

I am using MATLAB R2020b version.

Joel Silva

Brett Shoelson

@Tien, Would you please download the new version (v1.6) and try again?

Tien Nguyen

How do I fix this error :
Error in segmentImage (line 292)
I'm using MATLAB R2017b

Brett Shoelson

What version of MATLAB are you using? And what version of segmentImage()? I believe that the current version (1.5; updated February 2020) works with newer versions of MATLAB. Please try to install the latest version and let me know if it works for you.

Brit Wylie

Some errors still occuring: wavread needs to be replaced with audioread, 'textcolor' replaced with 'color' in annotation. I am also still getting Ahmad's error on R2019b:

Output argument "segtoolHandle" (and maybe others) not
assigned during call to "SegmentTool".

Brett Shoelson

I'm not sure I follow your question. Are you familiar with drawrectangle() ? You don't need this app for that.


A very good program. Is it possible to draw a manually bounding box (square/rectangle) around tot a region of interest and then export it? thank you

Brett Shoelson

@Ahmad, others:
I have downloaded a new version of segmentImage that I believe will address the issues introduced in R2019b. Please download again and let me know if you have more issues.

Ahmad Makky

I am using R2019b
When I open the app, I got this error message:
Output argument "segtoolHandle" (and maybe others) not assigned during call to "segmentImage".

I checked if the there is a shadowed file, I did not find any.

Could you please advice me how to resolve this problem so I can use the app.


Brett Shoelson

@jack Schapira: Apologies for the late reply--just seeing this now. Are you still unable to generate code at you Command Line?

rui rui

A very good program, I would like to ask the region, extension and color threshold is used in what method of image segmentation?

Sam Lim

Kiarash Ahi

Guojin Feng

Convenient app. Recommended.

jack schapira

The code doesn't print out on my pc for some reason?
Also is there a way of automatically applying this to a three dimensional matrix that has 124 slices?

Brett Shoelson

Can you send me an image and a snippet of code that recreates the failure? I am able to import and work with both double and uint16 images.

Yassine Zaafouri

Great app but i have a question. Why it is not functional when i Import a grayscale Image ( double or uint16) ?

thank you

Brett Shoelson

I'm a little confused, Dominic. The current version of segmentImage (on this page) includes a call to audioread(), but not to wavread(). Where are you encountering that message?


As a workaround, I created a new "wavread.m" with the audioread script inside. This way, I'm able to start it again.


I can't get it to start on Matlab R2016b. "wavread" has been replaced by "audioread" in R2015b, so the app won't start anymore.

Rabi Tripathy


Yuan Chao

Zhenqiang YING


Ahmed Ayoub

Shravankumar P

Shravankumar P

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

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!