CImage:Affine


The Affine method applies an affine transformation of shift, scale, and rotation to the image.

Syntax

bSuccess = CImage:Affine( nX, nY, nAngle, nScale )

bSuccess = CImage:Affine( nX, nY, nAngle, nScale, bResize )

where

    nX and nY specify the shifts, in pixel units.

    nAngle is the rotation angle, in degrees.

    nScale is the magnification relative to 1.0.

    bResize controls whether the image is expanded in order to hold the scaled image. It defaults to true.

    bSuccess is the returned success code. On success it is true, otherwise false.

  

The affine transformation first shifts the image center, then applies the rotation and the scale factor. To evalute the image at fractional pixel positions, the image is resampled. The resampling is controlled by members of the ResampleParams table. You can either do nothing and use the default parameters or set specific parameters and then call SetResampleParams function.

Examples

The following script shifts the image 10 pixels in x and 20.52 in y, rotates -30.25 degrees, and scales by 1.2 times:

I = CImage:new()

-- create a new CImage

nX = 10 ; nY = 20.52

-- shifts

A = -30.25 ; M = 1.2

-- angle and magnification

I:Affine( nX, nY, A, M )

-- perform the operation on image I

The script below performs the same operation after setting the resampling parameters:

R = ResampleParams

-- Alias the structure name to reduce typing

R.bMedianEdge = false

-- force a specific value for blank edge pixels

R.sEdgeValue = “100”

-- set blank edge pixels to a value of 100

R.bConserveFlux = false

-- do not conserve flux

R.sFilter = “bilinear”

-- choose the bi-linear resampling method

SetResampleParams( R )

-- assign the parameters to the script

    --

-- other script processing

I = CImage:new()

-- create a CImage

I:Open( sFileName )

-- open the image from a file

nX = 10 ; nY = 20.52

-- shifts

A = -30.25 ; M = 1.2

-- angle and magnification

I:Affine( nX, nY, A, M )

-- perform the operation

Related Topics

Shift

Scale

Rotate

Image Geometry Methods

CImage class

SetResampleParams