CImage:Expand1d


The Expand1d method enlarges a 1-dimensional image along axis 1, to increase the number of image columns. The image also can be offset as part of the expansion. By default, new pixels are filled with value 0. You also can specify a fill value and a noise value for the new pixels. To expand a 2-d or n-dimensional image, use Expand2d or Expand respectively.

Syntax

bSuccess = CImage:Expand1d( nLength )

bSuccess = CImage:Expand1d( nLength, nOffset )

bSuccess = CImage:Expand1d( nLength, nOffset, sValue )

bSuccess = CImage:Expand1d( nLength, nOffset, sValue, sSigma )

where

    nLength is the new number of elements (pixels).

    nOffset is the number of elements (pixels) to offset the existing data. If not specified, no offset is applied.

    sValue is the noise sigma used for blank pixels created by the expansion or offset.

    sSigma is the optional noise sigma for blank pixels created by the expansion or offset.

    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 = column (x) position in the expanded image.

    Let ymin = row (y) position 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

Expand

Expand2d

Offset1d

CImage class

CRect class