halcon 分水领域法详解(转载)
寻思自己写了的,但是这个大佬写的太好了,感谢Y忍冬草_ http://blog.csdn.net/y363703390 https://blog.csdn.net/y363703390/article/details/81806378
1.算子
通过阈值实现图像的分水岭算法分割
watersheds_threshold(Image : Basins : Threshold : )
2.原理
第1步:
通过分水岭算法watersheds()获取图像的盆地。
第2步:
根据第一步分水岭算法分离结果,若盆地部分的灰度**< threshold**,则被合并到一起。设B1和B2分别为相邻盆地的最小灰度值,W为将盆地分割为两个盆地的最小灰度值。则分割结果为:
3.案例
1)边缘振幅+分水岭阈值实现图像分割
dev_set_draw ('fill')
dev_set_line_width (2)
dev_set_colored (12)
read_image (ImageLogo, 'mvtec_logo.png')
dev_close_window ()
get_image_size (ImageLogo, Width, Height)
dev_open_window (0, 0, Width, Height, 'black', WindowHandle)
dev_display (ImageLogo)
disp_continue_message (WindowHandle, 'black', 'true')
stop ()
gauss_filter (ImageLogo, ImageGauss, 9)
sobel_amp (ImageGauss, EdgeAmplitude, 'sum_abs', 3)
disp_continue_message (WindowHandle, 'black', 'true')
stop ()
watersheds_threshold (EdgeAmplitude, Basins, 14)
dev_display (Basins)
disp_continue_message (WindowHandle, 'black', 'true')
stop ()
return ()
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
其他算子:
gauss_filter(Image : ImageGauss : Size : )高斯平滑滤波
sobel_amp(Image : EdgeAmplitude : FilterType, Size : )sobel计算图像边缘幅度
2)距离变换+watersheds_threshold等实现分割
* In this example, the task is to split the touching pellets.
* First, a simple thresholding operation yields the region of the pellets
* in the image. Unfortunately, some of the connected components
* of this region do not represent single pellets but contain more than one
* pellet. Therefore, in a second step the watersheds are computed based
* on the distance transformed pellets regions. The corresponding basins
* are finally used to split the falsely connected pellets by intersecting the
* basins with the pellets regions.
*
dev_set_draw ('margin')
dev_set_colored (12)
read_image (Image, 'pellets')
dev_close_window ()
get_image_size (Image, Width, Height)
dev_open_window (0, 0, Width, Height, 'black', WindowHandle)
threshold (Image, Region, 105, 255)
* 计算连通域
connection (Region, ConnectedRegions)
select_shape (ConnectedRegions, SelectedRegions, 'area', 'and', 20, 99999)
dev_display (Image)
dev_display (SelectedRegions)
disp_continue_message (WindowHandle, 'black', 'true')
stop ()
* 距离变换
distance_transform (SelectedRegions, DistanceImage, 'octagonal', 'true', 380, 350)
convert_image_type (DistanceImage, DistanceImageByte, 'byte')
invert_image (DistanceImageByte, DistanceImageInv)
* 扩大图像灰度范围【0,255】
scale_image_max (DistanceImageInv, DistanceImageInvScaled)
watersheds_threshold (DistanceImageInv, Basins, 5)
dev_display (DistanceImageInvScaled)
dev_display (Basins)
disp_continue_message (WindowHandle, 'black', 'true')
stop ()
*
dev_display (Image)
dev_display (SelectedRegions)
dev_set_color ('blue')
dev_display (Basins)
disp_continue_message (WindowHandle, 'black', 'true')
stop ()
* 图像求交
intersection (Basins, SelectedRegions, SegmentedPellets)
dev_display (Image)
dev_set_colored (12)
dev_display (SegmentedPellets)
disp_continue_message (WindowHandle, 'black', 'true')
stop ()
return ()
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
其他算子
connection(Region : ConnectedRegions : : )计算区域的连通域
select_shape (ConnectedRegions, SelectedRegions, ‘area’, ‘and’, 20, 99999) 根据区域特征(面积、长度等)提取区域
distance_transform(Region : DistanceImage : Metric, Foreground, Width, Height : )计算区域的距离变换
convert_image_type(Image : ImageConverted : NewType : )转换图像类型(byte* / direction* / cyclic* / int1* / int2* / uint2* / int4* / int8 / real* / complex*)
invert_image(Image : ImageInvert : : )反转图像
scale_image_max(Image : ImageScaleMax : : )将图像灰度范围扩大到【0,255】
intersection(Region1, Region2 : RegionIntersection : : )计算区域的交集
halcon 分水领域法详解(转载)的更多相关文章
- 如约而至,Java 10 正式发布! Spring+SpringMVC+MyBatis+easyUI整合进阶篇(十四)Redis缓存正确的使用姿势 努力的孩子运气不会太差,跌宕的人生定当更加精彩 优先队列详解(转载)
如约而至,Java 10 正式发布! 3 月 20 日,Oracle 宣布 Java 10 正式发布. 官方已提供下载:http://www.oracle.com/technetwork/java ...
- malloc 与 free函数详解<转载>
malloc和free函数详解 本文介绍malloc和free函数的内容. 在C中,对内存的管理是相当重要.下面开始介绍这两个函数: 一.malloc()和free()的基本概念以及基本用法: 1 ...
- jQuery的deferred对象详解(转载)
本文转载自: jQuery的deferred对象详解(转载)
- RAII惯用法详解
[1]什么是RAII惯用法? RAII是Resource Acquisition Is Initialization的缩写,意为“资源获取即初始化”. 它是C++之父Bjarne Stroustrup ...
- HS光流算法详解<转载>
HS 光流法详解 前言 本文较为详细地介绍了一种经典的光流法 - HS 光流法. 光流法简介 当人的眼睛与被观察物体发生相对运动时,物体的影像在视网膜平面上形成一系列连续变化的图像,这一系列变化的图像 ...
- 跟我学机器视觉-HALCON学习例程中文详解-FUZZY检测用于开关引脚测量
跟我学机器视觉-HALCON学习例程中文详解-FUZZY检测用于开关引脚测量 * This example program demonstrates the basic usage of a fuzz ...
- 跟我学机器视觉-HALCON学习例程中文详解-测量圆环脚宽间距
跟我学机器视觉-HALCON学习例程中文详解-测量圆环脚宽间距 This example program demonstrates the basic usage of a circular meas ...
- 跟我学机器视觉-HALCON学习例程中文详解-开关引脚测量
跟我学机器视觉-HALCON学习例程中文详解-开关引脚测量 This example program demonstrates the basic usage of a measure object. ...
- 跟我学机器视觉-HALCON学习例程中文详解-QQ摄像头读取条码
跟我学机器视觉-HALCON学习例程中文详解-QQ摄像头读取条码 第一步:插入QQ摄像头,安装好驱动(有的可能免驱动) 第二步:打开HDevelop,点击助手-打开新的Image Acquisitio ...
随机推荐
- 五、cent OS防火墙常用命令
查看防火墙开闭状态systemctl status firewalld 开启防火墙systemctl start firewalld 关闭防火墙systemctl stop firewalld 查看已 ...
- 流畅的python和cookbook学习笔记(一)
1.数据结构 1.1 内置序列类型 四种序列类型: 1.容器序列:list.tuple和collections.deque 2.扁平序列:str.bytes.bytearray.memoryview和 ...
- 我的Java编码规范
1.类名采用驼峰命名法,首字母大写. 2.类变量采用驼峰命名法,首字母小写. 3.方法名是一个动词短语,首字母小写,尽量能描述清楚这个方法的意图. 4.注释在精不在多,一个好的注释要尽量描述出这段代码 ...
- pyhton基础
python是一种什么语言?python是一种动态解释性的强类型定义的语言(1)编程语言分类 编译型: 把源程序的每一条语句都编译成机器语言,并保存成二进制文件, 这样运行时计算机可以直接以机器语言来 ...
- 【转】Dom节点操作常用方法
1.访问/获取节点 document.getElementById(id); //返回对拥有指定id的第一个对象进行访问 document.getElementsByName(name); //返回带 ...
- oozie安装总结
偶然的机会,去面试的时候听面试官讲他们的调度系统是基于hue+oozie,以前一直没有接触过,今天趁有空,尝试一下oozie 1.环境说明 cat /etc/issue CentOS release ...
- c++中%是什么意思?
两种意思:1.格式化字符串输出2.整数取余 1.目前printf支持以下格式的输出,例如:printf("%c",a):输出单个字符.printf("%d",a ...
- 第6课 仿Siri机器人-语音朗读和语音识别
一.功能设计 输入文本,单击“朗读”按钮,由手机读出该文本(如果没有输入文本,则弹出消息框警告“请输入文本):单击“识别”按钮,读入语音,从文本框中输出文字.(另,增加识别的视觉效果,如果读入的文本含 ...
- JavaScript中filter()方法
方法概述 用于把数组(Array)的某些元素过滤掉,然后返回剩下的元素组成的数组. 语法: var filteredArray = array.filter(callback[, thisObject ...
- Qt 资料大全
https://blog.csdn.net/liang19890820/article/details/51752029 简述 发福利了.发福利了.发福利了,重要的事情说三遍... 为了方便更多Qte ...