如何将HSL(色相,饱和度,亮度)转换为HSLum(色相,饱和度,亮度)和HSLum/RGB? [英] How to convert HSL (hue, saturation, lightness) to HSLum (hue, saturation, luminance) and HSLum/RGB?

查看:93
本文介绍了如何将HSL(色相,饱和度,亮度)转换为HSLum(色相,饱和度,亮度)和HSLum/RGB?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将一些颜色值从众所周知的HSL转换为鲜为人知的HSLum,该怎么做?

I want to convert some color values from well know HSL to less known HSLum how to do it?

hsl(0, 1.0, 0.5) - rgb red  is hslum(0, 1.0., 0.54)
hsl(120, 1.0, 0.5 - rgb green is hslum(0, 1.0, 0.80)
hsl(240, 1.0, 0.5) - rgb blue is hslum(0, 1.0, 0.44)

据我所知,亮度(不是亮度)的计算方式如下:

As far as I know luminance (not lightness) is calculate in such way:

Y = 0.2126 * R + 0.7152 * G + 0.0722 * B

我阅读了一些文章:亮度(相对) 21296247 HSL和HSV luma 孟塞尔但找不到解决方案?

I read some articles: Luminance (relative), 21296247, HSL and HSV, luma, Lightness, Munsell but not found solution?

据我所知,CIELab 1976公式接近 Munsell :

As far I know CIELab 1976 formula is near Munsell:

1.16*(Y/Ymax)^1.16*(Y/Ymax)^(1.0/3.0)-0.16 where Y/Ymax > 0.01

或更佳的插值/

1.16*(Y/Ymax)^(1.0/3.0)-0.16 where Y/Ymax > (6/29)^3
1.16*(841.0/108.0)*(Y/Ymax)+(4.0/29.0)-0.16 where Y/Ymax <= (6/29)^3

如何进行此类转换?

  1. HSL-> HSLum
  2. HSLum-> HSL
  3. HSLum-> RGB

任何提示都会受到欢迎-算法建议.

Any hints will be welcome - algorithms suggestions.

这是一些 HSLum 的工具.

推荐答案

如果您打算生成和使用感知均匀的颜色,则可以使用 Alexei Boronine 创建的库可以使用多种编程语言.

If you intend to generate and work with perceptually uniform colors you can use HSLuv, a library created by Alexei Boronine which is available in multiple programming languages.

它基于 CIELUV颜色空间,并实现了各种颜色转换例程,例如 rgbToHsluv hsluvToRgb hexToHsluv hsluvToHex

It is based on the CIELUV colorspace and implements various color conversion routines, like rgbToHsluv, hsluvToRgb, hexToHsluv, hsluvToHex etc.

该库不支持从HSL到HSLuv的直接转换,但是您可以按照

The library does not support direct conversion from HSL to HSLuv, but you can convert HSL to RGB as described here and afterwards use rgbToHsluv.

这篇关于如何将HSL(色相,饱和度,亮度)转换为HSLum(色相,饱和度,亮度)和HSLum/RGB?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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