2.6.5.5 imgRotate

Menu Information

Rotate

Brief Information

Rotate image by specified angle

Command Line Usage

1. imgRotate angle:=45 interpolate:=resample resize:=1 fill:=0; 
2. imgRotate angle:=30 resize:=0 img:=[Mbook1]Msheet1!Mat(1) oimg:=<new>;

X-Function Execution Options

Please refer to the page for additional option switches when accessing the x-function from script

Variables

Display
Name
Variable
Name
I/O
and
Type
Default
Value
Description
Angle angle

Input

double

0

Specifies the degree, by which the image is rotated. Valid range is from -180 to 180. A positive value will cause the image to be rotated clockwise, while a negative value will cause the image to be rotated counterclockwise.

Input Matrix img

Input

Image

<active>

Specifies the image to be manipulated. The default input is the active image.

Output Image oimg

Output

Image

<input>

Specifies the image to be manipulated. The default input is the active image. See the syntax here.

Interpolate interpolate

Input

int

none

Specifies whether to perform interpolation during rotation. If interpolation is to be performed, user can further specify to use either bilinear or bicubic interpolation.

Option list

  • none :None
Rotate the image without data interpolation.
  • resample:Resample
Perform rotation with a bilinear interpolation.
  • bicubic:Bicubic
Perform rotation with a bicubic interpolation.
Resize resize

Input

int

0

Specifies whether to resize the rotated image to fit the output image. If the image is not resized, it might be cropped and only part of it can be seen.

Fill Color fill

Input

int

0

Specifies a color from the Origin color list to be used to fill the background of the output image.

Description

This function allows user to rotate an image by a chosen degree. The rotation center is the center of the image. After rotation, the rotated image is either resized or cropped to fit the size of the output image.

Degradation might occur when the image is rotated. However, you can compensate it with interpolation. Two interpolation methods are available. They are bilinear interpolation and bicubic interpolation. In general, bilinear interpolation tends to produce a smooth image while bicubic interpolation is apt to result in sharp image.

ImgRotate help English files image002.jpg
ImgRotate help English files image004.jpg
ImgRotate help English files image006.jpg
ImgRotate help English files image008.jpg
Original image
Rotated image without
interpolation
Rotated image with
bilinear interpolation
Rotated image with
bicubic interpolation


Rotated images usually have empty areas near each corner. User can choose a color to fill these areas.

Examples

  • Code Sample
// Rotate image and trim empty areas
//Create a new folder in the Project Explorer
pe_mkdir RotateTrim path:=aa$;
pe_cd aa$;
//Create a matrix and import an image into it
window -t m;
fname$ = System.path.program$ +"samples\Image Processing and Analysis\rice.bmp";
impimage;
window -r %h Original;
matrix -pg DIM nCol1 nRow1;	 //Get the dimension of the original iamge
window -d;	//Duplicate the image
window -r %h Modified;

imgRotate angle:=42;
imgTrim t:=17;

matrix -pg DIM nCol2 nRow2; //Get the dimension of the modified iamge
window -s T;	//Tile the windows horizontally
//Report
window -n n Report;
old = type.redirection;
type.redirection = 2;
type.notes$=Report;
type "Dimension of the original image: ";
type "   $(nCol1) * $(nRow1)\r\n";
type "Dimension of the modified image: ";
type "   $(nCol2) * $(nRow2)\r\n";
type.redirection = old;

Algorithm

The computation uses L_RotateBitmap() function from LEADTOOLS Main API. Please refer to the LEADTOOLS Main API Help file, Version 14 and read the L_RotateBitmap topic.

References

LEADTOOLS Main API Help file, Version 14

Related X-Functions

imgCrop, imgResize, imgTrim, imgFlip