OpenCV對影象的光照歸一化處理
阿新 • • 發佈:2019-02-17
- #include <cv.h>
- #include <highgui.h>
- #include <stdio.h>
- #include <string>
- usingnamespace std;
- void main()
- {
- int i;
- IplImage *pImageChannel[4] = {0,0,0,0};
- int count = 15;
- char *name = newchar;
- while(count<=17)
- {
- string FileName = "S010_001_015942"
- itoa(count,name,10);
- FileName = FileName + name;
- FileName = FileName + string(".png");
- IplImage *pSrcImage = cvLoadImage(FileName.c_str());
- IplImage *pImage = cvCreateImage(cvGetSize(pSrcImage), pSrcImage->depth, pSrcImage->nChannels);
- if(pSrcImage)
- {
- for( i=0; i<pSrcImage->nChannels; i++)
- {
- pImageChannel[i] = cvCreateImage( cvGetSize(pSrcImage), pSrcImage->depth, 1);
- }
- // 通道分離
- cvSplit( pSrcImage, pImageChannel[0], pImageChannel[1],pImageChannel[2],NULL);
- for( i = 0; i < pImage->nChannels; i++ )
- {
- //直方圖均衡化
- cvEqualizeHist(pImageChannel[i], pImageChannel[i]);
- }
- // 通道組合
- cvMerge( pImageChannel[0], pImageChannel[1], pImageChannel[2],NULL,pImage);
- // ……影象顯示程式碼(略)
- // 釋放資源
- for( i=0; i<pSrcImage->nChannels; i++)
- {
- if(pImageChannel[i])
- {
- cvReleaseImage( &pImageChannel[i] );
- pImageChannel[i] = 0;
- }
- }
- cvNamedWindow("1");
- cvShowImage("1",pImage);
- cvWaitKey();
- cvDestroyWindow("1");
- //
- string saveFile = ".\\002\\histgram\\";
- saveFile = saveFile + name;
- saveFile = saveFile + ".bmp";
- cvSaveImage(saveFile.c_str(),pImage);
- count++;
- cvReleaseImage( &pImage );
- }
- }
- }
為什麼總在cvSaveImage那個函數出現錯誤:
OpenCV提高對比度.exe 中的 0x5f9ed7af (highgui200d.dll) 處未處理的異常: 0xC0000005: 讀取位置 0xed4674bb 時發生訪問衝突
先留個檔,以後繼續處理