Herror ::histo_to_thresh (
const HTuple &Histogramm,
const HTuple &Sigma,
HTuple *MinThresh,
HTuple *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 histogram is smoothed with a Gaussian.
Parameters
Histogramm (input_control)
|
histogram-array -> HTuple.long / double
|
|
Gray value histogram. |
Sigma (input_control)
|
number -> HTuple.double
|
|
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 |
|
Typical range of values: 0.1 <= Sigma <= 30.0 (lin) |
|
Minimum increment: 0.01
|
Recommended increment: 0.2
|
MinThresh (output_control)
|
integer-array -> HTuple.long *
|
|
Minimum thresholds. |
MaxThresh (output_control)
|
integer-array -> HTuple.long *
|
|
Maximum thresholds. |
Example
#include <iostream.h>
#include "HalconCpp.h"
int main (int argc, char *argv[])
{
if (argc != 2)
{
cout << "Usage : " << argv[0] << " <name of image>" << 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.GrayHisto (image, &HistoRel);
Smoothed = HistoAbs.FunctionSmoothMean (size, iter);
MinThres = Smoothed.HistoToThresh (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
::gray_histo
Possible Successors
::threshold
Alternatives
::auto_threshold
Module
Region processing
Copyright © 1996-2002 MVTec Software GmbH