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 ROI Creation Overview.
With the existing ROIs, you use makeConstrainToRectFcn
to
create a function to specify the limits of the area in which you can draw or move an
ROI. You then register this function with the ROI. When you use the
setPosition
object function, the ROI moves to wherever you
specify, even if it is outside of the constrained limits. If you use
setConstrainedPosition
, the ROI honors the limits set by the
constrained position function.
With the new ROIs, you use the DrawingArea
property of the ROI
to specify the area in which you can draw or move an ROI. When you set the location
using the Position
property, it does not honor limits set by the
DrawingArea
property.
Update CodeUpdate all instances of setConstrainedPosition
.
Discouraged Usage | Recommended Replacement |
---|
This example uses the
makeConstrainToRectFcn function to
create a 20-pixel border in which you cannot create or move
an ROI. The example then tries to specify a location for the
ROI that lies outside these limits. Using the
setConstrainedPosition object
function, the ROI does not honor locations specified outside
the limits. Using the setPosition object
function you can specify locations outside the
limits. | With the new ROIs, use the
DrawingArea property to limit the
area in which you can draw or move an ROI. This example
creates a 20-pixel margin inside the image boundary. There
is no way to make the ROI honor constraints when specifying
a location in the Position
property. |