📄 imageprocessingview.cpp
字号:
//DEL int rsl = DIBDWTStep(pDib,1);
//DEL
//DEL // 恢复光标形状
//DEL EndWaitCursor();
//DEL
//DEL // 如果小波变换不成功,则直接返回
//DEL if (!rsl)
//DEL return;
//DEL pDoc->UpdateAllViews(FALSE);
//DEL
//DEL // 设置脏标记
//DEL pDoc->SetModifiedFlag(TRUE);
//DEL
//DEL // 更新视图
//DEL pDoc->UpdateAllViews(NULL);
//DEL }
//DEL BOOL CImageProcessingView::DIBDWTStep(CDib* pDib, int nInv)
//DEL {
//DEL // 循环变量
//DEL int i, j;
//DEL
//DEL // 获取图象的长度和宽度
//DEL int nWidth = pDib->m_lpBMIH->biWidth;
//DEL int nHeight = pDib->m_lpBMIH->biHeight;
//DEL
//DEL // 获取变换的最大层数
//DEL int nMaxWLevel = Log2(nWidth);
//DEL int nMaxHLevel = Log2(nHeight);
//DEL int nMaxLevel;
//DEL if (nWidth == 1<<nMaxWLevel && nHeight == 1<<nMaxHLevel)
//DEL nMaxLevel = min(nMaxWLevel, nMaxHLevel);
//DEL
//DEL // 获取图象的存储尺寸
//DEL CSize sizeImageSave = pDib->GetDibSaveDim();
//DEL
//DEL // 临时变量
//DEL double *pDbTemp;
//DEL BYTE *pBits;
//DEL
//DEL // 如果小波变换的存储内存还没有分配,则分配此内存
//DEL if(!m_pDbImage){
//DEL m_pDbImage = new double[nWidth*nHeight];
//DEL if (!m_pDbImage) return FALSE;
//DEL
//DEL // 将图象数据放入m_pDbImage中
//DEL for (j=0; j<nHeight; j++)
//DEL {
//DEL pDbTemp = m_pDbImage + j*sizeImageSave.cx;
//DEL pBits = pDib->m_lpImage + (nHeight-1-j)*sizeImageSave.cx;
//DEL for (i=0; i<nWidth; i++)
//DEL pDbTemp[i] = pBits[i];
//DEL }
//DEL }
//DEL
//DEL // 进行小波变换(或反变换)
//DEL if (!DWTStep_2D(m_pDbImage, nMaxWLevel-m_nDWTCurDepth, nMaxHLevel-m_nDWTCurDepth,
//DEL nMaxWLevel, nMaxHLevel, nInv, 1, m_nSupp))
//DEL return FALSE;
//DEL
//DEL // 如果是反变换,则当前层数减1
//DEL if (nInv)
//DEL m_nDWTCurDepth --;
//DEL // 否则加1
//DEL else
//DEL m_nDWTCurDepth ++;
//DEL
//DEL // 然后,将数据拷贝回原CDib中,并进行相应的数据转换
//DEL int lfw = nWidth>>m_nDWTCurDepth, lfh = nHeight>>m_nDWTCurDepth;
//DEL for (j=0; j<nHeight; j++)
//DEL {
//DEL pDbTemp = m_pDbImage + j*sizeImageSave.cx;
//DEL pBits = pDib->m_lpImage + (nHeight-1-j)*sizeImageSave.cx;
//DEL for (i=0; i<nWidth; i++)
//DEL {
//DEL if (j<lfh && i<lfw)
//DEL pBits[i] = FloatToByte(pDbTemp[i]);
//DEL else
//DEL pBits[i] = BYTE(FloatToChar(pDbTemp[i]) ^ 0x80);
//DEL }
//DEL }
//DEL
//DEL // 返回
//DEL return TRUE;
//DEL }
//DEL void CImageProcessingView::OnEnhanceLintrans()
//DEL {
//DEL // 获取文档
//DEL CImageProcessingDoc* pDoc = GetDocument();
//DEL
//DEL // 创建对话框
//DEL CDlgEhnLinTrans dlgPara;
//DEL
//DEL // 点1坐标
//DEL int nX1;
//DEL int nY1;
//DEL
//DEL // 点2坐标
//DEL int nX2;
//DEL int nY2;
//DEL
//DEL // 判断是否是8-bpp位图(这里为了方便,只处理8-bpp位图的灰度拉伸,其它的可以类推)
//DEL if(pDoc->m_pDibInit->m_nColorTableEntries != 256)
//DEL {
//DEL // 提示用户
//DEL MessageBox("目前只支持256色位图的伪彩色变换!", "系统提示" ,
//DEL MB_ICONINFORMATION | MB_OK);
//DEL
//DEL // 返回
//DEL return;
//DEL }
//DEL
//DEL // 初始化变量值
//DEL dlgPara.m_nX1 = 50;
//DEL dlgPara.m_nY1 = 30;
//DEL dlgPara.m_nX2 = 200;
//DEL dlgPara.m_nY2 = 220;
//DEL
//DEL // 显示对话框,提示用户设定拉伸位置
//DEL if (dlgPara.DoModal() != IDOK)
//DEL {
//DEL // 返回
//DEL return;
//DEL }
//DEL
//DEL // 获取用户的设定
//DEL nX1 = dlgPara.m_nX1;
//DEL nY1 = dlgPara.m_nY1;
//DEL nX2 = dlgPara.m_nX2;
//DEL nY2 = dlgPara.m_nY2;
//DEL
//DEL // 删除对话框
//DEL delete dlgPara;
//DEL
//DEL // 更改光标形状
//DEL BeginWaitCursor();
//DEL
//DEL // 调用GrayStretch()函数进行灰度拉伸
//DEL GraySegLinTrans(pDoc->m_pDibInit, nX1, nY1, nX2, nY2);
//DEL
//DEL // 设置脏标记
//DEL pDoc->SetModifiedFlag(TRUE);
//DEL
//DEL // 更新视图
//DEL pDoc->UpdateAllViews(NULL);
//DEL
//DEL // 恢复光标
//DEL EndWaitCursor();
//DEL }
//DEL void CImageProcessingView::OnEnhanceHistequ()
//DEL {
//DEL // 直方图均衡
//DEL
//DEL // 获取文档
//DEL CImageProcessingDoc* pDoc = GetDocument();
//DEL
//DEL // 判断是否是8-bpp位图(这里为了方便,只处理8-bpp位图的直方图均衡,其它的可以类推)
//DEL if(pDoc->m_pDibInit->m_nColorTableEntries != 256)
//DEL {
//DEL // 提示用户
//DEL MessageBox("目前只支持256色位图的伪彩色变换!", "系统提示" ,
//DEL MB_ICONINFORMATION | MB_OK);
//DEL
//DEL // 返回
//DEL return;
//DEL }
//DEL
//DEL // 更改光标形状
//DEL BeginWaitCursor();
//DEL
//DEL // 调用HistogramEqualize()函数进行直方图均衡
//DEL HistogramEqualize(pDoc->m_pDibInit);
//DEL
//DEL // 设置脏标记
//DEL pDoc->SetModifiedFlag(TRUE);
//DEL
//DEL // 更新视图
//DEL pDoc->UpdateAllViews(NULL);
//DEL
//DEL // 恢复光标
//DEL EndWaitCursor();
//DEL }
/*************************************************************************
*
* \函数名称:
* OnRegReg()
*
* \输入参数:
* 无
*
* \返回值:
* 无
*
* \说明:
* 该函数实现图象的配准
*
*************************************************************************
*/
//DEL void CImageProcessingView::OnRegReg()
//DEL {
//DEL // 获得文档类句柄
//DEL CImageProcessingDoc* pDoc;
//DEL pDoc = GetDocument();
//DEL
//DEL // 判断是否是8-bpp位图(这里为了方便,只处理8-bpp位图的水平镜像,其它的可以类推)
//DEL if(pDoc->m_pDibInit->m_nColorTableEntries != 256)
//DEL {
//DEL // 提示用户
//DEL MessageBox("目前只支持256色位图的图象配准!", "系统提示" ,
//DEL MB_ICONINFORMATION | MB_OK);
//DEL
//DEL // 返回
//DEL return;
//DEL }
//DEL
//DEL // 打开图象配准对话框
//DEL CDlgReg* pDlg=new CDlgReg(NULL,pDoc);
//DEL
//DEL pDlg->DoModal();
//DEL
//DEL delete pDlg;
//DEL }
/*************************************************************************
*
* \函数名称:
* OnEnhanceSharp()
*
* \输入参数:
* 无
*
* \返回值:
* 无
*
* \说明:
* 该函数利用Laplacian算子实现图象的锐化
*
*************************************************************************
*/
//DEL void CImageProcessingView::OnEnhanceSharp()
//DEL {
//DEL //更改光标形状
//DEL BeginWaitCursor();
//DEL
//DEL CImageProcessingDoc * pDoc = (CImageProcessingDoc *)this->GetDocument();
//DEL CDib * pDib = pDoc->m_pDibInit;
//DEL
//DEL LPBITMAPINFOHEADER lpBMIH=pDib->m_lpBMIH;
//DEL
//DEL // 判断是否是8-bpp位图
//DEL if (lpBMIH->biBitCount != 8)
//DEL {
//DEL // 提示用户
//DEL MessageBox("目前只支持256色位图的图象分割!", "系统提示" ,
//DEL MB_ICONINFORMATION | MB_OK);
//DEL
//DEL // 返回
//DEL return;
//DEL }
//DEL
//DEL // 循环控制变量
//DEL int y;
//DEL int x;
//DEL
//DEL CSize sizeImage = pDib->GetDimensions();
//DEL int nWidth = sizeImage.cx ;
//DEL int nHeight= sizeImage.cy ;
//DEL
//DEL int nSaveWidth = pDib->GetDibSaveDim().cx;
//DEL
//DEL // 开辟内存,存储图象数据,该数据的存储不是DWORD对齐的
//DEL unsigned char * pUnchImage = new unsigned char[nWidth*nHeight];
//DEL
//DEL for(y=0; y<nHeight; y++)
//DEL {
//DEL for(x=0; x<nWidth; x++)
//DEL {
//DEL pUnchImage[y*nWidth+x] = pDib->m_lpImage[y*nSaveWidth+x];
//DEL }
//DEL }
//DEL
//DEL // 调用LinearSharpen函数进行图象锐化增强
//DEL LinearSharpen(pUnchImage, nWidth, nHeight) ;
//DEL
//DEL // 增强以后的图象拷贝到pDib中,进行显示
//DEL for(y=0; y<nHeight; y++)
//DEL {
//DEL for(x=0; x<nWidth; x++)
//DEL {
//DEL pDib->m_lpImage[y*nSaveWidth+x] = pUnchImage[y*nWidth+x];
//DEL }
//DEL }
//DEL
//DEL // 释放内存
//DEL delete []pUnchImage;
//DEL pUnchImage = NULL ;
//DEL
//DEL // 恢复光标形状
//DEL EndWaitCursor();
//DEL
//DEL // 设置脏标记
//DEL pDoc->SetModifiedFlag(TRUE);
//DEL
//DEL // 更新视图
//DEL pDoc->UpdateAllViews(NULL);
//DEL
//DEL }
/*************************************************************************
*
* \函数名称:
* OnEnhanceSmoothFr()
*
* \输入参数:
* 无
*
* \返回值:
* 无
*
* \说明:
* 该函数利用低通滤波实现图象平滑
*
************************************************************************
*/
//DEL void CImageProcessingView::OnEnhanceSmoothFr()
//DEL {
//DEL // TODO: Add your command handler code here
//DEL //更改光标形状
//DEL BeginWaitCursor();
//DEL
//DEL CImageProcessingDoc * pDoc = (CImageProcessingDoc *)this->GetDocument();
//DEL CDib * pDib = pDoc->m_pDibInit;
//DEL
//DEL LPBITMAPINFOHEADER lpBMIH=pDib->m_lpBMIH;
//DEL
//DEL // 判断是否是8-bpp位图
//DEL if (lpBMIH->biBitCount != 8)
//DEL {
//DEL // 提示用户
//DEL MessageBox("目前只支持256色位图的图象分割!", "系统提示" ,
//DEL MB_ICONINFORMATION | MB_OK);
//DEL
//DEL // 返回
//DEL return;
//DEL }
//DEL
//DEL // 循环控制变量
//DEL int y;
//DEL int x;
//DEL
//DEL CSize sizeImage = pDib->GetDimensions();
//DEL int nWidth = sizeImage.cx ;
//DEL int nHeight= sizeImage.cy ;
//DEL
//DEL int nSaveWidth = pDib->GetDibSaveDim().cx;
//DEL
//DEL // 开辟内存,存储图象数据,该数据的存储不是DWORD对齐的
//DEL unsigned char * pUnchImage = new unsigned char[nWidth*nHeight];
//DEL
//DEL for(y=0; y<nHeight; y++)
//DEL {
//DEL for(x=0; x<nWidth; x++)
//DEL {
//DEL pUnchImage[y*nWidth+x] = pDib->m_lpImage[y*nSaveWidth+x];
//DEL }
//DEL }
//DEL
//DEL // 调用低通滤波函数进行图象增强
//DEL LowPassFilterEnhance(pUnchImage, nWidth, nHeight, nWidth/16) ;
//DEL
//DEL // 增强以后的图象拷贝到pDib中,进行显示
//DEL for(y=0; y<nHeight; y++)
//DEL {
//DEL for(x=0; x<nWidth; x++)
//DEL {
//DEL pDib->m_lpImage[y*nSaveWidth+x] = pUnchImage[y*nWidth+x];
//DEL }
//DEL }
//DEL
//DEL // 释放内存
//DEL delete []pUnchImage;
//DEL pUnchImage = NULL ;
//DEL
//DEL // 恢复光标形状
//DEL EndWaitCursor();
//DEL
//DEL // 设置脏标记
//DEL pDoc->SetModifiedFlag(TRUE);
//DEL
//DEL // 更新视图
//DEL pDoc->UpdateAllViews(NULL);
//DEL }
/*************************************************************************
*
* \函数名称:
* OnEnhanceButtLow()
*
* \输入参数:
* 无
*
* \返回值:
* 无
*
* \说明:
* 该函数利用Butterworth低通滤波实现图象平滑
*
************************************************************************
*/
//DEL void CImageProcessingView::OnEnhanceButtLow()
//DEL {
//DEL // TODO: Add your command handler code here
//DEL //更改光标形状
//DEL BeginWaitCursor();
//DEL
//DEL CImageProcessingDoc * pDoc = (CImageProcessingDoc *)this->GetDocument();
//DEL CDib * pDib = pDoc->m_pDibInit;
//DEL
//DEL LPBITMAPINFOHEADER lpBMIH=pDib->m_lpBMIH;
//DEL
//DEL // 判断是否是8-bpp位图
//DEL if (lpBMIH->biBitCount != 8)
//DEL {
//DEL // 提示用户
//DEL MessageBox("目前只支持256色位图的图象分割!", "系统提示" ,
//DEL MB_ICONINFORMATION | MB_OK);
//DEL
//DEL // 返回
//DEL return;
//DEL }
//DEL
//DEL // 循环控制变量
//DEL int y;
//DEL int x;
//DEL
//DEL CSize sizeImage = pDib->GetDimensions();
//DEL int nWidth = sizeImage.cx ;
//DEL int nHeight= sizeImage.cy ;
//DEL
//DEL int nSaveWidth = pDib->GetDibSaveDim().cx;
//DEL
//DEL // 开辟内存,存储图象数据,该数据的存储不是DWORD对齐的
//DEL unsigned char * pUnchImage = new unsigned char[nWidth*nHeight];
//DEL
//DEL for(y=0; y<nHeight; y++)
//DEL {
//DEL for(x=0; x<nWidth; x++)
//DEL {
//DEL pUnchImage[y*nWidth+x] = pDib->m_lpImage[y*nSaveWidth+x];
//DEL }
//DEL }
//DEL
//DEL // 调用ButterWorth低通滤波函数进行图象增强
//DEL ButterWorthLowPass(pUnchImage, nWidth, nHeight, nWidth/2) ;
//DEL
//DEL // 增强以后的图象拷贝到pDib中,进行显示
//DEL for(y=0; y<nHeight; y++)
//DEL {
//DEL for(x=0; x<nWidth; x++)
//DEL {
//DEL pDib->m_lpImage[y*nSaveWidth+x] = pUnchImage[y*nWidth+x];
//DEL }
//DEL }
//DEL
//DEL // 释放内存
//DEL delete []pUnchImage;
//DEL pUnchImage = NULL ;
//DEL
//DEL // 恢复光标形状
//DEL EndWaitCursor();
//DEL
//DEL // 设置脏标记
//DEL pDoc->SetModifiedFlag(TRUE);
//DEL
//DEL // 更新视图
//DEL pDoc->UpdateAllViews(NULL);
//DEL }
/*************************************************************************
*
* \函数名称:
* OnEnhanceSharpFreq()
*
* \输入参数:
* 无
*
* \返回值:
* 无
*
* \说明:
* 该函数利用高通滤波实现图象增强
*
************************************************************************
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -