imrotate
result = imrotate(img, angle_degrees, [method="bilinear"], [bbox="loose"])
Input: img, angle_degrees, method, bbox · Output: result
What it is
Rotates an image about its own center. img is an Image; angle_degrees is a number, the rotation angle about the image center — positive = counterclockwise (MATLAB's convention). method is an optional named string, "nearest" or "bilinear" (default), controlling resampling. bbox is an optional named string: "loose" (default) expands the canvas to fit the rotated content; "crop" keeps the original width/height, clipping content that rotates outside the frame.
Overloads
One call shape — this function is not overloaded.
| Code | Input | Output | Description |
result = imrotate(img, angle_degrees, [method="bilinear"], [bbox="loose"]) | img Imageimg is an Image.angle_degrees numberangle_degrees is a number, the rotation angle about the image center — positive = counterclockwise (MATLAB's convention).method string, optional (default "bilinear")method is an optional named string, "nearest" or "bilinear" (default), controlling resampling.bbox string, optional (default "loose")bbox is an optional named string: "loose" (default) expands the canvas to fit the rotated content. | result Image | Returns a new Image. |
Examples
From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.
img = load_image("sample.bmp")
rotated = imrotate(img, 45, method="bilinear", bbox="loose")
imshow(rotated)
from images
How it works
imrotate(img, angle_degrees, [method="bilinear"], [bbox="loose"|"crop"]) — arbitrary-angle rotation about the image center. angle_degrees is positive = counterclockwise (MATLAB's own imrotate convention). bbox="loose" (the default, and MATLAB's own actual default) expands the output canvas to fit the full rotated content; "crop" keeps the input's own width/height, cropping whatever rotates outside the frame. See image::Image::rotate's doc comment for the sign-convention derivation and the bilinear-blend reuse.
From the note above this builtin in the interpreter, where the reasoning was written down as it was built.