expand_gray_refexpand_gray_refExpandGrayRefExpandGrayRef (Operator)

Name

expand_gray_refexpand_gray_refExpandGrayRefExpandGrayRef — 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)

Beschreibung

expand_gray_refexpand_gray_refExpandGrayRefExpandGrayRefExpandGrayRef dient dazu, Lücken zwischen den Eingaberegionen, wie sie z.B. durch Unterdrückung zu kleiner Regionen nach einer Bildsegmentation entstehen, zu schließen (Modus 'image'"image""image""image""image") oder überlappende Regionen zu trennen (Modus '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 ThresholdThresholdThresholdThresholdthreshold (je Kanal) unterscheiden. Bei Bildern vom Typ 'cyclic'"cyclic""cyclic""cyclic""cyclic" (z.B. Richtungsbilder) werden auch Bildpunkte mit einer Grauwertdifferenz von mindestens 255 - ThresholdThresholdThresholdThresholdthreshold zur Region hinzugenommen.

Expandiert wird dabei nur in Bildbereiche, die nicht als „verbotene Bereiche“ (Parameter ForbiddenAreaForbiddenAreaForbiddenAreaForbiddenAreaforbiddenArea) ausgewiesen sind. Die Zahl der Iterationen wird mit dem Parameter IterationsIterationsIterationsIterationsiterations festgelegt. Die Übergabe des strings 'maximal'"maximal""maximal""maximal""maximal" veranlasst bei expand_gray_refexpand_gray_refExpandGrayRefExpandGrayRefExpandGrayRef, 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" und '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_refExpandGrayRefExpandGrayRefExpandGrayRef 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 Segmentation der Bildebene ist also nicht total.

Ausführungsinformationen

Parameter

RegionsRegionsRegionsRegionsregions (input_object)  region(-array) objectHRegionHRegionHobject

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

ImageImageImageImageimage (input_object)  (multichannel-)image objectHImageHImageHobject (byte / cyclic)

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

ForbiddenAreaForbiddenAreaForbiddenAreaForbiddenAreaforbiddenArea (input_object)  region objectHRegionHRegionHobject

In diesen Bereich darf nicht expandiert werden.

RegionExpandRegionExpandRegionExpandRegionExpandregionExpand (output_object)  region(-array) objectHRegionHRegionHobject *

Expandierte oder getrennte Regionen.

IterationsIterationsIterationsIterationsiterations (input_control)  string HTupleHTupleHtuple (string / integer) (string / int / long) (HString / Hlong) (char* / Hlong)

Zahl der Iterationen.

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

Wertevorschläge: '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 ≤ 500 (lin)

Minimale Schrittweite: 1

Empfohlene Schrittweite: 1

ModeModeModeModemode (input_control)  string HTupleHTupleHtuple (string) (string) (HString) (char*)

Gewünschter Modus.

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

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

RefGrayRefGrayRefGrayRefGrayrefGray (input_control)  integer(-array) HTupleHTupleHtuple (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 ≤ 255 (lin)

Minimale Schrittweite: 1

Empfohlene Schrittweite: 10

ThresholdThresholdThresholdThresholdthreshold (input_control)  integer(-array) HTupleHTupleHtuple (integer) (int / long) (Hlong) (Hlong)

Maximalabweichung zwischen Referenzgrauwert und Kanditaten für die Expansion.

Defaultwert: 32

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

Typischer Wertebereich: 1 ≤ 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_refExpandGrayRefExpandGrayRefExpandGrayRef liefert normalerweise den Wert 2 (H_MSG_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>), 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>), und das bei leerer Ergebnisregion mit set_system('store_empty_region',<'true'/'false'>)set_system("store_empty_region",<"true"/"false">)SetSystem("store_empty_region",<"true"/"false">)SetSystem("store_empty_region",<"true"/"false">)SetSystem("store_empty_region",<"true"/"false">) festlegen. Gegebenenfalls wird eine Fehlerbehandlung durchgeführt.

Vorgänger

connectionconnectionConnectionConnectionConnection, regiongrowingregiongrowingRegiongrowingRegiongrowingRegiongrowing, pouringpouringPouringPouringPouring, class_ndim_normclass_ndim_normClassNdimNormClassNdimNormClassNdimNorm

Nachfolger

select_shapeselect_shapeSelectShapeSelectShapeSelectShape

Siehe auch

expand_grayexpand_grayExpandGrayExpandGrayExpandGray, expand_regionexpand_regionExpandRegionExpandRegionExpandRegion

Modul

Foundation