auto_thresholdauto_thresholdAutoThresholdAutoThresholdauto_threshold (Operator)

Name

auto_thresholdauto_thresholdAutoThresholdAutoThresholdauto_threshold — Segmentieren mit Schwellen aus dem Histogramm.

Signatur

auto_threshold(Image : Regions : Sigma : )

Herror auto_threshold(const Hobject Image, Hobject* Regions, double Sigma)

Herror T_auto_threshold(const Hobject Image, Hobject* Regions, const Htuple Sigma)

void AutoThreshold(const HObject& Image, HObject* Regions, const HTuple& Sigma)

HRegion HImage::AutoThreshold(const HTuple& Sigma) const

HRegion HImage::AutoThreshold(double Sigma) const

static void HOperatorSet.AutoThreshold(HObject image, out HObject regions, HTuple sigma)

HRegion HImage.AutoThreshold(HTuple sigma)

HRegion HImage.AutoThreshold(double sigma)

def auto_threshold(image: HObject, sigma: Union[int, float]) -> HObject

Beschreibung

auto_thresholdauto_thresholdAutoThresholdAutoThresholdAutoThresholdauto_threshold segmentiert ein einkanaliges Bild mittels mehrfacher Schwellenwertsegmentierung. Als erstes wird dabei das absolute Histogramm über den Grauwerten ermittelt. Dann werden im Histogramm relevante Minima gesucht, die schließlich nacheinander als Schwellen für die Schwellenwertsegmentierung dienen. Die Schwellen bestehen für Bilder vom Typ byte aus den Werten 0 und 255 und aus allen Minima des Histogramms (nach der Histogrammglättung mit einem Gaußfilter mit Standardabweichung SigmaSigmaSigmaSigmasigmasigma). Für jedes Grauwertintervall wird eine Region erzeugt. Die Anzahl der Regionen ist die Anzahl der Minima + 1. Für Bilder vom Typ uint2 gilt das oben beschriebene analog. Allerdings ist es hier so, dass die höchste Schwelle 65535 beträgt. Weiterhin bezieht sich bei uint2-Bildern der Wert von SigmaSigmaSigmaSigmasigmasigma (virtuell) auf ein Histogramm mit 256 Werten, obwohl intern Histogramme mit einer höheren Auflösung verwendet werden. Dies dient dazu, den Parameter SigmaSigmaSigmaSigmasigmasigma bei der Umstellung zwischen Bildtypen nicht ändern zu müssen. Für float Bilder sind die Schwellenwerte der minimale und maximale Grauwert aus dem Bild sowie alle Minima die aus dem Histogramm extrahiert wurden. Hier bezieht sich der Parameter SigmaSigmaSigmaSigmasigmasigma auf die ursprünglichen Grauwerte. Um so größer der Wert von SigmaSigmaSigmaSigmasigmasigma ist, um so weniger Regionen werden extrahiert. Das Verfahren ist dann einsetzbar, wenn die gesuchten Regionen einheitliche Grauwerte ausweisen (homogene Regionen).

Ausführungsinformationen

Parameter

ImageImageImageImageimageimage (input_object)  singlechannelimage(-array) objectHImageHObjectHImageHobject (byte / uint2 / real)

Eingabebild.

RegionsRegionsRegionsRegionsregionsregions (output_object)  region-array objectHRegionHObjectHRegionHobject *

Regionen mit den Punkten innerhalb der Grauwertintervalle.

SigmaSigmaSigmaSigmasigmasigma (input_control)  number HTupleUnion[int, float]HTupleHtuple (real / integer) (double / int / long) (double / Hlong) (double / Hlong)

Sigma für Gaußglättung des Histogramms.

Defaultwert: 2.0

Wertevorschläge: 0.0, 0.5, 1.0, 2.0, 3.0, 4.0, 5.0

Typischer Wertebereich: Sigma Sigma Sigma Sigma sigma sigma (lin)

Minimale Schrittweite: 0.01

Empfohlene Schrittweite: 0.3

Beispiel (HDevelop)

read_image (Image, 'fabrik')
median_image (Image, Median, 'circle', 3, 'mirrored')
auto_threshold (Median, Seg, 2.0)
connection (Seg, Connected)

Beispiel (C)

read_image(&Image,"fabrik");
median_image(Image,&Median,"circle",3,"mirrored");
auto_threshold(Median,&Seg,2.0);
connection(Seg,&Connected);
set_colored(WindowHandle,12);
disp_obj(Connected,WindowHandle);

Beispiel (C++)

#include "HIOStream.h"
#if !defined(USE_IOSTREAM_H)
using namespace std;
#endif
#include "HalconCpp.h"
using namespace Halcon;

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

  HImage       image(argv[1]);
  HImage       med;
  HWindow      w;

  w.SetDraw("margin");
  w.SetColored(12);

  image.Display (w);

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

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

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

  return 0;
}

Beispiel (HDevelop)

read_image (Image, 'fabrik')
median_image (Image, Median, 'circle', 3, 'mirrored')
auto_threshold (Median, Seg, 2.0)
connection (Seg, Connected)

Beispiel (HDevelop)

read_image (Image, 'fabrik')
median_image (Image, Median, 'circle', 3, 'mirrored')
auto_threshold (Median, Seg, 2.0)
connection (Seg, Connected)

Vorgänger

anisotropic_diffusionanisotropic_diffusionAnisotropicDiffusionAnisotropicDiffusionAnisotropicDiffusionanisotropic_diffusion, median_imagemedian_imageMedianImageMedianImageMedianImagemedian_image, illuminateilluminateIlluminateIlluminateIlluminateilluminate

Nachfolger

connectionconnectionConnectionConnectionConnectionconnection, select_shapeselect_shapeSelectShapeSelectShapeSelectShapeselect_shape, select_grayselect_graySelectGraySelectGraySelectGrayselect_gray

Alternativen

binary_thresholdbinary_thresholdBinaryThresholdBinaryThresholdBinaryThresholdbinary_threshold, char_thresholdchar_thresholdCharThresholdCharThresholdCharThresholdchar_threshold

Siehe auch

gray_histogray_histoGrayHistoGrayHistoGrayHistogray_histo, gray_histo_absgray_histo_absGrayHistoAbsGrayHistoAbsGrayHistoAbsgray_histo_abs, histo_to_threshhisto_to_threshHistoToThreshHistoToThreshHistoToThreshhisto_to_thresh, smooth_funct_1d_gausssmooth_funct_1d_gaussSmoothFunct1dGaussSmoothFunct1dGaussSmoothFunct1dGausssmooth_funct_1d_gauss, thresholdthresholdThresholdThresholdThresholdthreshold

Modul

Foundation