View License

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

» Watch video

Highlights from

4.3 | 3 ratings Rate this file 25 Downloads (last 30 days) File Size: 7.52 KB File ID: #4462 Version: 1.0
image thumbnail



Shanrong Zhang (view profile)


09 Feb 2004 (Updated )

These m-files let you process interactively and multiply on image ROIs.

| Watch this File

File Information

1) Goal: Draw & process multiple ROIs interactively within an image, which output area, mean, std, min, max, median and roicenter [x, y].

2) Usage: ROI(img, nroi), where 'img' is your image, and 'nroi' is a total number to ROIs to be processed. The opened image will be processed BY DEFAULT. A prefered procedure is as follows:

a) img = imread(...);
b) imh = imshow(img) and
c) ROI(img, nroi).

Alternatively, if there is no image in your WorkSpace, you MUST use square brackets to occupy the argument space for img, such as, ROI([],5), will let you open a new image and process with 5 ROIs.

3) Since getline('closed') is used to get the polygon interactively, please click left mouse button to select, and right button to finish up a ROI (Backspace to delete the lastest click). You may repeat this process till all ROIs were processed. For more infos, please may see help getline.

4) Results: ROI statistics are displayed on screen or output to a text file (optional).

5) The colors of line/text label are generated by 'jet' colormap, therefore, certain color may be too close to tell, especially when you select too many ROIs. In that case, you may need to edit the color after ROI processing. For more infos, please see

help jet

6) For your convenience, you may use the following m-scripts to clear your enviroments: 'dt', 'dl' and 'df' to delete all text characters, lines and figures, respectively.

7) This package includes 5 m-files: 'ROI.m', 'MultiROI.m', 'df.m', 'dl.m' and 'dt.m'.

Shanrong Zhang
Department of Radiology
University of Washington



Im Roi inspired this file.

This file inspired Mm Roi (Multiple Images With Multiple Ro Is).

Required Products Image Processing Toolbox
MATLAB release MATLAB 6.5 (R13)
Other requirements Works for Window. Not test for other platforms.
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (4)
30 Nov 2015 Sara Salimi

Hi. Thanks for sharing the code.
I downloaded your code and I tried to extract ROI from the attached image; however, I am getting this error, how can I run the code?
I am trying to automatically extract the cartilage from the knee, what is your suggestion, does this code work for my aim?

>> img=imread('edge.png');
>> imh=imshow(img);
>> roi(img,2);
Undefined function 'roi' for input arguments of type 'uint8'.

Could you please help me?
Many thanks in advance

Comment only
11 Jan 2011 Vivek

Vivek (view profile)

hey can i extract the ROI as separate image? in other words, i want to extract the polygon selection as separate image??
My Roi is in the link and highlighed and i want that ROI as separate image

23 Jul 2010 Alicja Bajorska

06 Nov 2007 m a

nice code

Contact us