area_centerarea_centerAreaCenterAreaCenterarea_center (Operator)
名称
area_centerarea_centerAreaCenterAreaCenterarea_center — 面积和区域中心。
签名
def area_center(regions: HObject) -> Tuple[Sequence[int], Sequence[float], Sequence[float]]
def area_center_s(regions: HObject) -> Tuple[int, float, float]
描述
The operator area_centerarea_centerAreaCenterAreaCenterAreaCenterarea_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.
In the documentation of this chapter (Regions / Features), you can
find an image illustrating regions which vary in their area.
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_systemSetSystemSetSystemSetSystemset_system).
执行信息
- Multithreading type: reentrant (runs in parallel with non-exclusive operators).
- Multithreading scope: global (may be called from any thread).
- Automatically parallelized on tuple level.
参数
RegionsRegionsRegionsRegionsregionsregions (input_object) region(-array) → objectHRegionHObjectHRegionHobject
Region(s) to be examined.
AreaAreaAreaAreaareaarea (output_control) integer(-array) → HTupleSequence[int]HTupleHtuple (integer) (int / long) (Hlong) (Hlong)
Area of the region.
RowRowRowRowrowrow (output_control) point.y(-array) → HTupleSequence[float]HTupleHtuple (real) (double) (double) (double)
Line index of the center.
ColumnColumnColumnColumncolumncolumn (output_control) point.x(-array) → HTupleSequence[float]HTupleHtuple (real) (double) (double) (double)
Column index of the center.
示例 (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);
}
示例(C)
threshold(&Image,&Seg,120.0,255.0);
connection(Seg,&Connected);
T_area_center(Connected,&Area,&Row,&Column);
示例 (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);
}
示例 (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);
}
示例 (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);
}
复杂性
If F is the area of a region the mean runtime
complexity is O(sqrt(F)).
结果
The operator area_centerarea_centerAreaCenterAreaCenterAreaCenterarea_center 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>)SetSystem("no_object_result",<Result>)SetSystem("no_object_result",<Result>)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>)set_system("empty_region_result",<Result>)SetSystem("empty_region_result",<Result>)SetSystem("empty_region_result",<Result>)SetSystem("empty_region_result",<Result>)set_system("empty_region_result",<Result>).
If necessary an exception is raised.
可能的前置算子
thresholdthresholdThresholdThresholdThresholdthreshold,
regiongrowingregiongrowingRegiongrowingRegiongrowingRegiongrowingregiongrowing,
connectionconnectionConnectionConnectionConnectionconnection
另见
select_shapeselect_shapeSelectShapeSelectShapeSelectShapeselect_shape
模块
Foundation