File Exchange

image thumbnail

FHROI: Interactive freehand ROI

version (2.03 KB) by Andrew Davis
Interactively specify 2D freehand ROI


Updated 07 Feb 2012

View License

FHROI: Interactively specify 2D freehand ROI

Overlays an imfreehand ROI on an image.
Gives the ability to tweak the ROI by adding and
subtracting regions as needed, while updating
the ROI boundaries as an overlay on the image.
Returns a logical matrix of the same size as the
overlain image.

Requires alphamask:

bwMask = fhroi([axHandle])
axHandle: handle to axes on which to operate (optional)
bwMask: ROI mask as logical matrix

I = rand(20) + eye(20);
imshow(I, [], 'Colormap', hot, 'initialMagnification', 1000);
bwMask = fhroi;


Cite As

Andrew Davis (2020). FHROI: Interactive freehand ROI (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (2)

I thought I would post this question I received via email in case others have a similar question:

Q: I was wondering if there is a modification that can be made to report the roi (bwMask) not as a binary, but with the original signal intensities of the image?

A: The nice thing about returning the ROI as a logical is that it can be used to index the original matrix directly. So if your original image was I, you can call
>> Iselected = I(bwMask);
to get a vector of signal intensities corresponding to the ROI. Or to get an image with the non-ROI pixels zeroed out, you could call
>> Imasked = I.*bwMask;

For more, see Steve's blog:



re-submission of the file since it didn't update last time

- Added 'delete ROI' user option
- Split off mask overlay code into alphamask function

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