📄 chap03.htm
字号:
<td width=141 valign=top class="Normal">
<p align=center style='text-align:center;line-height:18.0pt'><span
style='font-family:宋体;"Times New Roman"'>原图</span></p>
</td>
<td width=137 valign=top class="Normal">
<p align=center style='text-align:center;line-height:18.0pt'><span
style='font-family:宋体;"Times New Roman"'>经</span><span lang=EN-US>Box</span><span style='font-family:
宋体;"Times New Roman"'>模板处理后</span></p>
</td>
<td width=137 valign=top class="Normal">
<p align=center style='text-align:center;line-height:18.0pt'><span
style='font-family:宋体;"Times New Roman"'>经</span><span lang=EN-US>Gauss</span><span
style='font-family:宋体;"Times New Roman"'>模板处理后</span></p>
</td>
<td width=136 valign=top class="Normal">
<p align=center style='text-align:center;line-height:18.0pt'><span
style='font-family:宋体;"Times New Roman"'>经中值滤波处理后</span></p>
</td>
</tr>
<tr>
<td width=141 class="Normal">
<p align=center style='text-align:center;line-height:18.0pt'><span
lang=EN-US><sub> <img width=127 height=112
src="chap03.files/image043.gif" v:shapes="_x0000_i1035"> </sub> </span></p>
</td>
<td width=137 class="Normal">
<p align=center style='text-align:center;line-height:18.0pt'><span
lang=EN-US><sub> <img width=104 height=155
src="chap03.files/image045.gif" v:shapes="_x0000_i1036"> </sub> </span></p>
</td>
<td width=137 class="Normal">
<p align=center style='text-align:center;line-height:18.0pt'><span
lang=EN-US><sub> <img width=117 height=155
src="chap03.files/image047.gif" v:shapes="_x0000_i1037"> </sub> </span></p>
</td>
<td width=136 class="Normal">
<p align=center style='text-align:center;line-height:18.0pt'><span
lang=EN-US><sub> <img width=84 height=112
src="chap03.files/image049.gif" v:shapes="_x0000_i1038"> </sub> </span></p>
</td>
</tr>
</table>
<p style='line-height:18.0pt'><span
style='font-family:宋体;"Times New Roman"'>从原图中不难看出左边区域灰度值低,右边区域灰度值高,中间有一条明显的边界</span><span lang=EN-US>,</span><span
style='font-family:宋体;"Times New Roman"'>这一类图象称之为</span><span lang=EN-US>“step”(</span><span
style='font-family:宋体;"Times New Roman"'>就象灰度上了个台阶</span><span lang=EN-US>)</span><span
style='font-family:宋体;"Times New Roman"'>。应用平滑模板后,图象平滑了,但是也使边界模糊了。应用中值滤波,就能很好地保持原来的边界。所以说,中值滤波的特点是保护图象边缘的同时去除噪声。</span></p>
<p style='line-height:18.0pt'><span
style='font-family:宋体;"Times New Roman"'>再看第二幅图:</span></p>
<table border=0 cellspacing=0 cellpadding=0>
<tr>
<td width=138 valign=top class="Normal">
<p align=center style='text-align:center;line-height:18.0pt'><span
style='font-family:宋体;"Times New Roman"'>原图</span></p>
</td>
<td width=138 valign=top class="Normal">
<p align=center style='text-align:center;line-height:18.0pt'><span
style='font-family:宋体;"Times New Roman"'>经</span><span lang=EN-US>Box</span><span style='font-family:
宋体;"Times New Roman"'>模板处理后</span></p>
</td>
<td width=138 valign=top class="Normal">
<p align=center style='text-align:center;line-height:18.0pt'><span
style='font-family:宋体;"Times New Roman"'>经</span><span lang=EN-US>Gauss</span><span
style='font-family:宋体;"Times New Roman"'>模板处理后</span></p>
</td>
<td width=138 valign=top class="Normal">
<p align=center style='text-align:center;line-height:18.0pt'><span
style='font-family:宋体;"Times New Roman"'>经中值滤波处理后</span></p>
</td>
</tr>
<tr>
<td width=138 class="Normal">
<p align=center style='text-align:center;line-height:18.0pt'><span
lang=EN-US><sub> <img width=159 height=99
src="chap03.files/image051.gif" v:shapes="_x0000_i1025"> </sub> </span></p>
</td>
<td width=138 class="Normal">
<p align=center style='text-align:center;line-height:18.0pt'><span
lang=EN-US><sub> <img width=100 height=131
src="chap03.files/image053.gif" v:shapes="_x0000_i1026"> </sub> </span></p>
</td>
<td width=138 class="Normal">
<p align=center style='text-align:center;line-height:18.0pt'><span
lang=EN-US><sub> <img width=59 height=93
src="chap03.files/image055.gif" v:shapes="_x0000_i1027"> </sub> </span></p>
</td>
<td width=138 class="Normal">
<p align=center style='text-align:center;line-height:18.0pt'><span
lang=EN-US><sub> <img width=91 height=99
src="chap03.files/image057.gif" v:shapes="_x0000_i1028"> </sub> </span></p>
</td>
</tr>
</table>
<p style='line-height:18.0pt'><span
style='font-family:宋体;"Times New Roman"'>不难看出,原图中有很多噪声点</span><span lang=EN-US>(</span><span
style='font-family:宋体;"Times New Roman"'>灰度为正代表灰度值高的点,灰度为负代表灰度值低的点</span><span lang=EN-US>)</span><span
style='font-family:宋体;"Times New Roman"'>,而且是杂乱无章,随机分布的。这也是一类很典型的图,称之为高斯噪声。经过</span><span lang=EN-US>Box</span><span
style='font-family:宋体;"Times New Roman"'>平滑,噪声的程度有所下降。</span><span lang=EN-US>Gauss</span><span
style='font-family:宋体;"Times New Roman"'>模板对付高斯噪声非常有效。而中值滤波对于高斯噪声则无能为力。</span></p>
<p style='line-height:18.0pt'><span
style='font-family:宋体;"Times New Roman"'>最后看第三幅图:</span></p>
<table border=0 cellspacing=0 cellpadding=0>
<tr>
<td width=138 valign=top class="Normal">
<p align=center style='text-align:center;line-height:18.0pt'><span
style='font-family:宋体;"Times New Roman"'>原图</span></p>
</td>
<td width=138 valign=top class="Normal">
<p align=center style='text-align:center;line-height:18.0pt'><span
style='font-family:宋体;"Times New Roman"'>经</span><span lang=EN-US>Box</span><span style='font-family:
宋体;"Times New Roman"'>模板处理后</span></p>
</td>
<td width=138 valign=top class="Normal">
<p align=center style='text-align:center;line-height:18.0pt'><span
style='font-family:宋体;"Times New Roman"'>经</span><span lang=EN-US>Gauss</span><span
style='font-family:宋体;"Times New Roman"'>模板处理后</span></p>
</td>
<td width=138 valign=top class="Normal">
<p align=center style='text-align:center;line-height:18.0pt'><span
style='font-family:宋体;"Times New Roman"'>经中值滤波处理后</span></p>
</td>
</tr>
<tr>
<td width=138 class="Normal">
<p align=center style='text-align:center;line-height:18.0pt'><span
lang=EN-US><sub> <img width=105 height=71
src="chap03.files/image059.gif" v:shapes="_x0000_i1029"> </sub> </span></p>
</td>
<td width=138 class="Normal">
<p align=center style='text-align:center;line-height:18.0pt'><span
lang=EN-US><sub> <img width=85 height=116
src="chap03.files/image061.gif" v:shapes="_x0000_i1030"> </sub> </span></p>
</td>
<td width=138 class="Normal">
<p align=center style='text-align:center;line-height:18.0pt'><span
lang=EN-US><sub> <img width=76 height=116
src="chap03.files/image063.gif" v:shapes="_x0000_i1031"> </sub> </span></p>
</td>
<td width=138 class="Normal">
<p align=center style='text-align:center;line-height:18.0pt'><span
lang=EN-US><sub> <img width=59 height=71
src="chap03.files/image065.gif" v:shapes="_x0000_i1032"> </sub> </span></p>
</td>
</tr>
</table>
<p style='line-height:18.0pt'><span
style='font-family:宋体;"Times New Roman"'>从原图中不难看出,中间的灰度要比两边高许多。这也是一类很典型的图,称之为脉冲</span><span
lang=EN-US> (impulse)</span><span style='font-family:宋体;"Times New Roman";"Times New Roman"'>。可见,中值滤波对脉冲噪声非常有效。</span></p>
<p style='line-height:18.0pt'><span
style='font-family:宋体;"Times New Roman"'>综合以上三类图,不难得出下面的结论:中值滤波容易去除孤立点,线的噪声同时保持图象的边缘;它能很好的去除二值噪声,但对高斯噪声无能为力。要注意的是,当窗口内噪声点的个数大于窗口宽度的一半时,中值滤波的效果不好。这是很显然的。</span></p>
<p style='line-height:18.0pt'><span
style='font-family:宋体;"Times New Roman"'>下面的程序实现了中值滤波,参数</span><span lang=EN-US>Hori</span><span
style='font-family:宋体;"Times New Roman"'>是一个布尔变量,若为真,做水平中值滤波,否则,做垂直中值滤波。</span></p>
<p style='line-height:18.0pt'><span lang=EN-US>BOOL MedianFilter(HWND hWnd,BOOL
Hori)</span></p>
<p style='line-height:18.0pt'><span lang=EN-US>{</span></p>
<p style='line-height:18.0pt'>DWORD
OffBits,BufSize;</p>
<p style='line-height:18.0pt'>LPBITMAPINFOHEADER lpImgData;</p>
<p style='line-height:18.0pt'>LPSTR
lpPtr;</p>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -