如何从RGB值转换为色温? [英] How to convert from RGB values to color temperature?

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

问题描述

一个人如何获取以RGB值表示的颜色(例如,三个坐标从0-255)并从中产生色温用开尔文(或深红色)表示?

How does one take a color expressed in an RGB value (say, three coordinates from 0-255) and produce from it a color temperature in kelvin (or mireds)?

我看到了这个问题,看起来非常接近。但是,问题提到x和y,答案提到R1和S1,我认为它们是CIE XYZ颜色空间坐标。我也不太确定该怎么去。其他人链接到论文。有人如果不指定色彩空间,RGB值就毫无意义(我以为显示器决定只显示RGB来显示内容)值。)。

I see this question which looks pretty close. However, the question mentions x and y, an answer mentions R1 and S1, which I think are CIE XYZ color space coordinates. I'm not quite sure how to get to those either. Someone else links to a paper. Someone else says RGB values are meaningless without "stating a color space" (I thought my monitor decided to display something simply from RGB values?).

有人可以布置整个东西而无需指向其他地方并假设我知道所有颜色术语是什么吗?

Can someone just lay out the whole thing without pointing to other places and assuming I know what all the color terminology is?

推荐答案

您可以使用颜色使用 colour.xy_to_CCT_Hernandez1999 定义执行计算:

You could use Colour to perform that computation using the colour.xy_to_CCT_Hernandez1999 definition:

  import numpy as np
  import colour

  # Assuming sRGB encoded colour values.
  RGB = np.array([255.0, 235.0, 12.0])

  # Conversion to tristimulus values.
  XYZ = colour.sRGB_to_XYZ(RGB / 255)

  # Conversion to chromaticity coordinates.
  xy = colour.XYZ_to_xy(XYZ)

  # Conversion to correlated colour temperature in K.
  CCT = colour.xy_to_CCT(xy, 'hernandez1999')
  print(CCT)

  # 3557.10272422

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

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