Polyline
R2026bPolyline region of interest
Description
A Polyline object specifies the shape and position of an
axes-based polyline region of interest (ROI). You can customize the appearance and interactive
behavior of the ROI.
Axes-based ROIs enable you to draw and edit regions of interest
on images displayed using imshow or in MATLAB® axes. Axes-based ROIs offer maximum customization of appearance and behavior,
including line width, marker style, and edge color. Use axes-based ROIs for fine-grained control
over ROI appearance, integration with existing axes-based apps, or access to the assisted
freehand, crosshair, or cuboid ROI types. For a comparison of axes-based ROIs with other ROIs,
see Choose Approach to Annotate ROIs in Images.

For more information about using this ROI, including keyboard shortcuts, see Tips.
Creation
There are two ways to create a Polyline object. For more information, see
Create Axes-Based ROIs.
Use the
drawpolylinefunction. Use this function when you want to create the ROI and set the appearance in a single command. You can specify the shape and position of the ROI interactively by drawing the ROI over an image using the mouse, or programmatically by using name-value arguments.Use the
images.roi.Polylinefunction described here. Use this function when you want to specify the appearance and behavior of the ROI before you specify the shape and position of the ROI. After creating the object, you can specify the shape and position interactively by using thedrawfunction or programmatically by modifying properties of the object.
Syntax
Description
creates a
roi = images.roi.PolylinePolyline object with default properties.
creates the ROI in the axes specified by roi = images.roi.Polyline(ax,___)ax.
sets
properties
of the ROI using one or more name-value arguments.roi = images.roi.Polyline(___,PropertyName=Value)
Example: images.roi.Polyline(Color="y") creates a yellow colored
Polyline object.
Input Arguments
Properties
Object Functions
addlistener | Create event listener bound to event source |
beginDrawingFromPoint | Begin drawing ROI from specified point |
bringToFront | Bring ROI to front of Axes stacking order |
createMask | Create binary mask image from ROI |
draw | Begin drawing ROI interactively |
reduce | Reduce density of points in ROI |
wait | Block MATLAB command line until ROI operation is finished |
Examples
More About
Tips
To draw the ROI interactively using the
drawordrawpolylinefunction, position the cursor on the axes and click and drag to create the shape. As you draw, click to place vertices along the line. Double-click to finish drawing the polyline.The ROI supports the following interactivity, including keyboard shortcuts.
Behavior Keyboard shortcut Make drawn line snap at 15 degree angles. Hold the Shift key while drawing. Finish drawing the ROI. Double-click, which adds a final new vertex at the pointer position.
Right-click, which completes the polyline at the previous vertex without adding a new vertex at the pointer position.
Press Enter, which completes the polyline at the previous vertex without adding a new vertex at the pointer position.
Cancel drawing the ROI. Press Esc. The function returns a valid ROI object with an empty Positionproperty.Add a new vertex to the ROI. Position the pointer over the polygon and double-click. You can also position the pointer over the ROI, right-click, and choose Add Vertex.
Remove a vertex from the ROI. Position the pointer over the ROI, right-click, and choose Delete Vertex.
Remove the most recently added vertex but keep drawing. Press Backspace. The function redraws the line from the previous vertex to the current position of the pointer. You can only back up to the first vertex you drew. Resize (reshape) the ROI. Position pointer over a vertex and then click and drag.
Add a new vertex and then click and drag.
Remove a vertex and the shape of the ROI adjusts.
Move the ROI. Position the pointer over the line, not on a vertex. The pointer changes to the fleur shape. Click and drag the polygon. Delete the ROI. Position the pointer over the line, right-click, and select Delete Polyline from the context menu. You can also delete the ROI programmatically using the deletefunction.


