CImage:Sqrt CImage:Subx

CImage:Sub


The Sub method subtracts another image from the current one. The result replaces the current image.

Syntax

bResult = CImage:Sub( CImage )

    The CImage argument refers to another CImage.

    On success, this method returns true.

    On failure, this method returns false.

Remarks

For the byte, short, and ushort data types, Mira handles value overflow by truncating the output pixel value at the limits for the data type. For example, subtracting two short images may result in pixel values as low as -65536 but Mira truncates the result at -32768. If there is a chance of overflow and you want to accommodate the values, use SetDatatype to change to a "larger" datatype before calling Sub.

Example

The following script fragment loads two images from files sPath1 and sPath2, Adds them, and saves the result of the first image back to its file:

 

I = CImage:new()

-- create a new CImage

I2 = CImage:new()

-- create a new CImage

I:Open(sPath1)

-- load the first image from a file named sPath1

I2:Open(sPath2)

-- load the second image from a file named sPath2

I:Sub( I2 )

-- perform the operation on image I

I:Save()

 

I:delete()

 

I2:delete()

 

Related Topics

CImage