Main Content

getrect

Specify rectangle with mouse

getrect is not recommended. Use one of the ROI classes instead, described in Create ROI Shapes.

Description

example

rect = getrect lets you select a rectangle in the current axes using the mouse. When you finish selecting the rectangle, getrect returns information about the position and size of the rectangle in rect.

Use the mouse to click and drag the desired rectangle. To constrain the rectangle to be a square, use a shift- or right-click to begin the drag.

rect = getrect(fig) lets you select a rectangle in the current axes of figure fig, using the mouse.

rect = getrect(ax) lets you select a rectangle in axes ax, using the mouse.

Examples

collapse all

Display an image using imshow.

imshow('moon.tif')

Choose points interactively in the displayed image using the mouse. When you are done, getrect returns the size and position of your rectangle.

rect = getrect

Input Arguments

collapse all

Figure handle, specified as a handle.

Axes handle, specified as a handle.

Output Arguments

collapse all

Selected rectangle, returned as a 4-element numeric vector with the form [xmin ymin width height].

Version History

Introduced before R2006a

See Also

| |