drawpolyline
Create customizable polyline ROI
Description
The drawpolyline
function creates a Polyline
object that specifies the shape and position of a polyline region of interest (ROI). You
can create the ROI interactively by drawing the ROI over an image using the mouse, or
programmatically by using name-value arguments. You can also specify the initial
appearance and behavior of the ROI.
After you create the ROI, you can use object properties, object functions, and event notifications to customize the shape, position, appearance, and behavior of the ROI. For more information about using these capabilities, see Tips.
creates a
roi
= drawpolylinePolyline
ROI object and enables interactive drawing of the
ROI on the current axes.
To draw the ROI, position the pointer on the image. The cursor changes to a fleur shape. Click to draw vertices of the polyline and drag to draw the lines between the vertices. To finish the ROI, double-click the mouse button. For more information about using the ROI, including keyboard shortcuts and context menu options, see Tips.
modifies the appearance and behavior of the ROI using one or more name-value
arguments.roi
= drawpolyline(___,Name=Value
)
Examples
Input Arguments
Output Arguments
Tips
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 adds a final new vertex at the pointer position.
Press Enter, which adds a final new vertex at the pointer position..
Cancel drawing the ROI. Press Esc. The function returns a valid ROI object with an empty Position
property.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 ROI. Delete the ROI. Position the pointer anywhere on the ROI and right-click. Select Delete Polyline from the context menu. You can also delete the ROI using the delete
function.The
drawpolyline
function creates aPolyline
object. After you create the object, you can modify the shape, position, appearance, and behavior of the ROI by using these object capabilities.Capability Support Object properties ROI objects have properties that specify their shape, position, appearance, and behavior. After you create the ROI object, change properties using dot notation.
For example, to change the color of the
roi
to yellow, set itsColor
property:roi.Color = 'yellow'
Object functions ROI objects have object functions that operate on the ROIs. For example, if you want to pause the MATLAB command line after creating an ROI, use the wait
function.Event notifications ROI objects can notify your code when certain events occur, such as when the ROI is clicked or when the ROI is being moved. To receive event notifications, set up listeners. When the ROI notifies your application through the listener, it returns data specific to the event. For example, with the
ROIMoved
event, the ROI object returns its previous position and its current position. You can specify a callback function that executes when an event occurs.For an example of using event listeners with the
Polyline
object, see Set Up Listener for Polyline ROI Events.