当前位置:网站首页>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 FPGA programming from scratch -48]: Vision - development and application of intelligent sensors
- Livox lidar+apx15 real-time high-precision radar map reproduction and sorting
- What problems should be paid attention to in the serpentine wiring of PCB?
- Discuz淘宝客网站模板/迪恩淘宝客购物风格商业版模板
- webserver流程图——搞懂webserver各模块间调用关系
- 2022年PMP项目管理考试敏捷知识点(3)
- Batch processing - Excel import template 1.1- support multiple sheet pages
- Swing UI——容器(一)
- 量化交易入门教程
- Spug - 轻量级自动化运维平台
猜你喜欢

How vivado adds timing constraints

各种loam总结(激光slam)

Stream + Nacos

如何设置企业微信群机器人定时发消息?

Feign通过自定义注解实现路径的转义

What problems should be paid attention to in the serpentine wiring of PCB?

Death of 5 yuan youkuang in Yuanqi forest

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

Livox Lidar+APX15 实时高精度雷达建图复现整理

【经典干货书】数据科学中的信息理论方法,561页pdf
随机推荐
Follow the archiving tutorial to learn rnaseq analysis (IV): QC method for de analysis using deseq2
Livox lidar+ Haikang camera generates color point cloud in real time
MSP430F5529 单片机 读取 GY-906 红外温度传感器
跟着存档教程动手学RNAseq分析(三):使用DESeq2进行计数标准化
捷码赋能案例:湖南天辰产研实力迅速提升!实战玩转智慧楼宇/工地等项目
Azure Kinect DK realizes 3D reconstruction (Jetson real-time version)
【剑指Offer】48. 最长不含重复字符的子字符串
消除el-image图片周围间隙
Livox lidar+ Hikvision camera real-time 3D reconstruction based on loam to generate RGB color point cloud
Design of STM32 and rc522 simple bus card system
官宣!Apache Doris 从 Apache 孵化器毕业,正式成为 Apache 顶级项目!
Open source of local run / development library of hiplot online drawing tool
MySQL删除表后如何使ID从1开始
小程序referer
What problems should be paid attention to in the serpentine wiring of PCB?
通过 MQTT 检测对象和传输图像
跨系统数据一致性问题解决方案汇总
CUDA error:out of memory caused by insufficient video memory of 6G graphics card
NDSS 2022 接收的列表
Prediction of benign / malignant breast tumors (logistic regression classifier)