Polyline
Description
A Polyline object labels an open polygon, or polyline, in a
Viewer object. The properties of the object control the appearance and
behavior of the polyline annotation.
Viewer-based ROIs provide high-performance interactions with images and volumes you
display in a Viewer object using imageshow and
volshow, respectively. To draw a polyline on an
imshow image display, use drawpolyline
instead.
![]()
Creation
You can create a Polyline object in these ways:
Use the
uidrawfunction to interactively draw the ROI in a specified viewer and create the ROI object.Use the
images.ui.graphics.roi.Polylinefunction described here. After you create the ROI, you can display it by adding the object to theAnnotationsproperty of aViewerobject.
Description
p = images.ui.graphics.roi.Polyline creates a
Polyline object with default property values. Use
p to query and modify properties of the object after you
create it.
p = images.ui.graphics.roi.Polyline(Name=Value) sets one or
more writable properties using
name-value arguments.
Example:
images.ui.graphics.roi.Polyline(Position=[1 1; 10 1; 30 30; 1 20])
creates a polyline annotation with four vertices at xy-coordinates
of (1, 1), (10, 1), (30, 30), and (1, 20).
Properties
Object Functions
createMask | Create binary mask image from ROI |
Examples
Tips
The
uidrawandimages.ui.graphics.roi.Polylinefunctions create ROIs to display in aViewerobject. Viewer-based ROIs provide high-performance interactions with images and volumes you display in aViewerobject usingimageshowandvolshow, respectively. To draw a polyline on animshowimage display, usedrawpolylineinstead.The ROI supports this interactivity, including keyboard shortcuts.
Behavior Interaction Add annotation To enable interactive drawing of a polyline, call the
uidrawfunction and specify the second argument as"polyline". Click inside the viewer to add vertices.Make drawn line snap at 15 degree angles Hold Shift while drawing. Remove most recently added vertex, but continue drawing Press Backspace. The function redraws the line from the previous vertex to the current position of the pointer. You can only remove vertices added after the first vertex. Finish drawing annotation Double-click, which adds a new vertex at the pointer position and finishes drawing.
Right-click, which finishes drawing without adding another vertex to the polyline.
Click the first vertex, which finishes drawing without adding another vertex to the polyline.
Cancel drawing annotation Press Esc. Add a new vertex to annotation Double-click the edge of the ROI.
Resize (reshape) annotation Drag an existing vertex.
Add a new vertex to the polyline and drag it.
Double-click an existing vertex to remove it. The ROI redraws the line connecting the two neighboring vertices. If a polyline has only three vertices, you cannot remove additional vertices in this way.
Move annotation Hold Ctrl and drag the ROI. Edit annotation label Right-click the ROI. From the context menu, select Edit label. When the label text highlights, type new text for the label. To finish editing, click outside the label. Remove annotation Right-click the ROI and choose Remove annotation from the context menu. Select Remove all annotations to remove all annotations in the viewer.
Version History
Introduced in R2026a
