📄 chp4.htm
字号:
</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"'>256</span><span
lang=ZH-CN style='font-size:10.5pt'>级灰度的图案,就需要</span><span style='font-size:
10.5pt;font-family:"Times New Roman"'>256</span><span lang=ZH-CN
style='font-size:10.5pt'>×</span><span style='font-size:10.5pt;font-family:
"Times New Roman"'>16</span><span lang=ZH-CN style='font-size:10.5pt'>×</span><span
style='font-size:10.5pt;font-family:"Times New Roman"'>16</span><span
lang=ZH-CN style='font-size:10.5pt'>的二值点阵,占用的空间还是相当可观的。有一个更好的办法是:只存储一个整数矩阵,称为标准图案,其中的每个值从</span><span
style='font-size:10.5pt;font-family:"Times New Roman"'>0</span><span
lang=ZH-CN style='font-size:10.5pt'>到</span><span style='font-size:10.5pt;
font-family:"Times New Roman"'>255</span><span lang=ZH-CN style='font-size:
10.5pt'>。图象的实际灰度和阵列中的每个值比较,当该值大于等于灰度时,对应点打一黑点。下面举一个</span><span
style='font-size:10.5pt;font-family:"Times New Roman"'>25</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 class=a style='margin:0cm;margin-bottom:.0001pt;line-height:18.0pt'><!--[if gte vml 1]><v:shape
id="_x0000_i1028" type="#_x0000_t75" alt="" style='width:213.75pt;height:93pt'>
<v:imagedata src="./chp4.files/image004.jpg" o:href="http://www-scf.usc.edu/~flv/ipbook/chap04.files/image005.jpg"/>
</v:shape><![endif]--><![if !vml]><img width=285 height=124
src="./chp4.files/image004.jpg" v:shapes="_x0000_i1028"><![endif]></p>
<p align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;
line-height:18.0pt'><b><span lang=ZH-CN style='font-size:10.5pt'>图</span></b><b><span
style='font-size:10.5pt;font-family:"Times New Roman"'>4.4
</span></b><b><span lang=ZH-CN style='font-size:10.5pt'>标准图案举例</span></b><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"'>4.4</span><span
lang=ZH-CN style='font-size:10.5pt'>中,左边为标准图案,右边为灰度为</span><span
style='font-size:10.5pt;font-family:"Times New Roman"'>15</span><span
lang=ZH-CN style='font-size:10.5pt'>的图案,共有</span><span style='font-size:10.5pt;
font-family:"Times New Roman"'>10</span><span lang=ZH-CN style='font-size:10.5pt'>个黑点,</span><span
style='font-size:10.5pt;font-family:"Times New Roman"'>15</span><span
lang=ZH-CN style='font-size:10.5pt'>个白点。其实道理很简单,灰度为</span><span
style='font-size:10.5pt;font-family:"Times New Roman"'>0</span><span
lang=ZH-CN style='font-size:10.5pt'>时全是黑点,灰度每增加</span><span style='font-size:
10.5pt;font-family:"Times New Roman"'>1</span><span lang=ZH-CN
style='font-size:10.5pt'>,减少一个黑点。要注意的是,</span><span style='font-size:10.5pt;
font-family:"Times New Roman"'>5</span><span lang=ZH-CN style='font-size:10.5pt'>×</span><span
style='font-size:10.5pt;font-family:"Times New Roman"'>5</span><span
lang=ZH-CN style='font-size:10.5pt'>的图案可以表示</span><span style='font-size:10.5pt;
font-family:"Times New Roman"'>26</span><span lang=ZH-CN style='font-size:10.5pt'>种灰度,当灰度是</span><span
style='font-size:10.5pt;font-family:"Times New Roman"'>25</span><span
lang=ZH-CN style='font-size:10.5pt'>才是全白点,而不是灰度为</span><span style='font-size:
10.5pt;font-family:"Times New Roman"'>24</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"'>Limb</span><span
lang=ZH-CN style='font-size:10.5pt'>在</span><span style='font-size:10.5pt;
font-family:"Times New Roman"'>1969</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"'>2</span><span
lang=ZH-CN style='font-size:10.5pt'>×</span><span style='font-size:10.5pt;
font-family:"Times New Roman"'>2</span><span lang=ZH-CN style='font-size:10.5pt'>的矩阵开始:设</span><span
style='font-size:10.5pt;font-family:"Times New Roman"'>M<sub>1</sub>=<sub> <!--[if gte vml 1]><v:shape
id="_x0000_i1029" type="#_x0000_t75" alt="" style='width:36.75pt;height:36pt'>
<v:imagedata src="./chp4.files/image005.gif" o:href="http://www-scf.usc.edu/~flv/ipbook/chap04.files/image007.gif"/>
</v:shape><![endif]--><![if !vml]><img width=49 height=48
src="./chp4.files/image005.gif" v:shapes="_x0000_i1029"><![endif]></sub></span><span
lang=ZH-CN style='font-size:10.5pt'>,通过递归关系有</span><span style='font-size:10.5pt;
font-family:"Times New Roman"'>M<sub>n+1</sub>=<sub> <!--[if gte vml 1]><v:shape
id="_x0000_i1030" type="#_x0000_t75" alt="" style='width:135.75pt;height:38.25pt'>
<v:imagedata src="./chp4.files/image006.gif" o:href="http://www-scf.usc.edu/~flv/ipbook/chap04.files/image009.gif"/>
</v:shape><![endif]--><![if !vml]><img width=181 height=51
src="./chp4.files/image006.gif" v:shapes="_x0000_i1030"><![endif]></sub></span><span
lang=ZH-CN style='font-size:10.5pt'>,其中</span><span style='font-size:10.5pt;
font-family:"Times New Roman"'>M<sub>n</sub></span><span lang=ZH-CN
style='font-size:10.5pt'>和</span><span style='font-size:10.5pt;font-family:
"Times New Roman"'>U<sub>n</sub></span><span lang=ZH-CN style='font-size:10.5pt'>均为</span><span
style='font-size:10.5pt;font-family:"Times New Roman"'>2<sup>n</sup></span><span
lang=ZH-CN style='font-size:10.5pt'>×</span><span style='font-size:10.5pt;
font-family:"Times New Roman"'>2<sup>n</sup></span><span lang=ZH-CN
style='font-size:10.5pt'>的方阵,</span><span style='font-size:10.5pt;font-family:
"Times New Roman"'>U<sub>n</sub></span><span lang=ZH-CN style='font-size:10.5pt'>的所有元素都是</span><span
style='font-size:10.5pt;font-family:"Times New Roman"'>1</span><span
lang=ZH-CN style='font-size:10.5pt'>。根据这个算法,可以得到</span><span style='font-size:
10.5pt;font-family:"Times New Roman"'>M<sub>2</sub>=<sub> <!--[if gte vml 1]><v:shape
id="_x0000_i1031" type="#_x0000_t75" alt="" style='width:90pt;height:1in'>
<v:imagedata src="./chp4.files/image007.gif" o:href="http://www-scf.usc.edu/~flv/ipbook/chap04.files/image011.gif"/>
</v:shape><![endif]--><![if !vml]><img width=120 height=96
src="./chp4.files/image007.gif" v:shapes="_x0000_i1031"><![endif]></sub></span><span
lang=ZH-CN style='font-size:10.5pt'>,为</span><span style='font-size:10.5pt;
font-family:"Times New Roman"'>16</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"'>M<sub>3</sub>(8</span><span lang=ZH-CN style='font-size:
10.5pt'>×</span><span style='font-size:10.5pt;font-family:"Times New Roman"'>8</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"'>Bayer</span><span
lang=ZH-CN style='font-size:10.5pt'>抖动表。</span><span style='font-size:10.5pt;
font-family:"Times New Roman"'>M<sub>4</sub></span><span lang=ZH-CN
style='font-size:10.5pt'>是一个</span><span style='font-size:10.5pt;font-family:
"Times New Roman"'>16</span><span lang=ZH-CN style='font-size:10.5pt'>×</span><span
style='font-size:10.5pt;font-family:"Times New Roman"'>16</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"'>M<sub>3</sub></span><span
lang=ZH-CN style='font-size:10.5pt'>一个象素要用</span><span style='font-size:10.5pt;
font-family:"Times New Roman"'>8</span><span lang=ZH-CN style='font-size:10.5pt'>×</span><span
style='font-size:10.5pt;font-family:"Times New Roman"'>8</span><span
lang=ZH-CN style='font-size:10.5pt'>的图案表示,则一幅</span><span style='font-size:
10.5pt;font-family:"Times New Roman"'>N</span><span lang=ZH-CN
style='font-size:10.5pt'>×</span><span style='font-size:10.5pt;font-family:
"Times New Roman"'>N</span><span lang=ZH-CN style='font-size:10.5pt'>的图将变成</span><span
style='font-size:10.5pt;font-family:"Times New Roman"'>8N</span><span
lang=ZH-CN style='font-size:10.5pt'>×</span><span style='font-size:10.5pt;
font-family:"Times New Roman"'>8N</span><span lang=ZH-CN style='font-size:10.5pt'>大小。如果利用</span><span
style='font-size:10.5pt;font-family:"Times New Roman"'>M<sub>4</sub></span><span
lang=ZH-CN style='font-size:10.5pt'>,就更不得了,变成</span><span style='font-size:
10.5pt;font-family:"Times New Roman"'>16N</span><span lang=ZH-CN
style='font-size:10.5pt'>×</span><span style='font-size:10.5pt;font-family:
"Times New Roman"'>16N</span><span lang=ZH-CN style='font-size:10.5pt'>了。能不能在保持原图大小的情况下利用图案化技术呢?一种很自然的想法是:如果用</span><span
style='font-size:10.5pt;font-family:"Times New Roman"'>M<sub>2</sub></span><span
lang=ZH-CN style='font-size:10.5pt'>阵,则将原图中每</span><span style='font-size:10.5pt;
font-family:"Times New Roman"'>8</span><span lang=ZH-CN style='font-size:10.5pt'>×</span><span
style='font-size:10.5pt;font-family:"Times New Roman"'>8</span><span
lang=ZH-CN style='font-size:10.5pt'>个点中取一点,即重新采样,然后再应用图案化技术,就能够保持原图大小。实际上,这种方法并不可行。首先,你不知道这</span><span
style='font-size:10.5pt;font-family:"Times New Roman"'>8</span><span
lang=ZH-CN style='font-size:10.5pt'>×</span><span style='font-size:10.5pt;
font-family:"Times New Roman"'>8</span><span lang=ZH-CN style='font-size:10.5pt'>个点中找哪一点比较合适,另外,</span><span
style='font-size:10.5pt;font-family:"Times New Roman"'>8</span><span
lang=ZH-CN style='font-size:10.5pt'>×</span><span style='font-size:10.5pt;
font-family:"Times New Roman"'>8</span><span lang=ZH-CN style='font-size:10.5pt'>的间隔实在太大了,生成的图象和原图肯定相差很大,就象图</span><span
style='font-size:10.5pt;font-family:"Times New Roman"'>4.1</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"'>256</span><span
lang=ZH-CN style='font-size:10.5pt'>级灰度,利用</span><span style='font-size:10.5pt;
font-family:"Times New Roman"'>Bayer</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 align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;
line-height:18.0pt'><span style='font-size:10.5pt;font-family:"Times New Roman"'>if
(g[y][x]>>2) > bayer[y&7][x&7] then </span><span lang=ZH-CN
style='font-size:10.5pt'>打一白点</span><span style='font-size:10.5pt;font-family:
"Times New Roman"'> else </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"'>x,y</span><span
lang=ZH-CN style='font-size:10.5pt'>代表原图的象素坐标,</span><span style='font-size:
10.5pt;font-family:"Times New Roman"'>g[y][x]</span><span lang=ZH-CN
style='font-size:10.5pt'>代表该点灰度。首先将灰度右移两位,变成</span><span style='font-size:10.5pt;
font-family:"Times New Roman"'>64</span><span lang=ZH-CN style='font-size:10.5pt'>级,然后将</span><span
style='font-size:10.5pt;font-family:"Times New Roman"'>x</span><span
lang=ZH-CN style='font-size:10.5pt'>,</span><span style='font-size:10.5pt;
font-family:"Times New Roman"'>y</span><span lang=ZH-CN style='font-size:10.5pt'>做模</span><span
style='font-size:10.5pt;font-family:"Times New Roman"'>8</span><span
lang=ZH-CN style='font-size:10.5pt'>运算,找到</span><span style='font-size:10.5pt;
font-family:"Times New Roman"'>Bayer</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"'>8</span><span
lang=ZH-CN style='font-size:10.5pt'>运算使得原图分成了一个个</span><span style='font-size:
10.5pt;font-family:"Times New Roman"'>8</span><span lang=ZH-CN
style='font-size:10.5pt'>×</span><span style='font-size:10.5pt;font-family:
"Times New Roman"'>8</span><span lang=ZH-CN style='font-size:10.5pt'>的小块,每个小块和</span><span
style='font-size:10.5pt;font-family:"Times New Roman"'>8</span><span
lang=ZH-CN style='font-size:10.5pt'>×</span><span style='font-size:10.5pt;
font-family:"Times New Roman"'>8</span><span lang=ZH-CN style='font-size:10.5pt'>的</span><span
style='font-size:10.5pt;font-family:"Times New Roman"'>Bayer</span><span
lang=ZH-CN style='font-size:10.5pt'>表相对应。小块中的每个点都参与了比较,这样就避免了上面提到的选点和块划分过大的问题。模</span><span
style='font-size:10.5pt;font-family:"Times New Roman"'>8</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"'>4.5</span><span
lang=ZH-CN style='font-size:10.5pt'>就是利用了这个算法,使用</span><span style='font-size:
10.5pt;font-family:"Times New Roman"'>M<sub>3</sub>(Bayer</span><span
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -