File Exchange

image thumbnail


version 1.0 (11.3 KB) by

Interactive roi definition tool

3 Ratings



View License

ROITOOL enables to define different type of rois on images (intensity, RGB) by mouse. The supported types are 'polygon', 'circle' and 'rectangle'. ROIPOLY returns the handler of the line object relating
 to the roi. The created roi can be dragged and moved to any position of the image with the help of DRAGGABE function (developed by Francois Bouffard, see the help of draggable).

ROITOOL generates a context menu to the roi making possible the selection of the following commands:(MATLAB displays the context menu whenever you right-click over the object)

- change the roi color
- change the size of the line width
- switch on/off the 'statistical bar', which displays the main stat. results of the roi (mean, std, min, max, roi area)
- switch on/off the 'histogram figure', which shows the intensity histogram of the pixels belonging to the roi
- switch on/off the 'detailed rectangle' figure, which plots the zoomed image segment defined by the rectangle roi
- resize the roi (in case of circle or rectangle roi)
- delete the roi

ROITOOL('circledemo'), ROITOOL('rectangledemo') or ROITOOL('polygondemo')

start the roi definition using the MATLAB 'MRI' data set.
Installing, running: unzip the downloaded file and include them to your matlab path

Comments and Ratings (12)


arnold (view profile)

yes, so many great old tools are broken in the newer versions. Too bad Mathworks didn't care for backward compatibility.

addRoiToolbar is broken too.


Brian (view profile)

Does not work in Matlab 2015 anymore. Brings an error

Undefined function 'real' for input arguments of type ''.

It is very good!!! Thanks a lot.

I am trying to figure this code. I am having the error
Error using ==> roitool at 76
ROITOOL expects a current figure containing an image.

Please help me in this regard


Soha (view profile)


Soha (view profile)

I've tried this around a week ago and it's great. I would like to retrieve the histogram data, anyway I could do this? (pixels values in the area chosen)

Laszlo Balkay

Laszlo Balkay (view profile)

Comment to Winnie: You can get the ROI handler issuing (for example) ">> roi_handler = roitool('circledemo');" and the ROI coordinates can be import by "x = get(roi_handler,'Xdata');
y = get(roi_handler,'Ydata');"



winnie (view profile)

I tried this tool today, but I could not retrieve the output. All it gave me was a single number... Any ideas? I need an output telling me the ROI co-ordinates!

Gal Haspel

did not work at first. error when calling "var". I had to change lines 286 and 370 to
roistd = std(double(userdata.currentimage(pixel_range)));

after that, it's useful and nice. thanks a lot!

Laszlo Balkay

Comments to

The POLY2MASK sub-function is part of the image processing toolbox, which is required for ROITOOL. (see the detailed description above)


the POLY2MASK sub-function is undefined, why?
help please!


what sure i put in for arg1,2 and 3? help, please

MATLAB Release
MATLAB 7.0.4 (R14SP2)

Inspired by: draggable

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

» Watch video