expand_gray_refexpand_gray_refExpandGrayRefExpandGrayRefexpand_gray_ref (Operator)

Name

expand_gray_refexpand_gray_refExpandGrayRefExpandGrayRefexpand_gray_ref — Auffüllen von „Lücken“ zwischen Regionen (abhängig vom Grau- oder Farbwert) oder Trennen überlappender Regionen.

Signatur

expand_gray_ref(Regions, Image, ForbiddenArea : RegionExpand : Iterations, Mode, RefGray, Threshold : )

Herror expand_gray_ref(const Hobject Regions, const Hobject Image, const Hobject ForbiddenArea, Hobject* RegionExpand, const char* Iterations, const char* Mode, const Hlong RefGray, const Hlong Threshold)

Herror T_expand_gray_ref(const Hobject Regions, const Hobject Image, const Hobject ForbiddenArea, Hobject* RegionExpand, const Htuple Iterations, const Htuple Mode, const Htuple RefGray, const Htuple Threshold)

void ExpandGrayRef(const HObject& Regions, const HObject& Image, const HObject& ForbiddenArea, HObject* RegionExpand, const HTuple& Iterations, const HTuple& Mode, const HTuple& RefGray, const HTuple& Threshold)

HRegion HImage::ExpandGrayRef(const HRegion& Regions, const HRegion& ForbiddenArea, const HTuple& Iterations, const HString& Mode, const HTuple& RefGray, const HTuple& Threshold) const

HRegion HImage::ExpandGrayRef(const HRegion& Regions, const HRegion& ForbiddenArea, const HString& Iterations, const HString& Mode, Hlong RefGray, Hlong Threshold) const

HRegion HImage::ExpandGrayRef(const HRegion& Regions, const HRegion& ForbiddenArea, const char* Iterations, const char* Mode, Hlong RefGray, Hlong Threshold) const

HRegion HImage::ExpandGrayRef(const HRegion& Regions, const HRegion& ForbiddenArea, const wchar_t* Iterations, const wchar_t* Mode, Hlong RefGray, Hlong Threshold) const   (Nur Windows)

HRegion HRegion::ExpandGrayRef(const HImage& Image, const HRegion& ForbiddenArea, const HTuple& Iterations, const HString& Mode, const HTuple& RefGray, const HTuple& Threshold) const

HRegion HRegion::ExpandGrayRef(const HImage& Image, const HRegion& ForbiddenArea, const HString& Iterations, const HString& Mode, Hlong RefGray, Hlong Threshold) const

HRegion HRegion::ExpandGrayRef(const HImage& Image, const HRegion& ForbiddenArea, const char* Iterations, const char* Mode, Hlong RefGray, Hlong Threshold) const

HRegion HRegion::ExpandGrayRef(const HImage& Image, const HRegion& ForbiddenArea, const wchar_t* Iterations, const wchar_t* Mode, Hlong RefGray, Hlong Threshold) const   (Nur Windows)

static void HOperatorSet.ExpandGrayRef(HObject regions, HObject image, HObject forbiddenArea, out HObject regionExpand, HTuple iterations, HTuple mode, HTuple refGray, HTuple threshold)

HRegion HImage.ExpandGrayRef(HRegion regions, HRegion forbiddenArea, HTuple iterations, string mode, HTuple refGray, HTuple threshold)

HRegion HImage.ExpandGrayRef(HRegion regions, HRegion forbiddenArea, string iterations, string mode, int refGray, int threshold)

HRegion HRegion.ExpandGrayRef(HImage image, HRegion forbiddenArea, HTuple iterations, string mode, HTuple refGray, HTuple threshold)

HRegion HRegion.ExpandGrayRef(HImage image, HRegion forbiddenArea, string iterations, string mode, int refGray, int threshold)

def expand_gray_ref(regions: HObject, image: HObject, forbidden_area: HObject, iterations: Union[int, str], mode: str, ref_gray: MaybeSequence[int], threshold: MaybeSequence[int]) -> HObject

Beschreibung

