原图
左边是opencv的右边是matlab
解决办法见代码:
Mat a = imread("11.jpg");
Mat b, c, d;
Mat channels_m[3];
vector<Mat>channels;
vector<Mat>channels111;
//cvConvertScale
cvtColor(a, b, CV_BGR2YCrCb);
imshow("d", b);
waitKey(0);
split(b, channels111);
channels_m[0] = channels111[0];//y
channels_m[1] = channels111[1];//cr
channels_m[2] = channels111[2];//cb
channels111[0] = channels_m[1];
channels111[1] = channels_m[2];
channels111[2] = channels_m[0];
merge(channels111, d);
imshow("d", d);
waitKey(0);
跟上一把hsv问题是一样的
要吧RGB–>YCbCr
而在opencv里面是BGR–>YCrCb
所以我们要对应起来,就是R对于转换就是Y分量,G对应转换就是Cb分量,B对应转换就是Cr分量,这样输出的就是和matlab一样了
左边是opencv转的,右边是matlab转的。