Converts a bitmap into a black and white image without changing its bits per pixel by using a local threshold value for each pixel of the image. This function is also useful for pre-processing images for the purpose of improving barcode recognition results.
#include "ltwrappr.h"
virtual L_INT LBitmap::DynamicBinary (uDim, uLocalContrast, uFlags = 0)
Dimensions of the neighborhood used when evaluating each pixel (uDim x uDim), in pixels. uDim should be at least 1.
Local contrast threshold. If the contrast of the area surrounding the pixel is below uLocalContrast, the pixel is converted to black or white using a global pre-calculated threshold. If the contrast of the area surrounding the pixel is higher than uLocalContrast, the local threshold value is calculated and used. The valid values ranges are:
Reserved for future use. Must be 0.
Value | Meaning |
---|---|
SUCCESS | The function was successful. |
< 1 | An error occurred. Refer to Return Codes. |
This function converts a bitmap into a black and white image without changing its bits per pixel.
Use LBitmap::AutoBinary when you simply want to apply binary segmentation to the bitmap using an automatically calculated threshold based on a two-peak method of statistical analysis on its histogram. Use LBitmap::DynamicBinary if you want to convert a bitmap into a black and white image without changing its bits per pixel by using a local threshold value for each pixel of the image. Use LBitmap::AutoBinarize if you want:
Automatic pre-processing
Pre-processing to include background elimination
Pre-processing to include color leveling
To perform automatic, percentile or median thresholding
To manually specify a threshold value
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.
Each pixel is compared to a dynamically-calculated threshold. If the intensity of the pixel is higher (that is, the pixel is brighter) than the dynamic threshold, the pixel will be set to white. If the intensity of the pixel is lower (that is, the pixel is darker) than the dynamic threshold, the pixel will be set to black.
Here are some hints on using this function:
Increasing uLocalContrast increases the number of pixels that use the global threshold. This tends to preserve the general aspect of the image and reduces the improvement in the areas with many details. Reducing uLocalContrast, increases the contrast in areas with many details.
Increasing uDim increases the area used for local contrast. This makes the color changes smoother.
This function is good as a prerequisite for converting scanned images to 1-bit, because it uses one threshold for background and another for text.
To update a status bar or detect a user interrupt during execution of this function, refer to LBase::EnableStatusCallback.
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.
Dynamic Binary Function - Before
Dynamic Binary Function - After
View additional platform support for this Dynamic Binary function.
Win32, x64.
L_INT LBitmap__DynamicBinaryExample(LBitmap *pLeadBitmap)
{
/* This example converts it into a black and white image without changing its bits per pixel */
/* convert it into a black and white image without changing its bits per pixel */
return pLeadBitmap->DynamicBinary (8, 16);
}
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