imrect
(Not recommended) Create draggable rectangle
imrect is not recommended. Use the new Rectangle
            ROI object instead. You can also use the new ROI convenience function drawrectangle. For more information, see Version History.
Description
An imrect object encapsulates an interactive rectangle over
            an image.
You can adjust the size and position of the rectangle by using the mouse. The rectangle also has a context menu that controls aspects of its appearance and behavior. For more information, see Usage.
Creation
Syntax
Description
h = imrect begins interactive placement of a rectangle on
                    the current axes, and returns an imrect object.
h = imrect( begins
                    interactive placement of a rectangle on the object specified by
                        hparent)hparent.
h = imrect(___,"PositionConstraintFcn",
                    also specifies where the rectangle can be dragged using a position constraint
                    function, fcn)fcn.
Input Arguments
Properties
Usage
When you call imrect with an interactive syntax, the pointer
            changes to a cross hairs  when over the image. You can create the rectangle and
            adjust its size and position using the mouse. The rectangle also supports a context menu
            that you can use to control aspects of its appearance and behavior. Right-click on the
            rectangle to access this context menu.
 when over the image. You can create the rectangle and
            adjust its size and position using the mouse. The rectangle also supports a context menu
            that you can use to control aspects of its appearance and behavior. Right-click on the
            rectangle to access this context menu.

The table lists the interactive behaviors supported by
            imrect.
| Interactive Behavior | Description | 
|---|---|
| Moving the rectangle. | Move the pointer inside the rectangle. The pointer changes to a fleur
                            shape  . Click and drag the mouse to move the
                            rectangle. | 
| Resizing the rectangle. | Move the pointer over any of the edges or corners of the rectangle,
                            the shape changes to a double-ended arrow,  . Click and drag the edge or corner
                            using the mouse. | 
| Changing the color of the rectangle. | Move the pointer inside the rectangle. Right-click and select Set Color from the context menu. | 
| Retrieving the coordinates of the current position | Move the pointer inside the polygon. Right-click and select
                                Copy Position from the context menu. imrectcopies a four-element position vector to
                            the clipboard. | 
| Preserve the current aspect ratio of the rectangle during interactive resizing. | Move the pointer inside the rectangle. Right-click and select Fix Aspect Ratio from the context menu. | 
| Deleting the rectangle | Move the pointer inside the rectangle or on an edge of the rectangle.
                            Right-click and select Delete  from the
                            context menu. To remove this option from the context menu, set the Deletableproperty to false:h =
                                imrect(); h.Deletable = false; | 
When you use setResizeable to make
            the rectangle non-resizable, the Fix Aspect Ratio context
            menu item is not provided.
Object Functions
Each imrect object supports a number of functions. Type
                methods imrect to see a complete list.
| addNewPositionCallback | Add new-position callback to ROI object | 
| createMask | (Not recommended) Create mask within image | 
| delete | Delete handle object | 
| getColor | Get color used to draw ROI object | 
| getPosition | Return current position of ROI object | 
| getPositionConstraintFcn | Return function handle to current position constraint function | 
| removeNewPositionCallback | Remove new-position callback from ROI object | 
| resume | (Not recommended) Resume execution of MATLAB command line | 
| setColor | (Not recommended) Set color used to draw ROI object | 
| setConstrainedPosition | Set ROI object to new position | 
| setFixedAspectRatioMode | Preserve aspect ratio when resizing ROI object | 
| setPosition | (Not recommended) Move ROI object to new position | 
| setPositionConstraintFcn | Set position constraint function of ROI object | 
| setResizable | Set resize behavior of ROI object | 
| wait | (Not recommended) Block MATLAB command line until ROI creation is finished | 
Examples
Tips
If you use imrect with an axes that contains an image object, and
            do not specify a position constraint function, users can drag the rectangle outside the
            extent of the image. When used with an axes created by the plot
            function, the axes limits automatically expand to accommodate the movement of the
            rectangle.