⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chp8.htm

📁 数字图象处理入门,非常好的书!!!!推荐!
💻 HTM
📖 第 1 页 / 共 5 页
字号:
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=184 valign=top style='width:138.0pt;padding:0cm 0cm 0cm 0cm'>
  <p style='text-align:justify;text-justify:inter-ideograph;line-height:18.0pt'><span
  style='font-size:10.5pt;font-family:"Times New Roman"'><!--[if gte vml 1]><v:shape
   id="_x0000_i1030" type="#_x0000_t75" alt="" style='width:138pt;height:111pt'>
   <v:imagedata src="./chp8.files/image006.jpg" o:href="http://www-scf.usc.edu/~flv/ipbook/chap08.files/image011.jpg"/>
  </v:shape><![endif]--><![if !vml]><img width=184 height=148
  src="./chp8.files/image006.jpg" v:shapes="_x0000_i1030"><![endif]><o:p></o:p></span></p>
  <p align=center style='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"'>8.6&nbsp;&nbsp;&nbsp;&nbsp; </span></b><b><span
  lang=ZH-CN style='font-size:10.5pt'>前景</span></b><b><span style='font-size:
  10.5pt;font-family:"Times New Roman"'>+</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>
  </td>
  <td width=184 valign=top style='width:138.0pt;padding:0cm 0cm 0cm 0cm'>
  <p style='text-align:justify;text-justify:inter-ideograph;line-height:18.0pt'><span
  style='font-size:10.5pt;font-family:"Times New Roman"'><!--[if gte vml 1]><v:shape
   id="_x0000_i1031" type="#_x0000_t75" alt="" style='width:139.5pt;height:112.5pt'>
   <v:imagedata src="./chp8.files/image007.jpg" o:href="http://www-scf.usc.edu/~flv/ipbook/chap08.files/image013.jpg"/>
  </v:shape><![endif]--><![if !vml]><img width=186 height=150
  src="./chp8.files/image007.jpg" v:shapes="_x0000_i1031"><![endif]><o:p></o:p></span></p>
  <p align=center style='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"'>8.7&nbsp;&nbsp;&nbsp;&nbsp; </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>
  </td>
  <td width=184 valign=top style='width:138.0pt;padding:0cm 0cm 0cm 0cm'>
  <p style='text-align:justify;text-justify:inter-ideograph;line-height:18.0pt'><span
  style='font-size:10.5pt;font-family:"Times New Roman"'><!--[if gte vml 1]><v:shape
   id="_x0000_i1032" type="#_x0000_t75" alt="" style='width:139.5pt;height:112.5pt'>
   <v:imagedata src="./chp8.files/image008.jpg" o:href="http://www-scf.usc.edu/~flv/ipbook/chap08.files/image015.jpg"/>
  </v:shape><![endif]--><![if !vml]><img width=186 height=150
  src="./chp8.files/image008.jpg" v:shapes="_x0000_i1032"><![endif]><o:p></o:p></span></p>
  <p align=center style='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"'>8.8 </span></b><b><span lang=ZH-CN
  style='font-size:10.5pt'>图</span></b><b><span style='font-size:10.5pt;
  font-family:"Times New Roman"'>8.6</span></b><b><span lang=ZH-CN
  style='font-size:10.5pt'>、图</span></b><b><span style='font-size:10.5pt;
  font-family:"Times New Roman"'>8.7</span></b><span style='font-size:10.5pt;
  font-family:"Times New Roman"'><o:p></o:p></span></p>
  <p align=center style='text-align:center;line-height:18.0pt'><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>
  </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"'>8.6</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"'>)</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"'>)</span><span
lang=ZH-CN style='font-size:10.5pt'>。图</span><span style='font-size:10.5pt;
font-family:"Times New Roman"'>8.7</span><span lang=ZH-CN style='font-size:
10.5pt'>是背景图。图</span><span style='font-size:10.5pt;font-family:"Times New Roman"'>8.6</span><span
lang=ZH-CN style='font-size:10.5pt'>减图</span><span style='font-size:10.5pt;
font-family:"Times New Roman"'>8.7</span><span lang=ZH-CN style='font-size:
10.5pt'>的结果如图</span><span style='font-size:10.5pt;font-family:"Times New Roman"'>8.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"'>)</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"'><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"'>c:\test.bmp</span><span
lang=ZH-CN style='font-size:10.5pt'>,第二幅图的文件名是</span><span style='font-size:
10.5pt;font-family:"Times New Roman"'>c:\backgnd.bmp</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"'>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"'><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 Subtraction(HWND hWnd)<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-align:justify;text-justify:
inter-ideograph;line-height:18.0pt'><span style='font-size:10.5pt;font-family:
"Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DWORD&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OffBits,BufSize;<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"'>LPBITMAPINFOHEADER&nbsp;&nbsp;&nbsp; lpImgData;<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"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
LPSTR&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
lpPtr;<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"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
HGLOBAL&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hSecond;<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"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
LPBITMAPINFOHEADER&nbsp;&nbsp;&nbsp; lpSecondImgData;<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"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
LPSTR&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lpSecondPtr;<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"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
HLOCAL&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
hTempImgData;<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"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
LPBITMAPINFOHEADER&nbsp;&nbsp;&nbsp; lpTempImgData;<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"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
LPSTR&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
lpTempPtr;<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"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
HDC&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hDc;<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"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
HFILE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hf;<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"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
LONG&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; x,y;<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"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
int&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; num,pos;<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"'>//</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"'>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"'><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"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if( NumColors!=256){<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"'>MessageBox(hWnd,&quot;Must be a mono bitmap with grayscale
palette!&quot;,<o:p></o:p></span></p>

<p style='margin:0cm;margin-bottom:.0001pt;text-align:justify;text-justify:
inter-ideograph;line-

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -