PICTools Programmer's Reference
OP_BINARIZE

OP_BINARIZE: Convert DIB to black/white

The OP_BINARIZE opcode (see opcode specific data structure) operates on 1-bit, 8-bit, 24-bit, and 32-bit input DIBs, creating 1-bit output DIBs of the same dimensions, although cropping is supported. Binarization of a 32-bit input DIB ignores the fourth component. Alternative modes may be chosen according to the type of image and desired results.

The output DIB can be cropped to a specified subrectangle by setting F_InputCrop in PicParm.Flags and setting PicParm.IOCropXoff, PicParm.IOCropYoff, PicParm.IOCropWidth, and PicParm.IOCropHeight to describe the subrectangle.

This operation modifies the color palette associated with the DIB, setting it to two colors, with black as color 0 and white as color 1.

Quick-Text Mode

Quick-text mode is generally used for document-type images consisting of dark text and lines on a white or gray background. The result of the operation is to replace the text and lines in the image by black and the background by white.

 

Sample quick-text mode input:

Description: F1

 


Sample quick-text mode output:

Description: F2

Two parameters control the sensitivity of the binarization process. See the SB_PARMS structure section for more information.

Photo-Halftone Mode

Photo-halftone mode is generally used for color or grayscale photographic-type images, reproducing the shades of gray in the image by black and white dots of various sizes. The angle and pitch of the halftone grid are controllable.

Sample photo-halftone mode input:

Description: f3

 

Sample photo-halftone mode output:

Description: f4

 

Six parameters control the angle and pitch of the halftone grid, and the dot shape. See the SB_PARMS structure section for more information.


Local Contrast Enhancement

This preprocessing operation increases the contrast in each region of the image. When used as a prelude to binarization (usually Quick-text mode) it increases the sensitivity of the binarization to detail in all regions of the image.

 

Original image:

Description: F4a

 

With local contrast enhancement:

Description: f4b

 

With local contrast enhancement and binarization:

Description: f4c

 

Pre-Blur

The pre-blur option to local-contrast enhancement is useful when the original digitization is fine enough to reveal the halftone grid on the original document. It ensures that shades of gray are interpreted as such rather than a combination of black and white.

Two different modes, Gaussian and Smart, embodying different algorithms, are available for pre-blur.

Either mode of pre-blur can also be used without binarization as an image-processing operator for gray-level images.

 

Image binarized with local-contrast enhancement without pre-blur:

Description: f4d

 

Image binarized with local-contrast enhancement with (mode 1) pre-blur:

Description: f4c

 

1-Bit Input

OP_BINARIZE may sometimes be usefully applied to an already binary input image to act as a clean-up operation (particularly in quick-text mode with preblur).

Input 1-bit image with background noise:

Description: raw1

 


1-bit image after OP_BINARIZE:

Description: zz

Auto Binarize Mode

This mode automatically computes all necessary parameters by analyzing the input data before actually performing the binarization. The algorithm is tuned to typical document images, consisting of dark text on brighter background. It is robust to shadows, noise, and background images.

 

Input Image with background:

Description: check1

1-bit image after OP_BINARIZE with auto binarization option:

Description: check1-bin

 


Input Image with shadows:

Description: autoBinarizeSample-source

1-bit image after OP_BINARIZE with auto binarization option:

Description: autoBinarizeSample

Notes

 

 


©2022. Accusoft Corporation. All Rights Reserved.

Send Feedback