contlength contlength Contlength Contlength contlength (算子名称)
名称
contlength contlength Contlength Contlength contlength — Contour length of a region.
参数签名
def contlength (区域 : HObject) -> Sequence[float]
def contlength_s (区域 : HObject) -> float
描述
该算子 contlength contlength Contlength Contlength Contlength contlength calculates the total length of the contour
(sum of all connection components of the region) for each region of
区域 区域 区域 区域 区域 区域 . The distance between two neighboring contour
points parallel to the coordinate axes is rated 1, the distance in the diagonal
is rated
.
In the documentation of this chapter (Regions / Features ), you can
find an image illustrating regions which vary in the length of their
contours.
If more than one region is passed the numerical values of the
contour length are stored in a tuple, the position of a value in the tuple
corresponding to the position of the region in the input tuple. In case of an
empty region 该算子 contlength contlength Contlength Contlength Contlength contlength 返回值 0.
注意
The contour of holes is not calculated.
运行信息
多线程类型:可重入(与非独占操作符并行运行)。
多线程作用域:全局(可以从任何线程调用)。
在元组级别自动并行化。
参数表
区域 区域 区域 区域 区域 区域 (input_object) region(-array) → object HRegion HObject HRegion Hobject
Region(s) to be examined.
ContLength ContLength ContLength ContLength contLength cont_length (output_control) real(-array) → HTuple Sequence[float] HTuple Htuple (real) (double ) (double ) (double )
Contour length of the input region(s).
Assertion:
ContLength >= 0
Example (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(®);
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);
}
Example (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(®);
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);
}
Example (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(®);
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);
}
Example (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(®);
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);
}
Example (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(®);
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);
}
结果
该算子 contlength contlength Contlength Contlength Contlength contlength 返回值 2 (
H_MSG_TRUE )
if the input is not empty.
The behavior in case of empty input (no input regions available) is
set via 该算子 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>) .
If necessary an exception is raised.
可能的前置算子
threshold threshold Threshold Threshold Threshold threshold ,
regiongrowing regiongrowing Regiongrowing Regiongrowing Regiongrowing regiongrowing ,
connection connection Connection Connection Connection connection
可能的后置算子
get_region_contour get_region_contour GetRegionContour GetRegionContour GetRegionContour get_region_contour
可替代算子
compactness compactness Compactness Compactness Compactness compactness
参考其它
area_center area_center AreaCenter AreaCenter AreaCenter area_center ,
get_region_contour get_region_contour GetRegionContour GetRegionContour GetRegionContour get_region_contour
模块
Foundation