寻思自己写了的,但是这个大佬写的太好了,感谢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 分水领域法详解(转载)的更多相关文章

  1. 如约而至,Java 10 正式发布! Spring+SpringMVC+MyBatis+easyUI整合进阶篇(十四)Redis缓存正确的使用姿势 努力的孩子运气不会太差,跌宕的人生定当更加精彩 优先队列详解(转载)

    如约而至,Java 10 正式发布!   3 月 20 日,Oracle 宣布 Java 10 正式发布. 官方已提供下载:http://www.oracle.com/technetwork/java ...

  2. malloc 与 free函数详解<转载>

    malloc和free函数详解   本文介绍malloc和free函数的内容. 在C中,对内存的管理是相当重要.下面开始介绍这两个函数: 一.malloc()和free()的基本概念以及基本用法: 1 ...

  3. jQuery的deferred对象详解(转载)

    本文转载自: jQuery的deferred对象详解(转载)

  4. RAII惯用法详解

    [1]什么是RAII惯用法? RAII是Resource Acquisition Is Initialization的缩写,意为“资源获取即初始化”. 它是C++之父Bjarne Stroustrup ...

  5. HS光流算法详解<转载>

    HS 光流法详解 前言 本文较为详细地介绍了一种经典的光流法 - HS 光流法. 光流法简介 当人的眼睛与被观察物体发生相对运动时,物体的影像在视网膜平面上形成一系列连续变化的图像,这一系列变化的图像 ...

  6. 跟我学机器视觉-HALCON学习例程中文详解-FUZZY检测用于开关引脚测量

    跟我学机器视觉-HALCON学习例程中文详解-FUZZY检测用于开关引脚测量 * This example program demonstrates the basic usage of a fuzz ...

  7. 跟我学机器视觉-HALCON学习例程中文详解-测量圆环脚宽间距

    跟我学机器视觉-HALCON学习例程中文详解-测量圆环脚宽间距 This example program demonstrates the basic usage of a circular meas ...

  8. 跟我学机器视觉-HALCON学习例程中文详解-开关引脚测量

    跟我学机器视觉-HALCON学习例程中文详解-开关引脚测量 This example program demonstrates the basic usage of a measure object. ...

  9. 跟我学机器视觉-HALCON学习例程中文详解-QQ摄像头读取条码

    跟我学机器视觉-HALCON学习例程中文详解-QQ摄像头读取条码 第一步:插入QQ摄像头,安装好驱动(有的可能免驱动) 第二步:打开HDevelop,点击助手-打开新的Image Acquisitio ...

随机推荐

  1. JVM(五) class类文件的结构

    概述 class类文件的结构可见下面这样图(出处见参考资料),可以参照下面的例子,对应十六进制码,找出找出相应的信息. 其中u2 , u4 表示的意思是占用两个字节和占用四个字节,下面我们将会各项说明 ...

  2. web.xml配置文件中async-supported报错解决

    项目中配置spring时async-supported报错: 是因为<async-supported>true</async-supported>是web.xml 3.0的新特 ...

  3. zookeeper【2】集群管理

    Zookeeper 的核心是广播,这个机制保证了各个Server之间的同步.实现这个机制的协议叫做Zab协议. Zab协议有两种模式,它们分别是恢复模式(选主)和广播 模式(同步).当服务启动或者在领 ...

  4. 小任务之Canvas绘制时钟

    背景图的绘制(大圆.数字.小圆点) 掌握基础知识:圆的绘制(arc方法),关于圆的弧度的计算,数学中关于sin cos的用法 圆的弧度为2*Math.PI 12个数字分得弧度每个为2*Math.PI/ ...

  5. HTML5特效~3D立方体旋转

    先欣赏一下该特效的最终效果 本文源码参考自http://www.cnblogs.com/ECJTUACM-873284962/进行一点点优化,下面是对此特效原理上的的剖析. 该特效是基于Css3的一些 ...

  6. NOIP2017:逛公园

    Sol 发现\(NOIP2017\)还没\(AK\)??? 赶紧改 考场上明明打出了\(DP\),没时间了,没判环,重点是没初始化数组,爆\(0\) \(TAT\) 先最短路,然后\(f[i][j]\ ...

  7. C# Winform中的ComboBox控件绑定数据库项目作为列表内容

    //初始化院区下拉列表,使用了Oracle数据库中的表项目 try { //string connString = "User=system;Password=manager;Data So ...

  8. SpringBoot2.0+Mybatis+PageHelper+Redis实现缓存

    1.在maven引入相关的依赖 <parent> <groupId>org.springframework.boot</groupId> <artifactI ...

  9. JAVA基本数据类型、引用数据类型-参数传递详解

    1:基本类型的参数传值 对于基本数据类型,修改这个值并不会影响作为参数传进来的那个变量,因为你修改的是方法的局部变量,是一个副本.实参的精度级别应等于或低于形参的精度级别,否则报错. class JB ...

  10. Js 对Dom的操作

    一.DOM的概述 DOM(Document Object Model,文档对象模型)描绘了一个层次化的节点树,允许开发人员添加.移除和修改页面的某一部分.这使得JavaScript操作HTML,不是在 ...