Web Analytics

See also ebooksgratis.com: no banners, no cookies, totally FREE.

CLASSICISTRANIERI HOME PAGE - YOUTUBE CHANNEL
Privacy Policy Cookie Policy Terms and Conditions
HSL color space - Wikipedia, the free encyclopedia

HSL color space

From Wikipedia, the free encyclopedia

Color cones
Color sphere

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 can be drawn as a double cone or double hexcone as well as a sphere. 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 of the HSL double hexcone corresponds to hue, distance from the axis corresponds to saturation, and distance along the black-white axis corresponds to lightness.

The two poles of the HSL sphere correspond to black and white. The longitudinal parameter (theta) of the HSL sphere corresponds to hue, the latitudinal parameter (phi) corresponds to lightness, and the distance from the center (radius) corresponds to saturation.

Contents

[edit] Converting from RGB

An image, along with its H, S and L components.
Enlarge
An image, along with its H, S and L components.

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{cases} \mbox{undefined} & \mbox{if } MAX = MIN \\ 60^\circ \times \frac{G - B}{MAX - MIN} + 0^\circ,   & \mbox{if } MAX = R  \\ &\mbox{and } G \ge B \\ 60^\circ \times \frac{G - B}{MAX - MIN} + 360^\circ,   & \mbox{if } MAX = R \\ &\mbox{and } G < B \\ 60^\circ \times \frac{B - R}{MAX - MIN} + 120^\circ, & \mbox{if } MAX = G \\ 60^\circ \times \frac{R - G}{MAX - MIN} + 240^\circ, & \mbox{if } MAX = B \end{cases}

S =  \begin{cases} 0 & \mbox{if } L = 0 \\ \frac{MAX-MIN}{MAX+MIN} = \frac{MAX-MIN}{2L}, & \mbox{if } 0 < L \leq \frac{1}{2} \\ \frac{MAX-MIN}{2-(MAX+MIN)} = \frac{MAX-MIN}{2-2L}, & \mbox{if } L > \frac{1}{2} \end{cases}

L = \begin{matrix} \frac{1}{2} \end{matrix} (MAX + MIN)

H is generally normalised to lie between 0 and 360°, and H = 0 is often used when MAX = MIN 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 {MAX - MIN} {MAX}= 1- \frac {MIN} {MAX}

V = MAX \,

[edit] 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[1]

temp2= \begin{cases} L \times (1.0+S), & \mbox{if } L<0.5 \\ L+S-(L \times S), & \mbox{if } L \ge 0.5 \end{cases}

temp1 = 2.0 \times L - temp2 \,

H_k = {H \over 360} \, (convert to the range [0,1])

temp3_R = H_k+\frac{1}{3} \,

temp3_G = H_k \,

temp3_B = H_k-\frac{1}{3} \,

\mbox{if } temp3_c < 0 \rightarrow temp3_c = temp3_c + 1.0 \quad \mbox{for each}\,c=R,G,B \,

\mbox{if } temp3_c > 1 \rightarrow temp3_c = temp3_c - 1.0 \quad \mbox{for each}\,c=R,G,B \,

For each color c = R,G,B:

\qquad color_c= \begin{cases} temp1+ \left((temp2-temp1) \times 6.0 \times temp3_c\right), & \mbox{if } temp3_c < \frac{1}{6}  \\ temp2, & \mbox{if } \frac{1}{6} \le temp3_c < \frac{1}{2}  \\ temp1+\left((temp2-temp1) \times (\frac{2}{3}-temp3_c) \times 6.0 \right), & \mbox{if } \frac{1}{2} \le temp3_c < \frac{2}{3} \\ temp1, & \mbox{otherwise } \end{cases}

[edit] 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).

In software, a hue-based color model (HSV or HSL) is usually presented to the user in the form of a linear or circular hue chooser and a two-dimensional area (usually a square or a triangle) where you can choose saturation and value/lightness for the selected hue. With this representation, the difference between HSV or HSL is irrelevant. However, many programs also let you select a color via linear sliders or numeric entry fields, and for those controls, usually either HSL or HSV (not both) are used. HSV is traditionally more common. Here are some examples:

  • Applications that use HSV (HSB):

[edit] 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)    

