CImage:Mul
The Mul method multiplies this image by another image. The result replaces the current image.
bResult = CImage:Mul( CImage )
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 2 images may differ in data type is not a problem.
The following script fragment loads two images from files sPath1 andsPath2 , multiplies them, and saves the result of the first image back to its file. In addition, assume that image 2 has a short data type so that overflow can occur if the current image has a data type of byte, short, or ushort type. This code 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 |
|
|
|
-- perform the operation on image I |
|
|
|
|
|
|