📄 chp3.htm
字号:
inter-ideograph;line-height:18.0pt'><span lang=ZH-CN style='font-size:10.5pt'>从原图中不难看出左边区域灰度值低,右边区域灰度值高,中间有一条明显的边界</span><span
style='font-size:10.5pt;font-family:"Times New Roman"'>,</span><span
lang=ZH-CN style='font-size:10.5pt'>这一类图象称之为</span><span style='font-size:10.5pt;
font-family:"Times New Roman"'>“step”(</span><span lang=ZH-CN style='font-size:
10.5pt'>就象灰度上了个台阶</span><span style='font-size:10.5pt;font-family:"Times New Roman"'>)</span><span
lang=ZH-CN style='font-size:10.5pt'>。应用平滑模板后,图象平滑了,但是也使边界模糊了。应用中值滤波,就能很好地保持原来的边界。所以说,中值滤波的特点是保护图象边缘的同时去除噪声。</span><span
style='font-size:10.5pt;font-family:"Times New Roman"'><o:p></o:p></span></p>
<p style='margin:0cm;margin-bottom:.0001pt;text-align:justify;text-justify:
inter-ideograph;line-height:18.0pt'><span lang=ZH-CN style='font-size:10.5pt'>再看第二幅图:</span><span
style='font-size:10.5pt;font-family:"Times New Roman"'><o:p></o:p></span></p>
<div>
<table border=0 cellspacing=0 cellpadding=0 style='mso-cellspacing:0cm;
mso-padding-alt:0cm 0cm 0cm 0cm'>
<tr>
<td width=138 valign=top style='width:103.5pt;padding:0cm 0cm 0cm 0cm'>
<p align=center style='text-align:center;line-height:18.0pt'><span
lang=ZH-CN style='font-size:10.5pt'>原图</span><span style='font-size:10.5pt;
font-family:"Times New Roman"'><o:p></o:p></span></p>
</td>
<td width=138 valign=top style='width:103.5pt;padding:0cm 0cm 0cm 0cm'>
<p align=center style='text-align:center;line-height:18.0pt'><span
lang=ZH-CN style='font-size:10.5pt'>经</span><span style='font-size:10.5pt;
font-family:"Times New Roman"'>Box</span><span lang=ZH-CN style='font-size:
10.5pt'>模板处理后</span><span style='font-size:10.5pt;font-family:"Times New Roman"'><o:p></o:p></span></p>
</td>
<td width=138 valign=top style='width:103.5pt;padding:0cm 0cm 0cm 0cm'>
<p align=center style='text-align:center;line-height:18.0pt'><span
lang=ZH-CN style='font-size:10.5pt'>经</span><span style='font-size:10.5pt;
font-family:"Times New Roman"'>Gauss</span><span lang=ZH-CN style='font-size:
10.5pt'>模板处理后</span><span style='font-size:10.5pt;font-family:"Times New Roman"'><o:p></o:p></span></p>
</td>
<td width=138 valign=top style='width:103.5pt;padding:0cm 0cm 0cm 0cm'>
<p align=center style='text-align:center;line-height:18.0pt'><span
lang=ZH-CN style='font-size:10.5pt'>经中值滤波处理后</span><span style='font-size:
10.5pt;font-family:"Times New Roman"'><o:p></o:p></span></p>
</td>
</tr>
<tr>
<td width=138 style='width:103.5pt;padding:0cm 0cm 0cm 0cm'>
<p align=center style='text-align:center;line-height:18.0pt'><sub><span
style='font-size:10.5pt;font-family:"Times New Roman"'><!--[if gte vml 1]><v:shape
id="_x0000_i1052" type="#_x0000_t75" alt="" style='width:119.25pt;height:74.25pt'>
<v:imagedata src="./chp3.files/image023.gif" o:href="http://www-scf.usc.edu/~flv/ipbook/chap03.files/image051.gif"/>
</v:shape><![endif]--><![if !vml]><img width=159 height=99
src="./chp3.files/image023.gif" v:shapes="_x0000_i1052"><![endif]></span></sub><span
style='font-size:10.5pt;font-family:"Times New Roman"'><o:p></o:p></span></p>
</td>
<td width=138 style='width:103.5pt;padding:0cm 0cm 0cm 0cm'>
<p align=center style='text-align:center;line-height:18.0pt'><sub><span
style='font-size:10.5pt;font-family:"Times New Roman"'><!--[if gte vml 1]><v:shape
id="_x0000_i1053" type="#_x0000_t75" alt="" style='width:75pt;height:98.25pt'>
<v:imagedata src="./chp3.files/image024.gif" o:href="http://www-scf.usc.edu/~flv/ipbook/chap03.files/image053.gif"/>
</v:shape><![endif]--><![if !vml]><img width=100 height=131
src="./chp3.files/image024.gif" v:shapes="_x0000_i1053"><![endif]></span></sub><span
style='font-size:10.5pt;font-family:"Times New Roman"'><o:p></o:p></span></p>
</td>
<td width=138 style='width:103.5pt;padding:0cm 0cm 0cm 0cm'>
<p align=center style='text-align:center;line-height:18.0pt'><sub><span
style='font-size:10.5pt;font-family:"Times New Roman"'><!--[if gte vml 1]><v:shape
id="_x0000_i1054" type="#_x0000_t75" alt="" style='width:44.25pt;height:69.75pt'>
<v:imagedata src="./chp3.files/image025.gif" o:href="http://www-scf.usc.edu/~flv/ipbook/chap03.files/image055.gif"/>
</v:shape><![endif]--><![if !vml]><img width=59 height=93
src="./chp3.files/image025.gif" v:shapes="_x0000_i1054"><![endif]></span></sub><span
style='font-size:10.5pt;font-family:"Times New Roman"'><o:p></o:p></span></p>
</td>
<td width=138 style='width:103.5pt;padding:0cm 0cm 0cm 0cm'>
<p align=center style='text-align:center;line-height:18.0pt'><sub><span
style='font-size:10.5pt;font-family:"Times New Roman"'><!--[if gte vml 1]><v:shape
id="_x0000_i1055" type="#_x0000_t75" alt="" style='width:68.25pt;height:74.25pt'>
<v:imagedata src="./chp3.files/image026.gif" o:href="http://www-scf.usc.edu/~flv/ipbook/chap03.files/image057.gif"/>
</v:shape><![endif]--><![if !vml]><img width=91 height=99
src="./chp3.files/image026.gif" v:shapes="_x0000_i1055"><![endif]></span></sub><span
style='font-size:10.5pt;font-family:"Times New Roman"'><o:p></o:p></span></p>
</td>
</tr>
</table>
</div>
<p style='margin:0cm;margin-bottom:.0001pt;text-align:justify;text-justify:
inter-ideograph;line-height:18.0pt'><span lang=ZH-CN style='font-size:10.5pt'>不难看出,原图中有很多噪声点</span><span
style='font-size:10.5pt;font-family:"Times New Roman"'>(</span><span
lang=ZH-CN style='font-size:10.5pt'>灰度为正代表灰度值高的点,灰度为负代表灰度值低的点</span><span
style='font-size:10.5pt;font-family:"Times New Roman"'>)</span><span
lang=ZH-CN style='font-size:10.5pt'>,而且是杂乱无章,随机分布的。这也是一类很典型的图,称之为高斯噪声。经过</span><span
style='font-size:10.5pt;font-family:"Times New Roman"'>Box</span><span
lang=ZH-CN style='font-size:10.5pt'>平滑,噪声的程度有所下降。</span><span style='font-size:
10.5pt;font-family:"Times New Roman"'>Gauss</span><span lang=ZH-CN
style='font-size:10.5pt'>模板对付高斯噪声非常有效。而中值滤波对于高斯噪声则无能为力。</span><span
style='font-size:10.5pt;font-family:"Times New Roman"'><o:p></o:p></span></p>
<p style='margin:0cm;margin-bottom:.0001pt;text-align:justify;text-justify:
inter-ideograph;line-height:18.0pt'><span lang=ZH-CN style='font-size:10.5pt'>最后看第三幅图:</span><span
style='font-size:10.5pt;font-family:"Times New Roman"'><o:p></o:p></span></p>
<div>
<table border=0 cellspacing=0 cellpadding=0 style='mso-cellspacing:0cm;
mso-padding-alt:0cm 0cm 0cm 0cm'>
<tr>
<td width=138 valign=top style='width:103.5pt;padding:0cm 0cm 0cm 0cm'>
<p align=center style='text-align:center;line-height:18.0pt'><span
lang=ZH-CN style='font-size:10.5pt'>原图</span><span style='font-size:10.5pt;
font-family:"Times New Roman"'><o:p></o:p></span></p>
</td>
<td width=138 valign=top style='width:103.5pt;padding:0cm 0cm 0cm 0cm'>
<p align=center style='text-align:center;line-height:18.0pt'><span
lang=ZH-CN style='font-size:10.5pt'>经</span><span style='font-size:10.5pt;
font-family:"Times New Roman"'>Box</span><span lang=ZH-CN style='font-size:
10.5pt'>模板处理后</span><span style='font-size:10.5pt;font-family:"Times New Roman"'><o:p></o:p></span></p>
</td>
<td width=138 valign=top style='width:103.5pt;padding:0cm 0cm 0cm 0cm'>
<p align=center style='text-align:center;line-height:18.0pt'><span
lang=ZH-CN style='font-size:10.5pt'>经</span><span style='font-size:10.5pt;
font-family:"Times New Roman"'>Gauss</span><span lang=ZH-CN style='font-size:
10.5pt'>模板处理后</span><span style='font-size:10.5pt;font-family:"Times New Roman"'><o:p></o:p></span></p>
</td>
<td width=138 valign=top style='width:103.5pt;padding:0cm 0cm 0cm 0cm'>
<p align=center style='text-align:center;line-height:18.0pt'><span
lang=ZH-CN style='font-size:10.5pt'>经中值滤波处理后</span><span style='font-size:
10.5pt;font-family:"Times New Roman"'><o:p></o:p></span></p>
</td>
</tr>
<tr>
<td width=138 style='width:103.5pt;padding:0cm 0cm 0cm 0cm'>
<p align=center style='text-align:center;line-height:18.0pt'><sub><span
style='font-size:10.5pt;font-family:"Times New Roman"'><!--[if gte vml 1]><v:shape
id="_x0000_i1056" type="#_x0000_t75" alt="" style='width:78.75pt;height:53.25pt'>
<v:imagedata src="./chp3.files/image027.gif" o:href="http://www-scf.usc.edu/~flv/ipbook/chap03.files/image059.gif"/>
</v:shape><![endif]--><![if !vml]><img width=105 height=71
src="./chp3.files/image027.gif" v:shapes="_x0000_i1056"><![endif]></span></sub><span
style='font-size:10.5pt;font-family:"Times New Roman"'><o:p></o:p></span></p>
</td>
<td width=138 style='width:103.5pt;padding:0cm 0cm 0cm 0cm'>
<p align=center style='text-align:center;line-height:18.0pt'><sub><span
style='font-size:10.5pt;font-family:"Times New Roman"'><!--[if gte vml 1]><v:shape
id="_x0000_i1057" type="#_x0000_t75" alt="" style='width:63.75pt;height:87pt'>
<v:imagedata src="./chp3.files/image028.gif" o:href="http://www-scf.usc.edu/~flv/ipbook/chap03.files/image061.gif"/>
</v:shape><![endif]--><![if !vml]><img width=85 height=116
src="./chp3.files/image028.gif" v:shapes="_x0000_i1057"><![endif]></span></sub><span
style='font-size:10.5pt;font-family:"Times New Roman"'><o:p></o:p></span></p>
</td>
<td width=138 style='width:103.5pt;padding:0cm 0cm 0cm 0cm'>
<p align=center style='text-align:center;line-height:18.0pt'><sub><span
style='font-size:10.5pt;font-family:"Times New Roman"'><!--[if gte vml 1]><v:shape
id="_x0000_i1058" type="#_x0000_t75" alt="" style='width:57pt;height:87pt'>
<v:imagedata src="./chp3.files/image029.gif" o:href="http://www-scf.usc.edu/~flv/ipbook/chap03.files/image063.gif"/>
</v:shape><![endif]--><![if !vml]><img width=76 height=116
src="./chp3.files/image029.gif" v:shapes="_x0000_i1058"><![endif]></span></sub><span
style='font-size:10.5pt;font-family:"Times New Roman"'><o:p></o:p></span></p>
</td>
<td width=138 style='width:103.5pt;padding:0cm 0cm 0cm 0cm'>
<p align=center style='text-align:center;line-height:18.0pt'><sub><span
style='font-size:10.5pt;font-family:"Times New Roman"'><!--[if gte vml 1]><v:shape
id="_x0000_i1059" type="#_x0000_t75" alt="" style='width:44.25pt;height:53.25pt'>
<v:imagedata src="./chp3.files/image030.gif" o:href="http://www-scf.usc.edu/~flv/ipbook/chap03.files/image065.gif"/>
</v:shape><![endif]--><![if !vml]><img width=59 height=71
src="./chp3.files/image030.gif" v:shapes="_x0000_i1059"><![endif]></span></sub><span
style='font-size:10.5pt;font-family:"Times New Roman"'><o:p></o:p></span></p>
</td>
</tr>
</table>
</div>
<p style='margin:0cm;margin-bottom:.0001pt;text-align:justify;text-justify:
inter-ideograph;line-height:18.0pt'><span lang=ZH-CN style='font-size:10.5pt'>从原图中不难看出,中间的灰度要比两边高许多。这也是一类很典型的图,称之为脉冲</span><span
style='font-size:10.5pt;font-family:"Times New Roman"'> (impulse)</span><span
lang=ZH-CN style='font-size:10.5pt'>。可见,中值滤波对脉冲噪声非常有效。</span><span
style='font-size:10.5pt;font-family:"Times New Roman"'><o:p></o:p></span></p>
<p style='margin:0cm;margin-bottom:.0001pt;text-align:justify;text-justify:
inter-ideograph;line-height:18.0pt'><span lang=ZH-CN style='font-size:10.5pt'>综合以上三类图,不难得出下面的结论:中值滤波容易去除孤立点,线的噪声同时保持图象的边缘;它能很好的去除二值噪声,但对高斯噪声无能为力。要注意的是,当窗口内噪声点的个数大于窗口宽度的一半时,中值滤波的效果不好。这是很显然的。</span><span
style='font-size:10.5pt;font-family:"Times New Roman"'><o:p></o:p></span></p>
<p style='margin:0cm;margin-bottom:.0001pt;text-align:justify;text-justify:
inter-ideograph;line-height:18.0pt'><span lang=ZH-CN style='font-size:10.5pt'>下面的程序实现了中值滤波,参数</span><span
style='font-size:10.5pt;font-family:"Times New Roman"'>Hori</span><span
lang=ZH-CN style='font-size:10.5pt'>是一个布尔变量,若为真,做水平中值滤波,否则,做垂直中值滤波。</span><span
style='font-size:10.5pt;font-family:"Times New Roman"'><o:p></o:p></span></p>
<p style='margin:0cm;margin-bottom:.0001pt;text-align:justify;text-justify:
inter-ideograph;line-height:18.0pt'><span style='font-size:10.5pt;font-family:
"Times New Roman"'>BOOL MedianFilter(HWND hWnd,BOOL Hori)<o:p></o:p></span></p>
<p style='margin:0cm;margin-bottom:.0001pt;text-align:justify;text-justify:
inter-ideograph;line-height:18.0pt'><span style='font-size:10.5pt;font-family:
"Times New Roman"'>{<o:p></o:p></span></p>
<p style='margin:0cm;margin-bottom:.0001pt;text-
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -