doufei8691 2014-02-05 12:02 采纳率: 100%
浏览 76
已采纳

如何在PHP中将CIE颜色空间转换为RGB或HEX颜色代码

I`m working on some web application where I want to convert CIE 1931 color space code to RGB or HEX code. How can I convert it?

  • 写回答

1条回答 默认 最新

  • duanhao4909 2014-02-05 20:49
    关注

    Well, to get to RGB from XYZ you can use this matrix:

    [ R ]   [  3.240479 -1.537150 -0.498535 ]   [ X ]
    [ G ] = [ -0.969256  1.875992  0.041556 ] * [ Y ]
    [ B ]   [  0.055648 -0.204043  1.057311 ]   [ Z ]
    

    But since you have xyY (at least, I assume) values, you'll first need to convert them to XYZ values, like so:

    X = (x*Y)/y
    Y = Y
    Z = ((1-x-y)*Y)/y
    

    So in theory, you could calculate it like so:

    R = 3.240479*((x*Y)/y) + -1.537150*Y + -0.498535*(((1-x-y)*Y)/y)
    G = -0.969256*((x*Y)/y) + 1.875992*Y + 0.041556*(((1-x-y)*Y)/y)
    B = 0.055648*((x*Y)/y) + -0.204043*Y + 1.057311*(((1-x-y)*Y)/y)
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办