📄 chap03.htm
字号:
<html>
<!-- Mirrored from www.lgui.net/column/book1/chap03.htm by HTTrack Website Copier/3.x [XR&CO'2005], Mon, 21 Mar 2005 13:19:48 GMT -->
<head>
<meta http-equiv=Content-Type content="text/html; charset=GB2312">
<link rel=Edit-Time-Data href="chap03.files/editdata.html" >
<link rel=OLE-Object-Data href="chap03.files/oledata.mso" >
<title>第3章 图象的平滑(去噪声)、锐化</title>
<style><!--
.Normal
{text-align:justify;
text-justify:inter-ideograph;
text-indent:0pt;
line-height:normal;
font-size:10.5pt;
font-family:"Times New Roman";}
.a
{text-align:center;
text-indent:0pt;
line-height:20.0pt;
font-size:12.0pt;
font-family:"Times New Roman";}
-->
</style>
</head>
<body lang=ZH-CN link=blue vlink=purple class="Normal" bgcolor="#FFFFFF">
<div style='layout-grid:15.6pt'>
<h1><a name="_Toc486331873"></a><a name="_Toc486332873"></a><a
name="_Toc486338982"></a><a name="_Toc454810847"></a><a name="_Toc454856621"><span><span>第<span
lang=EN-US>3</span></span></span></a><span><span><span style='font-family:黑体;"Times New Roman"'>章</span>
</span></span><span><span><span
style='font-family:黑体;"Times New Roman"'>图象的平滑</span><span
lang=EN-US>(</span></span></span><span><span><span style='font-family:黑体;"Times New Roman"'>去噪声</span><span
lang=EN-US>)</span></span></span><span><span><span style='font-family:黑体;"Times New Roman"'>、锐化</span></span></span></h1>
<h2> <span
lang=EN-US>3.1</span> <span lang=EN-US> </span><a name="_Toc486331874"></a><a
name="_Toc486332874"></a><a name="_Toc486338983"></a><a name="_Toc454810848"></a><a
name="_Toc454856622"><span><span>平滑</span></span></a></h2>
<p style='line-height:18.0pt'><span
style='font-family:宋体;"Times New Roman"'>先举个例子说明一下什么是平滑</span><span lang=EN-US>(smoothing)</span><span
style='font-family:宋体;"Times New Roman"'>,如下面两幅图所示:可以看到,图</span><span lang=EN-US>3.2</span><span
style='font-family:宋体;"Times New Roman"'>比图</span><span lang=EN-US>3.1</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>)</span><span
style='font-family:宋体;"Times New Roman"'>。是不是觉得很神奇?其实实现起来很简单。我们将原图中的每一点的灰度和它周围八个点的灰度相加,然后除以</span><span
lang=EN-US>9</span><span style='font-family:宋体;
"Times New Roman"'>,作为新图中对应点的灰度,就能实现上面的效果。</span></p>
<table border=0 cellspacing=0 cellpadding=0>
<tr>
<td width=276 valign=top class="Normal">
<p class=a style='line-height:18.0pt'><span lang=EN-US> <img width=170 height=189
src="chap03.files/image001.gif" v:shapes="_x0000_i1043"> </span></p>
<p class=a style='line-height:18.0pt'><b><span style='font-family:宋体;
"Times New Roman"'>图</span>3.1 </b><b><span
style='font-family:宋体;"Times New Roman"'>原图</span><span lang=EN-US></span></b></p>
</td>
<td width=276 valign=top class="Normal">
<p align=center style='text-align:center;line-height:18.0pt'><span
lang=EN-US> <img width=168 height=188
src="chap03.files/image003.gif" v:shapes="_x0000_i1042"> </span></p>
<p align=center style='text-align:center;line-height:18.0pt'><b><span
style='font-family:宋体;"Times New Roman"'>图</span>3.2
</b><b><span style='font-family:
宋体;"Times New Roman"'>经过平滑处理后的图</span><span
lang=EN-US></span></b></p>
</td>
</tr>
</table>
<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>(low
pass filter)</span><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>9</span><span style='font-family:宋体;
"Times New Roman"'>,作为新图中对应点的灰度”这一操作,我们采用如下的表示方法:</span></p>
<p align=center style='text-align:center;line-height:18.0pt'><b><span
lang=EN-US><sub> <img width=92 height=75
src="chap03.files/image005.gif" v:shapes="_x0000_i1044"> </sub> </span></b></p>
<p align=right style='text-align:right;line-height:18.0pt'><span
lang=EN-US>(3.1)<b></b></span></p>
<p style='line-height:18.0pt'><span
style='font-family:宋体;"Times New Roman"'>这种表示方法有点象矩阵,我们称其为模板</span><span lang=EN-US>(template)</span><span
style='font-family:宋体;"Times New Roman"'>。中间的黑点表示中心元素,即,用哪个元素做为处理后的元素。例如</span><span lang=EN-US>[2.
1]</span><span style='font-family:宋体;
"Times New Roman"'>表示将自身的</span><span lang=EN-US>2</span><span
style='font-family:宋体;"Times New Roman"'>倍加上右边的元素作为新值,而</span><span lang=EN-US>[2
1.]</span><span
style='font-family:宋体;"Times New Roman"'>表示将自身加上左边元素的</span><span lang=EN-US>2</span><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><sub>
<img width=51 height=48
src="chap03.files/image007.gif" v:shapes="_x0000_i1045"> </sub> </span><span style='font-family:宋体;"Times New Roman";"Times New Roman"'>,原图是</span><span
lang=EN-US><sub> <img width=119 height=96
src="chap03.files/image009.gif" v:shapes="_x0000_i1046"> </sub> </span><span style='font-family:宋体;"Times New Roman";"Times New Roman"'>,经过模板操作后的图象为</span><span
lang=EN-US><sub> <img width=120 height=96
src="chap03.files/image011.gif" v:shapes="_x0000_i1047"> </sub> </span><span style='font-family:宋体;"Times New Roman";"Times New Roman"'>;其中数字代表灰度,</span><span
lang=EN-US>x</span><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>(Neighborhood
Operation)</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>)</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>
<p align=center style='text-align:center;line-height:18.0pt'><span
lang=EN-US><sub> <img width=107 height=75
src="chap03.files/image013.gif" v:shapes="_x0000_i1069"> </sub> </span></p>
<p align=right style='text-align:right;line-height:18.0pt'><span
lang=EN-US>(3.2)</span></p>
<p style='line-height:18.0pt'><span style='font-family:宋体;
"Times New Roman"'>为例,每个象素完成一次模板操作要用</span><span
lang=EN-US>9</span><span style='font-family:宋体;
"Times New Roman"'>个乘法、</span><span lang=EN-US>8</span><span
style='font-family:宋体;"Times New Roman"'>个加法、</span><span lang=EN-US>1</span><span style='font-family:
宋体;"Times New Roman"'>个除法。对于一幅</span><span
lang=EN-US>n</span><span style='font-family:宋体;
"Times New Roman"'>×</span><span lang=EN-US>n(</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>9n<sup>2</sup></span><span style='font-family:宋体;"Times New Roman";"Times New Roman"'>个乘法,</span><span
lang=EN-US>8n<sup>2</sup></span><span style='font-family:宋体;"Times New Roman";"Times New Roman"'>个加法和</span><span
lang=EN-US>n<sup>2</sup></span><span style='font-family:宋体;"Times New Roman";"Times New Roman"'>个除法,算法复杂度为</span><span
lang=EN-US>O(n<sup>2</sup>)</span><span style='font-family:宋体;"Times New Roman";"Times New Roman"'>,这对于大图象来说,是非常可怕的。所以,一般常用的模板并不大,如</span><span
lang=EN-US>3</span><span style='font-family:宋体;
"Times New Roman"'>×</span><span lang=EN-US>3</span><span
style='font-family:宋体;"Times New Roman"'>,</span><span lang=EN-US>4</span><span style='font-family:
宋体;"Times New Roman"'>×</span><span
lang=EN-US>4</span><span style='font-family:宋体;
"Times New Roman"'>。有很多专用的图象处理系统,用硬件来完成模板运算,大大提高了速度。另外,可以设法将二维模板运算转换成一维模板运算,对速度的提高也是非常可观的。例如,</span><span
lang=EN-US>(3.2)</span><span style='font-family:宋体;
"Times New Roman"'>式可以分解成一个水平模板和一个垂直模板,即,</span></p>
<p align=center style='text-align:center;line-height:18.0pt'><span
lang=EN-US><sub> <img width=107 height=75
src="chap03.files/image014.gif" v:shapes="_x0000_i1070"> </sub> =<sub> <img width=88 height=41
src="chap03.files/image016.gif" v:shapes="_x0000_i1071"> </sub> </span><span style='font-family:宋体;"Times New Roman";"Times New Roman"'>×</span>
<span
lang=EN-US><sub> <img width=55 height=75
src="chap03.files/image018.gif" v:shapes="_x0000_i1072"> </sub> =<sub> <img width=133 height=75
src="chap03.files/image020.gif" v:shapes="_x0000_i1073"> </sub> </span></p>
<p align=right style='text-align:right;line-height:18.0pt'><span
lang=EN-US>(3.3)</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><sub> <img width=96 height=96
src="chap03.files/image022.gif" v:shapes="_x0000_i1074"> </sub> </span><span style='font-family:宋体;"Times New Roman";"Times New Roman"'>,经过</span><span
lang=EN-US>(3.2)</span><span style='font-family:宋体;
"Times New Roman"'>式处理后变为</span><span lang=EN-US><sub> <img width=136 height=96
src="chap03.files/image024.gif" v:shapes="_x0000_i1075"> </sub> </span><span style='font-family:宋体;"Times New Roman";"Times New Roman"'>,经过</span><span
lang=EN-US>(3.3)</span><span style='font-family:宋体;
"Times New Roman"'>式处理后变为</span><span lang=EN-US><sub> <img width=136 height=96
src="chap03.files/image026.gif" v:shapes="_x0000_i1076"> </sub> </span><span style='font-family:宋体;"Times New Roman";"Times New Roman"'>,两者完全一样。如果计算时不考虑周围一圈的象素,前者做了</span><span
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -