Freehand
Description
A Freehand object labels a hand-drawn closed path in a
Viewer object. The properties of the object control the appearance and
behavior of the freehand 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 freehand annotation on an
imshow image display, use drawfreehand
instead.
![]()
Creation
You can create a Freehand 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.Freehandfunction described here. After you create the ROI, you can display it by adding the object to theAnnotationsproperty of aViewerobject.
Description
f = images.ui.graphics.roi.Freehand creates a
Freehand object with default property values. Use
f to query and modify properties of the object after you
create it.
f = images.ui.graphics.roi.Freehand(Name=Value) sets one or more
writable properties using
name-value arguments.
Example:
images.ui.graphics.roi.Freehand(Position=[1 1 1; 100 1 1; 1 200
1]) creates a freehand annotation with three vertices at the
xyz-coordinates (1, 1, 1), (100, 1, 1) and (1, 200,
1).
Properties
Object Functions
createMask | Create binary mask image from ROI |
Examples
Tips
The
uidrawandimages.ui.graphics.roi.Freehandfunctions 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 freehand annotation on animshowimage display, usedrawfreehandinstead.The ROI supports this interactivity, including keyboard shortcuts.
Behavior Interaction Add annotation To enable interactive drawing, call the
uidrawfunction and specify the second argument as"freehand". Click and drag to draw a smooth line that follows the pointer. Click to add a vertex connected by a straight line segment.Make drawn line snap at 15 degree angles Hold Shift while drawing. Finish drawing annotation Double-click, which adds a vertex at the pointer position and draws a line connecting this vertex to the first point drawn, closing the ROI.
Right-click, which draws a line connecting the last vertex drawn to the first vertex drawn.
Cancel drawing annotation Press Esc. Move annotation Pause on the edge of the ROI and drag it. Edit annotation label Right-click the edge of 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 edge of 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
