roipoly
Specify polygonal region of interest (ROI)
Syntax
Description
Create Polygon Interactively
creates an interactive
polygon tool associated with the image displayed in the current figure.
BW
= roipolyroipoly
returns the mask as a binary image, setting
pixels inside the ROI to 1
and pixels outside the ROI to
0
.
With this syntax and the other interactive syntaxes, the polygon selection tool blocks the MATLAB® command line until you complete the operation. For more information about using the polygon selection tool, see Interactive Behavior.
Create Polygon by Specifying Vertices
Specify Additional Output Options
roipoly(___)
without output arguments
displays the resulting mask image in a new figure window.
Examples
Input Arguments
Output Arguments
More About
Tips
roipoly
always produces a closed polygon. If you specify input vertex positions of a closed polygon (such that the last pair of coordinates is identical to the first pair), then the length of the output coordinate vectors is equal to the number of points specified. If the points specified do not describe a closed polygon, thenroipoly
adds a final point having the same coordinates as the first point. In this case the length of the output coordinate vectors is one greater than the number of points specified.For more information about classifying pixels on the ROI boundary, see Classify Pixels That Are Partially Enclosed by ROI.
For any of the
roipoly
syntaxes, you can replace the input imageI
with two arguments,m
andn
, that specify the row and column dimensions of an arbitrary image. For example, these commands create a 100-by-200 binary mask.c = [112 112 79 79]; r = [37 66 66 37]; BW = roipoly(100,200,c,r);
If you specify
m
andn
with an interactive form ofroipoly
, anm
-by-n
black image is displayed. Use the mouse to specify a polygon within this image.