CImage:Pow


The Pow method raises the image pixels to a power. The power is defined by an exponent which may be a specific value or may be the pixels of another image array of identical dimensions.

Syntax

bSuccess = CImage:Pow( nExponent )

bSuccess = CImage:Pow( CImage2 )

 

where

    nExponent is the power to raise the image pixels.

    CImage2 is a CImage in which each pixel acts as an exponent.

    bSuccess is the returned success code. On success it is true, otherwise false.

  

This method has a possibility of an illegal operation if a negative pixel value is raised to a non-integral power. 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.

Examples

Suppose an image is displayed in a CImageView named V. The following script raises the pixel values to the 1/4 power and redisplays the result:

I = V:GetImage()

-- attach the current displayed image

I:Pow( 0.25 )

-- perform the operation

V:Update()

-- update the display after the shift

The following script selects two images from the same CImageView window. It then raises each pixel of the first image I to an exponent defined by each pixel of a second image E. Assume that I is the image currently displayed.

I = V:GetImage()

-- attach the current image (which is image set member 1)

E = V:GetImage(2)

-- attach the second image from image set member 2

I:Pow( E )

-- perform the operation

V:Update()

-- update the display after the shift

The following script does the same thing using math operators from the CImage class:

I = V:GetImage()

-- attach the current image (which is image set member 1)

E = V:GetImage(2)

-- attach the second image from image set member 2

I = I ^ E

-- perform the operation

V:Update()

-- update the display after the shift

The previous example could be made more compact, like this:

V:GetImage():Pow( V:GetImage(2) )

-- do everything

V:Update()

-- update the display after the shift

Related Topics

Powa

Sqrt

CImage class