CImage:Offset2d
The Offset method offsets, or "shifts" the image by integral pixel amounts along the column and row 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 along axis 1, multiple, or higher dimensions, use the Offset1d or Offset method.
bSuccess = CImage:Offset2d( nOffsetX ) bSuccess = CImage:Offset2d( nOffsetX, nOffsetY ) bSuccess = CImage:Offset2d( nOffsetX, nOffsetY, Value ) bSuccess = CImage:Offset2d( nOffsetX, nOffsetY, Value, Sigma ) where |
nOffsetX and nOffsetY are the pixel shifts along axis 1 and axis 2. These are integer numbers and may be positive or negative.
Value is the noise sigma used for blank pixels created by the offset.
Sigma is the optional noise sigma for blank pixels created by the offset.
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.
The following script opens an image from the file named sFileName and shifts it +24 pixels along the column direction and -10 pixels along the row direction. Blank background pixels are set to value=1000 and noise sigma=8.25:
|
-- create a new CImage object |
|
-- open the image from a file |
|
-- shift the image |
|
-- save back to the file |