cvCvtColor函数

cvCvtColoropencv库中的一个函数

功能:函数cvCvtColor实现色彩空间转换

 

函数形式: void cvCvtColor( const CvArr* src, CvArr* dst, int code );

 

参数列表

src源图像输入的 8-bit , 16-bit 32-bit 单倍精度浮点数影像

dst:目标图像输入的 8-bit , 16-bit 32-bit 单倍精度浮点数影像

code

·RGB <--> BGRCV_BGR2BGRACV_RGB2BGRACV_BGRA2RGBACV_BGR2BGRACV_BGRA2BGR

RGB <--> 5X5CV_BGR5652RGBACV_BGR2RGB555、(以此类推,不一一列举)

RGB <---> GrayCV_RGB2GRAYCV_GRAY2RGBCV_RGBA2GRAYCV_GRAY2RGBA

RGB <--> CIE XYZCV_BGR2XYZCV_RGB2XYZCV_XYZ2BGRCV_XYZ2RGB

RGB <--> YCrCbYUVJPEGCV_RGB2YCrCbCV_RGB2YCrCbCV_YCrCb2BGRCV_YCrCb2RGBCV_RGB2YUV(将YCrCbYUV替代都可以)

RGB <--> HSVCV_BGR2HSVCV_RGB2HSVCV_HSV2BGRCV_HSV2RGB

RGB <--> HLSCV_BGR2HLSCV_RGB2HLSCV_HLS2BGRCV_HLS2RGB

RGB <--> CIE L*a*b*CV_BGR2LabCV_RGB2LabCV_Lab2BGRCV_Lab2RGB

RGB <--> CIE L*u*vCV_BGR2LuvCV_RGB2LuvCV_Luv2BGRCV_Luv2RGB

RGB <--> BayerCV_BayerBG2BGRCV_BayerGB2BGRCV_BayerRG2BGRCV_BayerGR2BGRCV_BayerBG2RGBCV_BayerGB2RGBCV_BayerRG2RGBCV_BayerGR2RGB(在CCDCMOS上常用的Bayer模式)

YUV420 <--> RGBCV_YUV420sp2BGRCV_YUV420sp2RGBCV_YUV420i2BGRCV_YUV420i2RGB

 

 

 

OPENCV默认图片通道顺序是BGR而不是RGB

 

 

程序应用示例:

 

#include "opencv2/imgproc/imgproc.hpp"

#include "opencv2/highgui/highgui.hpp"   

using namespace cv;   

int main()

{

Mat src = imread("1.jpg", 1), dst;

imshow("resoure", src);

cvtColor(src, dst, CV_RGB2GRAY);

imshow("效果图", dst);

cvWaitKey();

return 0;

}

你可能感兴趣的:(openCV)