?? 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 + -