auto_threshold ( Image : Regions : Sigma : )

Segment an image using thresholds determined from its histogram.

auto_threshold segments a single-channel image using multiple thresholding. First the relative histogram of the gray values is determined. Then relevant minima are extracted from the histogram, which are used successively as parameters for a thresholding operation. The thresholds used are 0, 255, and all minima extracted from the histogram (after the histogram has been smoothed). For each gray value interval one region is generated. Thus, the number of regions is the number of minima + 1. The larger the value of Sigma is chosen, the less regions will be extracted. This operator is particularly suited if the regions to be extracted exhibit similar gray values (homogeneous regions).


Parameters

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

Regions (output_object)
region-array -> object
Regions with gray values within the automatically determined intervals.

Sigma (input_control)
number -> real / integer
Sigma for the Gaussian smoothing of the histogram.
Default value: 2.0
Suggested values: 0.0, 0.5, 1.0, 2.0, 3.0, 4.0, 5.0
Typical range of values: 0.0 <= Sigma <= 100.0 (lin)
Minimum increment: 0.01
Recommended increment: 0.3
Restriction: Sigma >= 0.0


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.SetColored (12);

  image.Display (w);

  med = image.MedianImage ("circle", 3, -3);
  med.Display (w);

  HRegionArray reg = med.AutoThreshold2 (2.0);
  HRegionArray con = reg.Connection ();

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

  return (0);
}

Parallelization Information

auto_threshold is reentrant and automatically parallelized (on tuple level).


Possible Predecessors

anisotrope_diff, median_image, illuminate


Possible Successors

connection, select_shape, select_gray


Alternatives

gray_histo, smooth_funct_1d_gauss, threshold


Module

Region processing



Copyright © 1996-2005 MVTec Software GmbH