imline
(Not recommended) Create draggable, resizable line
imline
is not recommended. Use the new Line
ROI
object instead. You can also use the ROI creation convenience function drawline
.
For more information, see Version History.
Description
An imline
object encapsulates an interactive line over an
image.
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
Syntax
Description
h = imline
begins interactive placement of a line on the
current axes, and returns an imline
object.
h = imline(
begins
interactive placement of a line on the object specified by
hparent
)hparent
.
h = imline(___,"PositionConstraintFcn",
also specifies where the line can be dragged using a position constraint
function, fcn
)fcn
.
Input Arguments
Properties
Usage
When you call imline
with an interactive syntax, the pointer
changes to a cross hairs when over the image. Click and drag the mouse to
specify the position and length of the line. The line supports a context menu that you
can use to control aspects of its appearance and behavior.
The table describes the interactive behavior supported by
imline
.
Interactive Behavior | Description |
---|---|
Moving the line. | Move the pointer over the line. The pointer changes to a fleur shape . Click and drag the mouse to move the line. |
Moving the endpoints of the line. | Move the pointer over either end of the line. The pointer changes to the pointing finger, . Click and drag the mouse to resize the line. |
Changing the color used to display the line. | Move the pointer over the line. Right-click and select Set Color from the context menu. |
Retrieving the coordinates of the endpoints of the line. | Move the pointer over the line. Right-click and select
Copy Position from the context menu.
imline copies a 2-by-2 array to the clipboard
specifying the coordinates of the endpoints of the line in the form
[X1 Y1; X2 Y2] . |
Deleting the line | Move the pointer on top of the line. Right-click and select
Delete from the context menu. To remove
this option from the context menu, set the Deletable
property to false: h = imline(); h.Deletable =
false; |
Object Functions
Each imline
object supports a number of functions. Type
methods imline
to see a complete list.
addNewPositionCallback | Add new-position callback to ROI object |
createMask | (Not recommended) Create mask within image |
delete | Delete handle object |
getColor | Get color used to draw ROI object |
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 |
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
imline
with an axes that contains an image object, and do not specify a position constraint function, users can drag the line outside the extent of the image and lose the line. When used with an axes created by theplot
function, the axis limits automatically expand to accommodate the movement of the line.Use
imdistline
to create an interactive line with a text box that displays the distance between line endpoints.