Image Processing Toolbox | ![]() ![]() |
Image Cropping
To extract a rectangular portion of an image, use the imcrop
function. imcrop
accepts two primary arguments:
If you call imcrop
without specifying the crop rectangle, the cursor changes to a cross hair when it is over the image. Click on one corner of the region you want to select, and while holding down the mouse button, drag across the image. imcrop
draws a rectangle around the area you are selecting. When you release the mouse button, imcrop
creates a new image from the selected region.
In this example, you display an image and call imcrop
. The rectangle you select is shown in red.
The imcrop
function waits for you to draw the cropping rectangle on the image.
Now call imshow
to display the cropped image. If you call imcrop
without specifying any output arguments, imcrop
displays the image in a new figure.
![]() | Image Rotation | Performing General Spatial Transformations | ![]() |