python - 使用 python 转换图像 RGB->Lab

标签 python numpy scipy python-imaging-library color-space

目前使用 PIL/Numpy/SciPy 进行转换的首选方式是什么?

最佳答案

自 2010 年以来 linked question被问到相应的代码从 scipy 转移到一个单独的工具包: http://scikit-image.org/

所以这是我真正要寻找的代码:

from skimage import io, color
rgb = io.imread(filename)
lab = color.rgb2lab(rgb)

还应注意,由于 Lab性质 srgb->lab 转换依赖于一个附加参数:whitepoint,例如:
Photoshop 使用称为 D50 的白点(这是 icc 的标准)
OpenCV 和 skimage 使用 D65(这是 srgb 的标准)。
• 默认Matlab实现使用D50(它能够使用others),

这个不错FAQ是这样解释的:

You should use D65 unless you have a good reason to use something else.
The print industry commonly uses D50 and photography commonly uses D55.
These represent compromises between the conditions of indoor (tungsten) and daylight viewing.

您可以通过将 RGB (0,0,255) 转换为 Lab 来判断您正在处理的白点:
• D50 会给你 (30, 68, -112)
• D55                   (30, 73, -110)
• D65                  (32, 79, -108)

“D”后面的数字对应(内部)使用的白点色温:D50 = 5003 K(偏黄),D65 = 6504 K(偏蓝)

感谢 Alex 和 Roman 的回答,因为他们为我指明了正确的方向。

关于python - 使用 python 转换图像 RGB->Lab,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13405956/

相关文章:

python - 如何从 GZIP 文件中读取 NLTK 语法?

python - 二维数组上的 numpy 逻辑运算

python - 如何将数据框中的列与空列之间的值进行匹配

python - 在二维列表中检测矩形(相同元素值的子数组)

python - 如何限制tensorflow GPU内存使用?

python - 无法使用 pika 清除rabbitmq队列

python 3 : How do I get a string literal representation of a byte string?

python - 在 tensorflow 中创建张量数组?

python - 如何使用 numpy/scipy/matplotlib 以最小平滑度绘制线(多边形链)

python - 按数组numpy过滤