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

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

问题描述

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

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

推荐答案

自2010年以来,当 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天全站免登陆