Philliphotoshop Hue Bulb的RGB值转换为XY值
问题说明
如何正确地将拍摄的图片中的像素rgb值转换为发送到Phillips Hue设备所需的XY值? 我当前的代码执行以下操作: 1:拍照,找到最普通的颜色. 2:循环扔掉它们,然后再拍一张照片. 3:将值发送到Phillips Hue Bulbs. 如果您需要更多代码,请告诉我,如果有帮助,我可以共享所有内容. 我在这里特别困惑,因为colormath的转换给了我xyz而不只是xy.而且,如果我使用rbg(0,0,0)进行通话,则它会在色相灯泡上显示一段时间的颜色.
How do I properly convert the pixel rgb values in a picture I have taken to th XY values needed to to send to the Phillips Hue device? My current code does the following: 1:Take a picture, find the most common colors. 2:Cycle throw them and then take another picture. 3:Send the value to a Phillips Hue Bulbs. If you need more of the code, do tell, I can share everything if it helps. I am particularly confused here as the conversion in colormath gives me an xyz and not just an xy. And if I give the converstion of rbg(0,0,0) it gives a while color on the hue bulb.
from beautifulhue.api import Bridge
from colormath.color_objects import RGBColor
from time import sleep
while True:
from pprint import pprint
color_set = colors_from_cam()
pprint(color_set)
for item in color_set:
print "Getting the color"
pprint(item)
time_length = item[0] # prominence
red, green, blue = item[1] # colors
#Set a lights attributes based on RGB colors.
rgb_color = RGBColor(red,green,blue)
xyz_color = rgb_color.convert_to('xyz', target_rgb='cie_rgb')
xyz_x = xyz_color.xyz_x
xyz_y = xyz_color.xyz_y
xyz_z = xyz_color.xyz_z
resource = {
'which':3,
'data':{
'state':{'on':True,
'xy':[xyz_x, xyz_y],
'transitiontime': 1,
'bri': 255}
}
}
bridge.light.update(resource)
print "sleeping"
sleep(1)
sleep(2)
print "taking another picture."
正确答案
Z是从colormath转换中收到的XYZ值的必需组成部分,因此,当仅发送X和Y时,省略Z可能不是您要执行的操作色调.我相信您需要将Z集成到X和Y值中,以将它们归一化为2D颜色矩阵.
Z is a required component of the XYZ values you received from colormath's conversion, so omitting Z is probably not what you meant to do when you sent only X and Y to hue. I believe you need to integrate Z into your X and Y values to normalize them to a 2D color matrix.
x = X/(X Y Z);
x = X / (X Y Z);
y = Y/(X Y Z);
y = Y / (X Y Z);
请参阅: CIE 1931色彩空间,尤其是查看全文
这篇好文章是转载于:学新通技术网
- 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
- 本站站名: 学新通技术网
- 本文地址: /reply/detail/tanhcfigih
-
YouTube API 不能在 iOS (iPhone/iPad) 工作,但在桌面浏览器工作正常?
it1352 07-30 -
iPhone,一张图像叠加到另一张图像上以创建要保存的新图像?(水印)
it1352 07-17 -
保持在后台运行的 iPhone 应用程序完全可操作
it1352 07-25 -
使用 iPhone 进行移动设备管理
it1352 07-23 -
在android同时打开手电筒和前置摄像头
it1352 09-28 -
扫描 NFC 标签时是否可以启动应用程序?
it1352 08-02 -
检查邮件是否发送成功
it1352 07-25 -
Android微调工具-删除当前选择
it1352 06-20 -
希伯来语的空格句子标记化错误
it1352 06-22 -
Android App 和三星 Galaxy S4 不兼容
it1352 07-20