CImage:Expand


The Expand method enlarges the background "canvas"around the image. The border is assigned a value and Gaussian random noise may be optionally added. The result replaces the current image.

Syntax

bResult = CImage:Expand( CRect, value, noise=0 )

bullet.gif    CRect describes the new image size and placement. See Remarks.

bullet.gif    value is the pixel value of the new background, and may be a number or string.

bullet.gif    noise is the optional noise sigma, and may be a number or string.

bullet.gif    On success, this method returns true.

bullet.gif    On failure, this method returns false.

Remarks

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:

bullet.gif    Let xmax = new column dimension, in pixels.

bullet.gif    Let ymax = new row dimension, in pixels.

bullet.gif    Let xmin = column (x) position in the expanded image.

bullet.gif    Let ymin = row (y) position in the expanded image.

bullet.gif    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 = new_rect()

-- create a rectangle

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

 

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

-- perform the operation on image I

Related Topics

CImage class, CRect class


Mira Pro x64 Script User's Guide, Copyright Ⓒ 2024 Mirametrics, Inc. All Rights Reserved.