threshold threshold Threshold Threshold threshold (Operator)
Name
threshold threshold Threshold Threshold threshold — Segmentieren mit globalen Schwellenwerten.
Signatur
def threshold (image : HObject, min_gray : MaybeSequence[Union[int, float, str]], max_gray : MaybeSequence[Union[int, float, str]]) -> HObject
Beschreibung
threshold threshold Threshold Threshold Threshold threshold 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 MinGray MinGray MinGray MinGray minGray min_gray
und MaxGray MaxGray MaxGray MaxGray maxGray max_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" "min" beziehungsweise 'max' "max" "max" "max" "max" "max"
für MinGray MinGray MinGray MinGray minGray min_gray und MaxGray MaxGray MaxGray MaxGray maxGray max_gray gesetzt werden.
Achtung
Der Bildtyp kann Auswirkungen auf die Verwendung von MinGray MinGray MinGray MinGray minGray min_gray
und MaxGray MaxGray MaxGray MaxGray maxGray max_gray haben.
Für Bilder vom Typ Integer werden Fließkommawerte in MinGray MinGray MinGray MinGray minGray min_gray und
MaxGray MaxGray MaxGray MaxGray maxGray max_gray abgeschnitten. Für real-Bilder oder Vektorfeldbilder werden
MinGray MinGray MinGray MinGray minGray min_gray und MaxGray MaxGray MaxGray MaxGray maxGray max_gray , falls sie Doublewerte sind, als
Fließkommawerte verwendet.
Ausführungsinformationen
Multithreading-Typ: reentrant (läuft parallel zu nicht-exklusiven Operatoren).
Multithreading-Bereich: global (kann von jedem Thread aufgerufen werden).
Automatisch parallelisiert auf Tupelebene.
Automatisch parallelisiert auf interner Datenebene.
Parameter
Image Image Image Image image image (input_object) singlechannelimage(-array) → object HImage HObject HImage Hobject (byte / direction / cyclic / int1 / int2 / uint2 / int4 / int8 / real / vector_field)
Eingabebild.
Region Region Region Region region region (output_object) region(-array) → object HRegion HObject HRegion Hobject *
Segmentierte Region.
MinGray MinGray MinGray MinGray minGray min_gray (input_control) number(-array) → HTuple MaybeSequence[Union[int, float, str]] HTuple Htuple (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" "min" .
Defaultwert: 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" "min"
MaxGray MaxGray MaxGray MaxGray maxGray max_gray (input_control) number(-array) → HTuple MaybeSequence[Union[int, float, str]] HTuple Htuple (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" "max" .
Defaultwert: 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" "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)
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
threshold threshold Threshold Threshold Threshold threshold 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" "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_system set_system SetSystem SetSystem SetSystem set_system ). Gegebenenfalls wird
eine Fehlerbehandlung durchgeführt.
Vorgänger
histo_to_thresh histo_to_thresh HistoToThresh HistoToThresh HistoToThresh histo_to_thresh ,
min_max_gray min_max_gray MinMaxGray MinMaxGray MinMaxGray min_max_gray ,
sobel_amp sobel_amp SobelAmp SobelAmp SobelAmp sobel_amp ,
binomial_filter binomial_filter BinomialFilter BinomialFilter BinomialFilter binomial_filter ,
gauss_filter gauss_filter GaussFilter GaussFilter GaussFilter gauss_filter ,
reduce_domain reduce_domain ReduceDomain ReduceDomain ReduceDomain reduce_domain ,
fill_interlace fill_interlace FillInterlace FillInterlace FillInterlace fill_interlace
Nachfolger
connection connection Connection Connection Connection connection ,
dilation1 dilation1 Dilation1 Dilation1 Dilation1 dilation1 ,
erosion1 erosion1 Erosion1 Erosion1 Erosion1 erosion1 ,
opening opening Opening Opening Opening opening ,
closing closing Closing Closing Closing closing ,
rank_region rank_region RankRegion RankRegion RankRegion rank_region ,
shape_trans shape_trans ShapeTrans ShapeTrans ShapeTrans shape_trans ,
skeleton skeleton Skeleton Skeleton Skeleton skeleton
Alternativen
class_2dim_sup class_2dim_sup Class2dimSup Class2dimSup Class2dimSup class_2dim_sup ,
hysteresis_threshold hysteresis_threshold HysteresisThreshold HysteresisThreshold HysteresisThreshold hysteresis_threshold ,
dyn_threshold dyn_threshold DynThreshold DynThreshold DynThreshold dyn_threshold ,
binary_threshold binary_threshold BinaryThreshold BinaryThreshold BinaryThreshold binary_threshold ,
char_threshold char_threshold CharThreshold CharThreshold CharThreshold char_threshold ,
auto_threshold auto_threshold AutoThreshold AutoThreshold AutoThreshold auto_threshold ,
dual_threshold dual_threshold DualThreshold DualThreshold DualThreshold dual_threshold
Siehe auch
zero_crossing zero_crossing ZeroCrossing ZeroCrossing ZeroCrossing zero_crossing ,
background_seg background_seg BackgroundSeg BackgroundSeg BackgroundSeg background_seg ,
regiongrowing regiongrowing Regiongrowing Regiongrowing Regiongrowing regiongrowing
Modul
Foundation