LBitmap::AutoBinarize

Summary

Applies binary segmentation to a bitmap automatically. This function is useful for improving recognition results (OCR, Barcode, OMR, ICR). This feature is available in version 16 or higher.

Syntax

#include "ltwrappr.h"

L_INT LBitmap::AutoBinarize(uFactor, uFlags)

Parameters

L_UINT uFactor

Threshold Factor. The meaning of this factor depends on which type of thresholding is being used. For more information see the description of the uFlags parameter.

L_UINT uFlags

Flags that indicate the type of pre-processing to perform on the bitmap and the type of thresholding to use. You can use a bitwise OR ( | ) to specify one flag from each group.

The following flags indicate the type of pre-processing to perform on the bitmap:

Value Meaning
AUTO_BINARIZE_PRE_AUTO [0x00000000] Perform automatic pre-processing. This is the default value.
AUTO_BINARIZE_NO_PRE [0x00000001] Do not perform pre-processing.
AUTO_BINARIZE_PRE_BG_ELIMINATION [0x00000002] Eliminate the background of the bitmap but keep the key features, such as text.
AUTO_BINARIZE_PRE_LEVELING [0x00000004] Perform automatic color leveling.

The following flags indicate type of threshold to use:

Value Meaning
AUTO_BINARIZE_THRESHOLD_AUTO [0x00000000] Perform automatic thresholding. This is the default value.
AUTO_BINARIZE_THRESHOLD_USER [0x00000010] Let the user choose the threshold value, to be passed in uFactor. Valid values range from 0 to 255.
AUTO_BINARIZE_THRESHOLD_PERCENTILE [0x00000020] Perform percentile thresholding. In this case uFactor is the percentage of black pixels at which to perform thresholding, expressed in hundredths of a percent. For example, 500 means 5 percent. Valid values range from 0 to 10000
AUTO_BINARIZE_THRESHOLD_MEDIAN [0x00000040] Perform median thresholding.

Returns

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

Comments

This function is useful for improving recognition results (OCR, Barcode, OMR, ICR).

LBitmap::AutoBinarize options:

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

This function does not support 12 and 16-bit grayscale and 48 and 64-bit color images. If the image is 12 and 16-bit grayscale and 48 and 64-bit color, the function will not return an error.

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.

Auto Binarize Function - Before

Auto Binarize Function - Before

Auto Binarize Function - After

Auto Binarize Function - After

View additional platform support for this Auto Binarize function.

Required DLLs and Libraries

Platforms

Win32, x64.

See Also

Functions

Topics

Example

L_INT LBitmap__AutoBinarizeExample() 
{ 
   L_INT nRet; 
   LBitmap LeadBitmap; 
    
   nRet = LeadBitmap.Load(MAKE_IMAGE_PATH(TEXT("cannon.jpg")), 0,ORDER_BGR); 
   if(nRet !=SUCCESS) 
      return nRet; 
 
   nRet = LeadBitmap.AutoBinarize (0, AUTO_BINARIZE_PRE_AUTO | AUTO_BINARIZE_THRESHOLD_AUTO); 
   if(nRet !=SUCCESS) 
      return nRet; 
 
   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.