OpenCV的颜色空间转换函数:
 
C++: void cvtColor(InputArray src, OutputArray dst, int code, int dstCn=0 )
 
参数dstCn原来一直沿用CV_BGR2GRAY, CV_RGB2GRAY, CV_GRAY2BGR, CV_GRAY2RGB等格式,但最新几个版本的OpenCV已改为COLOR_BGR2GRAY类似形式,今天才看源代码imgproc.hpp才发现,但官方文档还没修改,如下图,如果程序中使用较新的版本OpenCV,采用CV_BGR2GRAY可能会一直出错。
 
 
 
新的OpenCV中imgproc.hpp的定义如下:
enum
{
COLOR_BGR2BGRA =,
COLOR_RGB2RGBA =COLOR_BGR2BGRA, COLOR_BGRA2BGR =,
COLOR_RGBA2RGB =COLOR_BGRA2BGR, COLOR_BGR2RGBA =,
COLOR_RGB2BGRA =COLOR_BGR2RGBA, COLOR_RGBA2BGR =,
COLOR_BGRA2RGB =COLOR_RGBA2BGR, COLOR_BGR2RGB =,
COLOR_RGB2BGR =COLOR_BGR2RGB, COLOR_BGRA2RGBA =,
COLOR_RGBA2BGRA =COLOR_BGRA2RGBA, COLOR_BGR2GRAY =,
COLOR_RGB2GRAY =,
COLOR_GRAY2BGR =,
COLOR_GRAY2RGB =COLOR_GRAY2BGR,
COLOR_GRAY2BGRA =,
COLOR_GRAY2RGBA =COLOR_GRAY2BGRA,
COLOR_BGRA2GRAY =,
COLOR_RGBA2GRAY =, COLOR_BGR2BGR565 =,
COLOR_RGB2BGR565 =,
COLOR_BGR5652BGR =,
COLOR_BGR5652RGB =,
COLOR_BGRA2BGR565 =,
COLOR_RGBA2BGR565 =,
COLOR_BGR5652BGRA =,
COLOR_BGR5652RGBA =, COLOR_GRAY2BGR565 =,
COLOR_BGR5652GRAY =, COLOR_BGR2BGR555 =,
COLOR_RGB2BGR555 =,
COLOR_BGR5552BGR =,
COLOR_BGR5552RGB =,
COLOR_BGRA2BGR555 =,
COLOR_RGBA2BGR555 =,
COLOR_BGR5552BGRA =,
COLOR_BGR5552RGBA =, COLOR_GRAY2BGR555 =,
COLOR_BGR5552GRAY =, COLOR_BGR2XYZ =,
COLOR_RGB2XYZ =,
COLOR_XYZ2BGR =,
COLOR_XYZ2RGB =, COLOR_BGR2YCrCb =,
COLOR_RGB2YCrCb =,
COLOR_YCrCb2BGR =,
COLOR_YCrCb2RGB =, COLOR_BGR2HSV =,
COLOR_RGB2HSV =, COLOR_BGR2Lab =,
COLOR_RGB2Lab =, COLOR_BayerBG2BGR =,
COLOR_BayerGB2BGR =,
COLOR_BayerRG2BGR =,
COLOR_BayerGR2BGR =, COLOR_BayerBG2RGB =COLOR_BayerRG2BGR,
COLOR_BayerGB2RGB =COLOR_BayerGR2BGR,
COLOR_BayerRG2RGB =COLOR_BayerBG2BGR,
COLOR_BayerGR2RGB =COLOR_BayerGB2BGR, COLOR_BGR2Luv =,
COLOR_RGB2Luv =,
COLOR_BGR2HLS =,
COLOR_RGB2HLS =, COLOR_HSV2BGR =,
COLOR_HSV2RGB =, COLOR_Lab2BGR =,
COLOR_Lab2RGB =,
COLOR_Luv2BGR =,
COLOR_Luv2RGB =,
COLOR_HLS2BGR =,
COLOR_HLS2RGB =, COLOR_BayerBG2BGR_VNG =,
COLOR_BayerGB2BGR_VNG =,
COLOR_BayerRG2BGR_VNG =,
COLOR_BayerGR2BGR_VNG =, COLOR_BayerBG2RGB_VNG =COLOR_BayerRG2BGR_VNG,
COLOR_BayerGB2RGB_VNG =COLOR_BayerGR2BGR_VNG,
COLOR_BayerRG2RGB_VNG =COLOR_BayerBG2BGR_VNG,
COLOR_BayerGR2RGB_VNG =COLOR_BayerGB2BGR_VNG, COLOR_BGR2HSV_FULL = ,
COLOR_RGB2HSV_FULL = ,
COLOR_BGR2HLS_FULL = ,
COLOR_RGB2HLS_FULL = , COLOR_HSV2BGR_FULL = ,
COLOR_HSV2RGB_FULL = ,
COLOR_HLS2BGR_FULL = ,
COLOR_HLS2RGB_FULL = , COLOR_LBGR2Lab = ,
COLOR_LRGB2Lab = ,
COLOR_LBGR2Luv = ,
COLOR_LRGB2Luv = , COLOR_Lab2LBGR = ,
COLOR_Lab2LRGB = ,
COLOR_Luv2LBGR = ,
COLOR_Luv2LRGB = , COLOR_BGR2YUV = ,
COLOR_RGB2YUV = ,
COLOR_YUV2BGR = ,
COLOR_YUV2RGB = , COLOR_BayerBG2GRAY = ,
COLOR_BayerGB2GRAY = ,
COLOR_BayerRG2GRAY = ,
COLOR_BayerGR2GRAY = , //YUV 4:2:0 formats family
COLOR_YUV2RGB_NV12 = ,
COLOR_YUV2BGR_NV12 = ,
COLOR_YUV2RGB_NV21 = ,
COLOR_YUV2BGR_NV21 = ,
COLOR_YUV420sp2RGB = COLOR_YUV2RGB_NV21,
COLOR_YUV420sp2BGR = COLOR_YUV2BGR_NV21, COLOR_YUV2RGBA_NV12 = ,
COLOR_YUV2BGRA_NV12 = ,
COLOR_YUV2RGBA_NV21 = ,
COLOR_YUV2BGRA_NV21 = ,
COLOR_YUV420sp2RGBA = COLOR_YUV2RGBA_NV21,
COLOR_YUV420sp2BGRA = COLOR_YUV2BGRA_NV21, COLOR_YUV2RGB_YV12 = ,
COLOR_YUV2BGR_YV12 = ,
COLOR_YUV2RGB_IYUV = ,
COLOR_YUV2BGR_IYUV = ,
COLOR_YUV2RGB_I420 = COLOR_YUV2RGB_IYUV,
COLOR_YUV2BGR_I420 = COLOR_YUV2BGR_IYUV,
COLOR_YUV420p2RGB = COLOR_YUV2RGB_YV12,
COLOR_YUV420p2BGR = COLOR_YUV2BGR_YV12, COLOR_YUV2RGBA_YV12 = ,
COLOR_YUV2BGRA_YV12 = ,
COLOR_YUV2RGBA_IYUV = ,
COLOR_YUV2BGRA_IYUV = ,
COLOR_YUV2RGBA_I420 = COLOR_YUV2RGBA_IYUV,
COLOR_YUV2BGRA_I420 = COLOR_YUV2BGRA_IYUV,
COLOR_YUV420p2RGBA = COLOR_YUV2RGBA_YV12,
COLOR_YUV420p2BGRA = COLOR_YUV2BGRA_YV12, COLOR_YUV2GRAY_420 = ,
COLOR_YUV2GRAY_NV21 = COLOR_YUV2GRAY_420,
COLOR_YUV2GRAY_NV12 = COLOR_YUV2GRAY_420,
COLOR_YUV2GRAY_YV12 = COLOR_YUV2GRAY_420,
COLOR_YUV2GRAY_IYUV = COLOR_YUV2GRAY_420,
COLOR_YUV2GRAY_I420 = COLOR_YUV2GRAY_420,
COLOR_YUV420sp2GRAY = COLOR_YUV2GRAY_420,
COLOR_YUV420p2GRAY = COLOR_YUV2GRAY_420, //YUV 4:2:2 formats family
COLOR_YUV2RGB_UYVY = ,
COLOR_YUV2BGR_UYVY = ,
//COLOR_YUV2RGB_VYUY = 109,
//COLOR_YUV2BGR_VYUY = 110,
COLOR_YUV2RGB_Y422 = COLOR_YUV2RGB_UYVY,
COLOR_YUV2BGR_Y422 = COLOR_YUV2BGR_UYVY,
COLOR_YUV2RGB_UYNV = COLOR_YUV2RGB_UYVY,
COLOR_YUV2BGR_UYNV = COLOR_YUV2BGR_UYVY, COLOR_YUV2RGBA_UYVY = ,
COLOR_YUV2BGRA_UYVY = ,
//COLOR_YUV2RGBA_VYUY = 113,
//COLOR_YUV2BGRA_VYUY = 114,
COLOR_YUV2RGBA_Y422 = COLOR_YUV2RGBA_UYVY,
COLOR_YUV2BGRA_Y422 = COLOR_YUV2BGRA_UYVY,
COLOR_YUV2RGBA_UYNV = COLOR_YUV2RGBA_UYVY,
COLOR_YUV2BGRA_UYNV = COLOR_YUV2BGRA_UYVY, COLOR_YUV2RGB_YUY2 = ,
COLOR_YUV2BGR_YUY2 = ,
COLOR_YUV2RGB_YVYU = ,
COLOR_YUV2BGR_YVYU = ,
COLOR_YUV2RGB_YUYV = COLOR_YUV2RGB_YUY2,
COLOR_YUV2BGR_YUYV = COLOR_YUV2BGR_YUY2,
COLOR_YUV2RGB_YUNV = COLOR_YUV2RGB_YUY2,
COLOR_YUV2BGR_YUNV = COLOR_YUV2BGR_YUY2, COLOR_YUV2RGBA_YUY2 = ,
COLOR_YUV2BGRA_YUY2 = ,
COLOR_YUV2RGBA_YVYU = ,
COLOR_YUV2BGRA_YVYU = ,
COLOR_YUV2RGBA_YUYV = COLOR_YUV2RGBA_YUY2,
COLOR_YUV2BGRA_YUYV = COLOR_YUV2BGRA_YUY2,
COLOR_YUV2RGBA_YUNV = COLOR_YUV2RGBA_YUY2,
COLOR_YUV2BGRA_YUNV = COLOR_YUV2BGRA_YUY2, COLOR_YUV2GRAY_UYVY = ,
COLOR_YUV2GRAY_YUY2 = ,
//COLOR_YUV2GRAY_VYUY = COLOR_YUV2GRAY_UYVY,
COLOR_YUV2GRAY_Y422 = COLOR_YUV2GRAY_UYVY,
COLOR_YUV2GRAY_UYNV = COLOR_YUV2GRAY_UYVY,
COLOR_YUV2GRAY_YVYU = COLOR_YUV2GRAY_YUY2,
COLOR_YUV2GRAY_YUYV = COLOR_YUV2GRAY_YUY2,
COLOR_YUV2GRAY_YUNV = COLOR_YUV2GRAY_YUY2, // alpha premultiplication
COLOR_RGBA2mRGBA = ,
COLOR_mRGBA2RGBA = , COLOR_RGB2YUV_I420 = ,
COLOR_BGR2YUV_I420 = ,
COLOR_RGB2YUV_IYUV = COLOR_RGB2YUV_I420,
COLOR_BGR2YUV_IYUV = COLOR_BGR2YUV_I420, COLOR_RGBA2YUV_I420 = ,
COLOR_BGRA2YUV_I420 = ,
COLOR_RGBA2YUV_IYUV = COLOR_RGBA2YUV_I420,
COLOR_BGRA2YUV_IYUV = COLOR_BGRA2YUV_I420,
COLOR_RGB2YUV_YV12 = ,
COLOR_BGR2YUV_YV12 = ,
COLOR_RGBA2YUV_YV12 = ,
COLOR_BGRA2YUV_YV12 = , COLOR_COLORCVT_MAX =
};

