dual_thresholddual_thresholdDualThresholdDualThresholddual_threshold (Operator)

Name

dual_thresholddual_thresholdDualThresholdDualThresholddual_threshold — Segmentieren mit Schwellen für Bilder mit Vorzeichen.

Signatur

dual_threshold(Image : RegionCrossings : MinSize, MinGray, Threshold : )

Herror dual_threshold(const Hobject Image, Hobject* RegionCrossings, const Hlong MinSize, double MinGray, double Threshold)

Herror T_dual_threshold(const Hobject Image, Hobject* RegionCrossings, const Htuple MinSize, const Htuple MinGray, const Htuple Threshold)

void DualThreshold(const HObject& Image, HObject* RegionCrossings, const HTuple& MinSize, const HTuple& MinGray, const HTuple& Threshold)

HRegion HImage::DualThreshold(Hlong MinSize, double MinGray, double Threshold) const

static void HOperatorSet.DualThreshold(HObject image, out HObject regionCrossings, HTuple minSize, HTuple minGray, HTuple threshold)

HRegion HImage.DualThreshold(int minSize, double minGray, double threshold)

def dual_threshold(image: HObject, min_size: int, min_gray: float, threshold: float) -> HObject

Beschreibung

dual_thresholddual_thresholdDualThresholdDualThresholdDualThresholddual_threshold segmentiert das Eingabebild in eine Teilregion mit Grauwerten ThresholdThresholdThresholdThresholdthresholdthreshold („positive“ Bildbereiche) und eine mit Grauwerten ThresholdThresholdThresholdThresholdthresholdthreshold („negative“ Bildbereiche). Nur „positive“ oder „negative“ Teilbereiche mit einer Fläche größer als MinSizeMinSizeMinSizeMinSizeminSizemin_size werden dabei berücksichtigt. Teilbereiche, deren maximaler Grauwert betragsmäßig kleiner ist als MinGrayMinGrayMinGrayMinGrayminGraymin_gray, werden unterdrückt.

Die durchgeführte Segmentierung ist nicht vollständig, d.h. die „positiven“ und „negativen“ Ergebnisregionen überdecken zusammengenommen nicht unbedingt das ganze Eingabebild. Es bleiben alle Bildbereiche unberücksichtigt, deren Grauwerte zwischen ThresholdThresholdThresholdThresholdthresholdthreshold und ThresholdThresholdThresholdThresholdthresholdthreshold (bzw. MinGrayMinGrayMinGrayMinGrayminGraymin_gray und MinGrayMinGrayMinGrayMinGrayminGraymin_gray) liegen.

dual_thresholddual_thresholdDualThresholdDualThresholdDualThresholddual_threshold schließt sich typischerweise an die Anwendung von Laplace-Operatoren wie (laplacelaplaceLaplaceLaplaceLaplacelaplace, laplace_of_gausslaplace_of_gaussLaplaceOfGaussLaplaceOfGaussLaplaceOfGausslaplace_of_gauss, derivate_gaussderivate_gaussDerivateGaussDerivateGaussDerivateGaussderivate_gauss oder diff_of_gaussdiff_of_gaussDiffOfGaussDiffOfGaussDiffOfGaussdiff_of_gauss) oder eine Bildsubtraktion (sub_imagesub_imageSubImageSubImageSubImagesub_image) an. In den Nulldurchgängen des Laplace-Operators spiegeln sich Bildkanten wider, die sich als Trennlinien zwischen den „positiven“ und „negativen“ Bildbereichen bestimmen lassen. Dazu ruft man zuerst dual_thresholddual_thresholdDualThresholdDualThresholdDualThresholddual_threshold mit ThresholdThresholdThresholdThresholdthresholdthreshold = 1 auf und erzeugt dann die komplementäre Regionen mittels complementcomplementComplementComplementComplementcomplement. Der Parameter MinGrayMinGrayMinGrayMinGrayminGraymin_gray steuert dabei die Rauschinvarianz,während MinSizeMinSizeMinSizeMinSizeminSizemin_size das Auflösungsvermögen der Kantendetektion steuert.

Bei Pixeltypen ohne Vorzeichen (byte) wird nur die positive Hälfte der Segmentierung durchgeführt. dual_thresholddual_thresholdDualThresholdDualThresholdDualThresholddual_threshold verhält sich also wie eine einfaches Schwellenwertverfahren (thresholdthresholdThresholdThresholdThresholdthreshold) mit nachgeschaltetem connectionconnectionConnectionConnectionConnectionconnection und select_grayselect_graySelectGraySelectGraySelectGrayselect_gray.

