CImage:ExpandOffset


The Expand method enlarges the background of the image, filling the new elements with value 0. Tp set the expanded region to a specific value or to add noise, use the Expand1d or Expand2d method.

Syntax

bSuccess = CImage:Expand( CRect )

bSuccess = CImage:Expand( nLengthX )

bSuccess = CImage:Expand( nLengthX, nLengthY )

bSuccess = CImage:Expand( nAxis, nLength, nOffset )

bSuccess = CImage:Expand( nAxis[], nLength[], nOffset[] )

where

    CRect describes the new image size and placement.

    nMin, nMax are the pixel coordinates of the value of the new background, and may be a number or string.

    noise is the optional noise sigma, and may be a number or string.bSuccess is the returned success code. On success it is true, otherwise false.

  

This method creates a new, larger image that extends the borders with a value and optional random noise. The scale of the image is not changed, but the existing image is imbedded into a larger canvas. The new size and the position of the current image are encoded in the members of a CRect as follows:

    Let xmax = new column dimension, in pixels.

    Let ymax = new row dimension, in pixels.

    Let xmin = X (column) offset in the expanded image.

    Let ymin = Y (row) offset in the expanded image.

    Use CRect:Set( xmin, xmax, ymin, ymax ) or an equivalent method to initialize the CRect.

If you do not want to add random noise to the border region, set noise=0 or omit the value from the argument list.

Example

Suppose that a CImage I exists. The following script doubles its width and height and centers the current image in the new image. The new background value is 1000 and the noise sigma is 8.25:

nCols = I:Cols() * 2

-- new width in pixels

nRows = I:Rows() * 2

-- new height in pixels

cOff = I:Cols() / 4

-- new edge at 1/4 of column dimension

rOff = I:Rows() / 4

-- new edge at 1/4 of row dimension

R = NewRect()

-- create a rectangle

R:Set(cOff,nCols,rOff,nRows)

 

I:Expand( R, "100", 8.25 )

-- perform the operation on image I

Related Topics

Expand1d

Expand2d

ExpandOffset

Offset

CImage class

CRect class