PANDORE Version 6 GREYC-IMAGE

pniblackbinarization



Adaptive binarization based on local contrast according to W. Niblack algorithm enhanced by J. Sauvola.



Synopsis

pniblackbinarization width height depth k [-m mask] [im_in|-] [im_out|-]

Description

pniblackbinarization is an adaptative binarization based on local contrast analysis. It classifies pixels of the input image im_in into 2 classes: foreground and background. The algorithm is based on the calculation of a local contrast for each pixel that depends on the local mean value and the local standard deviation in the neighboring of the pixel.

The principle of the algorithm is to slide a rectangular window over the image. The window defines the neighboring size. It should be small enough to preserve local contrast and large enough to suppress noise. The threshold T for the center pixel of the window is computed using the mean m and the standard deviation s:

   T = m . (1 - k. ( 1- s/R))

where R is the dynamics of the standard deviation (e.g., 128 with 8-bits images) and k a constant with positive value (e.g., 0.5).

Notice: This algorithm uses a strong assumption: objects are assumed to be dark (near 0) and the background is assumed to be white (near 255).

Parameters

Inputs

Outputs

Result

Returns SUCCESS or FAILURE.

Examples

Segmenting the tangram image into pieces and background:

  pinverse examples/tangram.pan a.pan
  pniblackbinarization 50 50 0 0.2 a.pan out.pan

See also

Thresholding

C++ prototype

Errc PNiblackBinarization( const Img2duc &im_in, Img2duc &im_out, int width, int height, int depth, float k );

References

W. Niblack, "An introduction to digital image processing", Prentice hall, pp. 115-116, 1986.

J. Sauvola, M. Pietikainen, "Adaptative document ipage binarization", Pattern Recognition, vol 33, pp 255-236, 2000.

Author: Régis Clouard