CImage:Mul
The Mul method multiplies this image by another image or a numeric value. The result replaces the current image.
bSuccess = CImage:Mul( CImage2 )
bSuccess = CImage:Mul( value )
where
CImage2 is another CImage.
value is a number or a string that can be converted to a numeric value.
bSuccess is the returned success code. On success it is true, otherwise false.
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, multiplying two short images may result in a pixel values above 1 billion and below -1 billion, but limits the result to the range [-32768, 32767]. To avoid this problem, you may wish to call SetDatatype to promote the current image to a "larger" data type such as long or float before performing the Mul operation. The fact that the two images may differ in data type is not a problem.
The following script loads two images from files sPath1 andsPath2 and multiplies them. In this example, assume that image 2 has a "short" integer data type so that overflow might occur if the current image has a data type of "byte", "short", or "ushort" type. This script avoids that problem:
|
-- create a new CImage |
|
-- create a new CImage |
|
-- load the first image |
|
-- load the second image |
|
-- if byte, short, or ushort |
|
-- convert I to long integer type |
|
|
|
-- Multiply I by 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 |
|
-- Multiply I by 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 |
|
-- Multiply all pixels of I by 10.25 |