[edit] References

  1. ^ Foley, James D., Andries van Dam (1982). Fundamentals of Interactive Computer Graphics. Boston, MA, USA: Addison-Wesley. ISBN 0-201-14468-9.

[edit] External links


Static Wikipedia (no images)

aa - ab - af - ak - als - am - an - ang - ar - arc - as - ast - av - ay - az - ba - bar - bat_smg - bcl - be - be_x_old - bg - bh - bi - bm - bn - bo - bpy - br - bs - bug - bxr - ca - cbk_zam - cdo - ce - ceb - ch - cho - chr - chy - co - cr - crh - cs - csb - cu - cv - cy - da - de - diq - dsb - dv - dz - ee - el - eml - en - eo - es - et - eu - ext - fa - ff - fi - fiu_vro - fj - fo - fr - frp - fur - fy - ga - gan - gd - gl - glk - gn - got - gu - gv - ha - hak - haw - he - hi - hif - ho - hr - hsb - ht - hu - hy - hz - ia - id - ie - ig - ii - ik - ilo - io - is - it - iu - ja - jbo - jv - ka - kaa - kab - kg - ki - kj - kk - kl - km - kn - ko - kr - ks - ksh - ku - kv - kw - ky - la - lad - lb - lbe - lg - li - lij - lmo - ln - lo - lt - lv - map_bms - mdf - mg - mh - mi - mk - ml - mn - mo - mr - mt - mus - my - myv - mzn - na - nah - nap - nds - nds_nl - ne - new - ng - nl - nn - no - nov - nrm - nv - ny - oc - om - or - os - pa - pag - pam - pap - pdc - pi - pih - pl - pms - ps - pt - qu - quality - rm - rmy - rn - ro - roa_rup - roa_tara - ru - rw - sa - sah - sc - scn - sco - sd - se - sg - sh - si - simple - sk - sl - sm - sn - so - sr - srn - ss - st - stq - su - sv - sw - szl - ta - te - tet - tg - th - ti - tk - tl - tlh - tn - to - tpi - tr - ts - tt - tum - tw - ty - udm - ug - uk - ur - uz - ve - vec - vi - vls - vo - wa - war - wo - wuu - xal - xh - yi - yo - za - zea - zh - zh_classical - zh_min_nan - zh_yue - zu -

Static Wikipedia 2007 (no images)

aa - ab - af - ak - als - am - an - ang - ar - arc - as - ast - av - ay - az - ba - bar - bat_smg - bcl - be - be_x_old - bg - bh - bi - bm - bn - bo - bpy - br - bs - bug - bxr - ca - cbk_zam - cdo - ce - ceb - ch - cho - chr - chy - co - cr - crh - cs - csb - cu - cv - cy - da - de - diq - dsb - dv - dz - ee - el - eml - en - eo - es - et - eu - ext - fa - ff - fi - fiu_vro - fj - fo - fr - frp - fur - fy - ga - gan - gd - gl - glk - gn - got - gu - gv - ha - hak - haw - he - hi - hif - ho - hr - hsb - ht - hu - hy - hz - ia - id - ie - ig - ii - ik - ilo - io - is - it - iu - ja - jbo - jv - ka - kaa - kab - kg - ki - kj - kk - kl - km - kn - ko - kr - ks - ksh - ku - kv - kw - ky - la - lad - lb - lbe - lg - li - lij - lmo - ln - lo - lt - lv - map_bms - mdf - mg - mh - mi - mk - ml - mn - mo - mr - mt - mus - my - myv - mzn - na - nah - nap - nds - nds_nl - ne - new - ng - nl - nn - no - nov - nrm - nv - ny - oc - om - or - os - pa - pag - pam - pap - pdc - pi - pih - pl - pms - ps - pt - qu - quality - rm - rmy - rn - ro - roa_rup - roa_tara - ru - rw - sa - sah - sc - scn - sco - sd - se - sg - sh - si - simple - sk - sl - sm - sn - so - sr - srn - ss - st - stq - su - sv - sw - szl - ta - te - tet - tg - th - ti - tk - tl - tlh - tn - to - tpi - tr - ts - tt - tum - tw - ty - udm - ug - uk - ur - uz - ve - vec - vi - vls - vo - wa - war - wo - wuu - xal - xh - yi - yo - za - zea - zh - zh_classical - zh_min_nan - zh_yue - zu -

