ConvertToColoredGray method (ILEADRasterProcess)

Visual Basic example

Visual C++ 5.0 example

 

Syntax

short ConvertToColoredGray(ILEADRaster *pRaster, short iRedFact, short iGreenFact, short iBlueFact, short iRedGrayFact, short iGreenGrayFact, short iBlueGrayFact);

Overview

Refer to Examining and Altering Bitmaps.

Remarks

(Document only) Converts a bitmap to a grayscale bitmap, then enhances the color components based on the specified parameters.

This method is more general than the GrayscaleExt method. ConvertToColoredGray can be used to give images an "sepia" look by adding a blue or brown color.

iRedFact + iGreenFact + iBlueFact must equal 1000. (Internally the values are divided by 1000).

For each pixel in the bitmap the red, green and blue values are modified by the iRedFact, iGreenFact and iBlueFact parameters, respectively. This allows the user to give more weight to one color, essentially enhancing that color, before the pixel is converted to grayscale.

For example, if this method is called with the iRedFact set to 500, the iGreenFact set to 250 and the iBlueFact set to 250, the red value of each pixel will get 50% of the weight when determining the grayscale value. The green value will get 25% of the weight and the blue value will get 25% of the weight when determining the grayscale value. This highlights or enhances the red in the bitmap, prior to conversion to grayscale. Upon conversion to grayscale, the red, green and blue components of the output pixel are the same. Call this value G. Therefore, the RGB values for the pixel would be (G, G, G).

Once the grayscale value for the pixel has been obtained, the red component of the output pixel can be further modified using the iRedGrayFact value. The equation for this can be seen below:

Goutput-red = G + G * iRedGrayFact / 1000

The green and blue components are found similarly, using the iGreenGrayFact and the iBlueGrayFact values, respectively.

Please note that the iRedGrayFact, iGreenGrayFact and iBlueGrayFact values can be negative. A negative value results in a decrease in pixel intensity. A positive value results in an increase in pixel intensity.

If iRedGrayFact = iGreenGrayFact = iBlueGrayFact = 0, then the output is the same as the output from the GrayScaleBitmapExt method.

This method supports 12 and 16-bit grayscale images and 48 and 64-bit color images. Support for 12 and 16-bit grayscale images and 48 and 64-bit color images is available only in the Document/Medical toolkits.

This method does not support signed data images. It returns the error code ERROR_SIGNED_DATA_NOT_SUPPORTED if a signed data image is passed to this method.

See Also

Elements:

BalanceColors method, GrayScale method, GrayscaleExt method, IsGrayscale property

Topics:

Raster Images: Doing Color Expansion or Reduction