CV_BGR2GRAYvsCV_GRAY2BGR
作者:Ray依依 | 来源:互联网 | 2023-09-04 23:10
转载地址:http:blog.csdn.nettimidsmilearticledetails9342855-----------------------------
转载地址:http://blog.csdn.net/timidsmile/article/details/9342855
---------------------------------------------------
来回转换过程中,应该没有什么损失吧
, 1);
if( !img ) return 0; IplImage *gray = cvCreateImage(cvGetSize(img), 8, 1); IplImage *dst = cvCreateImage(cvGetSize(img), 8, 3); IplImage *dst_gray = cvCreateImage(cvGetSize(img), 8, 1); cvCvtColor(img, gray, CV_BGR2GRAY); cvCvtColor(gray, dst, CV_GRAY2BGR); //灰度图转BGR3通道,但每通道的值都是原先单通道的值,所以也是显 //示灰色的 cvCvtColor(dst, dst_gray, CV_BGR2GRAY); cvNamedWindow( "img", 1 ); cvNamedWindow( "gray", 1 ); cvNamedWindow( "dst", 1); cvNamedWindow( "dst_gray", 1); cvShowImage("img", img); cvShowImage("gray", gray); cvShowImage("dst", dst); cvShowImage("dst_gray", dst_gray); cvWaitKey(-1); cvReleaseImage(&img); cvReleaseImage(&dst); cvReleaseImage(&dst_gray); cvDestroyAllWindows(); return 0; }