ColorizeGray method (Main Control)

C++ Builder example

Delphi example

 

Builder Syntax

int ColorizeGray(TBitmapHandle SrcBitmap, LPGRAYCOLOR pGrayColors, unsigned uGrayColorsCount);

Delphi Syntax

Function ColorizeGray (SrcBitmap: TBitmapHandle; pGrayColors: LPGRAYCOLOR; uGrayColorsCount: L_UINT): L_INT;

Overview

Refer to Grayscale Images

Remarks

(Raster Pro and above toolkits.) Colors an 8, 12 or 16-bit grayscale bitmap. The method changes the color bits/pixel of the bitmap from the specified formats into 24-bit RGB format.

The method can be used as a visualization aid. More precisely, this method can be used to show variations in a bitmap’s intensity values.

This method colors the grayscale bitmap by converting specified ranges of grayscale intensities into corresponding RGB values. Use the pGrayColors variable to set the intensity ranges and the RGB values.

Using this method you can show details that were never seen in the original bitmap. In 12 and 16-bit grayscale bitmaps, only the 8 most significant bits are displayed, whereas the rest are discarded. So by coloring these discarded bits you can make them visible instead.

The method will allocate and store a 24-bit bitmap. If you pass Nil (NULL) in the pGrayColors variable then the method colors the bitmap automatically using an algorithm that generates unique output colors. The output bitmap will contain 256 colors if the input bitmap is 8-bit, 4096 colors if the input bitmap is 12-bit and 65535 colors if the input bitmap is 16-bit. The uGrayColorsCount variable will be ignored if pGrayColors is Nil (NULL).

The sample below shows you how to color a 16-bit grayscale bitmap using pGrayColors.

In a 16-bit grayscale bitmap, the lowest pixel value is 0 and the highest pixel value is 65535.

The colors from the input images will be colored as follows:

Pixel intensities from 0 - 9999 will be colored as Red.

Pixel intensities from 10000 - 19999 will be colored as Green.

Pixel intensities from 20000 - 29999 will be colored as Blue.

Pixel intensities from 30000 - 39999 will be colored as Cyan.

Pixel intensities from 40000 - 49999 will be colored as Magenta.

Pixel intensities from 50000 - 65535 will be colored as Yellow. (Note: the Threshold value is ignored for the last entry in the pGrayColors array.)

For more information on filling the pGrayColors array to obtain this result, refer to the example.

This method supports 8, 12 and 16-bit grayscale bitmaps only. Support for 12 and 16-bit grayscale images are available only in the Document/Medical toolkits. It also can process the whole image or a region of the image. If a bitmap has a region, the effect is applied only to the region.

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:

WindowLevel method, GrayScaleToDuotone method, GrayScaleToMultitone method, ShiftData method, SelectData method.

Topics:

Raster Images: Doing Color Expansion or Reduction