expand_gray_refexpand_gray_refExpandGrayRefExpandGrayRefExpandGrayRefexpand_gray_ref dient dazu, Lücken zwischen den Eingaberegionen, wie sie z.B. durch Unterdrückung zu kleiner Regionen nach einer Bildsegmentierung entstehen, zu schließen (Modus 'image'"image""image""image""image""image") oder überlappende Regionen zu trennen (Modus 'region'"region""region""region""region""region"). Beide Effekte beruhen auf der Expansion von Regionen. Dabei werden bei jeder Iteration der Expansion die Bildpunkte innerhalb eines 1-Punkt breiten Streifens um die Region zu dieser hinzugefügt, deren Grau- bzw. Farbwerte sich vom übergebenen Referenzgrauwert der Region um höchstens ThresholdThresholdThresholdThresholdthresholdthreshold (je Kanal) unterscheiden. Bei Bildern vom Typ 'cyclic'"cyclic""cyclic""cyclic""cyclic""cyclic" (z.B. Richtungsbilder) werden auch Bildpunkte mit einer Grauwertdifferenz von mindestens 255 - ThresholdThresholdThresholdThresholdthresholdthreshold zur Region hinzugenommen.

Expandiert wird dabei nur in Bildbereiche, die nicht als „verbotene Bereiche“ (Parameter ForbiddenAreaForbiddenAreaForbiddenAreaForbiddenAreaforbiddenAreaforbidden_area) ausgewiesen sind. Die Zahl der Iterationen wird mit dem Parameter IterationsIterationsIterationsIterationsiterationsiterations festgelegt. Die Übergabe des strings 'maximal'"maximal""maximal""maximal""maximal""maximal" veranlasst bei expand_gray_refexpand_gray_refExpandGrayRefExpandGrayRefExpandGrayRefexpand_gray_ref, das Verfahren so lange zu iterieren, bis es konvergiert, also keine Änderungen mehr auftreten. Eine 0 auf dieser Parameterposition bewirkt die Ausgabe der nicht-überlappenden Teilregionen. Im Detail unterscheiden sich die beiden Modi 'image'"image""image""image""image""image" und 'region'"region""region""region""region""region" wie folgt:

'image'

Die Eingaberegionen werden iterativ so lange ausgedehnt, bis sie eine andere Region oder einen Bildrand berühren (bzw. das Wachstum aufgrund zu hoher Grauwertdifferenzen zum Stillstand kommt). Da expand_gray_refexpand_gray_refExpandGrayRefExpandGrayRefExpandGrayRefexpand_gray_ref alle Regionen simultan bearbeitet, werden die „Lücken“ zwischen den Regionen „gerecht“ auf Regionen mit ähnlichem Grau- oder Farbwert verteilt. Überlappende Regionen werden getrennt, indem ihre gemeinsamen Teilregionen (wiederum „gerecht“) auf sie verteilt werden.

'region'

Es wird keine Expansion der Eingaberegionen durchgeführt, sondern es werden nur überlappende Bildregionen getrennt, indem die gemeinsamen Teilregionen „gerecht“ auf die bzgl. Grau- bzw. Farbwert passende Regionen aufgeteilt werden.

Achtung

Da Regionen nur in Bereiche mit passenden Grau- bzw. Farbwerten expandiert werden, bleiben im allgemeinen Lücken zwischen den Ausgaberegionen bestehen. Die Segmentierung der Bildebene ist also nicht total.

Ausführungsinformationen

Parameter

RegionsRegionsRegionsRegionsregionsregions (input_object)  region(-array) objectHRegionHObjectHRegionHobject

Regionen, zwischen denen Lücken geschlossen oder die getrennt werden sollen.

ImageImageImageImageimageimage (input_object)  (multichannel-)image objectHImageHObjectHImageHobject (byte / cyclic)

Bild (evtl. mehrkanalig) für Graustufen- bzw. Farbtest.

ForbiddenAreaForbiddenAreaForbiddenAreaForbiddenAreaforbiddenAreaforbidden_area (input_object)  region objectHRegionHObjectHRegionHobject

