Freehand
R2026bDescription
A Freehand object labels an interactive hand-drawn closed path
in a Viewer object. The properties of the object control the appearance
and behavior of the freehand annotation.
Interactive viewer-based ROIs enable you to draw, edit, and
measure regions of interest on images and volumes displayed using imageshow
and volshow. Interactive ROIs support dragging, resizing, event callbacks,
and measurement labels. Use interactive viewer-based ROIs to manually annotate an image, build
annotation workflows in apps, or respond to user interactions with ROI shapes. For a comparison
of interactive viewer-based ROIs with other ROIs, see Choose Approach to Annotate ROIs in Images.
![]()
Creation
You can create a Freehand object in these ways. For more information,
see Create Interactive Viewer-Based ROIs.
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 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
