python rgb转lab,使用python转换图像RGB-> Lab

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

解决方案

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)

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),

This nice FAQ explains it this way:

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.

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)

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

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值