【问题标题】:Halcon - Get a score for branchesHalcon - 获得分支分数
【发布时间】:2020-12-08 10:20:32
【问题描述】:

我需要找到有很多分支的形状。但只有 region_features 我无法完成这项工作。

基本上,我需要一个“分支因素”的分数。例如,一颗星的分数会很高,因为每个提示都是一个分支。一张树枝的图片会有一个高分,因为它有许多较小的分支。球体或立方体的得分较低,因为它没有很多分支。

我试过面积和周长的比例,但不够精确..

这里有 2 个样本.. 一个应该有高分,一个应该有低分:

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

【问题讨论】:

    标签: shapes feature-selection region halcon


    【解决方案1】:

    不,没有这种参数。

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

    * 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, Rows, 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, RegionSelected, 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
    

    【讨论】:

    • 谢谢!你能描述一下你在这里做什么吗? get_region_convex 然后 gen_region_polygon_filled 有什么用?你最终不会得到原始区域的副本吗?
    • 我添加了一些 cmets
    • 很好的答案和解决方案!谢谢!并通过侵蚀 RegionDifference 我可以选择分支的最小大小.. 对吗?
    • 不,如果你侵蚀了 RegionDifference 你只能选择彼此相距很远的分支
    猜你喜欢
    • 1970-01-01
    • 2015-08-14
    • 2022-01-04
    • 2017-12-23
    • 1970-01-01
    • 2012-07-23
    • 1970-01-01
    • 1970-01-01
    • 2023-03-29
    相关资源
    最近更新 更多