L_ColorLevelBitmap

Summary

Applies color leveling to an image. It changes the image shadows, midtones and highlights.

Syntax

#include "l_bitmap.h"

L_LTIMGCLR_API L_INT L_ColorLevelBitmap(pBitmap, pLvlClr, uFlags)

Parameters

pBITMAPHANDLE pBitmap

Pointer to the bitmap handle.

pLVLCLR pLvlClr

Pointer to a LVLCLR structure that contains several LVLCLRINF structures, which in turn contain information about the shadows, midtones and highlights for the Red, Green, Blue and Master channels.

L_UINT uFlags

Flag that indicates the channel being leveled. Possible values are:

Value Meaning
LEVEL_RED [0x0001] Red channel
LEVEL_GREEN [0x0010] Green channel
LEVEL_BLUE [0x0100] Blue channel
LEVEL_MASTER [0x1000] All channels

Returns

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

Comments

This function is useful for pre-processing images for the purpose of improving barcode recognition results.

Before calling the L_ColorLevelBitmap function, initialize the size and all remaining fields of the LVLCLRINF structures within the LVLCLR structure. These fields tell L_ColorLevelBitmap what constitutes shadows, midtones, and highlights and how to remap the shadows, midtones and highlights.

Control the amount of image balance and leveling by controlling the values of the nMinInput, nMaxInput, nMinOutput, nMaxOutput, and uGamma members of the LVLCLRINF structure contained in the pLvlClr parameter. Keep in mind the following notes:

If only LEVEL_MASTER is set in uFlags, then the rest of the channels will still be affected.

If the image is a grayscale image, set LEVEL_MASTER in uFlags (otherwise, the function will not have any effect).

If nMinOutput > nMaxOutput then the bitmaps shadows and highlights will be inverted.

To update a status bar or detect a user interrupt during execution of this function, refer to L_SetStatusCallback.

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 in the Document and Medical Imaging toolkits.

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.

If the image has a region, the effect will be applied only on the region.

Color Level Function - Before

Color Level Function - Before

Color Level Function - After

Color Level Function - After

View additional platform support for this Color Level function.

Required DLLs and Libraries

Platforms

Win32, x64, Linux.

See Also

Functions

Topics

Example

For complete sample code, refer to the CHILD.C module of the DEMO example.
This example loads a bitmap and applies image leveling to it.

L_INT ColorLevelBitmapExample(L_VOID) 
{ 
   L_INT nRet; 
   BITMAPHANDLE LeadBitmap;   /* Bitmap handle to hold the loaded image. */ 
   LVLCLR lvlClr; 
 
   /* Load the bitmap, keeping the bits per pixel of the file */ 
   nRet = L_LoadBitmap(MAKE_IMAGE_PATH(TEXT("IMAGE1.CMP")), &LeadBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL); 
   if (nRet != SUCCESS) 
      return nRet; 
 
   lvlClr.uStructSize = sizeof(LVLCLR); 
   /* Specify Image levels */ 
   lvlClr.blue.nMinInput = 20; 
   lvlClr.blue.nMaxInput = 200; 
   lvlClr.blue.nMinOutput = 0; 
   lvlClr.blue.nMaxOutput = 255; 
   lvlClr.blue.uGamma = DEFAULT_GAMMA; 
 
   // Master will cause the image to be Inversed 
   lvlClr.master.nMinInput = 0; 
   lvlClr.master.nMaxInput = 255; 
   lvlClr.master.nMinOutput = 255; 
   lvlClr.master.nMaxOutput = 0; 
   lvlClr.master.uGamma = DEFAULT_GAMMA; 
 
   /* Level the Blue and Master channels */ 
   nRet = L_ColorLevelBitmap(&LeadBitmap, &lvlClr, LEVEL_BLUE | LEVEL_MASTER); 
   if (nRet != SUCCESS) 
      return nRet; 
 
   nRet = L_SaveBitmap(MAKE_IMAGE_PATH(TEXT("Result.BMP")), &LeadBitmap, FILE_BMP, 24, 0, NULL); 
   if (nRet != SUCCESS) 
      return nRet; 
 
   //free bitmap 
   if (LeadBitmap.Flags.Allocated) 
      L_FreeBitmap(&LeadBitmap); 
 
   return SUCCESS; 
} 

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

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