#include "l_bitmap.h"
L_LTIMGCOR_API L_INT L_SauvolaBinarize(pBitmap, pSauvolaBinarize, uFlags)
Applies the known Sauvola binarization to a bitmap.
Pointer to the bitmap handle referencing the bitmap having Sauvola binarization applied.
A structure that contains the parameters needed to apply Sauvola equation.
Preserved, should be zero.
Value | Meaning |
---|---|
SUCCESS | The function was successful. |
< 1 | An error occurred. Refer to Return Codes. |
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:
ERROR_GRAY32_UNSUPPORTED
if a 32-bit grayscale image is passed to this function.
Win32, x64
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 Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document