ClassesClassesClassesClasses | | | | Operators

area_centerarea_centerAreaCenterarea_centerAreaCenterAreaCenter (Operator)

Name

area_centerarea_centerAreaCenterarea_centerAreaCenterAreaCenter — Area and center of regions.

Signature

area_center(Regions : : : Area, Row, Column)

Herror area_center(const Hobject Regions, Hlong* Area, double* Row, double* Column)

Herror T_area_center(const Hobject Regions, Htuple* Area, Htuple* Row, Htuple* Column)

Herror area_center(Hobject Regions, Hlong* Area, double* Row, double* Column)

Herror area_center(Hobject Regions, HTuple* Area, HTuple* Row, HTuple* Column)

Hlong HRegion::AreaCenter(double* Row, double* Column) const

HTuple HRegionArray::AreaCenter(HTuple* Row, HTuple* Column) const

void AreaCenter(const HObject& Regions, HTuple* Area, HTuple* Row, HTuple* Column)

HTuple HRegion::AreaCenter(HTuple* Row, HTuple* Column) const

Hlong HRegion::AreaCenter(double* Row, double* Column) const

void HOperatorSetX.AreaCenter(
[in] IHUntypedObjectX* Regions, [out] VARIANT* Area, [out] VARIANT* Row, [out] VARIANT* Column)

VARIANT HRegionX.AreaCenter(
[out] VARIANT* Row, [out] VARIANT* Column)

static void HOperatorSet.AreaCenter(HObject regions, out HTuple area, out HTuple row, out HTuple column)

HTuple HRegion.AreaCenter(out HTuple row, out HTuple column)

int HRegion.AreaCenter(out double row, out double column)

Description

The operator area_centerarea_centerAreaCenterarea_centerAreaCenterAreaCenter calculates the area and the center of the input regions. The area is defined as the number of pixels of a region. The center is calculated as the mean value of the line or column coordinates, respectively, of all pixels.

If more than one region is passed the results are stored in tuples, the index of a value in the tuple corresponding to the index of the input region. In case of empty region all parameters have the value 0.0 if no other behavior was set (see set_systemset_systemSetSystemset_systemSetSystemSetSystem).

Parallelization

Parameters

RegionsRegionsRegionsRegionsRegionsregions (input_object)  region(-array) objectHRegionHRegionHRegionHRegionXHobject

Region(s) to be examined.

AreaAreaAreaAreaAreaarea (output_control)  integer(-array) HTupleHTupleHTupleVARIANTHtuple (integer) (int / long) (Hlong) (Hlong) (Hlong) (Hlong)

Area of the region.

RowRowRowRowRowrow (output_control)  point.y(-array) HTupleHTupleHTupleVARIANTHtuple (real) (double) (double) (double) (double) (double)

Line index of the center.

ColumnColumnColumnColumnColumncolumn (output_control)  point.x(-array) HTupleHTupleHTupleVARIANTHtuple (real) (double) (double) (double) (double) (double)

Column index of the center.

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

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

main()
{
  Tuple   area, row, column;

  HImage   img ("monkey");
  HWindow  w;

  img.Display (w);
  w.Click ();

  HRegionArray   reg = (img >= 164).Connection ();

  reg.Display (w);
  w.Click ();

  area = reg.AreaCenter (&row, &column);

  for (int i = 0; i < reg.Num (); i++)
  {
    cout << "Row    [" << i << "]" << "= " << row[i].D ();
    cout << "\t\tColumn [" << i << "]" << "= " << column[i].D () << endl;
  }

  cout << "Total number of regions: " << reg.Num () << endl;
  return(0);
}

Example (C)

threshold(&Image,&Seg,120.0,255.0);
connection(Seg,&Connected);
T_area_center(Connected,&Area,&Row,&Column);

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

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

main()
{
  Tuple   area, row, column;

  HImage   img ("monkey");
  HWindow  w;

  img.Display (w);
  w.Click ();

  HRegionArray   reg = (img >= 164).Connection ();

  reg.Display (w);
  w.Click ();

  area = reg.AreaCenter (&row, &column);

  for (int i = 0; i < reg.Num (); i++)
  {
    cout << "Row    [" << i << "]" << "= " << row[i].D ();
    cout << "\t\tColumn [" << i << "]" << "= " << column[i].D () << endl;
  }

  cout << "Total number of regions: " << reg.Num () << endl;
  return(0);
}

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

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

main()
{
  Tuple   area, row, column;

  HImage   img ("monkey");
  HWindow  w;

  img.Display (w);
  w.Click ();

  HRegionArray   reg = (img >= 164).Connection ();

  reg.Display (w);
  w.Click ();

  area = reg.AreaCenter (&row, &column);

  for (int i = 0; i < reg.Num (); i++)
  {
    cout << "Row    [" << i << "]" << "= " << row[i].D ();
    cout << "\t\tColumn [" << i << "]" << "= " << column[i].D () << endl;
  }

  cout << "Total number of regions: " << reg.Num () << endl;
  return(0);
}

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

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

main()
{
  Tuple   area, row, column;

  HImage   img ("monkey");
  HWindow  w;

  img.Display (w);
  w.Click ();

  HRegionArray   reg = (img >= 164).Connection ();

  reg.Display (w);
  w.Click ();

  area = reg.AreaCenter (&row, &column);

  for (int i = 0; i < reg.Num (); i++)
  {
    cout << "Row    [" << i << "]" << "= " << row[i].D ();
    cout << "\t\tColumn [" << i << "]" << "= " << column[i].D () << endl;
  }

  cout << "Total number of regions: " << reg.Num () << endl;
  return(0);
}

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

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

main()
{
  Tuple   area, row, column;

  HImage   img ("monkey");
  HWindow  w;

  img.Display (w);
  w.Click ();

  HRegionArray   reg = (img >= 164).Connection ();

  reg.Display (w);
  w.Click ();

  area = reg.AreaCenter (&row, &column);

  for (int i = 0; i < reg.Num (); i++)
  {
    cout << "Row    [" << i << "]" << "= " << row[i].D ();
    cout << "\t\tColumn [" << i << "]" << "= " << column[i].D () << endl;
  }

  cout << "Total number of regions: " << reg.Num () << endl;
  return(0);
}

Complexity

If F is the area of a region the mean runtime complexity is O(sqrt(F)).

Result

The operator area_centerarea_centerAreaCenterarea_centerAreaCenterAreaCenter returns the value 2 (H_MSG_TRUE) if the input is not empty. The behavior in case of empty input (no input regions available) is set via the operator 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>). The behavior in case of empty region (the region is the empty set) is set via set_system('empty_region_result',<Result>)set_system("empty_region_result",<Result>)SetSystem("empty_region_result",<Result>)set_system("empty_region_result",<Result>)SetSystem("empty_region_result",<Result>)SetSystem("empty_region_result",<Result>). If necessary an exception is raised.

Possible Predecessors

thresholdthresholdThresholdthresholdThresholdThreshold, regiongrowingregiongrowingRegiongrowingregiongrowingRegiongrowingRegiongrowing, connectionconnectionConnectionconnectionConnectionConnection

See also

select_shapeselect_shapeSelectShapeselect_shapeSelectShapeSelectShape

Module

Foundation


ClassesClassesClassesClasses | | | | Operators