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 Compatibility Considerations.
Create an ellipse ROI object. Specify a position constraint function using
makeConstrainToRectFcn
to keep the
ellipse inside the boundary of the image.
imshow('coins.png') h = imellipse(gca,[10 10 100 100]); 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.