CImage:ScaleLinVal CImage:SetDatatype

CImage:ScalePolyVal


The ScalePolyVal method applies a 1-D polynomial function of pixel value. The polynomial is independent of image coordinate.

Syntax

bResult = CImage:ScalePolyVal( CPolynomial )

Remarks

This method applies a polynomial function of pixel value, independent of position in the image. One application of this method is in applying a linearity correction.

When applying this method to byte, short, and ushort data types, one should be especially concerned about value overflow in which the resulting pixel value exceeds the capabilities of the Data Type, Mira handles value overflow by truncating the output pixel value at the limits for the data type. For example, applying this method to a short type image may result in pixel values outside the range [-32768, 32767]. Although Mira automatically truncates the result to this range, you may need to retain the values that fall outside the data type limits. To avoid the truncation, you may wish to call SetDatatype to promote the current image to a "larger" data type, such as long or float, before performing the ScalePolyVal operation.

Example

Assume that a CPolynomial P contains coefficients that correct non-linear signal response in the image. The following script fragment loads an image from files sPath, applies the linearity correction, and displays the result:

I = CImage:new()

-- create a new CImage

I:Open( sPath )

-- load the image

if ( I:GetDatatype() <= 3 ) then

-- if byte, short, or ushort

  I:SetDatatype("float")

-- convert I to 32 bit float type

end

 

I:ScalePolyVal( P )

-- perform the operation on image I

I:Display()

 

I:delete()

 

Related Topics

CImage, ScaleLinVal, PolyFitSub, PolyFitDiv