bin_wr2

[ XITE Reference Manual | XITE home ]

Contents


Name

bin_wr2, bin_iwr - binarize a gray-scale band using White and Rohrer`s method

Syntax

 #include <xite/binarize.h>

 int bin_wr2( int mode, int activity_limit,
    double distance_limit, int mean_size,
    int search_vec_len, int diagonal,
    int max_limit, int spot_size_limit,
    IBAND inband, IBAND outband,
    int intermediate_images );

 int bin_iwr( int mode, int activity_limit,
    int mean_size, int max_limit,
    int spot_size_limit, IBAND inband,
    IBAND outband, int intermediate_images );

Description

The input band inband is binarized using the Integrated function Algorithm of White and Rohrer, or an improved version. The result is returned in outband.

Several improvements and variations of the method have been implemented; some of these are available in bin_wr2, but to get all the improvements, bin_iwr must be used followed by remove_ghost.

White and Rohrer`s method uses a gradient-like operator called the activity on the image. Pixels with activity below activity_limit are labeled 0. The other pixels are further tested. If the Laplacian edge operator of the pixel is positive, the pixel is labeled +, otherwise -. That way a three-level label-image is constructed, with legal pixel values +, 0 and -. The idea is that in a sequence of labels, edges are identified as -+ transitions or +- transitions. Object pixels are assumed to be + and 0 labeled pixels between a -+ and +- pair. For each pixel to be classified, a search vector of length search_vec_len for each search direction is centered on the pixel. The -+ and +- must be inside the seach vector to be recognized. By using a low value on search_vec_len, only lines and small filled areas will be captured.

If spot_size_limit > 1, then small +-labeled regions having less than spot_size_limit pixels are relabeled as 0-regions.

By specifying activity_limit = 0, Kitler and Illingworth`s method is used to set the activity threshold. An upper bound for this value is specified by max_activity.

A lower limit on the distance between the -+ and +- for pixels to be classified as object pixels is specified by distance_limit. This can be used to eliminate the thinnest lines in inband.

The first improvement suggested by Trier and Taxt [1] can be used in bin_wr2:

The input image is smoothed by a mean filter of size (mean_size x mean_size) to remove stochastic noise. To run the original White and Rohrer`s method, mean_size = 1 must be used.

Variations on how pixels are classified as print or background are selected though the mode parameter:

If mode = WR_TWO_BY_TWO, the original approach is used. Two times two pixels are classified at a time, requiring that all four pixels are inside either horizontal or vertical object pixel sequences.

The reasons for classifying (2 x 2) pixels at a time in the original implementation was partly to save computational time, partly to reduce noise. With faster computers, a more time-consuming algorithm may be allowed.

If mode = WR_DOUBLE_VECTORS, then the idea is that a single pixel being part of an object pixel sequence is not enough. It has to have support from at least one of its neighbors. Either one of its vertical neighbors and the pixel itself have to be inside horizontal object pixel sequences or one of its horizontal neighbors and the pixel itself must be inside vertical object pixel sequences to be recognized as object pixels.

If mode = WR_SINGLE_VECTOR, only a single search vector is used in each direction.

If diagonal >= 1, then the horizontal and vertical search directions are complemented with two diagonal search directions. If diagonal == 0, then only the horizontal and vertical search directions are used.

If intermediate_images > 0, then some intermediate images are saved during the execution. This is useful for analyzing the method.

bin_iwr

bin_iwr is an improved version of bin_wr2. The parameter list is somewhat different. The mode parameter is kept for future improvements, but is currently ignored. The distance limit, search_vec_len, and diagonal parameters have been discarded from the parameter list, since the use of search vectors to locate print pixels in the three-level label image is abandoned in bin_iwr.

Instead, the following approach is used. First, all "+"-marked regions are labeled print and "-"-marked regions are marked backgrond. Then, for each "0"-marked region, the number of "-" and "+" pixels that are 8-connected to the region is counted. If the number of "+" pixels is in majority, the "0" -marked region is labeled print, otherwise background.

This approach prodces a lot of noise which can be seen as spurious print components, which must be removed by using remove_ghost afterwards.

Restrictions

inband and outband must have pixel type unsigned byte.

See also

binarize(1)

References

[1] Řivind Due Trier & Torfinn Taxt
"Improvement of `integrated function algorithm` for binarization of document images", Pattern Recognition Letters, to appear.

[2] J.M. White & G.D. Rohrer
"Image Thresholding for Optical Character Recognition and Other Applications Requiring Character Image Extraction", IBM Journal of Research and Development, vol 27, no 4, pp 400-411, July 1983.

Return value

 0 : ok
 1 : Bad input pixel type
 2 : Bad output pixel type

Files

src/binarize/bin_wr2.c

Author

Řivind Due Trier

Id

$Id: bin_wr2.c,v 1.11 1997/01/14 15:46:58 svein Exp $