<<Navigation: 执行失败 ['AllContext' object has no attribute 'values'] (see also the log)>>

预备知识

<<Include: 执行失败 [Missing parentheses in call to 'print'. Did you mean print(...)?] (see also the log)>>

<<Include: 执行失败 [Missing parentheses in call to 'print'. Did you mean print(...)?] (see also the log)>>

<<Include: 执行失败 [Missing parentheses in call to 'print'. Did you mean print(...)?] (see also the log)>>

膨胀和腐蚀

<<Include: 执行失败 [Missing parentheses in call to 'print'. Did you mean print(...)?] (see also the log)>>

<<Include: 执行失败 [Missing parentheses in call to 'print'. Did you mean print(...)?] (see also the log)>>

<<Navigation: 执行失败 ['AllContext' object has no attribute 'values'] (see also the log)>>

1. 常用的结构元素

在matlab中,可以用strel函数,生成一些常用的结构元素。

../table92.png

strel返回的不是矩阵,而是一个strel对象,它可以直接传给imdilate作为参数。也可以通过getnhood得到对应的矩阵。例如:

se = strel('diamond', 3)
B = getnhood(se)

<<Navigation: 执行失败 ['AllContext' object has no attribute 'values'] (see also the log)>>

<<Include: 执行失败 [Missing parentheses in call to 'print'. Did you mean print(...)?] (see also the log)>>

组合运算

<<Include: 执行失败 [Missing parentheses in call to 'print'. Did you mean print(...)?] (see also the log)>>

<<Include: 执行失败 [Missing parentheses in call to 'print'. Did you mean print(...)?] (see also the log)>>

<<Navigation: 执行失败 ['AllContext' object has no attribute 'values'] (see also the log)>>

1. 其他复合操作

在matlab中,使用bwmorph可以实现多种形态学运算

../table93.png

用法:

g = bwmorph(f, operation, n);

其中,operation是一个指定操作的字符串,n指定操作的重复次数,缺省是1。

例子:

g1 = bwmorph(f, 'thin', 1);
g2 = bwmorph(f, 'thin', 2);
ginf = bwmorph(f, 'thin', Inf);

../figure915.png

骨骼化(也称为提取骨架):

fs = bwmorph(f, 'skel', Inf);

../figure916.png

骨骼化的结果中会有一些毛刺,我们可以对起进行修剪,使用endpoints函数实现:

fs = fs&~endpoints(fs)

<<Navigation: 执行失败 ['AllContext' object has no attribute 'values'] (see also the log)>>

标记连通分量

figure917.png

一个像素p的上下左右四个像素称为4邻接像素,上下左右再加上四个对角线像素称为8邻接像素。如果两个像素p1和pn之间存在一条路径p1,p2,...pn,其中每相邻两个之间都是4邻接的,则称p1和pn是4连通的;如果每相邻两个像素之间都是8邻接的,则称p1和pn是8连通的;如果不存在这样的路径,则称为p1和pn是不连通的。与p连通的所有像素的集合称为包含p的连通分量。

在matlab中,可以由bwlabel函数来找出连通分量,为不同的连通分量标上不同的标记。

[L num] = bwlabel(f, conn)

conn是4或者8,表示选择4连通或者8连通。

figure918.png

figure919.png

figure920.png

形态学重构

figure921.png

1. 由重构做开运算

figure922.png

2. 填充空洞

3. 清除边界对象

ch3n2k.com | Copyright (c) 2004-2020 czk.