imdistline
Distance tool
Description
An imdistline
object encapsulates a Distance tool, which
consists of an interactive line over an image, paired with a text label that displays
the distance between the line endpoints.
You can adjust the size and position of the line by using the mouse. The line also has a context menu that controls aspects of its appearance and behavior. For more information, see Usage.
Creation
Description
creates a Distance
tool on the current axes. The function returns h
= imdistlineh
, a handle
to an imdistline
object.
creates a draggable Distance tool on the object specified by
h
= imdistline(hparent
)hparent
.
Input Arguments
Properties
Usage
To move the Distance tool, position the pointer over the line, the shape changes to the fleur, . Click and drag the line using the mouse. To resize the Distance tool, move the pointer over either of the endpoints of the line, the shape changes to the pointing finger, . Click and drag the endpoint of the line using the mouse.
The line also supports a context menu that allows you to control various aspects of its functioning and appearance. Right-click the line to access the context menu.
Distance Tool Behavior | Context Menu Item |
---|---|
Export endpoint and distance data to the workspace | Select Export to Workspace from the context menu. |
Toggle the distance label on/off. | Select Show Distance Label from the context menu. |
Specify horizontal and vertical drag constraints | Select Constrain Drag from the context menu. |
Change the color used to display the line. | Select Set Color from the context menu. |
Delete the Distance tool object | Select Delete from the context menu. |
Object Functions
addNewPositionCallback | Add new-position callback to ROI object |
createMask | (Not recommended) Create mask within image |
delete | Delete handle object |
getAngleFromHorizontal | Return angle between Distance tool and horizontal axis |
getColor | Get color used to draw ROI object |
getDistance | Return distance between endpoints of Distance tool |
getLabelHandle | Return handle to text label of Distance tool |
getLabelTextFormatter | Return format of text label of Distance tool |
getLabelVisible | Return visibility of text label of Distance tool |
getPosition | Return current position of ROI object |
getPositionConstraintFcn | Return function handle to current position constraint function |
removeNewPositionCallback | Remove new-position callback from ROI object |
resume | (Not recommended) Resume execution of MATLAB command line |
setColor | (Not recommended) Set color used to draw ROI object |
setConstrainedPosition | Set ROI object to new position |
setLabelTextFormatter | Set format used to display text label of Distance tool |
setLabelVisible | Set visibility of text label of Distance tool |
setPosition | (Not recommended) Move ROI object to new position |
setPositionConstraintFcn | Set position constraint function of ROI object |
wait | (Not recommended) Block MATLAB command line until ROI creation is finished |
Examples
Tips
If you use
imdistline
with an axes that contains an image object, and do not specify a drag constraint function, then you can drag the line outside the extent of the image. When used with an axes created by theplot
function, the axes limits automatically expand to accommodate the movement of the line.You can also use the
Line
ROI object to create an interactive customizable distance tool. For an example, see Measure Distances in an Image.
Version History
Introduced before R2006a