当前位置:网站首页>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参考结果:

边栏推荐
- Discuz taobaoke website template / Dean taobaoke shopping style commercial version template
- Stream + Nacos
- 支持删除,更新任意结点的优先级队列
- Spark BUG實踐(包含的BUG:ClassCastException;ConnectException;NoClassDefFoundError;RuntimeExceptio等。。。。)
- Realization of kaggle cat dog recognition by pytorch
- Swing UI container (I)
- Typora 1.2.5等版本下载
- 最新云开发微信余额充电器特效小程序源码
- Livox Lidar+APX15 实时高精度雷达建图复现整理
- 因美纳陷数据泄露“丑闻”:我国基因数据安全能交给美企吗?
猜你喜欢

Livox Lidar+海康Camera 基于loam的实时三维重建生成RGB彩色点云

Spark BUG實踐(包含的BUG:ClassCastException;ConnectException;NoClassDefFoundError;RuntimeExceptio等。。。。)

Discuz小鱼游戏风影传说商业GBK+UTF8版模板/DZ游戏网站模板

This kind of people began to be robbed by VC with a monthly salary of 80000 yuan

实践torch.fx:基于Pytorch的模型优化量化神器

Summary of solutions to cross system data consistency problems

第一性原理(最优解理论)

Ice cream or snow "high"?

C# Winform 读取Resources图片

Azure Kinect DK realizes 3D reconstruction (PC non real time version)
随机推荐
Summary of various loams (laser SLAM)
云辅助隐私集合求交(Server-Aided PSI)协议介绍:学习
mongodb基础操作之聚合操作、索引优化
官宣!Apache Doris 从 Apache 孵化器毕业,正式成为 Apache 顶级项目!
Redis principle - string
【Try to Hack】veil-evasion免杀
量化交易入门教程
Started a natural language model bloom
居家办公竟比去公司上班还累?
Typora 1.2.5等版本下载
webserver流程图——搞懂webserver各模块间调用关系
Bibliothèque d'exploitation / de développement locale open source pour l'outil de dessin en ligne hiplot
Discuz taobaoke website template / Dean taobaoke shopping style commercial version template
Technical implementation process of easycvr platform routing log function [code attached]
跟着存档教程动手学RNAseq分析(二)
跟着存档教程动手学RNAseq分析(一)
[js]var, let,const 的区别
Spug - 轻量级自动化运维平台
Livox lidar+apx15 real-time high-precision radar map reproduction and sorting
沉寂了一段时间 ,我又出来啦~