4274
备注:
|
1830
|
删除的内容标记成这样。 | 加入的内容标记成这样。 |
行号 13: | 行号 13: |
=== 膨胀 === | |
行号 15: | 行号 14: |
'''膨胀'''是使二值图像'''变粗'''的操作。变粗的程度由'''结构元素'''来控制。膨胀的过程可以由下图来说明: | <<Include(^图像的数学形态学处理/040 膨胀)>> |
行号 17: | 行号 16: |
{{attachment:figure94.png}} | <<Include(^图像的数学形态学处理/050 结构元素的分解)>> |
行号 19: | 行号 18: |
膨胀操作记为:{{{#!latex $$A \oplus B = \{ z|(\hat{B})_z \cap A \neq \phi \}$$ }}} |
<<Include(^图像的数学形态学处理/060 常用的结构元素)>> |
行号 23: | 行号 20: |
非对称的结构元素,需要先将其映射 {{attachment:figure95.png}} 在matlab中实现:{{{ C = imdilate(A, B); }}} {{attachment:figure96.png}} === 结构元素的分解 === 膨胀运算满足结合律:{{{#!latex $$A\oplus (B \oplus C) = (A \oplus B) \oplus C$$ }}} 如果一个结构元素B可以分解成两个结构元素B1和B2的膨胀{{{#!latex $$B=B_1\oplus B_2$$ }}}那么{{{#!latex $$A\oplus B = A \oplus (B_1 \oplus B_2) = (A \oplus B_1) \oplus B_2$$ }}} 计算膨胀所需要的时间正比于结构元素中非零像素的个数。如果分解后非零像素减少,那就可以节省计算时间。例如 {{{#!latex $$\left[\begin{array}{ccccc} 1 &1& 1& 1& 1\\ 1 &1& 1& 1& 1\\ 1 &1& \boxed{1}& 1& 1\\ 1 &1& 1& 1& 1\\ 1 &1& 1& 1& 1 \end{array}\right] $$ }}} 可以分解为{{{#!latex $$[1\ 1\ \boxed{1}\ 1\ 1] \oplus \left[ \begin{array}{c}1\\1\\\boxed{1}\\1\\1\end{array}\right]$$ }}} === 常用的结构元素 === 在matlab中,可以用strel函数,生成一些常用的结构元素。 {{attachment:table92.png}} strel返回的不是矩阵,而是一个strel对象,它可以直接传给imdilate作为参数。也可以通过getnhood得到对应的矩阵。例如:{{{ se = strel('diamond', 3) B = getnhood(se) }}} === 腐蚀 === '''腐蚀'''操作可以细化二值图像。细化的程度同样由一个结构元素控制。下图说明了腐蚀的过程: {{attachment:figure97.png}} 腐蚀定义为:{{{#!latex $$A \ominus B = \{ z|(B)_z \cap A^c = \phi \}$$ }}} 腐蚀可以用膨胀来表示:{{{#!latex $$A \ominus B = \{ z|(B)_z \cap A^c = \phi \} = \{ z|(B)_z \cap A^c \neq \phi \}^c = (A^c \oplus \hat{B})^c$$ }}} 在matlab中实现:{{{ C = imerode(A, B); }}} {{attachment:figure98.png}} |
<<Include(^图像的数学形态学处理/070 腐蚀)>> |
行号 91: | 行号 23: |
=== 开运算和闭运算 === | |
行号 93: | 行号 24: |
A与B的开运算定义为:{{{#!latex $$A\circ B = (A \ominus B) \oplus B$$ }}} |
<<Include(^图像的数学形态学处理/080 开运算和闭运算)>> |
行号 97: | 行号 26: |
A与B的闭运算定义为:{{{#!latex $$A\bullet B = (A \oplus B)\ominus B$$ }}} |
<<Include(^图像的数学形态学处理/090 击中击不中运算)>> |
行号 101: | 行号 28: |
{{attachment:figure99.png}} | <<Include(^图像的数学形态学处理/100 其他复合操作)>> |
行号 103: | 行号 30: |
在matlab中实现:{{{ C = imopen(A, B) C = imclose(A, B) }}} {{attachment:figure910.png}} {{attachment:figure911.png}} === 击中击不中运算 === 击中击不中运算定义为:{{{#!latex $$A \otimes B = (A\ominus B_1) \cap (A^c\ominus B_2)$$ }}} {{attachment:figure912.png}} 在matlab中实现{{{ c = bwhitmiss(A, B1, B2); }}} {{attachment:figure913.png}} === 其他复合操作 === 在matlab中,使用bwmorph可以实现多种形态学运算 {{attachment:table93.png}} {{attachment:figure915.png}} {{attachment:figure916.png}} |
目录
<<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函数,生成一些常用的结构元素。
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可以实现多种形态学运算
用法:
g = bwmorph(f, operation, n);
其中,operation是一个指定操作的字符串,n指定操作的重复次数,缺省是1。
例子:
g1 = bwmorph(f, 'thin', 1); g2 = bwmorph(f, 'thin', 2); ginf = bwmorph(f, 'thin', Inf);
骨骼化(也称为提取骨架):
fs = bwmorph(f, 'skel', Inf);
骨骼化的结果中会有一些毛刺,我们可以对起进行修剪,使用endpoints函数实现:
fs = fs&~endpoints(fs)
<<Navigation: 执行失败 ['AllContext' object has no attribute 'values'] (see also the log)>>
标记连通分量
一个像素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连通。
形态学重构
1. 由重构做开运算
2. 填充空洞