This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

Rotate an Image

To rotate an image, use the imrotate function. When you rotate an image, you specify the image to be rotated and the rotation angle, in degrees. If you specify a positive rotation angle, imrotate rotates the image counterclockwise; if you specify a negative rotation angle, imrotate rotates the image clockwise.

By default, imrotate creates an output image large enough to include the entire original image. Pixels that fall outside the boundaries of the original image are set to 0 and appear as a black background in the output image. You can, however, specify that the output image be the same size as the input image, using the 'crop' argument. Similarly, imrotate uses nearest-neighbor interpolation by default to determine the value of pixels in the output image, but you can specify other interpolation methods. See the imrotate reference page for a list of supported interpolation methods.

This example rotates an image 35° counterclockwise and specifies bilinear interpolation.

I = imread('circuit.tif');
J = imrotate(I,35,'bilinear');
figure, imshow(J)

Was this topic helpful?