setPosition
(Not recommended) Move ROI object to new position
setPosition
is not recommended. With the new ROIs, set the value of
the Position
property instead. For more information, see Version History.
Description
Input Arguments
pos
— New position of ROI object
numeric array
New position of the ROI object, specified as a numeric array. The shape of the array depends on the type of ROI object.
ROI Object | Position |
---|---|
imellipse | 4-element vector of the form [xmin ymin width
height] , representing the new size and
position of a bounding box around the ellipse. The new size
of the bounding box is
width -by-height
pixels. The upper-left corner of the box is at the new (x,y)
coordinate
(xmin ,ymin ). |
imline | 2-by-2 matrix of the form [x1 y1; x2
y2] , representing the new position of the two
endpoints of the line. |
impoint | 1-by-2 vector of the form [x
y] . |
impoly | n-by-2 matrix. The two columns define the new x- and y-coordinates, respectively, of each of the n vertices. |
imrect | 4-element vector of the form [xmin ymin width
height] . The new size of the rectangle is
width -by-height
pixels. The upper-left corner of the rectangle is at the new
(x,y) coordinate
(xmin ,ymin ). |
x
— New x-coordinate of points
2-element vector | numeric scalar
New x-coordinate of points.
If
h
is animline
object, thenx
is a 2-element vector that represents the x-coordinates of the two line endpoints.If
h
is animpoint
object, thenx
is a numeric scalar that represents the x-coordinate of the single point.
y
— New y-coordinate of points
2-element vector | numeric scalar
New y-coordinate of points.
If
h
is animline
object, theny
is a 2-element vector that represents the y-coordinates of the two line endpoints.If
h
is animpoint
object, theny
is a numeric scalar that represents the y-coordinate of the single point.
Version History
Introduced in R2008aR2018b: setPosition
is not recommended
Starting in R2018b, a new set of ROI objects replaces the existing set of ROI objects. The new objects provide more functional capabilities, such as face color transparency. The new classes also support events that you can use to respond to changes in your ROI such as moving or being clicked. Although there are no plans to remove the old ROI objects at this time, switch to the new ROIs to take advantage of the additional capabilities and flexibility. For more information on creating ROIs using the new ROI functions, see Create ROI Shapes.
To specify the current location of the ROI, assign a value to the
Position
property of the ROI.
Update all instances of setPosition
method.
Discouraged Usage | Recommended Replacement |
---|---|
This example sets the current location of the ROI using
the imshow('cameraman.tif');
h = imrect(gca,[10 10 100 100]);
setPosition(h,[20 20 200 200]);;
| Create one of the new ROI objects and replace use of
the imshow('cameraman.tif'); h = drawrectangle(gca,'Position',[10 10 100 100]); h.Position = [20 20 200 200]; |
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)