KlassenKlassenKlassenKlassen | | | | Operatoren

contlengthcontlengthContlengthcontlengthContlengthContlength (Operator)

Name

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

Herror contlength(Hobject Regions, double* ContLength)

Herror contlength(Hobject Regions, HTuple* ContLength)

double HRegion::Contlength() const

HTuple HRegionArray::Contlength() const

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

HTuple HRegion::Contlength() const

void HOperatorSetX.Contlength(
[in] IHUntypedObjectX* Regions, [out] VARIANT* ContLength)

VARIANT HRegionX.Contlength()

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

HTuple HRegion.Contlength()

Beschreibung

contlengthcontlengthContlengthcontlengthContlengthContlength berechnet für jede Region aus RegionsRegionsRegionsRegionsRegionsregions 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 des Operators region_featuresregion_featuresRegionFeaturesregion_featuresRegionFeaturesRegionFeatures 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 contlengthcontlengthContlengthcontlengthContlengthContlength den Wert 0.

Achtung

Die Kontur von Hohlflächen wird nicht mitgerechnet.

Parallelisierung

Parameter

RegionsRegionsRegionsRegionsRegionsregions (input_object)  region(-array) objectHRegionHRegionHRegionHRegionXHobject

Zu untersuchende Region(en).

ContLengthContLengthContLengthContLengthContLengthcontLength (output_control)  real(-array) HTupleHTupleHTupleVARIANTHtuple (real) (double) (double) (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++ (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[])
{
  if (argc < 2)
  {
    cout << "Usage: " << argv[0] << " <# of regions> " << endl;
    return (-1);
  }

  HWindow        w;
  HRegionArray   reg;

  int NumOfElements = atoi (argv[1]);

  cout << "Draw " << NumOfElements << " regions " << endl;

  for (int i=0; i < NumOfElements; i++)
  {
    reg[i] = w.DrawRegion ();
  }

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

  for (i = 0; i < NumOfElements; i++)
  {
    cout << "Circularity of " << i+1 << ". region = " << circ[i].D();
    cout << "\t\t Contour Length of" << i+1 <<
            ". region = " << cont[i].D() << 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

contlengthcontlengthContlengthcontlengthContlengthContlength 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>)set_system("no_object_result",<Result>)SetSystem("no_object_result",<Result>)SetSystem("no_object_result",<Result>) festlegen. Gegebenenfalls wird eine Fehlerbehandlung durchgeführt.

Vorgänger

thresholdthresholdThresholdthresholdThresholdThreshold, regiongrowingregiongrowingRegiongrowingregiongrowingRegiongrowingRegiongrowing, connectionconnectionConnectionconnectionConnectionConnection

Nachfolger

get_region_contourget_region_contourGetRegionContourget_region_contourGetRegionContourGetRegionContour

Alternativen

compactnesscompactnessCompactnesscompactnessCompactnessCompactness

Siehe auch

area_centerarea_centerAreaCenterarea_centerAreaCenterAreaCenter, get_region_contourget_region_contourGetRegionContourget_region_contourGetRegionContourGetRegionContour

Modul

Foundation


KlassenKlassenKlassenKlassen | | | | Operatoren