imcrop
Crop image
Syntax
Description
Crop Image Interactively
Note
The interactive syntaxes do not support categorical images. For categorical images,
you must specify the crop region, rect
.
creates an interactive
Crop Image tool to crop the grayscale, truecolor, or binary image displayed in the current
figure. Icropped
= imcropimcrop
returns the cropped image,
Icropped
.
With this syntax and the other interactive syntaxes, the Crop Image tool blocks the MATLAB® command line until you complete the operation. For more information about using the Crop Image tool, see Interactive Behavior.
___ = imcrop(
creates an
interactive Crop Image tool to crop the image in graphics object
h
)h
.
Crop Image by Specifying Crop Region
crops the image Icropped
= imcrop(I
,rect
)I
according to the position and dimensions specified
in the crop rectangle rect
. The cropped image includes all pixels in
the input image that are completely or partially enclosed by the
rectangle.
The actual size of the output image does not always correspond exactly with the width
and height specified by rect
. For example, suppose
rect
is [20 20 40 30]
, using the default spatial
coordinate system. The upper left corner of the specified rectangle is the center of the
pixel with spatial (x,y) coordinates (20,20). The lower right corner of the rectangle is the
center of the pixel with spatial (x,y) coordinates (60,50). The resulting output image has size 31-by-41
pixels, not 30-by-40 pixels.
Specify Additional Output Options
[___,
also returns the position of the crop rectangle in rectout
] = imcrop(___)rectout
. You can
use the input arguments of any other syntax.
imcrop(___)
without output arguments displays the
cropped image in a new figure window. This syntax does not support categorical
images.