In diesen Bereich darf nicht expandiert werden.

RegionExpandRegionExpandRegionExpandRegionExpandregionExpandregion_expand (output_object)  region(-array) objectHRegionHObjectHRegionHobject *

Expandierte oder getrennte Regionen.

IterationsIterationsIterationsIterationsiterationsiterations (input_control)  string HTupleUnion[int, str]HTupleHtuple (string / integer) (string / int / long) (HString / Hlong) (char* / Hlong)

Zahl der Iterationen.

Defaultwert: 'maximal' "maximal" "maximal" "maximal" "maximal" "maximal"

Wertevorschläge: 'maximal'"maximal""maximal""maximal""maximal""maximal", 1, 2, 3, 4, 5, 7, 10, 15, 20, 30, 50, 70, 100, 150, 200, 300, 500

Typischer Wertebereich: 1 ≤ Iterations Iterations Iterations Iterations iterations iterations ≤ 500 (lin)

Minimale Schrittweite: 1

Empfohlene Schrittweite: 1

ModeModeModeModemodemode (input_control)  string HTuplestrHTupleHtuple (string) (string) (HString) (char*)

Gewünschter Modus.

Defaultwert: 'image' "image" "image" "image" "image" "image"

Werteliste: 'image'"image""image""image""image""image", 'region'"region""region""region""region""region"

RefGrayRefGrayRefGrayRefGrayrefGrayref_gray (input_control)  integer(-array) HTupleMaybeSequence[int]HTupleHtuple (integer) (int / long) (Hlong) (Hlong)

Referenzgrauwert.

Defaultwert: 128

Wertevorschläge: 1, 10, 20, 50, 100, 128, 200, 255

Typischer Wertebereich: 1 ≤ RefGray RefGray RefGray RefGray refGray ref_gray ≤ 255 (lin)

Minimale Schrittweite: 1

Empfohlene Schrittweite: 10

ThresholdThresholdThresholdThresholdthresholdthreshold (input_control)  integer(-array) HTupleMaybeSequence[int]HTupleHtuple (integer) (int / long) (Hlong) (Hlong)

Maximalabweichung zwischen Referenzgrauwert und Kandidaten für die Expansion.

Defaultwert: 32

Wertevorschläge: 4, 10, 15, 20, 25, 30, 40

Typischer Wertebereich: 1 ≤ Threshold Threshold Threshold Threshold threshold threshold ≤ 255 (lin)

Minimale Schrittweite: 1

Empfohlene Schrittweite: 5

Beispiel (C++ (HALCON 5.0-10.0))

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

int main (int argc, char *argv[])
{
  HImage   image (argv[1]);
  HRegion  empty_region;
  HWindow  win;

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

  image.Display (win);

  HRegionArray seg = (image >= 100).Connection ();
  seg.Display (win);

  Tuple iter = "maximal";
  Tuple mode = "image";
  Tuple refg = 128;
  Tuple thrs = 32;

  HRegionArray exp = seg.ExpandGrayRef (image, empty_region,
                                        iter, mode, refg, thrs);
  exp.Display (win);
  win.Click ();

  return (0);
}

Beispiel (C)

read_image(&Image,"fabrik");
disp_image(Image,WindowHandle);
regiongrowing(Image,&RawSegments,3,3,6.0,100);
set_colored(WindowHandle,12);
disp_region(RawSegments,WindowHandle);
T_intensity(RawSegments,Image,&Mean,NULL);
set_i(Thresh,24,0);
set_s(Iter,"maximal",0);
set_s(Mode,"image",0);
T_expand_gray_ref(RawSegments,Image,EMPTY_REGION,&Segments,Iter,Mode,
               Mean,Thresh);
disp_region(Segments,WindowHandle);

Beispiel (C++ (HALCON 5.0-10.0))

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

