The imcrop function is used to extract a part of an image in MATLAB. Following is the syntax of the function:
main.m20 chars2 lines
where A is the input image and rect is a four-element position vector [xmin ymin width height], specifying the size and position of the crop rectangle.
Here is an example code snippet to crop a rectangular region from an input image:
main.m376 chars21 lines
This code will open a window displaying the input image, then allow the user to draw a rectangle on the image using the mouse. After the user finishes drawing the rectangle, the code crops the specified region using imcrop and displays the resulting image.
gistlibby LogSnag