CImage:Crop CImage:Hflip

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 )

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:

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 fragment 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 = CRect:new()

-- create a rectangle

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

 

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

-- perform the operation on image I

Related Topics

CImage, CRect