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 ...
随机推荐
- Expression Blend实例中文教程(7) - 动画基础快速入门Animation
通过前面文章学习,已经对Blend的开发界面,以及控件有了初步的认识.本文将讲述Blend的一个核心功能,动画设计.大家也许注意到,从开篇到现在,所有的文章都是属于快速入门,是因为这些文章,都是我曾经 ...
- Hibernate生成数据库表
首先创建实体类 import java.util.Date; public class ProductionEntity { public Integer getId() { return id; } ...
- 一:Redis安装
redis在Linux上的安装 1)安装redis编译的c环境,yum install gcc-c++ 2)将redis-2.6.16.tar.gz上传到Linux系统中 3)解压到/usr/loca ...
- IDEA创建Maven项目和子模块
一.新建Project a. 新建项目,点击Create New Project b. 选择使用maven来新建项目 选择新建Maven模块(对IDEA来说是项目) 如果Project SDK那里没有 ...
- Spring课程 Spring入门篇 6-1 Spring AOP API的PointCut、advice的概念及应用
本节主要是模拟spring aop 的过程. 实现spring aop的过程 这一节老师虽然说是以后在工作中不常用这些api,实际上了解还是有好处的, 我们可以从中模拟一下spring aop的过程. ...
- Effective C++ .37 virtual函数中默认参数的表现
#include <iostream> #include <cstdlib> using namespace std; class Pen { public: ) { cout ...
- centos7编译安装git最新版
假如系统已经安装了git,先删除. 如果是通过yum安装的,直接在终端使用以下指令删除: yum remove git 如果是通过源码编译安装的,参考以下文章: Linux ./configure & ...
- Codeforces Round #415 (Div. 2) C. Do you want a date?
C. Do you want a date? 2 seconds 256 megabytes Leha decided to move to a quiet town Vičkopolis, ...
- Codeforces Round #416 (Div. 2) A+B
A. Vladik and Courtesy 2 seconds 256 megabytes At regular competition Vladik and Valera won a and ...
- python基础(二)--多值参数以及类
1.多值参数函数 def 函数名(*args , **kwargs): ....... 多值参数函数顾名思义能够传入多个参数,args表示传入的元组,kwargs表示传入的字典 def functio ...