CImage:ScaleLinVal
The ScaleLinVal method does a linear scaling by applying an offset and factor to each pixel value.
bSuccess = CImage:ScaleLinVal( offset, factor ) where |
offset is the zero point value.
factor is the multiplication factor.
bSuccess is the returned success code. On success it is true, otherwise false.
This method duplicates the combination of Addx and Mulx methods. However, especially for integer data types, it better preserves the data precision by not truncating or rounding the intermediate result.
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 ScaleLinVal operation.
The following script loads an image from files sPath, applies a linear luminance scaling, and displays the result. The applied scale coefficients are offset=400 and factor=1.552:
|
-- create a new CImage |
|
-- load the image |
|
-- if byte, short, or ushort |
|
-- convert I to 32 bit float type |
|
|
|
-- perform the operation on image I |
|
|