LBitmap::WindowLevelBitmap

Summary

Converts a 12 or 16-bit grayscale image to an 8-bit grayscale or a 24-bit RGB bitmap.

Syntax

#include "ltwrappr.h"

virtual L_INT LBitmap::WindowLevelBitmap(nLowBit, nHighBit, pLUT, uLUTLength, nOrderDst, uFlags = 0)

Parameters

L_INT nLowBit

Value indicating the low bit used for leveling. 0 <= nLowBit <= nHighBit <= (11 for 12-bit grayscale or 15 for 16-bit grayscale).

L_INT nHighBit

Value indicating the high bit used for leveling. 0 <= nLowBit <= nHighBit <= (11 for 12-bit grayscale or 15 for 16-bit grayscale).

RGBQUAD * pLUT

Optional lookup table that can be used to implement a user defined conversion. For every intensity value between 0 and 2 raised to the power of (nHighBit - nLowBit + 1) - 1 there should be a corresponding entry in the lookup table that contains an RGB quad. If pLUT is NULL, the conversion is a normal shift (right or left) and the painted bitmap is 8-bit grayscale. If pLUT is not NULL, the painted bitmap is a 24-bit bitmap.

L_UINT uLUTLength

Value indicating the number of entries pointed to by pLUT.

L_INT nOrderDst

Value indicating the color order if the output bitmap will be 24-bit. If pLUT is NULL, this parameter is ignored. Possible values are:

Value Meaning
ORDER_RGB [0] The input colors are in red-green-blue order.
ORDER_BGR [1] The input colors are in blue-green-red order.

L_UINT32 uFlags

Reserved for future use. Must be 0.

Returns

Value Meaning
SUCCESS The function was successful.
< 1 An error occurred. Refer to Return Codes.

Comments

This function will convert the class object's bitmap to a window leveled bitmap. To implement window leveling without affecting the image, use LBitmap::WindowLevel.

The bitmap data is changed by this function.

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

This function supports signed data images.

LEADTOOLS supports two types of LUTs for 10-16-bit grayscale images (8-bit LUT and 16-bit LUT). Typical grayscale image display and processing is done using an 8-bit LUT. But, you can also use a 16-bit LUT, which offers more precision. Some special video cards and monitors also support display of grayscale images using a 16-bit LUT.

For information on saving bitmaps that have been window leveled, refer to Saving Window-Leveled Bitmaps.

Window Level Function - Before

Window Level Function - Before

Window Level Function - After

Window Level Function - After

View additional platform support for this Window Level function.

Required DLLs and Libraries

Platforms

Win32, x64.

See Also

Functions

Topics

Example

This example window levels the bitmap with a custom palette. The image data is changed in this example.

L_INT LBitmap__WindowLevelBitmapExample() 
{ 
   L_UINT32 x; 
   L_INT nLowBit; 
   L_INT nHighBit; 
   L_INT nLow; 
   L_INT nHigh; 
   L_UINT32 nSize; 
   RGBQUAD * ptmp; 
   RGBQUAD * pLUT; 
   LBitmap LeadBitmap; 
 
   /* Change the bitmap to 16-bit grayscale */ 
   LeadBitmap.GrayScale(16 ); 
 
   LeadBitmap.GetMinMaxBits(&nLowBit, &nHighBit); 
   LeadBitmap.GetMinMaxVal(&nLow, &nHigh); 
 
   nSize = (L_UINT32)(1L<<(nHighBit - nLowBit + 1)); 
   pLUT = (RGBQUAD *)GlobalAlloc(GHND, nSize * sizeof(RGBQUAD));     
 
   ptmp = pLUT; 
   /* fill the first half of the LUT with RED */ 
   for(x=0;x<nSize/2;x++) 
   { 
      ptmp->rgbRed       = 255; 
      ptmp->rgbGreen     = 0; 
      ptmp->rgbBlue      = 0; 
      ptmp->rgbReserved  = 0; 
      ptmp++; 
   } 
   /* fill the rest with gray values */ 
   for(x=nSize/2;x<nSize;x++) 
   { 
      ptmp->rgbRed       = ((L_UCHAR) ((L_UINT32) (x - nLow) * 255 / (nHigh - nLow))); 
      ptmp->rgbGreen     = ptmp->rgbRed; 
      ptmp->rgbBlue      = ptmp->rgbGreen; 
      ptmp->rgbReserved  = 0; 
      ptmp++; 
   } 
 
   LeadBitmap.WindowLevel(nLowBit, nHighBit, 
                        (RGBQUAD *)pLUT, nSize, ORDER_BGR); 
 
   GlobalFreePtr(pLUT); 
 
   return SUCCESS; 
} 

Help Version 22.0.2023.2.2
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C++ Class Library Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.