OriginLab Corporation - Scientific Graphing and Data Analysis Software - 2D graphs, 3D graphs, Contour Plots, Statistical Charts, Data Exploration, Statistics, Curve Fitting, Signal Processing, and Peak Analysis

imgRotate

Contents

Menu Information

Rotate

Brief Information

Rotates an image by a specified degree

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>;

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.

Image:imgRotate_help_English_files_image002.jpg
Image:imgRotate_help_English_files_image004.jpg
Image:imgRotate_help_English_files_image006.jpg
Image: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

In this example, we use the imgRotate function to rotate the input image by 30 degree:

  1. When the image is active, select Image: Geometric Transform: Rotate to open the dialog of the X-Function.
  2. In the dialog, change the settings as the screenshot below and click OK to close the dialog.
    Image:imgRotate_help_English_files_image010.jpg
    A new image is created. It is the rotated image.
Image:imgRotate_help_English_files_image012.jpg
Image:imgRotate_help_English_files_image014.jpg
The original image
The output image


For more examples, please refer to XF Script Dialog (press F11).


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