CImage:Div


The Div method divides this image by another image. The result replaces the current image.

Syntax

bResult = CImage:Div( CImage )

bullet.gif    TheCImage argument refers to another CImage.

bullet.gif    On success, this method returns true.

bullet.gif    On failure, this method returns false.

Remarks

This method has a possibility of an illegal divide by 0 operation when the pixel of the other image has a value of 0. Mira traps this condition and substitutes a replacement value into the output pixel. The replacement value is set for math operations using the SetMathErrVal method.

Example

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

SetMathErrVal( 1 )

-- output pixel set to 1 upon divide by 0 error

I = new_image()

-- create a new CImage

I:Open(sPath1)

-- load the image from the file sPath1

I2 = new_image()

-- create a new CImage

I2:Open(sPath2)

-- load the second image from the file sPath2

I:SetPixelType("float")

-- change pixel type for a more significant result

I:Div( I2 )

-- perform the operation on image I

I:Save()

-- save the image

I:delete()

-- remove I from memory

I2:delete()

-- remove I2 from memory

Related Topics

CImage class


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