Rectangle
Rectangular region of interest
Description
A Rectangle
object specifies the shape and position of a
rectangular region-of-interest (ROI). You can customize the appearance and interactive
behavior of the ROI.
For more information about using this ROI, including keyboard shortcuts, see Tips.
Creation
There are two ways to create a Rectangle
object. For more information,
see Create ROI Shapes.
Use the
drawrectangle
function. Use this function when you want to create the ROI and set the appearance in a single command. You can specify the shape and position of the ROI interactively by drawing the ROI over an image using the mouse, or programmatically by using name-value arguments.Use the
images.roi.Rectangle
function described here. Use this function when you want to specify the appearance and behavior of the ROI before you specify the shape and position of the ROI. After creating the object, you can specify the shape and position interactively by using thedraw
function or programmatically by modifying properties of the object.
Syntax
Description
creates a
roi
= images.roi.RectangleRectangle
object with default properties.
creates an ROI in the axes specified by roi
= images.roi.Rectangle(ax
)ax
.
sets writeable properties using name-value
arguments. You can specify multiple name-value arguments.roi
= images.roi.Rectangle(___,Name=Value
)
Example: images.roi.Rectangle(Color="y")
creates a yellow colored
Rectangle
object.
Input Arguments
Properties
Object Functions
addlistener | Create event listener bound to event source |
beginDrawingFromPoint | Begin drawing ROI from specified point |
bringToFront | Bring ROI to front of Axes stacking order |
createMask | Create binary mask image from ROI |
draw | Begin drawing ROI interactively |
inROI | Query if points are located in ROI |
wait | Block MATLAB command line until ROI operation is finished |
Examples
More About
Tips
To draw the ROI interactively using the
draw
ordrawrectangle
function, position the cursor on the axes and click and drag to create the shape. To finish the ROI, release the mouse button.The ROI supports the following interactivity, including keyboard shortcuts.
Behavior Keyboard shortcut Cancel drawing the ROI. Press Esc. The function returns a valid ROI object with an empty Position
property.Resize (reshape) the ROI. Position the cursor over a vertex and then click and drag. The rectangle has vertices at each corner and at the midpoint of each side. To preserve the aspect ratio while resizing, press the Shift key. To lock the aspect ratio, use the Fix Aspect Ratio in the right-click context menu.
Move the ROI. Position the cursor over the ROI. The cursor changes to the fleur shape. Click and drag the ROI. Delete the ROI. Position the pointer on the rectangle, right-click, and choose Delete Rectangle from the context menu. You can also delete the ROI programmatically using the delete
function.For information about using an ROI in an app created with App Designer, see Using ROIs in Apps Created with App Designer.