ROT Function
Standard Library function that rotates and magnifies (or demagnifies) a two-dimensional array.
Usage
result = ROT(image, ang[, mag, xctr, yctr])
Input Parameters
image—The input image to be manipulated. Can be of any data type except string. Must be two-dimensional.
ang—The angle of rotation in degrees clockwise.
mag—(optional) The magnification or demagnification factor (see Discussion).
xctr—(optional) The x subscript of the center of rotation. If omitted, xctr is equal to the number of columns in image divided by 2.
yctr(optional) The y subscript of the center of rotation. If omitted, yctr is equal to the number of rows in image divided by 2.
Returned Value
result—A rotated and magnified (or demagnified) image. The dimensions are the same as those for the input image.
Keywords
Interp—If present and nonzero, specifies that bilinear interpolation is to be used. Otherwise, the nearest neighbor interpolation method is used.
Missing—Data value to substitute for pixels in the output image that map outside the input image.
Discussion
ROT uses the POLY_2D function to rotate and scale the input image.
The magnification factor can be of integer or floating-point data type. It is specified as follows (with 1 being the default value):
*mag = 1—no change
*mag > 1—causes magnification
*mag < 1—causes demagnification
For example, if mag is set to 0.5, this would result in an image half the size of the original image, and if mag is set to 3, this would result in an image three times the size of the original.
 
note
If you only need to rotate an image by 90-degree increments, the ROTATE function is more efficient to use.
If you need a more accurate bilinear interpolation method, use the ROT_INT function.
Example
This example uses ROT to both rotate and demagnify an image. The image is rotated 135 degrees clockwise, while the demagnification factor is 0.63. Also, pixels that map outside the original image are assigned a value of 0. The results is shown in Figure 15-3: Original Image (left) and the Rotated and Magnified Image (right).
; Open the file containing the image.
OPENR, unit, !Data_dir + 'x2y2.dat', /Get_Lun
; Create an array large enough to hold the image.
image = BYTARR(320, 256)
; Read the image.
READU, unit, image
; Close the file and free the file unit number.
FREE_LUN, unit
; Create a window large enough to contain two 320-by-256 images.
WINDOW, 0, Xsize=640, Ysize=256
; Display the original image in the left-half of the window.
TV, image, 0
; Rotate the image 135 degrees clockwise, and demagnify it by a 
; factor of 0.63. Also, pixels that map outside the original image 
; are assigned a value of 0.
a = ROT(image, 135, 0.63, Missing=0)
; Display rotated, demagnified image in right-half of the window.
TV, a, 1
 
Figure 15-3: Original Image (left) and the Rotated and Magnified Image (right)
See Also
For information on interpolation methods, see the PV‑WAVE User’s Guide.