You are now following this Submission
- You will see updates in your followed content feed
- You may receive emails, depending on your communication preferences
mask2roi converts binary images/masks into roi positions. Only one input
is required for default algorithm, the mask. This mask can have any
number of regions which will be contained in separate cells of the
output. Additional outputs are perimeters (masks of edges) for each
region. The points are lined up to be used in drawpolygon as shown below:
EXAMPLE:
roiPositions = mask2roi(mask)
for i = 1:length(roiPositions)
drawpolygon("Position", roiPositions{i}, "Parent", imageAxes)
end
INPUTS:
mask - logical - binary image
NumROIs - numeric/int - specify the number of ROIs you want returned
Connectivity - numeric - must be 4 or 8
FillHoles - logical - in case you don't want holes filled in mask
ScaleNumVertices - numeric/int - higher numbers remove more points
RoundOutput - logical - rounds vertex coordinates
OUTPUTS:
roiPositions - cell of double arrays - arrays are n-by-2 where n is the
number of regions in the mask, x and y correspond to col 1 and 2
perimeters - optional - cell of 2D double arrays - Each with an edge mask
of the individual regions
Cite As
Alexander Moody (2026). mask2roi (https://www.mathworks.com/matlabcentral/fileexchange/133577-mask2roi), MATLAB Central File Exchange. Retrieved .
General Information
- Version 1.0.0 (2.93 KB)
MATLAB Release Compatibility
- Compatible with any release
Platform Compatibility
- Windows
- macOS
- Linux
| Version | Published | Release Notes | Action |
|---|---|---|---|
| 1.0.0 |
