Rotate
Rotate image by specified angle
1. imgRotate angle:=45 interpolate:=resample resize:=1 fill:=0; 2. imgRotate angle:=30 resize:=0 img:=[Mbook1]Msheet1!Mat(1) oimg:=<new>;
Please refer to the page for additional option switches when accessing the x-function from script
Display Name |
Variable Name |
I/O and Type |
Default Value |
Description |
---|---|---|---|---|
Angle | angle |
Input double |
|
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 |
|
Specifies the image to be manipulated. The default input is the active image. |
Output Image | oimg |
Output Image |
|
Specifies the image to be manipulated. The default input is the active image. See the syntax here. |
Interpolate | interpolate |
Input int |
|
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
|
Resize | resize |
Input int |
|
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 |
|
Specifies a color from the Origin color list to be used to fill the background of the output image. |
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.
![]() |
![]() |
![]() |
![]() |
|
|
|
|
Rotated images usually have empty areas near each corner. User can choose a color to fill these areas.
// 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;
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.
LEADTOOLS Main API Help file, Version 14