Ausführungsinformationen

Parameter

ImageImageImageImageimageimage (input_object)  singlechannelimage(-array) objectHImageHObjectHImageHobject (byte / int1 / int2 / int4 / real)

Eingabebild.

RegionCrossingsRegionCrossingsRegionCrossingsRegionCrossingsregionCrossingsregion_crossings (output_object)  region-array objectHRegionHObjectHRegionHobject *

„Positive“ und „negative“ Teilregionen.

MinSizeMinSizeMinSizeMinSizeminSizemin_size (input_control)  integer HTupleintHTupleHtuple (integer) (int / long) (Hlong) (Hlong)

Teilregionen mit weniger als MinSize Fläche werden unterdrückt.

Defaultwert: 20

Wertevorschläge: 0, 10, 20, 50, 100, 200, 500, 1000

Typischer Wertebereich: 0 ≤ MinSize MinSize MinSize MinSize minSize min_size ≤ 10000 (lin)

Minimale Schrittweite: 1

Empfohlene Schrittweite: 10

MinGrayMinGrayMinGrayMinGrayminGraymin_gray (input_control)  real HTuplefloatHTupleHtuple (real) (double) (double) (double)

Teilregionen, deren maximaler Grauwert betragsmäßig kleiner als MinGray ist, werden unterdrückt.

Defaultwert: 5.0

Wertevorschläge: 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 9.0, 11.0, 15.0, 20.0

Typischer Wertebereich: 0 ≤ MinGray MinGray MinGray MinGray minGray min_gray (lin)

Minimale Schrittweite: 1.0

Empfohlene Schrittweite: 10.0

ThresholdThresholdThresholdThresholdthresholdthreshold (input_control)  real HTuplefloatHTupleHtuple (real) (double) (double) (double)

Zurückgeliefert werden Teilregionen, deren Grauwerte größer gleich (bzw. kleiner gleich) Threshold (-Threshold) sind.

Defaultwert: 2.0

Wertevorschläge: 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 9.0, 11.0, 15.0, 20.0

Typischer Wertebereich: 0 ≤ Threshold Threshold Threshold Threshold threshold threshold (lin)

Minimale Schrittweite: 1.0

Empfohlene Schrittweite: 10.0

Beispiel (HDevelop)

* Edge detection with the Laplace operator (and edge thinning)
diff_of_gauss(Image,Laplace,2.0,1.6)
* find "`positive"' and "`negative"' regions:
dual_threshold(Laplace,Region,20,2,1)
* The zero runnings are the complement to these image section:
complement(Region,ZeroCrossings)

* Simulation of dual_threshold
dual_threshold(Laplace,Result,MinS,MinG,Threshold)
threshold(Laplace,Tmp1,Threshold,999999)
connection(Tmp1,Tmp2)
select_shape(Tmp2,Tmp3,'area','and',MinS,999999)
select_gray(Laplace,Tmp3,Tmp4,'max','and',MinG,999999)
threshold(Laplace,Tmp5,-999999,-Threshold)
connection(Tmp5,Tmp6)
select_shape(Tmp6,Tmp7,'area','and',MinS,999999)
select_gray(Laplace,Tmp7,Tmp8,'min','and',-999999,-MinG)
concat_obj(Tmp4,Tmp8,Result)

Beispiel (C)

/* Edge detection with the Laplace operator (and edge thinning) */
diff_of_gauss(Image,&Laplace,2.0,1.6);
/* find "`positive"' and "`negative"' regions: */
dual_threshold(Laplace,&Region,20,2,1);
/*The zero runnings are the complement to these image section: */
complement(Region,ZeroCrossings);

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]),
               laplace;
  HWindow      win;

  HRegionArray region,
               nulldg;

  image.Display (win);

  laplace = image.DiffOfGauss (2.0, 1.6);
  region  = laplace.DualThreshold (20, 2, 1);
  nulldg  = region.Complement ();

  laplace.Display (win);     win.Click ();
  region.Display (win);      win.Click ();
  nulldg.Display (win);      win.Click ();

  return (0);
}

Beispiel (HDevelop)

* Edge detection with the Laplace operator (and edge thinning)
diff_of_gauss(Image,Laplace,2.0,1.6)
* find "`positive"' and "`negative"' regions:
dual_threshold(Laplace,Region,20,2,1)
* The zero runnings are the complement to these image section:
complement(Region,ZeroCrossings)

