Crosshair
R2026bCrosshair region of interest
Description
A Crosshair object specifies the position of an axes-based
crosshair region of interest (ROI). You can customize the appearance and interactive behavior
of the ROI.
Axes-based ROIs enable you to draw and edit regions of interest
on images displayed using imshow or in MATLAB® axes. Axes-based ROIs offer maximum customization of appearance and behavior,
including line width, marker style, and edge color. Use axes-based ROIs for fine-grained control
over ROI appearance, integration with existing axes-based apps, or access to the assisted
freehand, crosshair, or cuboid ROI types. For a comparison of axes-based ROIs with other ROIs,
see Choose Approach to Annotate ROIs in Images.

For more information about using this ROI, including keyboard shortcuts, see Tips.
Creation
There are two ways to create a Crosshair object. For more information,
see Create Axes-Based ROIs.
Use the
drawcrosshairfunction. Use this function when you want to create the ROI and set the appearance in a single command. You can specify the position of the ROI interactively by drawing the ROI over an image using the mouse, or programmatically by using name-value arguments.Use the
images.roi.Crosshairfunction described here. Use this function when you want to specify the appearance and behavior of the ROI before you specify the position of the ROI. After creating the object, you can specify the position interactively by using thedrawfunction or programmatically by modifying properties of the object.
Syntax
Description
creates a
roi = images.roi.CrosshairCrosshair object with default properties.
creates the ROI in the axes specified by roi = images.roi.Crosshair(ax)ax.
sets properties
of the ROI using one or more name-value arguments.roi = images.roi.Crosshair(___,PropertyName=Value)
Example: images.roi.Crosshair(Color="y") creates a yellow colored
Crosshair object.
Input Arguments
Properties
Object Functions
addlistener | Create event listener bound to event source |
beginDrawingFromPoint | Begin drawing ROI from specified point |
bringToFront | Bring ROI to front of Axes stacking order |
draw | Begin drawing ROI interactively |
wait | Block MATLAB command line until ROI operation is finished |
Examples
More About
Tips
To draw the ROI interactively using the
drawordrawcrosshairfunction, position the cursor over the image and click the mouse to draw the ROI.The ROI supports the following interactivity, including keyboard shortcuts.
Task Description Cancel drawing operation. Press Esc. The function returns a valid ROI object with an empty Positionproperty.Move the ROI. Position the cursor over the center of the crosshair ROI (where the two lines cross) and click and drag the crosshair. Another way to move the crosshair ROI is to position the cursor anywhere on one of the two lines and click. The other line in the crosshair jumps to the new crosshair center position. Delete the ROI. Position the cursor over the ROI, right-click, and then choose Delete Crosshair from the context menu. You can also delete the ROI programmatically by using the deletefunction.