Static Wikipedia 2006 (no images)

aa - ab - af - ak - als - am - an - ang - ar - arc - as - ast - av - ay - az - ba - bar - bat_smg - bcl - be - be_x_old - bg - bh - bi - bm - bn - bo - bpy - br - bs - bug - bxr - ca - cbk_zam - cdo - ce - ceb - ch - cho - chr - chy - co - cr - crh - cs - csb - cu - cv - cy - da - de - diq - dsb - dv - dz - ee - el - eml - eo - es - et - eu - ext - fa - ff - fi - fiu_vro - fj - fo - fr - frp - fur - fy - ga - gan - gd - gl - glk - gn - got - gu - gv - ha - hak - haw - he - hi - hif - ho - hr - hsb - ht - hu - hy - hz - ia - id - ie - ig - ii - ik - ilo - io - is - it - iu - ja - jbo - jv - ka - kaa - kab - kg - ki - kj - kk - kl - km - kn - ko - kr - ks - ksh - ku - kv - kw - ky - la - lad - lb - lbe - lg - li - lij - lmo - ln - lo - lt - lv - map_bms - mdf - mg - mh - mi - mk - ml - mn - mo - mr - mt - mus - my - myv - mzn - na - nah - nap - nds - nds_nl - ne - new - ng - nl - nn - no - nov - nrm - nv - ny - oc - om - or - os - pa - pag - pam - pap - pdc - pi - pih - pl - pms - ps - pt - qu - quality - rm - rmy - rn - ro - roa_rup - roa_tara - ru - rw - sa - sah - sc - scn - sco - sd - se - sg - sh - si - simple - sk - sl - sm - sn - so - sr - srn - ss - st - stq - su - sv - sw - szl - ta - te - tet - tg - th - ti - tk - tl - tlh - tn - to - tpi - tr - ts - tt - tum - tw - ty - udm - ug - uk - ur - uz - ve - vec - vi - vls - vo - wa - war - wo - wuu - xal - xh - yi - yo - za - zea - zh - zh_classical - zh_min_nan - zh_yue - zu

Static Wikipedia February 2008 (no images)

aa - ab - af - ak - als - am - an - ang - ar - arc - as - ast - av - ay - az - ba - bar - bat_smg - bcl - be - be_x_old - bg - bh - bi - bm - bn - bo - bpy - br - bs - bug - bxr - ca - cbk_zam - cdo - ce - ceb - ch - cho - chr - chy - co - cr - crh - cs - csb - cu - cv - cy - da - de - diq - dsb - dv - dz - ee - el - eml - en - eo - es - et - eu - ext - fa - ff - fi - fiu_vro - fj - fo - fr - frp - fur - fy - ga - gan - gd - gl - glk - gn - got - gu - gv - ha - hak - haw - he - hi - hif - ho - hr - hsb - ht - hu - hy - hz - ia - id - ie - ig - ii - ik - ilo - io - is - it - iu - ja - jbo - jv - ka - kaa - kab - kg - ki - kj - kk - kl - km - kn - ko - kr - ks - ksh - ku - kv - kw - ky - la - lad - lb - lbe - lg - li - lij - lmo - ln - lo - lt - lv - map_bms - mdf - mg - mh - mi - mk - ml - mn - mo - mr - mt - mus - my - myv - mzn - na - nah - nap - nds - nds_nl - ne - new - ng - nl - nn - no - nov - nrm - nv - ny - oc - om - or - os - pa - pag - pam - pap - pdc - pi - pih - pl - pms - ps - pt - qu - quality - rm - rmy - rn - ro - roa_rup - roa_tara - ru - rw - sa - sah - sc - scn - sco - sd - se - sg - sh - si - simple - sk - sl - sm - sn - so - sr - srn - ss - st - stq - su - sv - sw - szl - ta - te - tet - tg - th - ti - tk - tl - tlh - tn - to - tpi - tr - ts - tt - tum - tw - ty - udm - ug - uk - ur - uz - ve - vec - vi - vls - vo - wa - war - wo - wuu - xal - xh - yi - yo - za - zea - zh - zh_classical - zh_min_nan - zh_yue - zu