* Simulation of dual_threshold
dual_threshold(Laplace,Result,MinS,MinG,Threshold)
threshold(Laplace,Tmp1,Threshold,999999)
connection(Tmp1,Tmp2)
select_shape(Tmp2,Tmp3,'area','and',MinS,999999)
select_gray(Laplace,Tmp3,Tmp4,'max','and',MinG,999999)
threshold(Laplace,Tmp5,-999999,-Threshold)
connection(Tmp5,Tmp6)
select_shape(Tmp6,Tmp7,'area','and',MinS,999999)
select_gray(Laplace,Tmp7,Tmp8,'min','and',-999999,-MinG)
concat_obj(Tmp4,Tmp8,Result)

Beispiel (HDevelop)

* Edge detection with the Laplace operator (and edge thinning)
diff_of_gauss(Image,Laplace,2.0,1.6)
* find "`positive"' and "`negative"' regions:
dual_threshold(Laplace,Region,20,2,1)
* The zero runnings are the complement to these image section:
complement(Region,ZeroCrossings)

* Simulation of dual_threshold
dual_threshold(Laplace,Result,MinS,MinG,Threshold)
threshold(Laplace,Tmp1,Threshold,999999)
connection(Tmp1,Tmp2)
select_shape(Tmp2,Tmp3,'area','and',MinS,999999)
select_gray(Laplace,Tmp3,Tmp4,'max','and',MinG,999999)
threshold(Laplace,Tmp5,-999999,-Threshold)
connection(Tmp5,Tmp6)
select_shape(Tmp6,Tmp7,'area','and',MinS,999999)
select_gray(Laplace,Tmp7,Tmp8,'min','and',-999999,-MinG)
concat_obj(Tmp4,Tmp8,Result)

Ergebnis

dual_thresholddual_thresholdDualThresholdDualThresholdDualThresholddual_threshold liefert normalerweise den Wert 2 (H_MSG_TRUE). Für das Verhalten bzgl. der Eingabebilder und Ausgaberegionen sind die Flags 'no_object_result'"no_object_result""no_object_result""no_object_result""no_object_result""no_object_result", 'empty_region_result'"empty_region_result""empty_region_result""empty_region_result""empty_region_result""empty_region_result" und 'store_empty_region'"store_empty_region""store_empty_region""store_empty_region""store_empty_region""store_empty_region" einstellbar (siehe set_systemset_systemSetSystemSetSystemSetSystemset_system). Gegebenenfalls wird eine Fehlerbehandlung durchgeführt.

Vorgänger

min_max_graymin_max_grayMinMaxGrayMinMaxGrayMinMaxGraymin_max_gray, sobel_ampsobel_ampSobelAmpSobelAmpSobelAmpsobel_amp, binomial_filterbinomial_filterBinomialFilterBinomialFilterBinomialFilterbinomial_filter, gauss_filtergauss_filterGaussFilterGaussFilterGaussFiltergauss_filter, reduce_domainreduce_domainReduceDomainReduceDomainReduceDomainreduce_domain, diff_of_gaussdiff_of_gaussDiffOfGaussDiffOfGaussDiffOfGaussdiff_of_gauss, sub_imagesub_imageSubImageSubImageSubImagesub_image, derivate_gaussderivate_gaussDerivateGaussDerivateGaussDerivateGaussderivate_gauss, laplace_of_gausslaplace_of_gaussLaplaceOfGaussLaplaceOfGaussLaplaceOfGausslaplace_of_gauss, laplacelaplaceLaplaceLaplaceLaplacelaplace, expand_regionexpand_regionExpandRegionExpandRegionExpandRegionexpand_region

Nachfolger

connectionconnectionConnectionConnectionConnectionconnection, dilation1dilation1Dilation1Dilation1Dilation1dilation1, erosion1erosion1Erosion1Erosion1Erosion1erosion1, openingopeningOpeningOpeningOpeningopening, closingclosingClosingClosingClosingclosing, rank_regionrank_regionRankRegionRankRegionRankRegionrank_region, shape_transshape_transShapeTransShapeTransShapeTransshape_trans, skeletonskeletonSkeletonSkeletonSkeletonskeleton

Alternativen

thresholdthresholdThresholdThresholdThresholdthreshold, dyn_thresholddyn_thresholdDynThresholdDynThresholdDynThresholddyn_threshold, check_differencecheck_differenceCheckDifferenceCheckDifferenceCheckDifferencecheck_difference

Siehe auch

connectionconnectionConnectionConnectionConnectionconnection, select_shapeselect_shapeSelectShapeSelectShapeSelectShapeselect_shape, select_grayselect_graySelectGraySelectGraySelectGrayselect_gray

Modul

Foundation