L_DynamicBinaryBitmap

#include "l_bitmap.h"

L_INT EXT_FUNCTION L_DynamicBinaryBitmap (pBitmap, uDim, uLocalContrast)

pBITMAPHANDLE pBitmap;

/* pointer to the bitmap handle */

L_UINT uDim;

/* dimensions of the neighborhood (uDim x uDim), in pixels */

L_UINT uLocalContrast;

/* local contrast threshold */

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 available in the Raster Pro and above toolkits.

Parameter

Description

pBitmap

Pointer to the bitmap handle referencing the bitmap to be changed.

uDim

Dimensions of the neighborhood used when evaluating each pixel (uDim x uDim), in pixels. uDim should be at least 1.

uLocalContrast

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 range for uLocalContrast is 0 to 255 for 8-bit, 0 to 4095 for 12-bit and 0 to 65535 for 16-bit.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

This function converts a bitmap into a black and white image without changing its bits per pixel.

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 L_SetStatusCallback.

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.

Required DLLs and Libraries

LTIMG

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application.

Platforms

Windows 95 / 98 / Me, Windows 2000 / XP, Windows CE.

See Also

Functions:

L_IntensityDetectBitmap, L_MedianFilterBitmap, L_BinaryFilterBitmap, L_MaxFilterBitmap, L_MinFilterBitmap, L_WindowLevel, L_DespeckleBitmap, L_DeskewBitmap, L_BricksTextureBitmap, L_DeskewBitmap, L_DeskewBitmapExt, L_DiffuseGlowBitmap, L_GlowFilterBitmap, L_HalfTonePatternBitmap, L_HighPassFilterBitmap, L_MaskConvolutionBitmap, L_PerspectiveBitmap, L_PlasmaFilterBitmap, L_PointillistBitmap, L_FragmentBitmap, L_UnsharpMaskBitmap

Topics:

Raster Image Functions: Modifying Intensity Values

Example

/* This example loads a bitmap and converts it into a black and white image without changing its bits per pixel */
BITMAPHANDLE LeadBitmap;   /* Bitmap handle to hold the loaded image. */
/* Load the bitmap, keeping the bits per pixel of the file */
L_LoadBitmap
 (TEXT("IMAGE1.CMP"), &LeadBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL);
/* convert it into a black and white image without changing its bits per pixel */
L_DynamicBinaryBitmap
 (&LeadBitmap, 8, 16);