OpenCV是否具有处理sRGB颜色空间中的非线性的功能? [英] Does OpenCV have functions to handle non-linearities in sRGB color space?

查看:111
本文介绍了OpenCV是否具有处理sRGB颜色空间中的非线性的功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道OpenCV是否具有处理sRGB颜色空间中非线性的功能.

I am wondering whether OpenCV has functions to handle the non-linearities in the sRGB color space.

说我想将JPEG图像从sRGB颜色空间转换为XYZ颜色空间.如在 Wiki页面中所指定的,首先需要撤消非线性以转换为线性RGB空格,然后与3x3颜色转换矩阵相乘.但是,我在 cvtColor 中找不到任何此类讨论.文档.我错过了什么吗?

Say I want to convert an JPEG image from sRGB color space into XYZ color space. As specified in this Wiki page, one needs to first undo the nonlinearities to convert to linear RGB space, and then multiply with the 3x3 color transform matrix. However, I couldn't find any such discussions in the cvtColor documentation. Did I miss something?

非常感谢!

推荐答案

文档中没有明确说明,因此您没有丢失任何内容,但是OpenCV不会在其 RGB2XYZ/BGR2XYZ 颜色转换.您可以通过查看

It's not explicitly stated in the documentation, so you're not missing anything, but OpenCV does not perform gamma correction in its RGB2XYZ/BGR2XYZ color conversions. You can confirm this by looking at the source code for cvtColor in

< OpenCV_dir>/modules/imgproc/src/color.cpp

如果您查看 RGB<-> ;,在XYZ 部分,您将看到输入RGB值仅乘以系数矩阵.

If you look at the RGB <-> XYZ section you'll see that the input RGB values are simply multiplied by the coefficient matrix.

我还没有找到任何对RGB图像执行伽玛校正的方法.

I have also not found any existing method to perform gamma correction on an RGB image.

有趣的是,自定义 RGB->完成XYZ 转换是将其转换为 L * a * b * L * u * v * 的准备步骤,并且在两种情况下均执行伽玛校正.

Interestingly, a custom RGB -> XYZ conversion is done as a preliminary step for converting to both L*a*b* and L*u*v*, and in both cases it performs gamma correction.

不幸的是,无法从 RGB2XYZ 代码访问此代码,但是您可以在自己的代码中重用它.我还在网络上看到了几个代码示例,其中大多数都使用查找表来查找 CV_8U 深度图像.

Unfortunately, this isn't accessible from RGB2XYZ code, but you might be able to reuse it in your own code. I've also seen several code samples on the web, mostly using look-up tables for CV_8U depth images.

这篇关于OpenCV是否具有处理sRGB颜色空间中的非线性的功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