impoint() - Image Processing
h = impoint begins interactive placement
of a draggable point on the current axes. The function returns h,
a handle to an impoint object. The point has a
context menu associated with it that controls aspects of its appearance
and behavior—see Interactive Behavior. Right-click on the point to access
this context menu.h = impoint(hparent) begins
interactive placement of a point on the object specified by hparent. hparent specifies
the HG parent of the point graphics, which is typically an axes but
can also be any other object that can be the parent of an hggroup.h = impoint(hparent,position) creates
a draggable point on the object specified by hparent.
position is a 1-by-2 array of the form [x
y] that specifies the initial position of the point. h = impoint(hparent,x, y) creates
a draggable point on the object specified by hparent. x and y are
both scalars that together specify the initial position of the point. h = impoint(..., param,val) creates a draggable
point , specifying parameters and corresponding values that control
the behavior of the point. The following table lists the parameter
available. Parameter names can be abbreviated, and case does not matter.ParameterDescription
'PositionConstraintFcn'Function handle fcn that is called
whenever the point is dragged using the mouse. You can use this function
to control where the point can be dragged. See the help for the setPositionConstraintFcn method for information
about valid function handles.
Interactive BehaviorWhen you call impoint with an interactive
syntax, the pointer changes to a cross hairs
when over the image. Click
and drag the mouse to specify the position of the point. The point
supports a context menu that you can use to control aspects of its
appearance and behavior. The following table describes the interactive
behavior of the point, including the right-click context menu options.
Interactive BehaviorDescription
Moving the point.Move the mouse pointer over the point. The mouse pointer changes
to a fleur shape
.
Click and drag the mouse to move the point.
Changing the color used to display the point. Move the mouse pointer over the point. Right-click and select Set
Color from the context menu and specify the color you
want to use.
Retrieving the coordinates of the point.Move the mouse pointer over the point. Right-click and select Copy
Position from the context menu to copy a 1-by-2 array
to the clipboard specifying the coordinates of the point [X
Y].
Deleting the pointMove the pointer on top of the point. Right-click and select Delete from
the context menu. To remove this option from the context menu, set
the Deletable property to false: h = impoint();
h.Deletable = false;
MethodsThe following lists the methods supported by the impoint object.
Type methods impoint to see a complete list of
all the methods.addNewPositionCallback — Add new-position callback to ROI objectSee imroi for information.delete — Delete ROI objectSee imroi for information.getColor — Get color used to draw ROI objectSee imroi for information.getPosition — Return current position of pointpos = getPosition(h) returns the current
position of the point h. The returned position, pos,
is a two-element vector [x y].getPositionConstraintFcn — Return function handle to current position constraint functionSee imroi for information.removeNewPositionCallback — Remove new-position callback
from ROI object.See imroi for information.resume — Resume execution of MATLAB command lineSee imroi for information.setColor — Set color used to draw ROI objectSee imroi for information.setConstrainedPosition — Set ROI object to new positionSee imroi for information.setPosition — Set point to new positionsetPosition(h,pos) sets the pointh to
a new position. The new position, pos, has the
form, [x y]. setPosition(h,new_x,new_y) sets the point h to
a new position. new_x and new_y are
both scalars that together specify the position of the point.setPositionConstraintFcn — Set position constraint function of ROI object.See imroi for information.setString — Set text label for pointsetString(h,s) sets a text label for the
point h. The string, s, is placed
to the lower right of the point.wait — Block MATLAB command line until ROI creation is finishedSee imroi for information.
Syntax
h = impointh = impoint(hparent)h = impoint(hparent,position)h = impoint(hparent,x, y)h = impoint(..., param,val)
Example
figure, imshow rice.png
h = impoint(gca,100,200);
% Update position in title using newPositionCallback
addNewPositionCallback(h,@(h) title(sprintf('(%1.0f,%1.0f)',h(1),h(2))));
% Construct boundary constraint function
fcn = makeConstrainToRectFcn('impoint',get(gca,'XLim'),get(gca,'YLim'));
% Enforce boundary constraint function using setPositionConstraintFcn
setPositionConstraintFcn(h,fcn);
setColor(h,'r');
setString(h,'Point label');
Output / Return Value
Limitations
Alternatives / See Also
Reference