Halcon-获得分行的分数

问题描述

我需要找到具有许多分支的形状。但是仅靠region_features我无法完成这项工作。

基本上,我需要一个“分支因子”的分数。例如,一颗星星的得分较高,因为每个尖端都是一个分支。高得分,因为它有很多较小的分支。.球体或立方体的得分很低,因为它没有很多分支。

我尝试过使用面积和周长之间的比例,但是它不够精确。

这里有2个样本..一个样本应具有较高的分数,而另一个样本应具有较低的分数:

enter image description here

enter image description here

这些只是解释分支的意思的示例。.形状可以具有任何形式..

解决方法

不,没有这种参数。

也许您可以使用以下代码提取此参数:

* load image example
read_image(Image,'ppUXL.jpg')

* create 4 Regions 
binary_threshold (Image,Region,'max_separability','dark',UsedThreshold)
connection (Region,Regions)

count_obj (Regions,NumRegions)
NumBranches :=[]
* for every region in Regions
for i:=1 to NumRegions by 1    
    * select the region 
    select_obj (Regions,RegionSelected,i)

    * --------------------------------------------------------------------------
    * Here I want to calculate the region convex hull,* i.e. the smallest region convex region that contains the selected region 
    * https://en.wikipedia.org/wiki/Convex_hull 
    * --------------------------------------------------------------------------
    * convex hull of a region as polygon
    get_region_convex (RegionSelected,Rows,Columns)    
    * trasform the polygon in a region
    gen_region_polygon_filled (ConvexRegion,Columns)    

    * For avoiding to merge separeted parts,I erode a little the convex region    
    erosion_circle (ConvexRegion,RegionErosion,1.5)

    * Now I remove the selected region from its convex (erosed) region.
    * In most of the case the results is the space between the branches
    difference (RegionErosion,RegionDifference)

    * --------------------------------------------------------------------------
    * I separate the space between the branches and I count the its number    
    * --------------------------------------------------------------------------
    * connection
    connection (RegionDifference,InsideRegions)   
    * I remove empy regions
    select_shape (InsideRegions,InsideSelectedRegions,'area','and',1,99999999)
    * I count the regions
    count_obj (InsideSelectedRegions,NumInsideRegions)

    * I add the result to the array
    NumBranches :=[NumBranches,NumInsideRegions]

endfor

test.jpg

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...