Herror ::area_center (
    Hobject Regions,
    long *Area,
    double *Row,
    double *Column
)
Herror ::area_center (
    Hobject Regions,
    HTuple *Area,
    HTuple *Row,
    HTuple *Column
)
long HRegion::AreaCenter (
    double *Row,
    double *Column
) const
HTuple HRegionArray::AreaCenter (
    HTuple *Row,
    HTuple *Column
) const

Area and center of regions.

The operator ::area_center 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_system).


Parameters

Regions (input_object)
region(-array) -> Hobject: HRegion(Array)
Region(s) to be examined.

Area (output_control)
integer(-array) -> (HTuple.) long *
Area of the region.

Row (output_control)
point.y(-array) -> (HTuple.) double *
Line index of the center.

Column (output_control)
point.x(-array) -> (HTuple.) double *
Column index of the center.


Example
#include  <iostream.h>
#include  "HalconCpp.h"

main()
{
  Tuple   area, row, column;

  HImage   img ("affe");
  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(F).


Result

The operator ::area_center returns the value 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>). The behavior in case of empty region (the region is the empty set) is set via ::set_system('empty_region_result',<Result>). If necessary an exception handling is raised.


Possible Predecessors

::threshold, ::regiongrowing, ::connection


See also

::select_shape


Module

Region processing



Copyright © 1996-2002 MVTec Software GmbH