当前位置:网站首页>halcon之区域:多种区域(Region)特征(6)
halcon之区域:多种区域(Region)特征(6)
2022-06-27 20:57:00 【无水先生】
一、提要
区域的算子,初学者最好是每个都试试,这不仅是个加强映像问题,而且是了解Halcon能力的过程,以及提高工程实践效率问题。本篇介绍几个在数值图像分析中,较为有用的区域算子。请学友们共享!
二、算子和实验
2.1 区域的扩张
- expand_region(Regions, ForbiddenArea : RegionExpanded : Iterations, Mode : )
填充区域之间的间隙或拆分重叠区域。ForbiddenArea是不参与运算(保留)的区域。
- 测试代码:
read_image(Image, 'F:/images/maps/manyRegs')
rgb1_to_gray(Image,gray)
get_image_size(Image, Width, Height)
threshold(gray, Region, 0, 215)
connection(Region, ConRegions)
gen_empty_region(EmptyRegion)
expand_region(ConRegions, EmptyRegion, RegionExpanded, 'maximal', 'image')
结果显示:
先将区域分成多元组区域。
将多元组的区域进行展开,铺满整个全图区域。
2.2 从区域元组中选中index个区域
select_obj 将具有 Index 给出的索引(从 1 开始)的图标对象从图标输入对象元组 Objects 复制到输出对象 ObjectSelected。没有为区域和图像分配新的存储空间。相反,会创建包含对现有对象的引用的新对象。一个对象元组中的对象个数可以通过操作count_obj来查询。
如:取出第12个区域的个体,存入 ObjectSelected元组
select_obj (RegionExpanded, ObjectSelected,12)
2.3 区域的近邻列出
find_neighbors 功能:搜寻直接邻域。
- find_neighbors (ObjectSelected, RegionExpanded, 1, RegionIndex1, RegionIndex2)
输出 RegionIndex1, RegionIndex2存放,ObjectSelected区域的所有近邻的序号对。
参考代码:
read_image(Image, 'F:/images/maps/manyRegs')
rgb1_to_gray(Image,gray)
get_image_size(Image, Width, Height)
threshold(gray, Region, 0, 215)
connection(Region, ConRegions)
gen_empty_region(EmptyRegion)
expand_region(ConRegions, EmptyRegion, RegionExpanded, 'maximal', 'image')
select_obj (RegionExpanded, ObjectSelected,1)
find_neighbors (RegionExpanded, RegionExpanded, 3, RegionIndex1, RegionIndex2)
三、一个官方教程的例子
下面是一个官方手册上的例子,其结果是将所有区域的近邻提取出来。
read_image (Image, 'fabrik')
dev_close_window ()
dev_open_window (0, 0, 512, 512, 'black', WindowID)
dev_set_colored (6)
regiongrowing (Image, Regions, 1, 1, 3, 200)
gen_empty_region (Empty)
expand_region (Regions, Empty, RegionExpanded, 'maximal', 'image')
dev_clear_window ()
select_obj (RegionExpanded, ObjectSelected, 19)
find_neighbors (ObjectSelected, RegionExpanded, 1, RegionIndex1, RegionIndex2)
select_obj (RegionExpanded, ObjectSelected, RegionIndex2)
gen_empty_obj (NoObj)
find_neighbors (NoObj, RegionExpanded, 1, RegionIndex1, RegionIndex2)
shape_trans (RegionExpanded, RegionTrans, 'inner_center')
area_center (RegionTrans, Area, Row, Column)
stop ()
dev_clear_window ()
dev_set_colored (6)
dev_display (RegionExpanded)
dev_set_draw ('margin')
dev_set_color ('black')
dev_set_line_width (1)
dev_display (RegionExpanded)
dev_set_color ('white')
dev_set_line_width (3)
for i := 0 to |RegionIndex1| - 1 by 1
disp_line (WindowID, Row[RegionIndex1[i] - 1], Column[RegionIndex1[i] - 1], Row[RegionIndex2[i] - 1], Column[RegionIndex2[i] - 1])
endfor
参考结果:
边栏推荐
- Learn rnaseq analysis by following the archiving tutorial (I)
- Spark bug practice (including bug:classcastexception; connectexception; NoClassDefFoundError; runtimeException, etc.)
- 【剑指Offer】47. 礼物的最大价值
- Detect objects and transfer images through mqtt
- [essay]me53n add button to call URL
- 量化交易入门教程
- Fsnotify interface of go language to monitor file modification
- virtualbox扩展动态磁盘大小的坑
- Follow the archiving tutorial to learn rnaseq analysis (III): count standardization using deseq2
- 跟着存档教程动手学RNAseq分析(三):使用DESeq2进行计数标准化
猜你喜欢
The most illusory richest man in China is even more illusory
PE buys a underwear company
通过 MQTT 检测对象和传输图像
各种loam总结(激光slam)
官宣!Apache Doris 从 Apache 孵化器毕业,正式成为 Apache 顶级项目!
Spark bug practice (including bug:classcastexception; connectexception; NoClassDefFoundError; runtimeException, etc.)
Azure Kinect DK 实现三维重建 (PC非实时版)
最新云开发微信余额充电器特效小程序源码
Sentinel
Liuleifeng, a "good man in Guangzhou" in the first quarter of 2022, has a strong sense of integrity and food safety
随机推荐
[essay]me53n add button to call URL
Classification of cifar-10 dataset with pytorch
6G显卡显存不足出现CUDA Error:out of memory解决办法
Feign implements path escape through custom annotations
Advertising is too "wild", Yoshino "surrenders"
2022年PMP项目管理考试敏捷知识点(3)
电子科大(申恒涛团队)&京东AI(梅涛团队)提出用于视频问答的结构化双流注意网络,性能SOTA!优于基于双视频表示的方法!
Livox lidar+apx15 real-time high-precision radar map reproduction and sorting
C# Winform 读取Resources图片
未能加载文件或程序集“CefSharp.Core.Runtime.dll”或它的某一个依赖项。 不是有效的 Win32 应用程序。 (异常来自 HRESULT:0x800700C1)
【经典干货书】数据科学中的信息理论方法,561页pdf
Arcgis-engine二次开发之空间关系查询与按图形查询
【数字IC/FPGA】检测最后一个匹配序列的位置
How vivado adds timing constraints
[electron] 基础学习
通过 MQTT 检测对象和传输图像
云辅助隐私集合求交(Server-Aided PSI)协议介绍:学习
Livox Lidar+APX15 实时高精度雷达建图复现整理
新加坡国立大学|采用无模型强化学习方法评估能源效益数据中心的节能情况
Introduction to quantitative trading