View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
Multi ROI/Mask Editor Class

5.0 | 10 ratings Rate this file 27 Downloads (last 30 days) File Size: 5.95 KB File ID: #31388 Version: 1.0
image thumbnail

Multi ROI/Mask Editor Class



This Class allows you to easily define multiple regions of interest (binary masks) with a nice UI.

| Watch this File

File Information

This is a class with a convenient user interface to define multiple region of interest (ROI) masks on a given image.

All the imroi tools (freehand, circle, rectangle, polygon) can be used to define these region(s).

Loading and storing of previously defined ROI masks to and from files is easily done via the UI toolbar.

Multiple regions are labeled using the connected component labeling method (using the MATLAB built-in bwlabel function).

Generated Information:
- Binary Mask (obj.roi)
- Label Mask (obj.labels)
- number of independent regions (obj.number)

You can listen to the object's "MaskDefined" event to retrieve the ROI information generated (obj.getROIData) or get them directly from the objects public properties.

Run the example to see how it works.

Required Products Image Processing Toolbox
MATLAB release MATLAB 7.12 (R2011a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (15)
06 Jan 2017 afextwin

Hi, Thank you for your great job. This is really nice.

I want to make multiple polygon ROIs in an image about 56 region but they join each ROIs.

For example. I drew 28 ROIs but only 11 ROI labels exist. When I check them in image, they joined in one ROI.

10 Nov 2016 Peyman Obeidy

nice job, I have the same question as Fred, how can I add my ROI into the workspace, I need to calculate the area for different mask?

Comment only
07 Oct 2016 Weizhi Li


Comment only
26 Jan 2016 fred blue


How can I add my ROI on the workspace?


Comment only
05 Nov 2015 Yue Hou

Hi Jonas,
There is a bug for delete button at line 183:
"this.current = str2double(regexp(Tag,'\d','match'));"
If there are more than 10 ROIs, the delete button doesn't work for ROIs #10, 11, 12, etc.
so I correct it to
"this.current = str2double(regexp(Tag,'\d+','match'));"
And it works fine, now.

28 Apr 2014 gilad

gilad (view profile)

hi Nizamettin,
If I understood you, after running the example, look at the ans.roi, and save it as a variable.

03 Feb 2014 Nizamettin ogutman

How can you extract the mask and obtain it as a variable in the workspace?

Comment only
31 Jul 2013 Muhammet

18 Jul 2013 hamid

hamid (view profile)

thank you for your effort. i downloaded the file but after extracting i cant open it in matlab editor. it gives me the error of
"CROIEditor\example.m is not
a valid function name. This will generate an error in a future release.
> In open at 36
In uiopen at 196 "

is there any suggestion
many thanks

Comment only
26 Feb 2013 Natalia

Excellent, you have save me so much time!!
Really really good!

25 Jun 2012 Felix

Felix (view profile)

very good!

31 Mar 2012 zaidan

zaidan (view profile)

nice code

10 Feb 2012 Gregoris

Very nice tool and extremely helpfull.

23 Jun 2011 Damien

Damien (view profile)

The tool itself is very convenient.
Many comments make the code easy to read.
Can also be used as a good tutorial for : GUI, Classes, imroi

I myself was in need of a more versatile tool. For exemple being able to save not only the binary mask but also the imroi shapes themself.
With such a funcionality you can reuse the shapes on another image and modify it if needed.
I implemented this funcionality in an enhanced version of your tool. I may submit it soon

11 Jun 2011 Thiago Lima

Very good and easy to use.

Contact us