You are here : matlabImage Processingimfreehand

imfreehand() - Image Processing

h = imfreehand begins interactive placement
of a freehand region of interest on the current axes. The function
returns h, a handle to an imfreehand object.
A freehand region of interest can be dragged interactively using the
mouse and supports a context menu that controls aspects of its appearance
and behavior. See Interactive Behavior.h = imfreehand(hparent) begins
interactive placement of a freehand region of interest on the object
specified by hparent.  hparent specifies
the HG parent of the freehand region graphics, which is typically
an axes, but can also be any other object that can be the parent of
an hggroup. h = imfreehand(...,param1, val1,...) creates
a freehand ROI, specifying parameters and corresponding values that
control the behavior of the tool. The following table lists the parameters
available. Parameter names can be abbreviated, and case does not matter.ParameterDescription
'Closed'Scalar logical that controls whether the freehand region is
closed. When set to true (the default), imfreehand draws
a straight line to connect the endpoints of the freehand line to create
a closed region. If set to false, imfreehand leaves
the region open.
'PositionConstraintFcn'Function handle specifying the function that is called
whenever the freehand region is dragged using the mouse. Use this
parameter to control where the freehand region can be dragged. See
the help for the setPositionConstraintFcn method
for information about valid function handles.
Interactive BehaviorWhen you call imfreehand with an interactive
syntax, the pointer changes to a cross hairs 
when positioned over an
image. Click and drag the mouse to draw the freehand region. By default, imfreehand draws
a straight line connecting the last point you drew with the first
point, but you can control this behavior using the 'Closed' parameter.
The following figure illustrates a freehand region with its context
menu.
The following table lists the interactive features supported
by imfreehand.Interactive BehaviorDescription
Moving the region.Move the pointer inside the freehand region. The pointer changes
to a fleur shape 
.
Click and hold the left mouse button to move the region. 
Changing the color used to draw the region. Move the pointer inside the freehand region. Right-click and
select Set Color from the context menu. 
Retrieving the current position of the freehand region. Move the pointer inside the freehand region. Right-click and
select Copy Position from the context menu. imfreehand copies
an n-by-2 array of coordinates on the boundary
of the ROI to the clipboard. 
Deleting the regionMove the pointer inside the region. Right-click and select Delete  from
the context menu. To remove this option from the context menu, set
the Deletable property to false: h = imfreehand();
h.Deletable = false;
MethodsThe imfreehand object supports the following
methods. Type methods imfreehand to see a complete
list of all methods. addNewPositionCallback — Add new-position callback to ROI  objectSee imroi for information.createMask — Create mask within imageSee 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 freehand regionpos = getPosition(h) returns the current
position of the freehand region h. The returned
position, pos, is an N-by-2 array [X1
Y1;...;XN YN].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.setClosed — Set geometry of freehand regionsetClosed(h,TF) sets the geometry of the
freehand region h. TF is a logical
scalar. True means that the freehand region is
closed. False means that the freehand region is
open. setColor — Set color used to draw ROI objectSee imroi for information.setConstrainedPosition — Set ROI object to new positionSee imroi for information.setPositionConstraintFcn — Set position constraint function
of  ROI object.See imroi for information.wait — Block MATLAB command line until ROI creation
is  finishedSee imroi for information.


Syntax

h = imfreehandh = imfreehand(hparent)h = imfreehand(...,param1, val1,...)


Example

figure, imshow('pout.tif');
h = imfreehand(gca);


Output / Return Value


Limitations


Alternatives / See Also


Reference