SelectData method (Main Control)

C++ Builder example

Delphi example

 

Builder Syntax

int SelectData(TBitmapHandle ScrBitmap, unsigned crVariance, unsigned uSrcLowBit, unsigned uSrcHighBit, unsigned uThreshold, bool bCombine);

Delphi Syntax

Function SelectData (ScrBitmap: TBitmapHandle; crVariance: COLORREF; uSrcLowBit: L_UINT; uSrcHighBit: L_UINT; uThreshold: L_UINT; bCombine: Boolean): L_INT;

Overview

Refer to Grayscale Images

Remarks

(Medical only) Selects a specified number of bits of an 8, 12 or 16-bit grayscale bitmap and puts them into a mask, then colors the bitmap depending on the mask. This can show bitmap variances depending on user-defined conditions.

This method is used as a visualization aid. You can select certain bits of the supported type bitmap and show the variances of that bitmap under conditions that you define.

When the method returns successfully the Bitmap property will be updated with a 24-bit RGB bitmap.

For 8, 12 and 16-bit grayscale bitmap, the uSrcLowBit can range from 0 to 7, 11, and 15 respectively. However if this value exceeds the range then the method will not return an error, and the Bitmap property will contain a pure black bitmap.

For 8, 12 and 16-bit grayscale bitmap, the uSrcHighBit can range from uSrcLowBit to 7, 11, and 15 respectively. No error will be returned if uSrcHighBit is greater than 7, 11 or 15. The method will return an invalid parameter error if uSrcHighBit < uSrcLowBit.

The method will first construct a mask from bits uSrcLowBit through uSrcHighBit. For each pixel, the pixel value will be combined with the mask using a bitwise ‘and’ operation. The result will be shifted to the right by uSrcLowBit. This result will be compared with the threshold: if the value is greater than or equal to the threshold, the output pixel’s color is changed using crVariance. If the result is less than the threshold, the output is set to 0.

The following example shows you how to treat a 16-bit grayscale bitmap:

In a16-bit grayscale bitmap, the bits are ordered as b15 b14 b13 ... b2 b1 b0.

For uSrcLowBit = 3, uSrcHighBit = 8, uThreshold = 16 and crVariance = RGB(0, 255, 0):

In Source bitmap (SrcBitmap)

------------------- 

b15 b14 b13 b12 b11 b10 b9 |b8 b7 b6 b5 b4 b3| b2 b1 b0

-------------------  

0 1 1 0 1 1 1 0 1 0 0 1 1 1 0 1 

In our case, the mask is 010011 in base 2 (19 in decimal). Since 19 >= 16, the destination pixel will be colored using crVariance. The output pixel will be:

if bCombine = FALSE: crVariance = RGB(0,255,0)

if bCombine = TRUE: we take the high byte of the source pixel, which is 01101110 in base 2 ($6E), and then the value is AND-ed with each component of the crVariance. So the output pixel will be RGB($00 & $6E, $FF & $6E, $00 & $6E) which is RGB($00, $6E, $00).

Let us consider another case: the source pixel is 0110111000011101 the mask value is 000011 in base 2(3 in decimal). Since 3 < 16, the destination pixel will be:

if bCombine = FALSE: RGB(0,0,0)

if bCombine = TRUE: The high byte of source pixel will bet set for the RGB, that is RGB($6E, $6E, $6E).

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, ColorizeGray method, SelectiveColor method.

Topics:

Raster Images: Doing Color Expansion or Reduction

 

Using Color Values in LEADTOOLS