setFixedAspectRatioMode
Preserve aspect ratio when resizing ROI object
setFixedAspectRatioMode
is not recommended. With the new ROIs, set
the value of the FixedAspectRatio
property instead. For more
information, see Version History.
Description
Examples
Fix Aspect Ratio of Ellipse
Create an ellipse ROI object.
imshow("coins.png")
h = imellipse(gca,[10 10 100 100]);
Specify a position constraint function using makeConstrainToRectFcn
to
keep the ellipse inside the boundary of the image.
fcn = makeConstrainToRectFcn("imellipse",get(gca,"XLim"),get(gca,"YLim")); setPositionConstraintFcn(h,fcn);
Try resizing and reshaping the ellipse.
Now, fix the aspect ratio of the ellipse.
setFixedAspectRatioMode(h,true);
Try resizing the ellipse. The aspect ratio of the ellipse does not change.
Input Arguments
Version History
Introduced before R2006aR2018b: setFixedAspectRatioMode
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 control whether an Ellipse
or Rectangle
ROI maintains the aspect ratio when being resized, use the
FixedAspectRatio
property of the ROI.
Update all instances of setFixedAspectRatioMode
method.
Discouraged Usage | Recommended Replacement |
---|---|
This example uses the
imshow("cameraman.tif")
h = imrect(gca,[10 10 100 100]);
setFixedAspectRatioMode(h,true);
| Create a Rectangle ROI, using the new ROI objects, and
replace use of the
imshow("camerman.tif") h = drawrectangle(gca,"Position",[10 10 100 100]); h.FixedAspectRatio = true; |
See Also
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)