Create customizable crosshair ROI
creates a
roi
= drawcrosshairCrosshair
object and enables interactive drawing of the crosshair
region-of-interest (ROI) on the current axes. The crosshair ROI is made up of two
perpendicular lines that are the full width and height of the axes.
To draw the ROI, move the cursor over the axes and click. For more information about using the ROI, including keyboard shortcuts and context menu options, see Tips.
Note
drawcrosshair
is a convenience function for creating a crosshair
ROI object. If you create the ROI object directly, by calling Crosshair
,
you must call the draw
object function to enable interactive drawing
of the ROI. In contrast, the drawcrosshair
function creates the ROI
object and calls the draw
object function for you. After creating the
ROI using either option, to customize its appearance and behavior, you must use object
properties, object functions, and event notifications. For more information about using
these capabilities, see Tips.
customizes the appearance and behavior of the ROI using one or more name-value pairs.
Unspecified name-value pairs are set to the default value.roi
= drawcrosshair(___,Name,Value
)
This table describes how to perform common tasks with a crosshair ROI.
Task | Description |
---|---|
Cancel the drawing operation. | Start drawing the ROI and press Esc before releasing the
mouse. The function returns a valid ROI object with an empty
Position property. |
Move the ROI. | Position the pointer over the ROI. The pointer changes to a fleur shape. Click and drag to move the ROI. |
Delete the ROI. | Position the pointer over the ROI and right-click to view its context menu.
Select Delete Crosshair from the menu. You can also
delete the ROI using the delete object function. |
The drawcrosshair
function returns a Crosshair
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 Crosshair
object,
see Display Value of Pixel Specified By Crosshair ROI. For more details
about these capabilities, see the Crosshair
object documentation.
Crosshair
| drawassisted
| drawcircle
| drawcuboid
| drawellipse
| drawfreehand
| drawline
| drawpoint
| drawpolygon
| drawpolyline
| drawrectangle