CImage:Mul


The Mul method multiplies this image by another image. The result replaces the current image.

Syntax

bResult = CImage:Mul( 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

For the byte, short, and ushort Pixel Types, Mira handles value overflow by truncating the output pixel value at the limits for the pixel 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 SetPixelType to promote the current image to a "larger" pixel type such as long or float before performing the Mul operation. The fact that the 2 images may differ in pixel type is not a problem.

Example

The following script 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 pixel type so that overflow can occur if the current image has a pixel type of byte, short, or ushort type. This code avoids that problem:

I = new_image()

-- create a new CImage

I2 = new_image()

-- create a new CImage

I:Open(sPath1)

-- load the first image

I2:Open(sPath2)

-- load the second image

if I:GetPixelType() <= 3 then

-- if byte, short, or ushort

  I:SetPixelType("long")

-- convert I to long integer type

end

 

I:Mul( I2 )

-- perform the operation on image I

I:Save()

 

I:delete()

 

I2:delete()

 

Related Topics

CImage


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