如何解决Halcon-获得分行的分数
我需要找到具有许多分支的形状。但是仅靠region_features我无法完成这项工作。
基本上,我需要一个“分支因子”的分数。例如,一颗星星的得分较高,因为每个尖端都是一个分支。高得分,因为它有很多较小的分支。.球体或立方体的得分很低,因为它没有很多分支。
我尝试过使用面积和周长之间的比例,但是它不够精确。
这里有2个样本..一个样本应具有较高的分数,而另一个样本应具有较低的分数:
这些只是解释分支的意思的示例。.形状可以具有任何形式..
解决方法
不,没有这种参数。
也许您可以使用以下代码提取此参数:
* 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
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。