L_SauvolaBinarize

Summary

Applies the known Sauvola binarization to a bitmap.

Syntax

#include "l_bitmap.h"

L_LTIMGCOR_API L_INT L_SauvolaBinarize(pBitmap, pSauvolaBinarize, uFlags)

Parameters

pBITMAPHANDLE pBitmap

Pointer to the bitmap handle referencing the bitmap having Sauvola binarization applied.

pSAUVOLABINARIZE pSauvolaBinarize

A structure that contains the parameters needed to apply Sauvola equation.

L_UINT uFlags

Preserved, should be zero.

Returns

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

Comments

Sauvola Binarizer converts a colored image into a black and white image using Sauvola equation introduced in https://www.sciencedirect.com/science/article/abs/pii/S0031320399000552, without losing important image features such as text. It can be adjusted to be suitable for a specific input device, such as a scanner or camera. This function is especially useful for improving recognition results (such as OCR and Barcode).

L_SauvolaBinarize does not support the following file formats:

Required DLLs and Libraries

Platforms

Win32, x64

See Also

Functions

Topics

Example

L_INT SauvolaBinarizeBitmapExample(L_VOID) 
{ 
   L_INT nRet; 
   BITMAPHANDLE LeadBitmap;   /* Bitmap handle to hold the loaded image. */ 
 
   /* Load the bitmap, keeping the bits per pixel of the file */ 
   nRet = L_LoadBitmap(MAKE_IMAGE_PATH(TEXT("glare.jpg")), &LeadBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL); 
   if (nRet != SUCCESS) 
      return nRet; 
 
   SAUVOLABINARIZE sb = { 0 }; 
   sb.uStructSize = sizeof(SAUVOLABINARIZE); 
   sb.nWSize = 55; 
   sb.dKFactor = 0.15; 
   sb.nRFactor = 128; 
 
   nRet = L_SauvolaBinarize(&LeadBitmap, &sb, 0); 
   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.