LEADTOOLS Raster Imaging C++ Class Library Help > Classes and Member Functions > LBitmap > LBitmap Member Functions > LBitmap::LightControl |
#include "ltwrappr.h"
virtual L_INT LBitmap::LightControl (puLowerAvr, puAvrage, puUpperAvr,uFlags)
L_UINT * puLowerAvr; |
/* pointer to the new low average(s) array */ |
L_UINT * puAvrage; |
/* pointer to the new average(s) array */ |
L_UINT * puUpperAvr; |
/* pointer to the new high average(s) array */ |
L_UINT uFlags; |
/* flag */ |
Lightens or darkens all or part of a bitmap by remapping the pixel values. This function is also useful for pre-processing images for the purpose of improving barcode recognition results.
Parameter |
Description |
|
puLowerAvr |
Pointer to an array containing the new average pixel value for those pixels with values between 0 and the average pixel value for the entire bitmap. The size of the array equals one, if uFlags is YUV_SPACE or GRAY_SPACE, or three, if uFlags is RGB_SPACE. If uFlags is RGB_SPACE the first element corresponds to the new blue lower average value, the second element to the green, and the last element to the red. |
|
puAvrage |
Pointer to an array containing the new average pixel value for the entire bitmap. The size of the array equals one, if uFlags is YUV_SPACE or GRAY_SPACE, or three, if uFlags is RGB_SPACE. If uFlags is RGB_SPACE the first element corresponds to the new blue average value, the second element to the green, and the last element to the red. |
|
puUpperAvr |
Pointer to an array containing the new average pixel value for those pixels with values between the average pixel value for the entire bitmap and the highest pixel value in the bitmap. The size of the array equals either one if uFlags is YUV_SPACE or GRAY_SPACE or three if uFlags is RGB_SPACE where the first element corresponds to the new blue upper side average value, the second element to the green, and the last element to the red. |
|
uFlags |
Flag that indicates which color space to remap. Possible values are: |
|
|
Value |
Meaning |
|
RGB_SPACE |
[0x0001] Use the histogram of RGB color space. (separated channels) |
|
YUV_SPACE |
[0x0002] Use the histogram of YUV color space.(Best results) |
|
GRAY_SPACE |
[0x0004] Use the histogram of a gray level representation of the image. |
Returns
SUCCESS |
The function was successful. |
< 1 |
An error occurred. Refer to Return Codes. |
Comments
This function remaps the pixel values of the bitmap across the full range of available pixel values, in order to achieve the values passed in puLowerAvr, puAvrage and puUpperAvr.
For example, call this function for a grayscale bitmap, with puAvrage containing 150, puLowerAvr containing 100 and puUpperAvr containing 190. The pixels of the bitmap will be remapped so that the new average pixel value for the entire bitmap will be 150, the new average value for those pixels with a value between 0 and the average value for the entire bitmap will be 100, and the new average value for those pixels with a value between the average value for the entire bitmap and the maximum pixel value in the bitmap will be 190.
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.
To update a status bar or detect a user interrupt during execution of this function, refer to LBase::EnableStatusCallback.
To obtain this effect, the following settings were used with the function:
uLowerAvr = 100
uAverage = 255
uUpperAvr = 255
uFlags = YUV_SPACE
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. |
Win32, x64.
See Also
Example
The following example applies light control function.
L_INT LBitmap__LightControlExample(LAnimationWindow *BitmapWindow) { L_UINT puLowerAvr[3]; L_UINT puAverage[3]; L_UINT puUpperAvr[3]; puLowerAvr[0] = 100;/*for blue, gray or yuv*/ puLowerAvr[1] = 120;/*for green*/ puLowerAvr[2] = 80;/*for red*/ puAverage[0] = 150;/*for blue, gray or yuy*/ puAverage[1] = 140;/*for green*/ puAverage[2] = 128;/*for red*/ puUpperAvr[0] = 190;/*for blue, gray or yuv*/ puUpperAvr[1] = 200;/*for green*/ puUpperAvr[2] = 220;/*for red*/ return BitmapWindow->LightControl(puLowerAvr, puAverage, puUpperAvr, YUV_SPACE); }