OpenCV 颜色空间转换参数CV_BGR2GRAY改变的更多相关文章

  1. 颜色空间转换 cvtColor()[OpenCV 笔记13]

    void cvtColor(InputArray src, OutputArray dst, ) src: 输入图像 dst: 输出图像 code: 颜色空间转换标识符 OpenCV2的CV_前缀宏命 ...

  2. OpenCV 的颜色空间转换

    # coding: utf-8 ''' 第13章主要介绍:颜色空间转换 ''' import cv2 import numpy as np ''' 经常用到的颜色空间转换是: BGR<-> ...

  3. opencv学习笔记——颜色空间转换函数cv::cvtColor详解

    cv::cvtColor()用于将图像从一个颜色空间转换到另一个颜色空间的转换(目前常见的颜色空间均支持),并且在转换的过程中能够保证数据的类型不变,即转换后的图像的数据类型和位深与源图像一致. 具体 ...

  4. OpenCV 学习笔记(10)HSV颜色空间及颜色空间转换(RGB-HSV)

    1.1 颜色空间介绍 RGB 颜色空间是大家最熟悉的颜色空间,即三基色空间,任何一种颜色都可以由该三种 颜色混合而成.然而一般对颜色空间的图像进行有效处理都是在 HSV 空间进行的,HSV(色 调 H ...

  5. OpenCV学习笔记(5)——颜色空间转换

    学习如歌对图像进行颜色空间转换,从BGR到灰度图,或者从BGR到HSV等 创建一个程序用来从一幅图像中获取某个特定颜色的物体 1.转换颜色空间 OpenCV中有超过150种进行颜色空间转化的方法,但是 ...

  6. python数字图像处理(4):图像数据类型及颜色空间转换

    一.图像数据类型及转换 在skimage中,一张图片就是一个简单的numpy数组,数组的数据类型有很多种,相互之间也可以转换.这些数据类型及取值范围如下表所示: Data type Range uin ...

  7. 【OpenCV-Python】-颜色空间转换

    OpenCV官方教程中文版 for Python,原文为段立辉翻译,感谢Linux公社www.linuxidc.com此文档为自学转述,如有侵权请联系本人 使用工具Python3.6使用包cv2,nu ...

  8. Python-OpenCV中图像颜色空间转换

    目录 cv2.cvtColor() 1. RGB to GRAY 2. RGB to CIE XYZ 3. RGB to YCrCb JPEG 4. RGB to HSV 5. RGB to HLS ...

  9. (Ooencv3)颜色空间转换

    (Ooencv3)颜色空间转换 opencv中有多种色彩空间,包括 RGB.HSI.HSL.HSV.HSB.YCrCb.CIE XYZ.CIE Lab8种,使用中经常要遇到色彩空间的转化,以便生成ma ...

随机推荐

  1. Kubelet资源预留

    目录 Kubelet Node Allocatable 配置参数 配置示例 Kubelet Node Allocatable Kubelet Node Allocatable用来为Kube组件和Sys ...

  2. NO.3day 网络基础

    网络基础 1.互联网协议 概念:通过互联网传输数据的标准. 功能:定义计算机如何接入internet,以及接入internet的计算机通信的标准. 2.OSI五层模型 应用层--传输层--网络层--数 ...

  3. P3924 康娜的线段树

    P3924 康娜的线段树 题目描述 小林是个程序媛,不可避免地康娜对这种人类的"魔法"产生了浓厚的兴趣,于是小林开始教她OI. 今天康娜学习了一种叫做线段树的神奇魔法,这种魔法可以 ...

  4. Oracle 中常用数据字典大总结

    原文出处:小宝马的爸爸 - 梦想的家园 前面呢,也断断续续的介绍了一些诸如 Sql*Plus 等等关于 Oracle 的基本的内容, 对于 Oracle 这样的大型数据库呢,自身的运行和维护也是个不得 ...

  5. 使用IDEA复用代码时常见问题

    使用IDEA复用代码时常见问题 觉得有用的话,欢迎一起讨论相互学习~Follow Me 作为新手在直接复用别人的java代码并使用IDEA进行二次开发时,经常出现一些奇怪的问题,在此做一些总结~ In ...

  6. 数据分析与展示---Numpy数据存取与函数

    简介 一:数据的CSV文件存取(一维或二维) (一)写入文件savetxt (二)读取文件loadtxt 二:多维数据的存取 (一)保存文件tofile (二)读取文件fromfile (三)NumP ...

  7. Linux查看服务器公网ip的方法

    在解决网络问题时,需要查看本机的出口公网IP信息,有如下两个方法: curl ifconfig.me 在linux系统中输入上述的命令,可以查看到本机连接的公网信息: 如果该命令无效,可以使用下面一个 ...

  8. poj 2185 Milking Grid

    Milking Grid http://poj.org/problem?id=2185 Time Limit: 3000MS   Memory Limit: 65536K       Descript ...

  9. NGINX+TOMCAT实现反向代理

    环境说明 NGINX: 192.168.10.10 TOMCAT: 192.168.10.11 NGINX部分 [root@nginx ~]# wget http://nginx.org/downlo ...

  10. Machine Learning Trick of the Day (1): Replica Trick

    Machine Learning Trick of the Day (1): Replica Trick 'Tricks' of all sorts are used throughout machi ...