Function File: imrotate (imgPre, theta, method, bbox, extrapval)

Rotate image about its center.

Input parameters:

imgPre a gray-level image matrix

theta the rotation angle in degrees counterclockwise

The optional argument method defines the interpolation method to be used. All methods supported by interp2 can be used, except "spline", which is not supported by imrotate in current versions of core Octave.

In addition, Fourier interpolation by decomposing the rotation matrix into 3 shears can be used with the fourier method. By default, the nearest method is used.

For MATLAB compatibility, the methods bicubic (same as cubic), bilinear and triangle (both the same as linear) are also supported.

bbox

  • "loose" grows the image to accommodate the rotated image (default).
  • "crop" rotates the image about its center, clipping any part of the image that is moved outside its boundaries.

extrapval sets the value used for extrapolation. The default value is 0. This argument is ignored of Fourier interpolation is used.

Output parameters:

imgPost the rotated image matrix

H the homography mapping original to rotated pixel coordinates. To map a coordinate vector c = [x;y] to its rotated location, compute round((H * [c; 1])(1:2)).

Package: image