寻思自己写了的,但是这个大佬写的太好了,感谢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. 基数排序——Java实现

    一.基数排序思想 相比其它排序,主要是利用比较和交换,而基数排序则是利用分配和收集两种基本操作.基数 排序是一种按记录关键字的各位值逐步进行排序的方法.此种排序一般适用于记录的关键字为整数类型的情况. ...

  2. jQuery Text-to-Speech 谷歌在线语音

    <!DOCTYPE html> <html> <head> <meta content="text/html; charset=utf-8" ...

  3. jquery中的$().each和$.each的区别

    jquery中的$().each和$.each的区别 注意:jquery中的$().each和$.each的区别,前者只能遍历数组,后者可以遍历数组和对象 备注:sinobook项目中地名本体相关地按 ...

  4. JavaScript中实现DI的原理(二)

    JavaScript中实现DI的原理 在JavaScript中实现DI,看起来难,实际上原理很简单,它的核心技术是Function对象的toString().我们都知道,对一个函数对象执行toStri ...

  5. Apache服务器运维笔记(3)----容器部分

    1.<IfModule>容器 <IfModule>容器作用于模块,它会首先判断模块是否载入,然后再决定是否进行处理,也就是说只有当判断结果为真时才会执行容器内的指令,相反如果为 ...

  6. mongoDB BI 分析利器 - PostgreSQL FDW (MongoDB Connector for BI)

    背景 mongoDB是近几年迅速崛起的一种文档型数据库,广泛应用于对事务无要求,但是要求较好的开发灵活性,扩展弹性的领域,. 随着企业对数据挖掘需求的增加,用户可能会对存储在mongo中的数据有挖掘需 ...

  7. 弧形菜单(Android)

    弧形菜单(Android) 前言:公司需求,自己写的一个弧形菜单! 效果: 开发环境:AndroidStudio2.2.1+gradle-2.14.1 涉及知识:1.自定义控件,2.事件分发等 部分代 ...

  8. DBGridEh常用技巧

    一.增加多表头显示方式 DBGridEh1.UseMultiTitle:=True; //打开多标题显示方式 DBGridEh1.Columns[].Title.Caption:='员工编号'; // ...

  9. UML面向对象建模基础

    一个比较好的UML教程PPT https://wenku.baidu.com/view/cf80902e26284b73f242336c1eb91a37f11132ac.html

  10. skype for business server2015部署向导启动服务失败

    命令行执行start-cspool失败 解决: 1.cmd执行servers.msc打开服务列表,将所有skype服务启动,默认是延迟启动 2.用管理员权限打开cmd,而不是普通权限 重新执行启动服务 ...