資源簡介
KL變換可以實現(xiàn)圖像特征空間的運動,從而達(dá)到縮減數(shù)據(jù)量的目的,等等,支持位圖,可隨意修改波段數(shù)量
代碼附帶了說明文檔,有圖有真相

代碼片段和文件信息
//?cdib.cpp
//?new?version?for?WIN32
#include?“stdafx.h“
#include?“cdib.h“
#ifdef?_DEBUG
#define?new?DEBUG_NEW
#undef?THIS_FILE
static?char?THIS_FILE[]?=?__FILE__;
#endif
IMPLEMENT_SERIAL(CDib?Cobject?0);
CDib::CDib()
{
m_hFile?=?NULL;
m_hBitmap?=?NULL;
m_hPalette?=?NULL;
m_nBmihAlloc?=?m_nImageAlloc?=?noAlloc;
Empty();
}
CDib::CDib(CSize?size?int?nBitCount)
{
m_hFile?=?NULL;
m_hBitmap?=?NULL;
m_hPalette?=?NULL;
m_nBmihAlloc?=?m_nImageAlloc?=?noAlloc;
Empty();
ComputePaletteSize(nBitCount);
m_lpBMIH?=?(LPBITMAPINFOHEADER)?new?
char[sizeof(BITMAPINFOHEADER)?+?sizeof(RGBQUAD)?*?m_nColorTableEntries];
m_nBmihAlloc?=?crtAlloc;
m_lpBMIH->biSize?=?sizeof(BITMAPINFOHEADER);
m_lpBMIH->biWidth?=?size.cx;
m_lpBMIH->biHeight?=?size.cy;
m_lpBMIH->biPlanes?=?1;
m_lpBMIH->biBitCount?=?nBitCount;
m_lpBMIH->biCompression?=?BI_RGB;
m_lpBMIH->biSizeImage?=?0;
m_lpBMIH->biXPelsPerMeter?=?0;
m_lpBMIH->biYPelsPerMeter?=?0;
m_lpBMIH->biClrUsed?=?m_nColorTableEntries;
m_lpBMIH->biClrImportant?=?m_nColorTableEntries;
ComputeMetrics();
memset(m_lpvColorTable?0?sizeof(RGBQUAD)?*?m_nColorTableEntries);
m_lpImage?=?NULL;??//?no?data?yet
}
CDib::~CDib()
{
Empty();
}
CSize?CDib::GetDimensions()
{
if(m_lpBMIH?==?NULL)?return?CSize(0?0);
return?CSize((int)?m_lpBMIH->biWidth?(int)?m_lpBMIH->biHeight);
}
BOOL?CDib::AttachMapFile(const?char*?strPathname?BOOL?bShare)?//?for?reading
{
//?if?we?open?the?same?file?twice?Windows?treats?it?as?2?separate?files
//?doesn‘t?work?with?rare?BMP?files?where?#?palette?entries?>?biClrUsed
HANDLE?hFile?=?::CreateFile(strPathname?GENERIC_WRITE?|?GENERIC_READ
bShare???FILE_SHARE_READ?:?0
NULL?OPEN_EXISTING?FILE_ATTRIBUTE_NORMAL?NULL);
ASSERT(hFile?!=?INVALID_HANDLE_VALUE);
DWORD?dwFileSize?=?::GetFileSize(hFile?NULL);
HANDLE?hMap?=?::CreateFileMapping(hFile?NULL?PAGE_READWRITE?0?0?NULL);
DWORD?dwErr?=?::GetLastError();
if(hMap?==?NULL)
{
AfxMessageBox(“Empty?bitmap?file“);
return?FALSE;
}
LPVOID?lpvFile?=?::MapViewOfFile(hMap?FILE_MAP_WRITE?0?0?0);?//?map?whole?file
ASSERT(lpvFile?!=?NULL);
if(((LPBITMAPFILEHEADER)?lpvFile)->bfType?!=?0x4d42)
{
AfxMessageBox(“Invalid?bitmap?file“);
DetachMapFile();
return?FALSE;
}
AttachMemory((LPBYTE)?lpvFile?+?sizeof(BITMAPFILEHEADER));
m_lpvFile?=?lpvFile;
m_hFile?=?hFile;
m_hMap?=?hMap;
return?TRUE;
}
BOOL?CDib::CopyToMapFile(const?char*?strPathname)
{
//?copies?DIB?to?a?new?file?releases?prior?pointers
//?if?you?previously?used?CreateSection?the?HBITMAP?will?be?NULL?(and?unusable)
BITMAPFILEHEADER?bmfh;
bmfh.bfType?=?0x4d42;??//?‘BM‘
bmfh.bfSize?=?m_dwSizeImage?+?sizeof(BITMAPINFOHEADER)?+
sizeof(RGBQUAD)?*?m_nColorTableEntries?+?sizeof(BITMAPFILEHEADER);
//?meaning?of?bfSize?open?to?interpretation
bmfh.bfReserved1?=?bmfh.bfReserved2?=?0;
bmfh.bfOffBits?=?sizeof(BITMAPFILEHEADER)?+?sizeof
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????16440??2010-08-21?08:52??CDib.cpp
?????文件???????1924??2010-12-05?12:39??CDib.h
?????文件????????240??2010-12-02?14:01??KL2.clw
?????文件??????14524??2010-12-05?23:03??KL2.cpp
?????文件???????4416??2010-12-05?11:30??KL2.dsp
?????文件????????531??2010-12-02?14:01??KL2.dsw
?????文件????????317??2010-12-02?14:01??KL2.h
?????文件???????1451??2010-12-05?14:17??KL2.rc
?????文件?????172245??2010-12-09?09:30??K-L變換實驗報告.docx
?????文件???????1584??2010-12-02?14:01??ReadMe.txt
?????文件????????450??2010-12-05?14:17??resource.h
?????文件????????290??2010-12-02?14:01??StdAfx.cpp
?????文件???????1145??2010-12-02?23:43??StdAfx.h
-----------?---------??----------?-----??----
???????????????215557????????????????????13
- 上一篇:計算圖像之間的偏差指數(shù)
- 下一篇:max4.0發(fā)布接口.rar
評論
共有 條評論