将RGB转换为sRGB? [英] Convert RGB to sRGB?

查看:4628
本文介绍了将RGB转换为sRGB?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将RGB转换为感知上均匀的色彩空间CIELAB。维基百科声明:

I am trying to convert an RGB to the perceptually uniform color space, CIELAB. Wikipedia states:


首先必须将RGB或CMYK值转换为特定的
绝对色彩空间,例如sRGB或Adobe RGB。此调整将
取决于设备,但转换后得到的数据将是
设备无关,允许将数据转换为CIE 1931
颜色空间然后转换进入L * a * b *。

"The RGB or CMYK values first must be transformed to a specific absolute color space, such as sRGB or Adobe RGB. This adjustment will be device-dependent, but the resulting data from the transform will be device-independent, allowing data to be transformed to the CIE 1931 color space and then transformed into L*a * b*."

我知道转换为sRGB后有一些简单的转换,但我还没有找到任何转换材料从RGB到sRGB。那么,有什么方法可以进行这样的转换?

I know there are some straightforward transformations once converting to sRGB, but I have not found any material to go from RGB to sRGB. So, what methods exist to do such a conversion?

推荐答案

不,你不应该从(线性)RGB转到sRGB。事实上,它是相反的。以下是步骤:

No, you should not go from (linear) RGB to sRGB. In fact, it is the other way round. Following are the steps:


  1. 将sRGB转换为线性RGB。 sRGB图像是伽马编码,这意味着摄像机将伽马函数 pow(x,1 / 2.2)应用于光信号。此sRGB位于非线性的伽马空间中。

  1. Convert sRGB into linear RGB. sRGB image is a gamma encoded which means a camera applies gamma function pow(x, 1/2.2) onto the light signal. This sRGB is in gamma-space which is non-linear.

现在,将线性RGB转换为LAB涉及两个步骤:首先将线性RGB转换为XYZ颜色空间(这是一个基本的颜色空间)。该转换是线性运算,即矩阵乘法。这就是为什么你需要线性RGB值而不是sRGB的原因。它需要处于线性空间。最后,通过非线性操作将XYZ值转换为LAB值,该操作包含一些标准公式(您不必担心)。

Now, converting linear RGB to LAB involves two steps: first is converting linear RGB to XYZ color space (this is a basic color-space). This conversion is a linear operation, i.e., matrix multiplication. This is the reason why you would need linear RGB values not sRGB. It needs to be in linear space. Finally, XYZ values are converted into LAB values through a non-linear operation which contains some standard formulas (which you don't need to be worried about).

有趣的链接:

(i)了解sRGB和线性RGB空间: http://filmicgames.com/archives/299 ; http://www.cambridgeincolour.com/tutorials/gamma-correction.htm

(i) Understanding sRGB and linear RGB space: http://filmicgames.com/archives/299; http://www.cambridgeincolour.com/tutorials/gamma-correction.htm

(ii)MATLAB教程: https://de.mathworks.com/help/vision/ref/colorspaceconversion.html

(ii) MATLAB tutorial: https://de.mathworks.com/help/vision/ref/colorspaceconversion.html

(iii)Python包: http://pydoc.net/Python/pwkit/0.2.1/pwkit.colormaps /

(iii) Python package: http://pydoc.net/Python/pwkit/0.2.1/pwkit.colormaps/

(iv)C代码: http://svn.int64.org/viewvc/int64/colors/color.c?view=markup

(v)OpenCV不执行此sRGB到线性RGB转换,但它在color.cpp代码中执行转换(OpenCV_DIR\modules\imgproc\src\color.cpp)。检查出名为 initLabTabs()的方法,有一个gamma编码和解码。 OpenCV颜色转换API: http://docs.opencv.org/3.1 .0 / de / d25 / imgproc_color_conversions.html

(v) OpenCV does not do this sRGB to linear RGB conversion but it does the conversion inside color.cpp code (OpenCV_DIR\modules\imgproc\src\color.cpp). Check out method called initLabTabs(), there is a gamma encoding and decoding. OpenCV color conversion API: http://docs.opencv.org/3.1.0/de/d25/imgproc_color_conversions.html

这篇关于将RGB转换为sRGB?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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