使用 python 转换图像 RGB->Lab [英] Convert an image RGB->Lab with python

查看:64
本文介绍了使用 python 转换图像 RGB->Lab的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

What is the preferred way of doing the conversion using PIL/Numpy/SciPy today?

推荐答案

自从 2010 年 链接问题 被问到将相应的代码从 scipy 移动到单独的工具包:http://scikit-image.org/

Since 2010 when the linked question was asked the corresponding code moved from scipy to a separate toolkit: http://scikit-image.org/

这里是我真正要找的代码:

So here's the code I was actually looking for:

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(它能够使用 其他人),

It should also be noted that due to Lab nature srgb->lab conversion depends on an additional parameter: whitepoint, eg:
   • Photoshop uses a white point called D50 (which is a standard for icc)
   • OpenCV and skimage use D65 (which is a standard for srgb).
   • default Matlab implementation uses D50 (it is capable of using others),

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

This nice FAQ explains it this way:

除非您有充分的理由使用某些东西,否则您应该使用 D65否则.
印刷行业常用D50,摄影常用使用 D55.
这些代表了室内条件之间的妥协(钨)和日光观察.

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)

You can tell which whitepoint you're dealing with by converting RGB (0,0,255) to Lab:
   • D50 would give you (30, 68, -112)
   • D55                         (30, 73, -110)
   • D65                         (32, 79, -108)

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

The numbers after 'D' correspond to (internally) used color temperature of white point: D50 = 5003 K (yellowish), D65 = 6504 K (blueish)

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

I'm grateful to Alex and Roman for their answers because they pointed me into the right direction.

这篇关于使用 python 转换图像 RGB->Lab的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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