CImage:Offset


The Offset method offsets, or "shifts" the image by integral pixel amounts along one or more axes. By default, pixels that become blank are filled with value 0. Blank pixels also can be assigned a specific value and, optionally, random noise. To shift only along axis 1 or axis 2, also see the Offset1d and Offset2d methods.

Syntax

These formats apply a single offset along the specified axis:

bSuccess = CImage:Offset( nAxis, nOffset )

bSuccess = CImage:Offset( nAxis, nOffset, Value )

bSuccess = CImage:Offset( nAxis, nOffset, Value, Sigma )

These formats permit offsets to be made along multiple axes:

bSuccess = CImage:Offset( nAxis[], nOffset[] )

bSuccess = CImage:Offset( nAxis[], nOffset[], Value )

bSuccess = CImage:Offset( nAxis[], nOffset[], Value, Sigma )

where

    nAxis and nAxis[] specify one or more axes along which to offset.

    bOffset and nOffset[] specify the integral pixel offset along each of the specified axes.

    Value is the value assigned to blank pixels created by the offset. It defaults to 0.

    Sigma is the optional sigma value for noise assigned to blank pixels created by the offset. It defaults to 0.

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

  

If the image has a numeric data type, specify the Value and Sigma as a number, like 45.62. If the image has a color data type with 3 or 4 channels, specify the Value and Sigma as a string, like "15,22.4,75.112". The nOffset may be a positive or negative value. If you do not want to add noise to the blank region, omit it from the argument list. For example, nAxes=1 means the offset will be done along the column axis, thus moving the image values to different column numbers.

Example

The following script opens a 3-dimensional image from the file named sFileName and then applies a shift along each pf the 3 axes. Blank background pixels are set to value=1000 and noise sigma=8.25:

I = CImage:new()

-- create a new CImage object

I:Open( sFileName )

-- open the image from a file

Axis = { 1, 2, 3 }

-- tabe of axes to offset

Off = { -50, 200, 12 }

-- table of amounts to offset

I:Offset( Axis, Off, 1000, 8.25 )

-- shift the image

I:Save()

-- save back to the file

Related Topics

Offset1d

Offset2d

Expand

ExpandOffset

CImage class