Rotation of a 2D matrix about its center.
Input parameters:
imgPre a gray-level image matrix
theta the rotation angle in degrees counterclockwise
method
- "nearest" neighbor: fast, but produces aliasing effects.
- "bilinear" interpolation: does anti-aliasing, but is slightly slower (default).
- "bicubic" interpolation: does anti-aliasing, preserves edges better than bilinear interpolation, but gray levels may slightly overshoot at sharp edges. This is probably the best method for most purposes, but also the slowest.
- "Fourier" uses Fourier interpolation, decomposing the rotation matrix into 3 shears. This method often results in different artifacts than homography-based methods. Instead of slightly blurry edges, this method can result in ringing artifacts (little waves near high-contrast edges). However, Fourier interpolation is better at maintaining the image information, so that unrotating will result in an image closer to the original than the other methods.
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
NA
for images represented using doubles, and 0 otherwise. 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)).
valid a binary matrix describing which pixels are valid, and which pixels are extrapolated. This output is not available if Fourier interpolation is used.