Create freehand ROI on image with assistance from image edges
creates an
roi
= drawassistedAssistedFreehand
object and enables interactive drawing of the
hand-drawn region-of-interest (ROI) on the current axes. The
AssistedFreehand
ROI uses the edges in the underlying image to "assist"
you as you draw the shape.
To draw the ROI, position the pointer on the image, click and release to place the first vertex (waypoint), and then move the pointer to draw a line. As you move the pointer to draw the shape, the line follows the contours of edges in the underlying image automatically. As you draw, click to place vertices along the line. To finish the ROI and close the shape, double-click. For more information about using the ROI, including keyboard shortcuts and context menu options, see Tips.
Note
drawassisted
is a convenience function for creating an
AssistedFreehand
ROI object. If you create the ROI object directly,
calling AssistedFreehand
, you must call the draw
object function
to enable interactive drawing of the ROI. In contrast, the
drawassisted
function creates the ROI object and calls the
draw
object function for you. Whichever way you create the ROI, you
use object properties, object functions, and event notifications to customize its
appearance and behavior. For more information about using these capabilities, see Tips.
modifies the appearance and behavior of the ROI using one or more name-value pairs.
Unspecified name-value pairs are set to default values.roi
= drawassisted(___,Name,Value
)
This table describes how to perform common tasks with the
AssistedFreehand
ROI.
Behavior | Keyboard shortcut |
---|---|
Cancel drawing the ROI. | Press Esc. The function returns a valid ROI object with an
empty Position field. |
Finish drawing (close) the ROI. | Double-click, which adds a point at the pointer position and draws a line connecting this point to the first point drawn, closing the ROI. Right-click, which draws a line connecting the last point to the first point drawn. Position the pointer over the first point and click. Press Enter, which draws a line connecting the last point to the first point drawn. |
Resize (reshape) the ROI. | Position pointer over a waypoint and then click and drag. No assistance (snapping to edges) is available in this mode. |
Add a waypoint. | Position the pointer on an edge of the ROI, right-click, and select Add Waypoint. You can also position the pointer on an edge of the ROI and double-click. |
Remove a waypoint. | Position the pointer on a waypoint, right-click, and select Remove Waypoint. |
Move the ROI. | Position the pointer over the ROI. The pointer changes to the fleur shape. Click and drag to move the ROI. |
Delete an ROI. | Position the pointer on the ROI (not on a vertex), right-click, and select
Delete Freehand from the context menu. You can also
delete the ROI programmatically using the delete object
method. |
The drawassisted
function returns an AssistedFreehand
ROI object. After creation, use these capabilities of the
object to customize the appearance and behavior of the ROI.
Object properties — ROI objects support properties that modify their appearance or behavior. For example, to change the color of the roi
to yellow, set its Color
property, roi.Color = 'yellow'
.
Object functions — ROI objects support a set of object functions that operate on the ROIs. For example, if you want to pause the MATLAB command line after creating an ROI, call the wait
object function.
Event notifications — ROI objects can notify your code when certain events, such as being moved or clicked, happen to the ROI. To receive these notifications, use the addlistener
object function to set up listeners for specific events. In the listener, specify an event, such as 'ROIMoved'
, and a callback function that executes when the event occurs. 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.
For an example of using event listeners with the AssistedFreehand
object, see Set Up Listener for AssistedFreehand Events. For more details
about these capabilities, see the AssistedFreehand
object documentation.
AssistedFreehand
| drawcircle
| drawcrosshair
| drawcuboid
| drawellipse
| drawline
| drawpoint
| drawpolygon
| drawpolyline
| drawrectangle