我想从一组区域中选择最大的区域(ConnectedRegions
在这种情况下)。
threshold (Image, Region, 250, 255)
connection (Region, ConnectedRegions)
* TODO: Get the largest region in ConnectedRegions
实现这一目标的优雅方法是什么?
我想从一组区域中选择最大的区域(ConnectedRegions
在这种情况下)。
threshold (Image, Region, 250, 255)
connection (Region, ConnectedRegions)
* TODO: Get the largest region in ConnectedRegions
实现这一目标的优雅方法是什么?
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)