📄 wvltdoc.cpp
字号:
//从设备的显示缓存中获取原始图像的数据
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;
}
void CWvltDoc::OnDiprocRever()
{
// 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;
//图像矩阵的坐标
int x,y,cur;
int tempR, tempG, tempB;
//图像数据与图像处理数据的存放空间
short **spOriginData, **spTransData0;
spOriginData = new short* [biHeight];
spTransData0 = new short* [biHeight];
////spTransData1 = new short* [biHeight];
//分配数据的内存空间
for(int i = 0; i < biHeight; i ++)
{
spOriginData[i] = new short [biWidth];
spTransData0[i] = new short [biWidth];
// spTransData1[i] = new short [biWidth];
}
//创建数字处理类
CDiproc *pDip;
//如果图像只经过一次小波变换,则进行相应的逆变换
if(m_bOnce)
{
pDip->DIP_WvltRevers(spOriginData, spTransData0, m_WvltCoeff,biHeight,biHeight/2,biWidth,biWidth/2,1,1.414);
m_bOnce = FALSE;
delete m_WvltCoeff;
}
//如果图像只经过两次小波变换,则进行相应的逆变换
else if(m_bTwice)
{
pDip->DIP_WvltRevers(spOriginData, spTransData0, m_WvltCoeff,biHeight ,biHeight/2,biWidth,biWidth/2,2,1.414);
m_bTwice = FALSE;
delete m_WvltCoeff;
}
//如果图像只经过三次小波变换,则进行相应的逆变换
else if(m_bTribl)
{
pDip->DIP_WvltRevers(spOriginData, spTransData0, m_WvltCoeff, biHeight, biHeight/2,biWidth,biWidth/2,3,1.414);
m_bTribl = FALSE;
delete m_WvltCoeff;
}
//判断是否有小波系数可以进行图像的复原
else if(m_bFilter)
{
MessageBoxA(NULL,_T("没有找到可用小波系数,或者是未做小波变换"),_T("Message"),MB_ICONEXCLAMATION|MB_OK);
m_bFilter = FALSE;
}
//将图像数据放入显示缓存中
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)spOriginData[biHeight - 1- y][x];
m_pTransfered[cur+1]= (unsigned char)spOriginData[biHeight - 1 - y][x];
m_pTransfered[cur+2]= (unsigned char)spOriginData[biHeight - 1 - y][x];
}
}
//显示图像复原的结果
UpdateAllViews(NULL);
//删除临时的数据内存空间
delete spOriginData;
delete spTransData0;
//delete spTransData1;
}
void CWvltDoc::OnFilterBlur()
{
// 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(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.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] = (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 CWvltDoc::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(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.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 CWvltDoc::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(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_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] = (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 CWvltDoc::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(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;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -