Herror ::bin_threshold (
    Hobject Image,
    Hobject *Region
)
HRegion HImage::BinThreshold (
    void
) const
HRegionArray HImageArray::BinThreshold (
    void
) const

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_threshold. 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) -> Hobject: HImage(Array) ( byte )
Image to be segmented.

Region (output_object)
region(-array) -> Hobject * : HRegion(Array)
Dark regions of the image.


Example
#include  "HalconCpp.h"
#include  <iostream.h>

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_image, ::illuminate


Possible Successors

::connection, ::select_shape, ::select_gray


Alternatives

::auto_threshold, ::char_threshold, ::gray_histo, ::smooth_funct_1d_gauss, ::threshold


Module

Region processing



Copyright © 1996-2002 MVTec Software GmbH