FUNCTION REFERENCE
imrotate
Rotate an image.
Rotate an image.
Syntax
J = imrotate(I, angle)Syntax
J = imrotate(I, angle, method, bbox)Rotates counterclockwise by angle degrees about the image centre ((width+1)/2, (height+1)/2). Methods: 'nearest' (default) and 'bilinear'. bbox 'loose' (default) makes the output large enough for the whole rotated image: ceil(w|cos| + h|sin|) columns by ceil(w|sin| + h|cos|) rows; 'crop' keeps the input size. Points outside the input read 0 (bilinear blends with 0 at the border). Exact multiples of 90 degrees use rot90, without interpolation; with 'crop' the turned image is then cut or padded with 0 to the input size, centred (an odd difference cuts the extra row or column from the bottom or right, or pads it at the top or left). The class is kept (logical results are true above 0.5). Works on 2-D and M-by-N-by-C arrays.
Example
imrotate([1 2; 3 4], 90) % [2 4; 1 3]Example
size(imrotate(ones(6, 8), 30)) % [10 10]Example
imrotate(magic(4), 30, 'bilinear', 'crop')Example
imrotate(reshape(1:12, 3, 4), 90, 'crop') % [0 10 11 12; 0 7 8 9; 0 4 5 6]Differences from MATLAB: 'bicubic', the 'FillValues' option and categorical images are not supported yet. MATLAB does not publish its 'loose' output size; MatRust's formula above may give a different size for some angles. MATLAB does not publish the half-pixel placement of a quarter turn with 'crop' on a non-square image either; the rule above is MatRust's (GNU Octave's image package resamples instead, which mixes rows).
These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.