【发布时间】:2021-03-09 12:13:55
【问题描述】:
我想从一组区域中选择最大的区域(在本例中为ConnectedRegions)。
threshold (Image, Region, 250, 255)
connection (Region, ConnectedRegions)
* TODO: Get the largest region in ConnectedRegions
有什么优雅的方法可以实现这一目标?
【问题讨论】:
标签: halcon
我想从一组区域中选择最大的区域(在本例中为ConnectedRegions)。
threshold (Image, Region, 250, 255)
connection (Region, ConnectedRegions)
* TODO: Get the largest region in ConnectedRegions
有什么优雅的方法可以实现这一目标?
【问题讨论】:
标签: halcon
select_shape_std (ConnectedRegions, MaxRegion, 'max_area', 0)
对于其他选择标准,有select_shape。
使用三个运算符,您可以解决示例中的任务:area_center、tuple_sort_index 和 select_obj
threshold (Image, Region, 250, 255)
connection (Region, ConnectedRegions)
* Get the area of each region. R and C return values are not used.
area_center (ConnectedRegions, Areas, R, C)
* Get the indices to sort the areas in descending order.
tuple_sort_index (- Areas, SortIndices)
* Select the region using the first index.
* We need to add 1, because control tuples use 0-based indexing,
* while object tuples are 1-based
select_obj (ConnectedRegions, MaxRegion, SortIndices[0] + 1)
【讨论】: