?? imageprocessingview.cpp
字號:
//DEL int rsl = DIBDWTStep(pDib,1);
//DEL
//DEL // 恢復(fù)光標(biāo)形狀
//DEL EndWaitCursor();
//DEL
//DEL // 如果小波變換不成功,則直接返回
//DEL if (!rsl)
//DEL return;
//DEL pDoc->UpdateAllViews(FALSE);
//DEL
//DEL // 設(shè)置臟標(biāo)記
//DEL pDoc->SetModifiedFlag(TRUE);
//DEL
//DEL // 更新視圖
//DEL pDoc->UpdateAllViews(NULL);
//DEL }
//DEL BOOL CImageProcessingView::DIBDWTStep(CDib* pDib, int nInv)
//DEL {
//DEL // 循環(huán)變量
//DEL int i, j;
//DEL
//DEL // 獲取圖象的長度和寬度
//DEL int nWidth = pDib->m_lpBMIH->biWidth;
//DEL int nHeight = pDib->m_lpBMIH->biHeight;
//DEL
//DEL // 獲取變換的最大層數(shù)
//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 // 如果小波變換的存儲內(nèi)存還沒有分配,則分配此內(nèi)存
//DEL if(!m_pDbImage){
//DEL m_pDbImage = new double[nWidth*nHeight];
//DEL if (!m_pDbImage) return FALSE;
//DEL
//DEL // 將圖象數(shù)據(jù)放入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 // 進(jìn)行小波變換(或反變換)
//DEL if (!DWTStep_2D(m_pDbImage, nMaxWLevel-m_nDWTCurDepth, nMaxHLevel-m_nDWTCurDepth,
//DEL nMaxWLevel, nMaxHLevel, nInv, 1, m_nSupp))
//DEL return FALSE;
//DEL
//DEL // 如果是反變換,則當(dāng)前層數(shù)減1
//DEL if (nInv)
//DEL m_nDWTCurDepth --;
//DEL // 否則加1
//DEL else
//DEL m_nDWTCurDepth ++;
//DEL
//DEL // 然后,將數(shù)據(jù)拷貝回原CDib中,并進(jìn)行相應(yīng)的數(shù)據(jù)轉(zhuǎn)換
//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 // 創(chuàng)建對話框
//DEL CDlgEhnLinTrans dlgPara;
//DEL
//DEL // 點1坐標(biāo)
//DEL int nX1;
//DEL int nY1;
//DEL
//DEL // 點2坐標(biāo)
//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色位圖的偽彩色變換!", "系統(tǒng)提示" ,
//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 // 顯示對話框,提示用戶設(shè)定拉伸位置
//DEL if (dlgPara.DoModal() != IDOK)
//DEL {
//DEL // 返回
//DEL return;
//DEL }
//DEL
//DEL // 獲取用戶的設(shè)定
//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 // 更改光標(biāo)形狀
//DEL BeginWaitCursor();
//DEL
//DEL // 調(diào)用GrayStretch()函數(shù)進(jìn)行灰度拉伸
//DEL GraySegLinTrans(pDoc->m_pDibInit, nX1, nY1, nX2, nY2);
//DEL
//DEL // 設(shè)置臟標(biāo)記
//DEL pDoc->SetModifiedFlag(TRUE);
//DEL
//DEL // 更新視圖
//DEL pDoc->UpdateAllViews(NULL);
//DEL
//DEL // 恢復(fù)光標(biāo)
//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色位圖的偽彩色變換!", "系統(tǒng)提示" ,
//DEL MB_ICONINFORMATION | MB_OK);
//DEL
//DEL // 返回
//DEL return;
//DEL }
//DEL
//DEL // 更改光標(biāo)形狀
//DEL BeginWaitCursor();
//DEL
//DEL // 調(diào)用HistogramEqualize()函數(shù)進(jìn)行直方圖均衡
//DEL HistogramEqualize(pDoc->m_pDibInit);
//DEL
//DEL // 設(shè)置臟標(biāo)記
//DEL pDoc->SetModifiedFlag(TRUE);
//DEL
//DEL // 更新視圖
//DEL pDoc->UpdateAllViews(NULL);
//DEL
//DEL // 恢復(fù)光標(biāo)
//DEL EndWaitCursor();
//DEL }
/*************************************************************************
*
* \函數(shù)名稱:
* OnRegReg()
*
* \輸入?yún)?shù):
* 無
*
* \返回值:
* 無
*
* \說明:
* 該函數(shù)實現(xiàn)圖象的配準(zhǔn)
*
*************************************************************************
*/
//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色位圖的圖象配準(zhǔn)!", "系統(tǒng)提示" ,
//DEL MB_ICONINFORMATION | MB_OK);
//DEL
//DEL // 返回
//DEL return;
//DEL }
//DEL
//DEL // 打開圖象配準(zhǔn)對話框
//DEL CDlgReg* pDlg=new CDlgReg(NULL,pDoc);
//DEL
//DEL pDlg->DoModal();
//DEL
//DEL delete pDlg;
//DEL }
/*************************************************************************
*
* \函數(shù)名稱:
* OnEnhanceSharp()
*
* \輸入?yún)?shù):
* 無
*
* \返回值:
* 無
*
* \說明:
* 該函數(shù)利用Laplacian算子實現(xiàn)圖象的銳化
*
*************************************************************************
*/
//DEL void CImageProcessingView::OnEnhanceSharp()
//DEL {
//DEL //更改光標(biāo)形狀
//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色位圖的圖象分割!", "系統(tǒng)提示" ,
//DEL MB_ICONINFORMATION | MB_OK);
//DEL
//DEL // 返回
//DEL return;
//DEL }
//DEL
//DEL // 循環(huán)控制變量
//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 // 開辟內(nèi)存,存儲圖象數(shù)據(jù),該數(shù)據(jù)的存儲不是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 // 調(diào)用LinearSharpen函數(shù)進(jìn)行圖象銳化增強(qiáng)
//DEL LinearSharpen(pUnchImage, nWidth, nHeight) ;
//DEL
//DEL // 增強(qiáng)以后的圖象拷貝到pDib中,進(jìn)行顯示
//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 // 釋放內(nèi)存
//DEL delete []pUnchImage;
//DEL pUnchImage = NULL ;
//DEL
//DEL // 恢復(fù)光標(biāo)形狀
//DEL EndWaitCursor();
//DEL
//DEL // 設(shè)置臟標(biāo)記
//DEL pDoc->SetModifiedFlag(TRUE);
//DEL
//DEL // 更新視圖
//DEL pDoc->UpdateAllViews(NULL);
//DEL
//DEL }
/*************************************************************************
*
* \函數(shù)名稱:
* OnEnhanceSmoothFr()
*
* \輸入?yún)?shù):
* 無
*
* \返回值:
* 無
*
* \說明:
* 該函數(shù)利用低通濾波實現(xiàn)圖象平滑
*
************************************************************************
*/
//DEL void CImageProcessingView::OnEnhanceSmoothFr()
//DEL {
//DEL // TODO: Add your command handler code here
//DEL //更改光標(biāo)形狀
//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色位圖的圖象分割!", "系統(tǒng)提示" ,
//DEL MB_ICONINFORMATION | MB_OK);
//DEL
//DEL // 返回
//DEL return;
//DEL }
//DEL
//DEL // 循環(huán)控制變量
//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 // 開辟內(nèi)存,存儲圖象數(shù)據(jù),該數(shù)據(jù)的存儲不是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 // 調(diào)用低通濾波函數(shù)進(jìn)行圖象增強(qiáng)
//DEL LowPassFilterEnhance(pUnchImage, nWidth, nHeight, nWidth/16) ;
//DEL
//DEL // 增強(qiáng)以后的圖象拷貝到pDib中,進(jìn)行顯示
//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 // 釋放內(nèi)存
//DEL delete []pUnchImage;
//DEL pUnchImage = NULL ;
//DEL
//DEL // 恢復(fù)光標(biāo)形狀
//DEL EndWaitCursor();
//DEL
//DEL // 設(shè)置臟標(biāo)記
//DEL pDoc->SetModifiedFlag(TRUE);
//DEL
//DEL // 更新視圖
//DEL pDoc->UpdateAllViews(NULL);
//DEL }
/*************************************************************************
*
* \函數(shù)名稱:
* OnEnhanceButtLow()
*
* \輸入?yún)?shù):
* 無
*
* \返回值:
* 無
*
* \說明:
* 該函數(shù)利用Butterworth低通濾波實現(xiàn)圖象平滑
*
************************************************************************
*/
//DEL void CImageProcessingView::OnEnhanceButtLow()
//DEL {
//DEL // TODO: Add your command handler code here
//DEL //更改光標(biāo)形狀
//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色位圖的圖象分割!", "系統(tǒng)提示" ,
//DEL MB_ICONINFORMATION | MB_OK);
//DEL
//DEL // 返回
//DEL return;
//DEL }
//DEL
//DEL // 循環(huán)控制變量
//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 // 開辟內(nèi)存,存儲圖象數(shù)據(jù),該數(shù)據(jù)的存儲不是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 // 調(diào)用ButterWorth低通濾波函數(shù)進(jìn)行圖象增強(qiáng)
//DEL ButterWorthLowPass(pUnchImage, nWidth, nHeight, nWidth/2) ;
//DEL
//DEL // 增強(qiáng)以后的圖象拷貝到pDib中,進(jìn)行顯示
//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 // 釋放內(nèi)存
//DEL delete []pUnchImage;
//DEL pUnchImage = NULL ;
//DEL
//DEL // 恢復(fù)光標(biāo)形狀
//DEL EndWaitCursor();
//DEL
//DEL // 設(shè)置臟標(biāo)記
//DEL pDoc->SetModifiedFlag(TRUE);
//DEL
//DEL // 更新視圖
//DEL pDoc->UpdateAllViews(NULL);
//DEL }
/*************************************************************************
*
* \函數(shù)名稱:
* OnEnhanceSharpFreq()
*
* \輸入?yún)?shù):
* 無
*
* \返回值:
* 無
*
* \說明:
* 該函數(shù)利用高通濾波實現(xiàn)圖象增強(qiáng)
*
************************************************************************
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -