OpenCV默认颜色通道

网上查了一下,OpenCV读取图片之后Mat默认的颜色通道都说是BGR,有点不信,试了一下,先用PS做一张纯色的图片,还有颜色的RGB值

     

然后用OpenCV读取图片之后读取RGB值逐一显示出来:

 1 // OpenCV_default_color_channel.cpp : 定义控制台应用程序的入口点。
 2 //
 3 
 4 
 5 #include "opencv2/core/core.hpp"
 6 #include "opencv2/highgui/highgui.hpp"
 7 #include "opencv2/imgproc/imgproc.hpp"
 8 #include "opencv2/imgproc/imgproc_c.h"
 9 #include <iostream>
10 #include <string>
11 
12 using namespace cv;
13 using namespace std;
14 
15 
16 int main(int argc, char* argv[])
17 {
18     Mat src;
19     src = imread("pic.jpg");
20 
21     int channel1 = 0, channel2 = 0, channel3 = 0;
22     channel1 = ((uchar *)(src.data))[0];
23     channel2 = ((uchar *)(src.data))[1];
24     channel3 = ((uchar *)(src.data))[2];
25 
26     cout << "channel1:" << channel1 << endl;
27     cout << "channel2:" << channel2 << endl;
28     cout << "channel3:" << channel3 << endl;
29 
30     imshow("pic", src);
31 
32     waitKey(0);
33     return 0;
34 
35 }

结果如下,还真是BGR的坑爹顺序:

转载于:https://www.cnblogs.com/wangshaohao/p/4471499.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值