Cropping an image means creating a new image from a part of an original image. To crop an image using the Image Viewer, use the Crop Image tool. To use the Crop Image tool, follow this procedure.
By default, if you close the Image Viewer, it does not save the modified image data. To save the cropped image, you can use the Save As option from the Image Viewer File menu to store the modified data in a file or use the Export to Workspace option to save the modified data in the workspace variable.
I = imread('moon.tif'); imtool(I)
Start the Crop Image tool by clicking Crop Image in the Image Viewer toolbar or selecting Crop Image from the Image Viewer Tools menu. (Another option is to open a figure window with imshow and call imcrop from the command line.) When you move the pointer over the image, the pointer changes to cross hairs .
Define the rectangular crop region, by clicking and dragging the mouse over the image. You can fine-tune the crop rectangle by moving and resizing the crop rectangle using the mouse. Or, if you want to crop a different region, move to the new location and click and drag again. To zoom in or out on the image while the Crop Image tool is active, use Ctrl+Plus or Ctrl+Minus keys. Note that these are the Plus(+) and Minus(-) keys on the numeric keypad of your keyboard. The following figure shows a crop rectangle being defined using the Crop Image tool.
When you are finished defining the crop region, perform the crop operation. Double-click the left mouse button or right-click inside the region and select Crop Image from the context menu. The Image Viewer displays the cropped image. If you have other modular interactive tools open, they will update to show the newly cropped image.
To save the cropped image, use the Save as option or the Export to Workspace option on the Image Viewer File menu.