Rotate image
Syntax
B=imrotate(A,angle)
B=imrotate(A,angle,method)
B = imrotate(A,angle,method,bbox)
Description
B = imrotate(A,angle) rotates image A by angle degrees in a counterclockwise direction around its center point. To rotate the image clockwise, specify a negative value for angle. imrotate makes the output image B large enough to contain the entire rotated image. imrotate uses nearest neighbor interpolation, setting the values of pixels in B that are outside the rotated image to 0 (zero).
B = imrotate(A,angle,method) rotates image A, using the interpolation method specified by method. method is a text string that can have one of these values. The default value is enclosed in braces ({}).
B = imrotate(A,angle,method,bbox) rotates image A, where bbox specifies the size of the returned image. bbox is a text string that can have one of the following values. The default value is enclosed in braces ({}).
Value | Description |
'crop' | Make output image B the same size as the input image A, cropping the rotated image to fit |
{'loose'} | Make output image B large enough to contain the entire rotated image. B is generally larger than A. |
Example :-
A rotation of -1 degree is all that is required.
I = fitsread('solarspectra.fts');
I = mat2gray(I);
J = imrotate(I,-1,'bilinear','crop');
subplot(1,2,1), subimage(I),subplot(1,2,2), subimage(J)
Crop image
Syntax
I=imcrop
I2=imcrop(I)
X2=imcrop(X,map)
I=imcrop(h)
I2=imcrop(I,rect)
X2=imcrop(X,map,rect)
[...]=imcrop(x,y,...)
[I2rect]=imcrop(…)
[X,Y,I2,rect] = imcrop(…)
Description
I = imcrop creates an interactive Crop Image tool associated with the image displayed in the current figure, called the target image. The Crop Image tool is a moveable, resizable rectangle that you can position interactively using the mouse. When the Crop Image tool is active, the pointer changes to cross hairs when you move it over the target image. Using the mouse, you specify the crop rectangle by clicking and dragging the mouse. You can move or resize the crop rectangle using the mouse. When you are finished sizing and positioning the crop rectangle, create the cropped image by double-clicking the left mouse button or by choosing Crop Image from the context menu. imcrop returns the cropped image, I.
I2 = imcrop(I) displays the image I in a figure window and creates a cropping tool associated with that image. I can be a grayscale image, a truecolor image, or a logical array. The cropped image returned, I2, is of the same type as I.
X2 = imcrop(X, map) displays the indexed image X in a figure using the colormap map, and creates a cropping tool associated with that image.
I = imcrop(h) creates a cropping tool associated with the image specified by handle h. h may be an image, axes, uipanel, or figure handle. If h is an axes, uipanel, or figure handle, the cropping tool acts on the first image found in the container object.
Note With these interactive syntaxes, the cropping tool blocks the MATLAB command line until you complete the operation. |
I2 = imcrop(I, rect) crops the image I. rect is a four-element position vector[xmin ymin width height] that specifies the size and position of the crop rectangle.
X2 = imcrop(X, map, rect) crops the indexed image X. map specifies the colormap used with X. rect is a four-element position vector [xmin ymin width height] that specifies the size and position of the cropping rectangle.
[...] = imcrop(x, y,...) specifies a non-default spatial coordinate system for the target image. x and y are two-element vectors specifying XData and YData.
[I2 rect] = imcrop(…) returns the cropping rectangle in rect, a four-element position vector.
[X,Y,I2,rect] = imcrop(…) returns x and y, two-element vectors that specify the XData and YData of the target image.
Example
I = imread('circuit.tif');
I2 = imcrop(I,[75 68 130 112]);
subplot(1,2,1), subimage(I),subplot(1,2,2), subimage(I2)
No comments:
Post a Comment