circularity circularity Circularity Circularity circularity (算子)
名称
circularity circularity Circularity Circularity circularity — 区域圆形度(与圆的相似性)的形状系数。
签名
def circularity (regions : HObject) -> Sequence[float]
def circularity_s (regions : HObject) -> float
描述
算子 circularity circularity Circularity Circularity Circularity circularity calculates the similarity of
the input region with a circle.
Calculation:
If F is the area of the region and max is the maximum distance from
the center to all contour pixels, the shape factor C
is defined as:
C = min(1,C')
The shape factor C of a circle is 1. If the region
is long or has holes, C is smaller than 1.
The operator circularity circularity Circularity Circularity Circularity circularity especially responds to large bulges,
holes and unconnected regions. The value of C is clipped to 1.0,
because the pixel area of a region can only be an approximation of a
real circle's area. This approximation error is bigger for small
regions than for large regions.
In the documentation of this chapter (Regions / Features ), you can
find an image illustrating regions which vary in their circularity.
In case of an empty region the operator circularity circularity Circularity Circularity Circularity circularity returns the
value 0 (if no other behavior was set (see set_system set_system SetSystem SetSystem SetSystem set_system )).
If more than one region is passed the numerical values of the shape
factor are stored in a tuple, the position of a value in the tuple corresponding
to the position of the region in the input tuple.
执行信息
多线程类型:可重入(与非独占算子并行运行)。
多线程作用域:全局(可从任何线程调用)。
在元组级别上自动并行化。
参数
Regions Regions Regions Regions regions regions (输入对象) region(-array) → object HRegion HObject HRegion Hobject
待检查的区域。
Circularity Circularity Circularity Circularity circularity circularity (输出控制) real(-array) → HTuple Sequence[float] HTuple Htuple (real) (double ) (double ) (double )
Circularity of the input region(s).
Assertion:
0 <= Circularity && Circularity <= 1.0
示例(HDevelop)
* Comparison between shape factors of rectangle, circle and ellipse:
gen_rectangle1(R1,10,10,20,20)
gen_rectangle2(R2,100,100,0.0,100,20)
gen_ellipse(E100,100,100,0.0,100,20)
gen_circle(C,100,100,20)
circularity(R1,M_R1)
circularity(R2,M_R2)
circularity(E100,M_E)
circularity(C,M_C)
fwrite_string(FileId,['quadrate: ',M_R1])
fnew_line(FileId)
fwrite_string(FileId,['rectangle: ',M_R2])
fnew_line(FileId)
fwrite_string(FileId,['ellipse: ',M_E])
fnew_line(FileId)
fwrite_string(FileId,['circle: ',M_C])
fnew_line(FileId)
示例(C)
/* Comparison between shape factors of rectangle, circle and ellipse */
gen_rectangle1(&R1,10.0,10.0,20.0,20.0);
gen_rectangle2(&R2,100.0,100.0,0.0,100.0,20.0);
gen_ellipse(&E,100.0,100.0,0.0,100.0,20.0);
gen_circle(&C,100.0,100.0,20.0);
circularity(R1,&R1_);
circularity(R2,&R2_);
circularity(E,&E_);
circularity(C,&C_);
printf("quadrate: %g\n",R1_);
printf("rectangle: %g\n",R2_);
printf("ellipse: %g\n",E_);
printf("circle: %g\n",C_);
示例(HDevelop)
* Comparison between shape factors of rectangle, circle and ellipse:
gen_rectangle1(R1,10,10,20,20)
gen_rectangle2(R2,100,100,0.0,100,20)
gen_ellipse(E100,100,100,0.0,100,20)
gen_circle(C,100,100,20)
circularity(R1,M_R1)
circularity(R2,M_R2)
circularity(E100,M_E)
circularity(C,M_C)
fwrite_string(FileId,['quadrate: ',M_R1])
fnew_line(FileId)
fwrite_string(FileId,['rectangle: ',M_R2])
fnew_line(FileId)
fwrite_string(FileId,['ellipse: ',M_E])
fnew_line(FileId)
fwrite_string(FileId,['circle: ',M_C])
fnew_line(FileId)
示例(HDevelop)
* Comparison between shape factors of rectangle, circle and ellipse:
gen_rectangle1(R1,10,10,20,20)
gen_rectangle2(R2,100,100,0.0,100,20)
gen_ellipse(E100,100,100,0.0,100,20)
gen_circle(C,100,100,20)
circularity(R1,M_R1)
circularity(R2,M_R2)
circularity(E100,M_E)
circularity(C,M_C)
fwrite_string(FileId,['quadrate: ',M_R1])
fnew_line(FileId)
fwrite_string(FileId,['rectangle: ',M_R2])
fnew_line(FileId)
fwrite_string(FileId,['ellipse: ',M_E])
fnew_line(FileId)
fwrite_string(FileId,['circle: ',M_C])
fnew_line(FileId)
示例(HDevelop)
* Comparison between shape factors of rectangle, circle and ellipse:
gen_rectangle1(R1,10,10,20,20)
gen_rectangle2(R2,100,100,0.0,100,20)
gen_ellipse(E100,100,100,0.0,100,20)
gen_circle(C,100,100,20)
circularity(R1,M_R1)
circularity(R2,M_R2)
circularity(E100,M_E)
circularity(C,M_C)
fwrite_string(FileId,['quadrate: ',M_R1])
fnew_line(FileId)
fwrite_string(FileId,['rectangle: ',M_R2])
fnew_line(FileId)
fwrite_string(FileId,['ellipse: ',M_E])
fnew_line(FileId)
fwrite_string(FileId,['circle: ',M_C])
fnew_line(FileId)
结果
算子 circularity circularity Circularity Circularity Circularity circularity 在输入不为空时返回值 2 ( H_MSG_TRUE )。当输入为空(无可用输入区域)时,可设置行为通过算子 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>) 。空区域(区域是空集)的情况下的可设置行为通过
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>) 。如有必要,则抛出异常。
可能的前趋
threshold threshold Threshold Threshold Threshold threshold ,
regiongrowing regiongrowing Regiongrowing Regiongrowing Regiongrowing regiongrowing ,
connection connection Connection Connection Connection connection
替代
roundness roundness Roundness Roundness Roundness roundness ,
compactness compactness Compactness Compactness Compactness compactness ,
convexity convexity Convexity Convexity Convexity convexity ,
eccentricity eccentricity Eccentricity Eccentricity Eccentricity eccentricity
另见
area_center area_center AreaCenter AreaCenter AreaCenter area_center ,
select_shape select_shape SelectShape SelectShape SelectShape select_shape
模块
基础