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

边栏推荐
- 跟着存档教程动手学RNAseq分析(三):使用DESeq2进行计数标准化
- Aggregation and index optimization of mongodb basic operations
- 因美纳陷数据泄露“丑闻”:我国基因数据安全能交给美企吗?
- Azure Kinect DK 实现三维重建 (jetson实时版)
- Livox lidar+ Haikang camera generates color point cloud in real time
- Ice cream or snow "high"?
- go日志包 log的使用
- 良/恶性乳腺肿瘤预测(逻辑回归分类器)
- [network] common request methods
- Follow the archiving tutorial to learn rnaseq analysis (IV): QC method for de analysis using deseq2
猜你喜欢

webserver流程图——搞懂webserver各模块间调用关系

Ice cream or snow "high"?

Discuz淘宝客网站模板/迪恩淘宝客购物风格商业版模板

小程序referer

The latest cloud development wechat balance charger special effect applet source code

使用SQL进行数据去重的N种方法

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

Swing UI container (I)

【IDEA】IDEA 格式化 代码技巧 idea 格式化 会加 <p> 标签

Small chip chiplet Technology
随机推荐
Hiplot 在線繪圖工具的本地運行/開發庫開源
Zabbix6.0 upgrade Guide - how to synchronize database upgrades?
This year's examinees are more "desperate" than the college entrance examination
企业架构师面试的100个问题
Working at home is more tiring than going to work at the company?
SQL Server 2016详细安装教程(附注册码和资源)
凌云出海记 | 沐融科技&华为云:打造非洲金融SaaS解决方案样板
[js]var, let, const
第一性原理(最优解理论)
Classification of cifar-10 dataset with pytorch
[sword finger offer] 47 Maximum value of gifts
Go语言fsnotify接口实现监测文件修改
[electron] 基础学习
mongodb基础操作之聚合操作、索引优化
[网络]常见的请求方法
Getting started with pytorch
Swing UI——容器(一)
Summary of various loams (laser SLAM)
通过tidymodels使用XGBOOST
消除el-image图片周围间隙