area_center—区域的区域和中心
2022-11-13
新闻来源:网淘巴
围观:766
''
简短描述
area_center—区域的区域和中心
签名
area_center(Regions : : : Area, Row, Column)
描述
运算符area_center计算输入区域的面积和中心。面积定义为一个区域的像素数。中心分别计算为所有像素的线坐标或列坐标的平均值。
在本章的文档(区域/特征)中,你可以找到一个说明不同区域的图像。
如果传递了多个区域,则结果存储在元组中,元组中值的索引对应于输入区域的索引。在空区域的情况下,如果没有设置其他行为,所有参数的值都是0.0(参见set_system)。
参数
Regions (input_object) region(-array)→object
要检查的区域。
Area (output_control) integer(-array)→(integer)
区域的面积。
Row (output_control) point.y(-array)→(real)
中心的线索引。
列(output_control) point.x(-array)→(real)
中心的列索引。
例程
#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);
}
返回结果