HSL color space
Encyclopedia : H : HS : HSL : HSL color space
The HSL color space, also called HLS or HSI, stands for Hue, Saturation, Lightness (also Luminance or Luminosity) / Intensity. While HSV (Hue, Saturation, Value) can be viewed graphically as a color cone or hexcone, HSL is drawn as a double cone or double hexcone. Both systems are non-linear deformations of the RGB colour cube. The two apexes of the HSL double hexcone correspond to black and white. The angular parameter corresponds to hue, distance from the axis corresponds to saturation, and distance along the black-white axis corresponds to lightness.
Converting from RGB
The (R, G, B) values must be expressed as numbers from 0 to 1. Let [MAX] equal the greatest of the (R, G, B) values, and [MIN] equal the least of those values. The formula can then be written as
[H =\begin\mbox & \mbox MAX = MIN \\60^\circ \times \frac, & \mbox MAX = R \\60^\circ \times \frac + 120^\circ, & \mbox MAX = G \\60^\circ \times \frac + 240^\circ, & \mbox MAX = B\end]
[S = \begin0 & \mbox MIN = MAX \\\frac = \frac, & \mbox 0 < L \leq \frac \\\frac = \frac, & \mbox L > \frac\end]
[L = \begin \frac \end (MAX + MIN)]
[H] is generally normalised to lie between 0 and 360°, and [H=0] is often used instead of leaving [H] undefined. HSL and HSV have the same definition of hue, but the other components differ. The other two components of HSV are defined as follows:
[S = \frac = 1- \frac ]
[V = MAX \,]
Converting to RGB
Given a color defined by (H, S, L) values, with H, ranging from 0.0 inclusive to 360.0 exclusive, indicating the angle, in degrees, around the color circle where the hue is located, and with S and L, varying between 0.0 and 1.0, representing the saturation and value, respectively, a corresponding (R, G, B) color can be determined through a series of formulas. Note that the (R, G, B) values will be between 0.0 and 1.0.First, if S is equal to 0.0, then the resulting color is achromatic, or grey. In this special case, R, G, and B are simply equal to L. As above, H is irrelevant in this situation.
When S is non-zero, the following procedure can be used
[temp2=\beginL \times (1.0+S), & \mbox L<0.5 \\L+S-L \times S, & \mbox L \ge 0.5\end]
[temp1 = 2.0 \times L - temp2 \, ]
[H_k = \, ] (convert to the range [0,1])
[temp3_R = H_k+\frac \, ]
[temp3_G = H_k \, ]
[temp3_B = H_k-\frac \, ]
[\mbox temp3_c < 0 \rightarrow temp3 = temp3 + 1.0 \quad \mbox\,c=R,G,B \,]
[\mbox temp3_c > 1 \rightarrow temp3 = temp3 - 1.0 \quad \mbox\,c=R,G,B \, ]
For each color [c=R,G,B]:
[\qquad color_c=\begintemp1+(temp2-temp1) \times 6.0 \times temp3_c, & \mbox temp3_c < \frac \\temp2, & \mbox \frac \le temp3_c < \frac \\temp1+(temp2-temp1) \times (\frac-temp3_c) \times 6.0, & \mbox \frac \le temp3_c < \frac \\temp1, & \mbox\end]
Comparison of HSL and HSV
HSL is similar to HSV but better reflects the intuitive notion of "saturation" and "lightness" as two independent parameters, and is therefore more suitable for use by artists. The CSS3 specification from the W3C states, "Advantages of HSL are that it is symmetrical to lightness and darkness (which is not the case with HSV for example)..." This means that:
- In HSL, the Saturation component always goes from fully saturated color to the equivalent gray (in HSV, with V at maximum, it goes from saturated color to white, which may be considered counterintuitive).
- The Lightness in HSL always spans the entire range from black through the chosen hue to white (in HSV, the V component only goes half that way, from black to the chosen hue).
- Applications that use HSV (HSB):
- * Apple Mac OS X system color picker (has a color disk for H/S and a slider for V)
- * The GIMP
- * Xara X
- * Paint.NET (has a color disk for H/S and a slider for V)
- Applications that use HSL:
- * The CSS3 specification
- * Inkscape (starting from version 0.42)
- * Macromedia Studio
- * Microsoft Windows system color picker (including Microsoft Paint)
- * Paint Shop Pro
- Applications that use both HSV and HSL:
- * Adobe graphic applications (Illustrator, Photoshop, and others)
- * Pixel image editor (starting from Beta5)
Examples
The RGB values are shown in the range 0.0 to 1.0.
| RGB | HSL | HSV | Result |
| (1, 0, 0) | (0°, 1, 0.5) | (0°, 1, 1) | |
| (0.5, 1, 0.5) | (120°, 1, 0.75) | (120°, 0.5, 1) | |
| (0, 0, 0.5) | (240°, 1, 0.25) | (240°, 1, 0.5) |
See also
- Color space:
- *RGB color model commonly used for color monitors
- *CMYK color model for color printing
- *HSV color space
- *RYB color model the traditional color model used by artists.
- *YUV for PAL television
- *YDbDr for SECAM television
- *YIQ for NTSC television
References
External links
- An explanation of HSL and how it differs from RGB can be found in the [W3C's CSS3 Color Module].
- Formulas for converting to and from RGB can be found on [EasyRGB.com].
- [Models color space HLS, HSI]
From Wikipedia, the Free Encyclopedia. Original article here. Support Wikipedia by contributing or donating.
All text is available under the terms of the GNU Free Documentation License See Wikipedia Copyrights for details.
