HSLuv

From HandWiki
Short description: Color space for computer displays

In colorimetry, the HSLuv color space is a human-friendly alternative to the HSL color space. It was formerly known as "husl". It is a variation of the CIE LCH(uv) color space, where the C (colorfulness) component is replaced by a "Saturation" (S) component representing the colorfulness percentage relative to the maximum sRGB can provide given the L and H values.[1] The value has nothing to do with "saturation" in color theory.

History

The color spaces used widely for computer display, such as standard Red Green Blue (sRGB) (and the color models built on it like HSL and HSV) are irregular, which means that even though the rectangles have evenly spaced hue values, the corresponding effect is not linear to the human eye.[2]

The CIELUV color space was designed for perceptual uniformity, based on human experiments, and was adopted in 1976 by the International Commission on Illumination (CIE) as a simple-to-compute transformation of the 1931 CIE XYZ color space. CIELUV has been extensively used for applications such as computer graphics which deal with colored lights. Although additive mixtures of different colored lights will fall on a line in CIELUV's uniform chromaticity diagram (dubbed the CIE 1976 UCS), such additive mixtures will not, contrary to popular belief, fall along a line in the CIELUV color space unless the mixtures are constant in lightness. When accessed by polar coordinates, CIELUV becomes functionally similar to the HSL color space, with the problem that its chroma component doesn't fit into a specific range. Even though CIELUV and CIELAB color spaces are based on human perception, they are not intuitive when working in code.[2]

By extending CIELUV with a new "saturation" component, HSLuv now allows spanning all of the available chroma as a percentage.[3] The HSLuv project is one of the more recent attempts at making these color spaces more intuitive. It allows you to use the CIELUV color space in the same dimensions as the HSL color model. Referred to as a human-friendly HSL, the original code was written in the Haxe programming language, but the project is now implemented in most of the popular programming languages, including JavaScript.[2]

Implementation

The reference implementation is written in Haxe and released under the MIT license.

HSLuv has been ported to the following computer languages: C, C#, Elm, Emacs, GLSL, Haskell, Haxe, Go, Java, JavaScript, Lua, Objective-C, Perl, PHP, Python, Ruby, Rust, Sass, and Swift.[4]

See also

References

External links

  • [1] Explanation of differences between sRGB and HSLuv color spaces with comparisons and Javascript examples.
  • [2] Javascript implementation of HSLuv with math, examples, comparisons, and links to implementations in various programming languages.