halcon - 如何在 HALCON 中选择最大的区域?
问题描述
我想从一组区域中选择最大的区域(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)
推荐阅读
- .net-core - Azure DevOps YAML - .Net Core CLI 无法使用内部工件源打包
- c# - 从soap响应中删除CDATA标签
- python - 在 Pyside2 for Python 上显示应用程序后,我们如何刷新事件?
- c# - 尝试使用多线程将大型数据集填充到组合框中时,Windows 窗体冻结?
- android - 如果手动更改日历时间,如何在 Android 中获取当前时间?
- javascript - 如何将 Id 赋予 @using (Ajax.BeginForm("Index", "Customer", FormMethod.Post, new AjaxOptions(){})){....}
- swift - 在 Cocoapod 之后,Swift 中没有这样的模块错误
- python - 通过几个函数后的参数变化 - Python
- html - 想要在视差区域上使文本 div 透明
- python - 如何将 django 模型导出到按特定列排序的 pandas 数据框