int main (int argc, char *argv[])
{
  HImage   image (argv[1]);
  HRegion  empty_region;
  HWindow  win;

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

  image.Display (win);

  HRegionArray seg = (image >= 100).Connection ();
  seg.Display (win);

  Tuple iter = "maximal";
  Tuple mode = "image";
  Tuple refg = 128;
  Tuple thrs = 32;

  HRegionArray exp = seg.ExpandGrayRef (image, empty_region,
                                        iter, mode, refg, thrs);
  exp.Display (win);
  win.Click ();

  return (0);
}

Beispiel (C++ (HALCON 5.0-10.0))

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

int main (int argc, char *argv[])
{
  HImage   image (argv[1]);
  HRegion  empty_region;
  HWindow  win;

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

  image.Display (win);

  HRegionArray seg = (image >= 100).Connection ();
  seg.Display (win);

  Tuple iter = "maximal";
  Tuple mode = "image";
  Tuple refg = 128;
  Tuple thrs = 32;

  HRegionArray exp = seg.ExpandGrayRef (image, empty_region,
                                        iter, mode, refg, thrs);
  exp.Display (win);
  win.Click ();

  return (0);
}

Beispiel (C++ (HALCON 5.0-10.0))

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

int main (int argc, char *argv[])
{
  HImage   image (argv[1]);
  HRegion  empty_region;
  HWindow  win;

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

  image.Display (win);

  HRegionArray seg = (image >= 100).Connection ();
  seg.Display (win);

  Tuple iter = "maximal";
  Tuple mode = "image";
  Tuple refg = 128;
  Tuple thrs = 32;

  HRegionArray exp = seg.ExpandGrayRef (image, empty_region,
                                        iter, mode, refg, thrs);
  exp.Display (win);
  win.Click ();

  return (0);
}

Ergebnis

expand_gray_refexpand_gray_refExpandGrayRefExpandGrayRefExpandGrayRefexpand_gray_ref liefert normalerweise den Wert TRUE. Das Verhalten bei leerer Eingabe (keine Eingabebilder vorhanden) lässt sich mittels set_system('no_object_result',<Result>)set_system("no_object_result",<Result>)SetSystem("no_object_result",<Result>)SetSystem("no_object_result",<Result>)SetSystem("no_object_result",<Result>)set_system("no_object_result",<Result>), das bei leerer Region mit set_system('empty_region_result',<Result>)set_system("empty_region_result",<Result>)SetSystem("empty_region_result",<Result>)SetSystem("empty_region_result",<Result>)SetSystem("empty_region_result",<Result>)set_system("empty_region_result",<Result>), und das bei leerer Ergebnisregion mit set_system('store_empty_region',<'2 (H_MSG_TRUE)'/'3 (H_MSG_FALSE)'>)set_system("store_empty_region",<"2 (H_MSG_TRUE)"/"3 (H_MSG_FALSE)">)SetSystem("store_empty_region",<"2 (H_MSG_TRUE)"/"3 (H_MSG_FALSE)">)SetSystem("store_empty_region",<"2 (H_MSG_TRUE)"/"3 (H_MSG_FALSE)">)SetSystem("store_empty_region",<"2 (H_MSG_TRUE)"/"3 (H_MSG_FALSE)">)set_system("store_empty_region",<"2 (H_MSG_TRUE)"/"3 (H_MSG_FALSE)">) festlegen. Gegebenenfalls wird eine Fehlerbehandlung durchgeführt.

Vorgänger

connectionconnectionConnectionConnectionConnectionconnection, regiongrowingregiongrowingRegiongrowingRegiongrowingRegiongrowingregiongrowing, pouringpouringPouringPouringPouringpouring, class_ndim_normclass_ndim_normClassNdimNormClassNdimNormClassNdimNormclass_ndim_norm

Nachfolger

select_shapeselect_shapeSelectShapeSelectShapeSelectShapeselect_shape

Siehe auch

expand_grayexpand_grayExpandGrayExpandGrayExpandGrayexpand_gray, expand_regionexpand_regionExpandRegionExpandRegionExpandRegionexpand_region

Modul

Foundation