資源簡介
由純C實現的圖像配準代碼,安心下載,可以通過。

代碼片段和文件信息
#include?
#include?“stdafx.h“
#include?“math.h“
#include?“memory.h“
#include?“stdlib.h“
using?namespace?std;
void?main()
{
CFile?file;
CFile?file1;
unsigned?char?*pHeader1;
unsigned?char?*pHeader2;
BITMAPFILEHEADER?*pfHeader11;
BITMAPFILEHEADER?*pfHeader21;
HLOCAL?ppHeader1;
HLOCAL?ppHeader2;
CString?repStr;
if(!file.Open(“a.bmp“CFile::modeRead))
{
AfxMessageBox(“文件打開失敗,請確認輸入文件名正確!“);
return;
}
int?totallength1=file.GetLength();
????int?fhSize1;
unsigned?char?*pfHeader1;
BITMAPINFOHEADER?*pInfoHeader1;
ppHeader1=LocalAlloc(LHNDtotallength1);
pHeader1=(unsigned?char?*)LocalLock(ppHeader1);
if(pHeader1==NULL)
{
AfxMessageBox(“內存分配沒成功!請重來“);
return;
}
fhSize1=file.Read(pHeader1totallength1);
if(fhSize1!=totallength1)
{
AfxMessageBox(“讀取文件出錯,請重來!“);
return;
}
pfHeader1=(unsigned?char?*)pHeader1;
pfHeader11=(BITMAPFILEHEADER*)pHeader1;
pInfoHeader1=(BITMAPINFOHEADER*)(pHeader1+sizeof(BITMAPFILEHEADER));
if(pfHeader11->bfType!=0x4d42)
{
AfxMessageBox(“該文件不是BMP文件,或文件已經損壞!“);
return;
}
cout< cout<biHeight<<“\n“;
cout<biWidth<<“\n“;
cout<bfOffBits<<“\n“;
file.Close();
if(!file.Open(“b.bmp“CFile::modeRead))
{
AfxMessageBox(“文件打開失敗,請確認輸入文件名正確!“);
return;
}
int?totallength2=file.GetLength();
????int?fhSize2;
unsigned?char?*pfHeader2;
BITMAPINFOHEADER?*pInfoHeader2;
ppHeader2=LocalAlloc(LHNDtotallength2);
pHeader2=(unsigned?char?*)LocalLock(ppHeader2);
if(pHeader2==NULL)
{
AfxMessageBox(“內存分配沒成功!請重來“);
return;
}
fhSize2=file.Read(pHeader2totallength2);
if(fhSize2!=totallength2)
{
AfxMessageBox(“讀取文件出錯,請重來!“);
return;
}
pfHeader2=(unsigned?char?*)pHeader2;
pfHeader21=(BITMAPFILEHEADER*)pHeader2;
pInfoHeader2=(BITMAPINFOHEADER*)(pHeader2+sizeof(BITMAPFILEHEADER));
if(pfHeader21->bfType!=0x4d42)
{
AfxMessageBox(“該文件不是BMP文件,或文件已經損壞!“);
return;
}
cout< cout<biHeight<<“\n“;
cout<biWidth<<“\n“;
cout<bfOffBits<<“\n“;
file.Close();
int?width1=pInfoHeader1->biWidth;
int?width2=pInfoHeader2->biWidth;
????int?height1=pInfoHeader1->biHeight;
????int?height2=pInfoHeader2->biHeight;
float?base[500]?image[298][500];
for(int?a=0;a<=499;a++)
{
base[a]=(float)pHeader1[(60+a)*width1-1+pfHeader11->bfOffBits]/(pHeader1[(60+a)*width1-1-20+pfHeader11->bfOffBits]+1);
}
for(int?b=0;b<297;b++)
{
for(int?c=0;c<=499;c++)
{
image[b][c]=(float)pHeader2[(60+c)*width2+b+20+pfHeader21->bfOffBits]/(pHeader2[(60+c)*width2+b+pfHeader21->bfOffBits]+1);
}
? }
????float?err[370];
????for(int?k=0;k<=width2/2;k++)
{
????????err[k]=0;
???? for(int?d=0;d<=499;d++)
{
???????????err[k]=err[k]+(image[k][d]-base[d])*(image[k][d]-base[d])/1000;
}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????378598??2005-06-29?11:59??mosaic\a.bmp
?????文件?????361658??2005-06-29?11:58??mosaic\b.bmp
?????文件?????581878??2012-01-09?13:47??mosaic\c.bmp
?????文件?????378598??2005-06-29?11:59??mosaic\Debug\a.bmp
?????文件?????361658??2005-06-29?11:58??mosaic\Debug\b.bmp
?????文件??????10080??2011-12-07?14:19??mosaic\Debug\BuildLog.htm
?????文件?????581878??2011-11-28?13:23??mosaic\Debug\c.bmp
?????文件????1839104??2011-12-07?14:19??mosaic\Debug\jie.exe
?????文件????????406??2011-12-07?14:19??mosaic\Debug\jie.exe.em
?????文件????????472??2011-12-07?14:19??mosaic\Debug\jie.exe.em
?????文件????????381??2011-12-07?14:19??mosaic\Debug\jie.exe.intermediate.manifest
?????文件????5875904??2011-12-07?14:19??mosaic\Debug\jie.ilk
?????文件?????354923??2011-12-07?14:19??mosaic\Debug\jie.obj
?????文件???11635712??2011-12-07?14:19??mosaic\Debug\jie.pdb
?????文件?????????69??2011-12-07?14:19??mosaic\Debug\mt.dep
?????文件?????773120??2011-12-07?14:19??mosaic\Debug\vc90.idb
?????文件?????765952??2011-12-07?14:19??mosaic\Debug\vc90.pdb
?????文件???????4466??2011-11-27?12:16??mosaic\jie.cpp
?????文件???????3397??2007-07-06?13:35??mosaic\jie.dsp
?????文件????????529??2007-07-06?13:35??mosaic\jie.dsw
?????文件???23235584??2012-01-09?13:48??mosaic\jie.ncb
?????文件??????48640??2007-07-06?13:35??mosaic\jie.opt
?????文件???????1199??2007-07-06?13:27??mosaic\jie.plg
?????文件????????871??2011-12-07?14:18??mosaic\jie.sln
????..A..H.??????9728??2012-01-09?13:48??mosaic\jie.suo
?????文件???????4805??2011-11-27?09:50??mosaic\jie.vcproj
?????文件???????1427??2012-01-09?13:48??mosaic\jie.vcproj.B04KILE5DW7IU1U.Administrator.user
?????文件????????616??2001-08-24?17:52??mosaic\StdAfx.cpp
?????文件???????1054??1999-09-13?13:24??mosaic\StdAfx.h
?????目錄??????????0??2011-12-07?14:19??mosaic\Debug
............此處省略4個文件信息
評論
共有 條評論