?? waveletdoc.cpp
字號:
void CWaveletDoc::OnOptionValue()
{
// TODO: Add your command handler code here
// TODO: Add your command handler code here
CompressOption CpOption;
if (CpOption.DoModal() == IDOK)
minthr=CpOption.m_posvalue;
return;
}
void CWaveletDoc::OnFilterBlur()
{
// TODO: Add your command handler code here
// TODO: Add your command handler code here
//讀取數字圖像的文件頭,獲取圖像的屬性參數
LPBITMAPINFOHEADER lpBitmapInfoHeader = (LPBITMAPINFOHEADER)(m_pBitmap+14);
LPBITMAPFILEHEADER lpBitmapFileHeader = (LPBITMAPFILEHEADER)m_pBitmap;
unsigned char *lpData = m_pBitmap + lpBitmapFileHeader->bfOffBits;
unsigned long biHeight = lpBitmapInfoHeader->biHeight;
unsigned long biWidth = lpBitmapInfoHeader->biWidth;
unsigned long biAlign = (biWidth*3+3)/4 *4;
unsigned long bmSize = biHeight * biAlign;
if(m_pTransfered==NULL)
m_pTransfered=(unsigned char*) malloc (bmSize);
if(m_pTransfered==NULL)
return;
//圖像小波系數的低通濾波層數為3層
int MaxLayer = 3;
short **ImgData;
float fTempBufforDisp;
//圖像矩陣坐標與圖像數據
int tempR, tempG, tempB, x, y, cur;
//分配圖像數據的內存空間
ImgData = new short * [biHeight];
for(int i = 0; i < biHeight; i ++)
{
ImgData[i] = new short [biWidth];
}
for(i=0;i<=2;i++)
{
//獲取顯示緩存中的原始圖像數據
for(y=0; y<(int)biHeight; y++)
{
for(x=0; x<(int)biWidth; x++)
{
cur = y*biAlign+3*x;
//tempB=lpData[cur];
//tempG=lpData[cur+1];
//tempR=lpData[cur+2];
//ImgData[biHeight-1-y][x]=(short)(0.3*tempR+0.59*tempG+0.11*tempB); //no problem
ImgData[biHeight-1-y][x]=(short)(lpData[cur+i]);
}
}
//創建小波濾波器類
CWFilter Filter;
//小波低通濾波處理
Filter.LPass_Filter(ImgData, biHeight, biWidth, MaxLayer, 1);
//屏蔽圖像復原操作標志
m_bFilter = TRUE;
//將處理后的圖像數據放入顯示緩存中
for(y=0; y<(int)biHeight; y++)
{
for(x=0; x<(int)biWidth; x++)
{
cur= y*biAlign+3*x; //當前像素的位置
m_pTransfered[cur+i] = (unsigned char)Filter.m_FilterData[biHeight - 1- y][x];
//m_pTransfered[cur+1]= (unsigned char)Filter.m_FilterData[biHeight - 1 - y][x];
//m_pTransfered[cur+2]= (unsigned char)Filter.m_FilterData[biHeight - 1 - y][x];
}
}
}
//顯示圖像
delete m_WaveletCoeff;
m_WaveletCoeff=NULL;
UpdateAllViews(NULL);
//刪除臨時的圖像數據空間
delete ImgData;
}
void CWaveletDoc::OnFilterBlur2()
{
// TODO: Add your command handler code here
//讀取數字圖像的文件頭,獲取圖像的屬性參數
LPBITMAPINFOHEADER lpBitmapInfoHeader = (LPBITMAPINFOHEADER)(m_pBitmap+14);
LPBITMAPFILEHEADER lpBitmapFileHeader = (LPBITMAPFILEHEADER)m_pBitmap;
unsigned char *lpData = m_pBitmap + lpBitmapFileHeader->bfOffBits;
unsigned long biHeight = lpBitmapInfoHeader->biHeight;
unsigned long biWidth = lpBitmapInfoHeader->biWidth;
unsigned long biAlign = (biWidth*3+3)/4 *4;
unsigned long bmSize = biHeight * biAlign;
if(m_pTransfered==NULL)
m_pTransfered=(unsigned char*) malloc (bmSize);
if(m_pTransfered==NULL)
return;
//圖像小波系數的低通濾波層數為3層
int MaxLayer = 3;
short **ImgData;
float fTempBufforDisp;
//圖像矩陣坐標與圖像數據
int tempR, tempG, tempB, x, y, cur;
//分配圖像數據的內存空間
ImgData = new short * [biHeight];
for(int i = 0; i < biHeight; i ++)
{
ImgData[i] = new short [biWidth];
}
//獲取顯示緩存中的原始圖像數據
for(i=0;i<=2;i++)
{
for(y=0; y<(int)biHeight; y++)
{
for(x=0; x<(int)biWidth; x++)
{
cur = y*biAlign+3*x;
//tempB=lpData[cur];
//tempG=lpData[cur+1];
//tempR=lpData[cur+2];
//ImgData[biHeight-1-y][x]=(short)(0.3*tempR+0.59*tempG+0.11*tempB); //no problem
ImgData[biHeight-1-y][x]=(short)(lpData[cur+i]);
}
}
//創建小波濾波器類
CWFilter Filter;
//小波低通濾波處理
Filter.LPass_Filter(ImgData, biHeight, biWidth, MaxLayer, 2);
//屏蔽圖像復原操作標志
m_bFilter = TRUE;
//將處理后的圖像數據放入顯示緩存中
for(y=0; y<(int)biHeight; y++)
{
for(x=0; x<(int)biWidth; x++)
{
cur= y*biAlign+3*x; //當前像素的位置
m_pTransfered[cur] = (unsigned char)Filter.m_FilterData[biHeight - 1- y][x];
m_pTransfered[cur+1]= (unsigned char)Filter.m_FilterData[biHeight - 1 - y][x];
m_pTransfered[cur+2]= (unsigned char)Filter.m_FilterData[biHeight - 1 - y][x];
}
}
}
//顯示圖像
UpdateAllViews(NULL);
//刪除臨時的圖像數據空間
delete ImgData;
}
void CWaveletDoc::OnFilterSharpness()
{
// TODO: Add your command handler code here
//讀取數字圖像的文件頭,獲取圖像的屬性參數
LPBITMAPINFOHEADER lpBitmapInfoHeader = (LPBITMAPINFOHEADER)(m_pBitmap+14);
LPBITMAPFILEHEADER lpBitmapFileHeader = (LPBITMAPFILEHEADER)m_pBitmap;
unsigned char *lpData = m_pBitmap + lpBitmapFileHeader->bfOffBits;
unsigned long biHeight = lpBitmapInfoHeader->biHeight;
unsigned long biWidth = lpBitmapInfoHeader->biWidth;
unsigned long biAlign = (biWidth*3+3)/4 *4;
unsigned long bmSize = biHeight * biAlign;
if(m_pTransfered==NULL)
m_pTransfered=(unsigned char*) malloc (bmSize);
if(m_pTransfered==NULL)
return;
//圖像小波系數的高通濾波層數為3層
int MaxLayer = 3;
short **ImgData;
float fTempBufforDisp;
//圖像矩陣坐標與圖像數據
int tempR, tempG, tempB, x, y, cur;
//分配圖像數據的內存空間
ImgData = new short * [biHeight];
for(int i = 0; i < biHeight; i ++)
{
ImgData[i] = new short [biWidth];
}
//獲取顯示緩存中的原始圖像數據
for(i=0;i<=2;i++)
{
for(y=0; y<(int)biHeight; y++)
{
for(x=0; x<(int)biWidth; x++)
{
cur = y*biAlign+3*x;
// tempB=lpData[cur];
//tempG=lpData[cur+1];
//tempR=lpData[cur+2];
//ImgData[biHeight-1-y][x]=(short)(0.3*tempR+0.59*tempG+0.11*tempB); //no problem
ImgData[biHeight-1-y][x]=(short)(lpData[cur+i]);
}
}
//創建小波濾波器類
CWFilter Filter;
//小波高通濾波處理
Filter.HPass_Filter(ImgData, biHeight, biWidth, MaxLayer);
//屏蔽圖像復原操作標志
m_bFilter = TRUE;
//將處理后的圖像數據放入顯示緩存中
for(y=0; y<(int)biHeight; y++)
{
for(x=0; x<(int)biWidth; x++)
{
cur= y*biAlign+3*x; //當前像素的位置
m_pTransfered[cur+i] = (unsigned char)Filter.m_FilterData[biHeight - 1- y][x];
//m_pTransfered[cur+1]= (unsigned char)Filter.m_FilterData[biHeight - 1 - y][x];
//m_pTransfered[cur+2]= (unsigned char)Filter.m_FilterData[biHeight - 1 - y][x];
}
}
}
//顯示圖像
UpdateAllViews(NULL);
//刪除臨時的圖像數據空間
delete ImgData;
}
void CWaveletDoc::OnFilterSharpness2()
{
// TODO: Add your command handler code here
//讀取數字圖像的文件頭,獲取圖像的屬性參數
LPBITMAPINFOHEADER lpBitmapInfoHeader = (LPBITMAPINFOHEADER)(m_pBitmap+14);
LPBITMAPFILEHEADER lpBitmapFileHeader = (LPBITMAPFILEHEADER)m_pBitmap;
unsigned char *lpData = m_pBitmap + lpBitmapFileHeader->bfOffBits;
unsigned long biHeight = lpBitmapInfoHeader->biHeight;
unsigned long biWidth = lpBitmapInfoHeader->biWidth;
unsigned long biAlign = (biWidth*3+3)/4 *4;
unsigned long bmSize = biHeight * biAlign;
if(m_pTransfered==NULL)
m_pTransfered=(unsigned char*) malloc (bmSize);
if(m_pTransfered==NULL)
return;
//圖像小波系數的高通濾波層數為3層
int MaxLayer = 3;
short **ImgData;
float fTempBufforDisp;
//圖像矩陣坐標與圖像數據
int tempR, tempG, tempB, x, y, cur;
//分配圖像數據的內存空間
ImgData = new short * [biHeight];
for(int i = 0; i < biHeight; i ++)
{
ImgData[i] = new short [biWidth];
}
//獲取顯示緩存中的原始圖像數據
for(i=0;i<2;i++)
{
for(y=0; y<(int)biHeight; y++)
{
for(x=0; x<(int)biWidth; x++)
{
cur = y*biAlign+3*x;
//tempB=lpData[cur];
//tempG=lpData[cur+1];
//tempR=lpData[cur+2];
//ImgData[biHeight-1-y][x]=(short)(0.3*tempR+0.59*tempG+0.11*tempB); //no problem
}
}
}
//創建小波濾波器類
CWFilter Filter;
//小波高通濾波處理
Filter.HPass_Filter2(ImgData, biHeight, biWidth, MaxLayer);
//屏蔽圖像復原操作標志
m_bFilter = TRUE;
//將處理后的圖像數據放入顯示緩存中
for(y=0; y<(int)biHeight; y++)
{
for(x=0; x<(int)biWidth; x++)
{
cur= y*biAlign+3*x; //當前像素的位置
m_pTransfered[cur] = (unsigned char)Filter.m_FilterData[biHeight - 1- y][x];
m_pTransfered[cur+1]= (unsigned char)Filter.m_FilterData[biHeight - 1 - y][x];
m_pTransfered[cur+2]= (unsigned char)Filter.m_FilterData[biHeight - 1 - y][x];
}
}
//顯示圖像
UpdateAllViews(NULL);
//刪除臨時的圖像數據空間
delete ImgData;
}
void CWaveletDoc::OnCodeDecode()
{
// TODO: Add your command handler code here
CEzwCode Ezw;
int k=0;
LPBITMAPINFOHEADER lpBitmapInfoHeader = (LPBITMAPINFOHEADER)(m_pBitmap+14);
int biHeight = lpBitmapInfoHeader->biHeight;
int biWidth = lpBitmapInfoHeader->biWidth;
for (k=0;k<=2;k++)
Ezw.HuffmanDecode(minthr,biHeight,biWidth,k,m_pstore,fsize);
return;
}
void CWaveletDoc::OnResult()
{
// TODO: Add your command handler code here
}
void CWaveletDoc::OnDiprocFusion()
{
// TODO: Add your command handler code here
//讀取數字圖像的文件頭,獲取圖像的屬性參數
LPBITMAPINFOHEADER lpBitmapInfoHeader = (LPBITMAPINFOHEADER)(m_pBitmap+14);
LPBITMAPFILEHEADER lpBitmapFileHeader = (LPBITMAPFILEHEADER)m_pBitmap;
unsigned char *lpData = m_pBitmap + lpBitmapFileHeader->bfOffBits;
unsigned long biHeight = lpBitmapInfoHeader->biHeight;
unsigned long biWidth = lpBitmapInfoHeader->biWidth;
unsigned long biAlign = (biWidth*3+3)/4 *4;
unsigned long bmSize = biHeight * biAlign;
//定義圖像的內存數據空間指針
short **pData, **pDataFusion;
CString cstrFileName = m_strFileFusion;
//圖像矩陣的坐標與像素數據
int x, y, cur;
int tempR, tempG, tempB;
//分配圖像的數據空間
pData = new short * [biHeight];
pDataFusion = new short * [biHeight];
for(int i = 0; i < biWidth; i ++)
{
pDataFusion[i] = new short [biWidth];
pData[i] = new short [biWidth];
}
//從設備的顯示緩存中獲取原始圖像的數據
for(y = 0; y < (int) biHeight; y ++)
{
for(x = 0; x < (int) biWidth; x ++)
{
cur = y * biAlign + 3 * x;
tempB = lpData[cur];
tempG = lpData[cur + 1];
tempR = lpData[cur + 2];
pData[biHeight - 1 - y][x] = 0.3 * tempR + 0.59 * tempG + 0.11 * tempB;
}
}
//釋放設備占用的顯示緩存
//m_pBitmap = NULL;
//打開另外一幅用于融合的圖像文件
MessageBoxA(NULL,_T("請在WvltDip\\Fusion目錄中打開另外一幅圖像,進行圖像融合"),_T("Message"),MB_ICONEXCLAMATION|MB_OK);
while(!abs((int)strcmp(m_strFileFusion, cstrFileName)))
{
CFileDialog dlg( TRUE,NULL,NULL,
OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,
_T("Bitmap (*.BMP)|*.BMP|"));
if( dlg.DoModal()==IDOK )
cstrFileName = dlg.GetPathName();
//如果文件重名,提示重新打開文件
if(!abs((int)strcmp(m_strFileFusion, cstrFileName)))
MessageBoxA(NULL,_T("文件"+m_strFileFusion+"已打開,請打開該目錄中另外一個文件"),_T("Message"),MB_ICONEXCLAMATION|MB_OK);
else
MessageBoxA(NULL,_T("用于圖像融合的文件是:\n"+m_strFileFusion+"\n"+cstrFileName),_T("Message"),MB_ICONEXCLAMATION|MB_OK);
}
//讀取位圖數據,載入顯示緩存中
ReadBitmap(cstrFileName, m_pTransfered);
//顯示新打開的圖像
UpdateAllViews(NULL);
//讀取另外一幅圖像的數據
lpBitmapInfoHeader = (LPBITMAPINFOHEADER)(m_pTransfered+14);
lpBitmapFileHeader = (LPBITMAPFILEHEADER)m_pTransfered;
unsigned char *lpImgData = m_pTransfered + lpBitmapFileHeader->bfOffBits;
//從設備的顯示緩存中獲取原始圖像的數據
for(y = 0; y < biHeight; y ++)
{
for (x = 0; x < biWidth; x++)
{
cur = y * biAlign + 3 * x;
tempB = lpImgData[cur];
tempG = lpImgData[cur + 1];
tempR = lpImgData[cur + 2];
pDataFusion[biHeight - 1 - y][x] = 0.3 * tempR + 0.59 * tempG + 0.11 * tempB;
}
}
//清空顯示緩存,并重新分配顯示緩存
m_pTransfered = NULL;
m_pTransfered=(unsigned char*) malloc (bmSize);
if(m_pTransfered==NULL)
return;
//創建用于圖像融合的Diproc類
CDiproc *pDIP;
pDIP->DIP_ImageFusion(pData, pDataFusion, biHeight, biWidth);
//將圖像數據放入顯示緩存中
for(y=0; y<(int)biHeight; y++)
{
for(x=0; x<(int)biWidth; x++)
{
cur= y*biAlign+3*x; //current pixel
m_pTransfered[cur] = (unsigned char)pDataFusion[biHeight - 1- y][x];
m_pTransfered[cur+1]= (unsigned char)pDataFusion[biHeight - 1 - y][x];
m_pTransfered[cur+2]= (unsigned char)pDataFusion[biHeight - 1 - y][x];
}
}
//顯示圖像復原的結果
UpdateAllViews(NULL);
//刪除臨時的數據內存空間
delete pData;
delete pDataFusion;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -