- #include <cv.h>
- #include <highgui.h>
- #include <stdio.h>
- #include <string>
- using namespace std;
- void main()
- {
- int i;
- IplImage *pImageChannel[4] = {0,0,0,0};
- int count = 15;
- char *name = new char;
- 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 时发生访问冲突
本文介绍了一个使用OpenCV进行图像增强的示例程序,包括图像读取、通道分离、直方图均衡化、通道合并及保存处理后的图像等步骤。探讨了在cvSaveImage函数调用时遇到的访问冲突错误。
27万+

被折叠的 条评论
为什么被折叠?



