You are here : matlabImage Processingimrotate

imrotate() - Image Processing

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).exampleB = imrotate(A,angle,method) rotates
image A, using the interpolation method specified
by method.exampleB = 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.examplegpuarrayB = imrotate(gpuarrayA,method) perform
operation on a graphics processing unit (GPU), where gpuarrayA is
a gpuArray object that contains a grayscale or
binary image, and the output image is a gpuArray object.
This syntax requires the Parallel Computing Toolbox™.Code Generation support:
Yes.MATLAB Function Block support:
Yes


Syntax

B = imrotate(A,angle) exampleB = imrotate(A,angle,method) exampleB = imrotate(A,angle,method,bbox) examplegpuarrayB = imrotate(gpuarrayA,method) example


Example

Rotate Image Clockwise for Better Horizontal AlignmentOpen This Example
Read image into the workspace.I = fitsread('solarspectra.fts');
Convert to grayscale.I = mat2gray(I);
Rotate the image 1 degree clockwise to bring it into better horizontal alignment. The example specified bilinear interpolation and requests that the result be cropped to be the same size as the original image.J = imrotate(I,-1,'bilinear','crop');
Display the original image and the rotated image.figure
imshow(I)
title('Original Image')
figure
imshow(J)
title('Rotated Image')


Rotate Image on GPURead image into a gpuArray object. X = gpuArray(imread('pout.tif'));
Rotate the image, performing the operation on the graphics
processing unit (GPU).Y = imrotate(X, 37, 'loose', 'bilinear');
Display the rotated image.figure; imshow(Y)


Output / Return Value


Limitations


Alternatives / See Also


Reference