LBitmap::AutoColorLevel
#include "ltwrappr.h"
virtual L_INT LBitmap::AutoColorLevel (pLvlClr, uBlackClip, uWhiteClip, uFlag);
pLVLCLR pLvlClr; |
/* pointer to a LVLCLR structure that specifies input level values for all channels */ |
L_UINT uBlackClip; |
/* percentage of the bitmaps black (Shadow) pixels to clip */ |
L_UINT uWhiteClip; |
/* percentage of the bitmaps white (Highlight) pixels to clip */ |
L_UINT uFlag; |
/* a flag that indicates the type of leveling to perform */ |
Applies one of several types of automatic color leveling to an image. This function is also useful for pre-processing images for the purpose of improving barcode recognition results.
Parameter |
Description |
|
pLvlClr |
Pointer to a LVLCLR structure that specifies the color leveling information used by the function. If AUTO_NOPROCESS is not set in uFlag, you can pass NULL if you are not interested in using these values. If AUTO_NOPROCESS is set in uFlag, then this parameter cannot be NULL. |
|
uBlackClip |
An unsigned integer that represents the percentage of black pixels to clip from the bitmap, in hundredths of a percent. Valid values range from 0 to 10000 (which represents 100%). Best results are found using 0.3 to 0.9 %. The default is DEFAULT_BLACK_CLIP, which indicates to clip 0.5% of the black pixels. |
|
uWhiteClip |
An unsigned integer that represents the percentage of pixels to clip from the bitmap, in hundredths of a percent. Valid values range from 0 to 10000 (which represents 100%). The default is DEFAULT_WHITE_CLIP, which indicates to clip 0.5% of the white pixels. |
|
uFlag |
A flag that indicates the type of leveling to perform. Possible values are: |
|
|
Value |
Meaning |
|
AUTO_LEVEL |
[0x0001] Perform leveling on the individual R, G and B channels, treating each of the R, G and B channels as a separate entity. It introduces color cast on the image. |
|
AUTO_CONTRAST |
[0x0002] Perform leveling on the MASTER channel (the grayscale values of the pixels). No color cast will be introduced. |
|
AUTO_INTENSITY |
[0x0003] Perform leveling on the RGB channel (the sum of the R, G, and B channels). No color cast will be introduced. |
|
AUTO_NOPROCESS |
[0x0004] Do not process the bitmap. Just update pLvlClr with the color leveling information used. The color leveling information used depends on which of the other flags was set with AUTO_NOPROCESS. Only one other flag may be set with AUTO_NOPROCESS. |
Returns
SUCCESS |
The function was successful. |
< 1 |
An error occurred. Refer to Return Codes. |
Comments
This function makes the dark values darker and the light values lighter, which automatically enhances shadows and brightens the image. It also maximizes the tonal range of the image. It enhances the contrast and intensity using the image's histogram and a color distribution-based algorithm.
Before you call LBitmap::AutoColorLevel, you need to initialize the size of the LVLCLR structure. The other fields in the structure will be updated with the nMinInput, nMaxInput, nMinOutput, nMaxOutput and uGamma values used by the function for the appropriate channel(s).
If you set the AUTO_NOPROCESS flag in uFlag, the pLvlClr parameter will be updated with the color leveling information used by the LBitmap::AutoColorLevel function. If you then pass the updated pLvlClr structure to the LBitmap::ColorLevel function, you will obtain the same result that you would have obtained if you had called the LBitmap::AutoColorLevel function with the leveling flag by itself.
If you set AUTO_NOPROCESS in uFlag and pass NULL to pLvlClr the function will return an error code.
If you pass only AUTO_NOPROCESS to uFlag then the function will return an error code.
If the image is a grayscale image, then AUTO_LEVEL, AUTO_CONTRAST and AUTO_INTENSITY give identical results. Also the member variables master, red, green and blue of the structure pLvlClr will have the same values.
This function supports 12 and 16-bit grayscale and 48 and 64-bit color images. Support for 12 and 16-bit grayscale and 48 and 64-bit color images is available only in the Document/Medical toolkits.
If the bitmap has a region, the effect will be applied on the region only.
This function 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 function.
This function does not support 32-bit grayscale images. It returns the error code ERROR_GRAY32_UNSUPPORTED if a 32-bit grayscale image is passed to this function.
Required DLLs and Libraries
LTIMGCLR For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application. |
See Also
Example
This example applies auto image leveling.
L_INT LBitmap__AutoColorLevelExample(LAnimationWindow * LAniWnd) { L_INT nRet; LVLCLR lc; /* Structure to hold the level values, used for display only */ L_TCHAR buffer[100]; /* Apply "Auto Leveling" to the bitmap */ lc.uStructSize = sizeof(LVLCLR); nRet =LAniWnd->AutoColorLevel (&lc, DEFAULT_BLACK_CLIP, DEFAULT_WHITE_CLIP, AUTO_LEVEL); if(nRet !=SUCCESS) return nRet; wsprintf (buffer, TEXT("Min and Max input values for the blue channel using auto level are %d and %d"), lc.blue.nMinInput, lc.blue.nMaxInput); return SUCCESS; }