bin_threshold ( Image : Region : : )

Segment a black-and-white image using an automatically determined threshold.

bin_threshold segments a single-channel gray value image using an automatically determined threshold. First the relative histogram of the gray values is determined. Then relevant minima are extracted from the histogram, which are used as parameters for a thresholding operation. In order to reduce the number of minima, the histogram is smoothed with a Gaussian, as in auto_threshold2. The mask size is enlarged until there is only one minimum in the smoothed histogram. The selected region contains the pixels with gray values from 0 to the minimum. This operator is particularly suited for the segmentation of dark characters on a light paper.


Parameters

Image (input_object)
image(-array) -> object : byte
Image to be segmented.

Region (output_object)
region(-array) -> object
Dark regions of the image.


Example
#include  "HCPP.H"
#include  

int main (int argc, char *argv[])
{
  if (argc != 2)
  {
    cout << "Usage : " << argv[0] << " 'image' " << endl;
    return (-1);
  }

  HImage       image (argv[1]),
               med;
  HWindow      w;

  w.SetDraw ("margin");
  w.SetShape ("rectangle1");
  w.SetColored (12);

  image.Display (w);

  HRegionArray reg = image.BinThreshold();
  HRegionArray con = reg.Connection ();

  cout << "Display image after BinThreshold segmentation " << endl;
  con.Display (w);
  w.Click ();

  return (0);
}

Possible Predecessors

anisotrope_diff__, median, illuminate__


Possible Successors

connection, select_shape, select_grey__


Alternatives

auto_threshold2, auto_threshold1, histo__, histo_gauss, threshold__



Copyright © 1996-1997 MVTec Software GmbH