thresholdthresholdThresholdThresholdthreshold (Operator)

Name

thresholdthresholdThresholdThresholdthreshold — Segmentieren mit globalen Schwellenwerten.

Signatur

threshold(Image : Region : MinGray, MaxGray : )

Herror threshold(const Hobject Image, Hobject* Region, double MinGray, double MaxGray)

Herror T_threshold(const Hobject Image, Hobject* Region, const Htuple MinGray, const Htuple MaxGray)

void Threshold(const HObject& Image, HObject* Region, const HTuple& MinGray, const HTuple& MaxGray)

HRegion HImage::Threshold(const HTuple& MinGray, const HTuple& MaxGray) const

HRegion HImage::Threshold(double MinGray, double MaxGray) const

static void HOperatorSet.Threshold(HObject image, out HObject region, HTuple minGray, HTuple maxGray)

HRegion HImage.Threshold(HTuple minGray, HTuple maxGray)

HRegion HImage.Threshold(double minGray, double maxGray)

def threshold(image: HObject, min_gray: MaybeSequence[Union[int, float, str]], max_gray: MaybeSequence[Union[int, float, str]]) -> HObject

Beschreibung

thresholdthresholdThresholdThresholdthreshold wählt aus den Eingabebildern die Bildpunkte aus, deren Grauwerte g der Schwellenwertbedingung genügen.

Alle Punkte eines Eingabebildes, die die Bedingung erfüllen, werden gemeinsam als eine neue Region abgespeichert. Wird mehr als ein Grauwertbereich übergeben (Tupel von Werten für MinGrayMinGrayMinGrayminGraymin_gray und MaxGrayMaxGrayMaxGraymaxGraymax_gray), dann wird für jedes dieser Intervalle eine Region erzeugt. Für Vektorfeldbilder wird der Schwellenwert nicht auf Grauwerte sondern auf die Länge der Vektoren angewandt. Um die Grenzen nach unten oder oben offen zu lassen, kann statt eines Wertes auch 'min'"min""min""min""min" beziehungsweise 'max'"max""max""max""max" für MinGrayMinGrayMinGrayminGraymin_gray und MaxGrayMaxGrayMaxGraymaxGraymax_gray gesetzt werden.

Achtung

Der Bildtyp kann Auswirkungen auf die Verwendung von MinGrayMinGrayMinGrayminGraymin_gray und MaxGrayMaxGrayMaxGraymaxGraymax_gray haben.

Für Bilder vom Typ Integer werden Fließkommawerte in MinGrayMinGrayMinGrayminGraymin_gray und MaxGrayMaxGrayMaxGraymaxGraymax_gray abgeschnitten. Für real-Bilder oder Vektorfeldbilder werden MinGrayMinGrayMinGrayminGraymin_gray und MaxGrayMaxGrayMaxGraymaxGraymax_gray, falls sie Doublewerte sind, als Fließkommawerte verwendet.

Ausführungsinformationen

Parameter

ImageImageImageimageimage (input_object)  singlechannelimage(-array) objectHImageHObjectHObjectHobject (byte / direction / cyclic / int1 / int2 / uint2 / int4 / int8 / real / vector_field)

Eingabebild.

RegionRegionRegionregionregion (output_object)  region(-array) objectHRegionHObjectHObjectHobject *

Segmentierte Region.

MinGrayMinGrayMinGrayminGraymin_gray (input_control)  number(-array) HTupleMaybeSequence[Union[int, float, str]]HTupleHtuple (real / integer / string) (double / int / long / string) (double / Hlong / HString) (double / Hlong / char*)

Untere Schwelle für die Grauwerte oder 'min'"min""min""min""min".

Default: 128.0

Wertevorschläge: 0.0, 10.0, 30.0, 64.0, 128.0, 200.0, 220.0, 255.0, 'min'"min""min""min""min"

MaxGrayMaxGrayMaxGraymaxGraymax_gray (input_control)  number(-array) HTupleMaybeSequence[Union[int, float, str]]HTupleHtuple (real / integer / string) (double / int / long / string) (double / Hlong / HString) (double / Hlong / char*)

Obere Schwelle für die Grauwerte oder 'max'"max""max""max""max".

Default: 255.0

