这是我在opencv 中使用C接口显示图像的代码
IplImage * mSrcImg = cvLoadImage("C:\test.jpg");
IplImage * mOutImg;
vector<IplImage*> b , g ,r;
cvSplit(&mSrcImg , &b , &g , &r , NULL);
cvEqualizeHist(&b, &b);
cvEqualizeHist(&g, &g);
cvEqualizeHist(&r, &r);
cvMerge(&b, &g, &r, NULL, &mOutImg );
cvShowImage("Image" , mOutImg);
cvWaitKey();
但是在其中得到运行时错误。
错误
Bad argument (unknown array type) in unknown function , file ......sourcematrix.cpp line 698
如果您需要使用C api,请参阅下面的内容,它将与上面的内容相同,
IplImage*src=0,*bgr,*b,*g,*r;
src = cvLoadImage("Flower.jpg",1);
bgr = cvCreateImage( cvGetSize(src), 8, 3 ) ;
b = cvCreateImage( cvGetSize(src), 8, 1 );
g = cvCreateImage( cvGetSize(src), 8, 1 );
r = cvCreateImage( cvGetSize(src), 8, 1 ) ;
cvSplit(src, b, g, r, 0 );
cvEqualizeHist( b, b );
cvEqualizeHist( g, g );
cvEqualizeHist( r, r );
cvMerge(b,g,r,0,bgr);
cvNamedWindow("source");
cvShowImage("source",src);
cvNamedWindow("hsv");
cvShowImage("hsv",bgr);
cvWaitKey(0);
也可以在C++接口中看到相同的
Mat src=imread("Flower.jpg",1);
Mat bgr[3];
split(src,bgr);
equalizeHist(bgr[0],bgr[0]);
equalizeHist(bgr[1],bgr[1]);
equalizeHist(bgr[2],bgr[2]);
Mat dst;
merge(bgr,3,dst);
imshow("src",src);
imshow("dst",dst);
waitKey();