CImage:Mod
The Mod method computes the remainder (or modulus) resulting from dividing the image by another image or by a numeric value. The result replaces the current image.
bSuccess = CImage:Mod( CImage2 )
bSuccess = CImage:Mod( value )
where
CImage2 is another CImage object.
value is a number or a string than can be converted to a number.
bSuccess is the returned success code. On success it is true, otherwise false.
This method has a possibility of an illegal divide by 0 operation when the pixel of the operand 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.
The following script loads two images from files sPath1 and sPath2 and calculates the modulus (remainder) of the first image divided by the second image:
|
-- sets the output pixel to 1 upon divide by 0 error. |
|
-- create a new CImage |
|
-- create a new CImage |
|
-- load the first image from a file named sPath1 |
|
-- load the second image from a file named sPath2 |
|
-- calculate the modulus of I / I2 |
The same result can be accomplished using the % math operator:
|
-- create a new CImage |
|
-- create a new CImage |
|
-- load the first image from a file named sPath1 |
|
-- load the second image from a file named sPath2 |
|
-- calculate the modulus of I / I2 |
The following script reads an image from a file and multiplies every pixel by 10.25:
|
-- create a new CImage |
|
-- load the image from a file named sPath |
|
-- calculate the modulus of I / 10 |