Wertevorschläge: 0.0, 10.0, 30.0, 64.0, 128.0, 200.0, 220.0, 255.0, 'max'"max""max""max""max"

Restriktion: MaxGray >= MinGray

Beispiel (HDevelop)

read_image(Image,'fabrik')
sobel_dir(Image,EdgeAmp,EdgeDir,'sum_abs',3)
threshold(EdgeAmp,Seg,50,255)
skeleton(Seg,Rand)
connection(Rand,Lines)
select_shape(Lines,Edges,'area','and',10,1000000)

Beispiel (C)

read_image(&Image,"fabrik");
sobel_amp(Image,&EdgeAmp,"sum_abs",3);
threshold(EdgeAmp,&Seg,50.0,255.0);
skeleton(Seg,&Rand);
connection(Rand,&Lines);
select_shape(Lines,&Edges,"area","and",10.0,1000000.0);

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 != 4)
  {
    cout << "Usage : " << argv[0] << " 'image' MinGray MaxGray" << endl;
    return (-1);
  }

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

  image.Display (win);

  int MinGray = atoi (argv[2]);
  int MaxGray = atoi (argv[3]);

  Sobel = image.SobelAmp ("sum_abs", 3);

  HRegionArray rand  = ((image >= MinGray) & (image <= MaxGray)).Skeleton();
  HRegionArray lines = rand.Connection();
  HRegionArray edges = lines.SelectShape("area", "and", 10.0, 10000000.0);

  edges.Display (win);
  win.Click ();

  return (0);
}

Beispiel (HDevelop)

read_image(Image,'fabrik')
sobel_dir(Image,EdgeAmp,EdgeDir,'sum_abs',3)
threshold(EdgeAmp,Seg,50,255)
skeleton(Seg,Rand)
connection(Rand,Lines)
select_shape(Lines,Edges,'area','and',10,1000000)

Komplexität

Sei A die Fläche der Eingaberegion, dann ist die Laufzeitkomplexität O(A).

Ergebnis

thresholdthresholdThresholdThresholdthreshold liefert den Wert 2 ( H_MSG_TRUE) , falls die Parameter korrekt sind. 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", '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" einstellbar (siehe set_systemset_systemSetSystemSetSystemset_system). Gegebenenfalls wird eine Fehlerbehandlung durchgeführt.

Vorgänger

histo_to_threshhisto_to_threshHistoToThreshHistoToThreshhisto_to_thresh, min_max_graymin_max_grayMinMaxGrayMinMaxGraymin_max_gray, sobel_ampsobel_ampSobelAmpSobelAmpsobel_amp, binomial_filterbinomial_filterBinomialFilterBinomialFilterbinomial_filter, gauss_filtergauss_filterGaussFilterGaussFiltergauss_filter, reduce_domainreduce_domainReduceDomainReduceDomainreduce_domain, fill_interlacefill_interlaceFillInterlaceFillInterlacefill_interlace

Nachfolger

connectionconnectionConnectionConnectionconnection, dilation1dilation1Dilation1Dilation1dilation1, erosion1erosion1Erosion1Erosion1erosion1, openingopeningOpeningOpeningopening, closingclosingClosingClosingclosing, rank_regionrank_regionRankRegionRankRegionrank_region, shape_transshape_transShapeTransShapeTransshape_trans, skeletonskeletonSkeletonSkeletonskeleton

Alternativen

class_2dim_supclass_2dim_supClass2dimSupClass2dimSupclass_2dim_sup, hysteresis_thresholdhysteresis_thresholdHysteresisThresholdHysteresisThresholdhysteresis_threshold, dyn_thresholddyn_thresholdDynThresholdDynThresholddyn_threshold, binary_thresholdbinary_thresholdBinaryThresholdBinaryThresholdbinary_threshold, char_thresholdchar_thresholdCharThresholdCharThresholdchar_threshold, auto_thresholdauto_thresholdAutoThresholdAutoThresholdauto_threshold, dual_thresholddual_thresholdDualThresholdDualThresholddual_threshold

Siehe auch

zero_crossingzero_crossingZeroCrossingZeroCrossingzero_crossing, background_segbackground_segBackgroundSegBackgroundSegbackground_seg, regiongrowingregiongrowingRegiongrowingRegiongrowingregiongrowing

Modul

Foundation