histo_to_thresh ( : : Histogramm, Sigma : MinThresh, MaxThresh )

Determine gray value thresholds from a histogram.

histo_to_thresh determines gray value thresholds from a histogram for a segmentation of an image using threshold__. The thresholds returned are 0, 255, and all minima extracted from the histogram. Before the thresholds are determined the hostogram is smoothed with a Gaussian.


Parameters

Histogramm (input_control)
histogram.values-array -> integer
Gray value histogram.

Sigma (input_control)
number -> real
Sigma for the Gaussian smoothing of the histogram.
Default value: 2.0
Suggested values: 0.5, 1.0, 2.0, 3.0, 4.0, 5.0
Range of values: 0.1 <= Sigma <= 50.0 (lin)
Minimum increment: 0.01
Recommended increment: 0.2

MinThresh (output_control)
integer-array -> integer
Minimum thresholds.

MaxThresh (output_control)
integer-array -> integer
Maximum thresholds.


Example
#include  
#include  "HCPP.H"

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

  HImage   image (argv[1]),
           Smoothed;
  HWindow  win;

  Tuple MinThres, MaxThres,
        HistoAbs, HistoRel,
        size   = 10,
        iter   = 3,
        thresh = 0.0;

  HRegionArray reg = image.GetDomain ();

  HistoAbs = reg.Histo (image, &HistoRel);
  Smoothed = HistoAbs.HistoMean (size, iter);
  MinThres = Smoothed.HistoToThres (thresh, &MaxThres);

  HRegionArray seg = image.Threshold (MinThres, MaxThres);
  HRegionArray con = seg.Connection ();

  /* Alternativkonstrukt fuer Threshold() in
     Aufrufkombination mit Connection()
     -------------------------------------------------------
     HRegionArray con = ((image >= MinThres) &
                         (image <= MaxThres)).Connection ();
     ------------------------------------------------------- */

  con.Display (win);
  win.Click ();

  return (0);
}

Possible Predecessors

histo__, histo_mean, histo_gauss


Possible Successors

threshold__


Alternatives

auto_threshold1, auto_threshold2



Copyright © 1996-1997 MVTec Software GmbH