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 ...
随机推荐
- Eclipse 工具栏无法移动的解决办法
升级到Juno后发现工具栏有些乱 而且无法拖动,试了下http://blog.csdn.net/cxx504659987/article/details/38532599的方法 发现配置文件里没有文中 ...
- centos 同步网络时间
centos 同步网络时间 # yum -y install ntp ntpdate # ntpdate cn.pool.ntp.org # date
- 五、mybatis集成使用
1.添加依赖 <!-- mybatis-spring集成--> <dependency> <groupId>org.mybatis.spring.boot</ ...
- JAVA_SE_Day02 String 的正则表达式
字符串支持正则表达式的方法一: boolean matches(String regex) 注意: 给定的正则表达式就算不指定边界符(^,$),也会全匹配验证 空字符串和null 空字符串是看不见,而 ...
- Oracle 数据库字典 sys.col$ 表中关于type#的解释
sys.col$ 表是oracle基础数据字典表中的列表,表中描述了数据库中各列信息,其中type#是列的数据类型.以下表格说明了各个数值的含义,以供参考. 值 说明 1 如果列 charsetfor ...
- Windows下RSA密钥生成工具openssl
下载openssl.zip 1. 生成原始 RSA私钥文件 private_key.pem openssl genrsa -out private_key.pem 1024 2. 将原始 RSA私钥转 ...
- tp3.2开启允许跨域
在入口文件<?PHP下加上 header('Access-Control-Allow-Origin:*');header("Access-Control-Allow-Headers: ...
- html和css入门 (四)
背景样式 背景颜色 属性名 background-color 属性值 合法的颜色的名,比如:red:十六进制值,比如:#ff0000:RGB 值,比如:rgb(255,0,0) 默认值 transpa ...
- java.util.Collections.unmodifiableMap 示例
1. 概述 public static <K,V> Map<K,V> unmodifiableMap(Map<? extends K,? extends V> m) ...
- ASPF(Application Specific Packet Filter)
ASPF ASPF(Application Specific Packet Filter)是针对应用层的包过滤,其原理是检测通过设备的报文的应用层协议信息,记录临时协商的数据连接,使得某些在安全策略中 ...