histo_mean ( : : Histogramm, SmoothSize, Iterations : Smoothed )

Smooth a histogram by averaging its values.

histo_mean smooths a histogram by applying an average (mean) filter multiple times. The histogram contains 256 values.


Parameters

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

SmoothSize (input_control)
integer -> integer
Size of the averaging mask.
Default value: 10
Suggested values: 1, 3, 5, 7, 9, 11, 13, 15, 21, 31, 51
Range of values: 1 <= SmoothSize <= 256 (lin)
Minimum increment: 1
Recommended increment: 1
Restriction: (SmoothSize > 0) && (SmoothSize < 256)

Iterations (input_control)
integer -> integer
Number of iterations the smoothing is applied.
Default value: 3
Suggested values: 1, 2, 3, 4, 5, 6, 7, 8, 9
Range of values: 1 <= Iterations <= 100 (lin)
Minimum increment: 1
Recommended increment: 1
Restriction: Iterations >= 1

Smoothed (output_control)
histogram.values-array -> integer
Smoothed gray value histogram.


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__


Possible Successors

histo_to_thresh, histo_to_region


Alternatives

histo_gauss


See also

auto_threshold1, auto_threshold2



Copyright © 1996-1997 MVTec Software GmbH