0

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

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

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

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

在此处输入图像描述 在此处输入图像描述

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

4

1 回答 1

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

测试.jpg

于 2020-08-19T15:21:10.537 回答