contlengthcontlengthContlengthContlength (Operator)

Name

contlengthcontlengthContlengthContlength — Ermitteln der Konturlänge einer Region.

Signatur

contlength(Regions : : : ContLength)

Herror contlength(const Hobject Regions, double* ContLength)

Herror T_contlength(const Hobject Regions, Htuple* ContLength)

void Contlength(const HObject& Regions, HTuple* ContLength)

HTuple HRegion::Contlength() const

static void HOperatorSet.Contlength(HObject regions, out HTuple contLength)

HTuple HRegion.Contlength()

Beschreibung

contlengthcontlengthContlengthContlengthContlength berechnet für jede Region aus RegionsRegionsRegionsRegionsregions die Gesamtlänge der Kontur (Summe über alle Zusammenhangskomponenten der Region). Dabei wird der Abstand von zwei benachbarten Konturpunkten parallel zu den Koordinatenachsen mit 1, der Abstand in der Diagonalen mit bewertet.

In der Dokumentation zu diesem Kapitel (Regionen / Merkmale) finden Sie ein Bild mit Regionen, die sich in der Konturlänge unterscheiden.

Wird mehr als eine Region übergeben, dann werden die Zahlenwerte der Konturlänge in einem Tupel abgespeichert, wobei die Position eines Wertes in dem Tupel der Position einer Region im Eingabetupel entspricht. Bei einer leeren Region liefert contlengthcontlengthContlengthContlengthContlength den Wert 0.

Achtung

Die Kontur von Hohlflächen wird nicht mitgerechnet.

Ausführungsinformationen

Parameter

RegionsRegionsRegionsRegionsregions (input_object)  region(-array) objectHRegionHRegionHobject

Zu untersuchende Region(en).

ContLengthContLengthContLengthContLengthcontLength (output_control)  real(-array) HTupleHTupleHtuple (real) (double) (double) (double)

Konturlänge der Eingaberegion(en).

Zusicherung: ContLength >= 0

Beispiel (C++)

#include "HalconCpp.h"
#include <iostream>
using namespace HalconCpp;

int main (int argc, char *argv[])
{
  HWindow        w(10,10,512,512);
  HRegion        reg;
  int            NumOfElements = 3;

  std::cout << "Draw " << NumOfElements << " regions " << std::endl;
  GenEmptyObj(&reg);
  for (int i=0; i < NumOfElements; i++)
  {
    reg = reg.ConcatObj(w.DrawRegion());
  }

  HTuple circ = reg.Circularity ();
  HTuple cont = reg.Contlength ();

  for (int i = 0; i < NumOfElements; i++)
  {
    std::cout << "region " << i+1 << ": \tcircularity = " << circ[i].D() <<
                 "\tcontour length =" << cont[i].D() << std::endl;
  }
  std::cout << "Click into the graphics window to end." << std::endl;
  w.Click ();
  return(0);
}

Beispiel (C++)

#include "HalconCpp.h"
#include <iostream>
using namespace HalconCpp;

int main (int argc, char *argv[])
{
  HWindow        w(10,10,512,512);
  HRegion        reg;
  int            NumOfElements = 3;

  std::cout << "Draw " << NumOfElements << " regions " << std::endl;
  GenEmptyObj(&reg);
  for (int i=0; i < NumOfElements; i++)
  {
    reg = reg.ConcatObj(w.DrawRegion());
  }

  HTuple circ = reg.Circularity ();
  HTuple cont = reg.Contlength ();

  for (int i = 0; i < NumOfElements; i++)
  {
    std::cout << "region " << i+1 << ": \tcircularity = " << circ[i].D() <<
                 "\tcontour length =" << cont[i].D() << std::endl;
  }
  std::cout << "Click into the graphics window to end." << std::endl;
  w.Click ();
  return(0);
}

Beispiel (C++)

#include "HalconCpp.h"
#include <iostream>
using namespace HalconCpp;

int main (int argc, char *argv[])
{
  HWindow        w(10,10,512,512);
  HRegion        reg;
  int            NumOfElements = 3;

  std::cout << "Draw " << NumOfElements << " regions " << std::endl;
  GenEmptyObj(&reg);
  for (int i=0; i < NumOfElements; i++)
  {
    reg = reg.ConcatObj(w.DrawRegion());
  }

  HTuple circ = reg.Circularity ();
  HTuple cont = reg.Contlength ();

  for (int i = 0; i < NumOfElements; i++)
  {
    std::cout << "region " << i+1 << ": \tcircularity = " << circ[i].D() <<
                 "\tcontour length =" << cont[i].D() << std::endl;
  }
  std::cout << "Click into the graphics window to end." << std::endl;
  w.Click ();
  return(0);
}

Beispiel (C++)

#include "HalconCpp.h"
#include <iostream>
using namespace HalconCpp;

int main (int argc, char *argv[])
{
  HWindow        w(10,10,512,512);
  HRegion        reg;
  int            NumOfElements = 3;

  std::cout << "Draw " << NumOfElements << " regions " << std::endl;
  GenEmptyObj(&reg);
  for (int i=0; i < NumOfElements; i++)
  {
    reg = reg.ConcatObj(w.DrawRegion());
  }

  HTuple circ = reg.Circularity ();
  HTuple cont = reg.Contlength ();

  for (int i = 0; i < NumOfElements; i++)
  {
    std::cout << "region " << i+1 << ": \tcircularity = " << circ[i].D() <<
                 "\tcontour length =" << cont[i].D() << std::endl;
  }
  std::cout << "Click into the graphics window to end." << std::endl;
  w.Click ();
  return(0);
}

Beispiel (C++)

#include "HalconCpp.h"
#include <iostream>
using namespace HalconCpp;

int main (int argc, char *argv[])
{
  HWindow        w(10,10,512,512);
  HRegion        reg;
  int            NumOfElements = 3;

  std::cout << "Draw " << NumOfElements << " regions " << std::endl;
  GenEmptyObj(&reg);
  for (int i=0; i < NumOfElements; i++)
  {
    reg = reg.ConcatObj(w.DrawRegion());
  }

  HTuple circ = reg.Circularity ();
  HTuple cont = reg.Contlength ();

  for (int i = 0; i < NumOfElements; i++)
  {
    std::cout << "region " << i+1 << ": \tcircularity = " << circ[i].D() <<
                 "\tcontour length =" << cont[i].D() << std::endl;
  }
  std::cout << "Click into the graphics window to end." << std::endl;
  w.Click ();
  return(0);
}

Ergebnis

contlengthcontlengthContlengthContlengthContlength liefert den Wert 2 (H_MSG_TRUE), falls die Eingabe nicht leer ist. Das Verhalten bei leerer Eingabe (keine Eingaberegionen 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>) festlegen. Gegebenenfalls wird eine Fehlerbehandlung durchgeführt.

Vorgänger

thresholdthresholdThresholdThresholdThreshold, regiongrowingregiongrowingRegiongrowingRegiongrowingRegiongrowing, connectionconnectionConnectionConnectionConnection

Nachfolger

get_region_contourget_region_contourGetRegionContourGetRegionContourGetRegionContour

Alternativen

compactnesscompactnessCompactnessCompactnessCompactness

Siehe auch

area_centerarea_centerAreaCenterAreaCenterAreaCenter, get_region_contourget_region_contourGetRegionContourGetRegionContourGetRegionContour

Modul

Foundation