标签:图像 win bsp ase include named img 目标 class
将代码中的图片路径换成实际路径即可。
#include "stdafx.h" #include "cv.h" #include "highgui.h" #include <highgui.h> #include <cv.h> using namespace std; int main(int argc, char** argv) { int k; IplImage* src = cvLoadImage("..\\4_3.jpg", 1); IplImage* imgChannel[4] = { 0, 0, 0, 0 }; IplImage* dst = cvCreateImage(cvGetSize(src), IPL_DEPTH_8U, 3); if (src) { for (k = 0; k < src->nChannels; k++) { imgChannel[k] = cvCreateImage(cvGetSize(src), IPL_DEPTH_8U, 1); //要求单通道图像才能直方图均衡化 } //通道分离 cvSplit(src, imgChannel[0], imgChannel[1], imgChannel[2], imgChannel[3]);//BGRA cout << "dst->nChannels:" << dst->nChannels; for (k = 0; k < dst->nChannels; k++) { //直方图均衡化,原始图像和目标图像必须是单通道 cvEqualizeHist(imgChannel[k], imgChannel[k]); } //通道组合 cvMerge(imgChannel[0], imgChannel[1], imgChannel[2], imgChannel[3], dst); cvNamedWindow("src", 1); cvShowImage("src", src); cvNamedWindow("Equalize", 1); cvShowImage("Equalize", dst); cvWaitKey(0); //释放资源 for (k = 0; k < src->nChannels; k++) { if (imgChannel[k]) { cvReleaseImage(&imgChannel[k]); //imgChannel[i] = 0; } } cvReleaseImage(&dst); } return 0; }
标签:图像 win bsp ase include named img 目标 class
原文地址:http://www.cnblogs.com/begoogatprogram/p/6059384.html