VBspeed /
Articles /
Color Models
|
VBspeed © 2000-10, updated: 19-Nov-2001 |
Color Models |
RGB vs HSB (aka HSL)
A remark by Branco Medeiros, 1999
'----------------------------------------------------------------------
' * The RGB color model represents colors as they are used in light
' emiting objects, such as the beams in a monitor. In this model,
' each light beam represents the Red, Green or Blue lights.
' RGB colors are called "Additive", that is, the frequencies
' of each light beam are combined to emit the final color.
' This way, as any beam value is incremented, the resulting color
' becomes lighter. The white color, for instance, is given by the
' maximum value of each beam (Red=255, Green=255, Blue=255), and
' black is given by the absence of light in each beam
' (Red=0, Green=0, Blue=0).
' Compare this with the "Subtractive" model (such us the one used
' in printing and painting and other real life objects that don't
' emit light): the light that touches a paint spot
' fires energy in specific frequencies, thus perceived by our
' eyes as a given color. The practical effect of this is that the
' color spot "absorbs" all colors but the one that we see.
' Take, for example, a blue object. We see it blue because it
' absorbs all light frequencies but the blue frequency (It's
' funny to think that actually a blue object is any color but blue).
' In the subtractive model, more quantities of "paint" means darker
' colors, while less quantities give us a lighter color.
'----------------------------------------------------------------------
' * The HSB color model is just a mathematical representation of
' color, in a way more similar to our color perception.
' For instance, the HSB model breaks the color into three
' components: The Hue (which would be the "pure" color), the
' percentage of Saturation ("how much" color) and the Brightness
' of the color (also a percentage). The Hue comes in the
' range of 0 to 360. The HSB model is also called HSL (L is for
' "Lightness") or HSV (V is for "Value" [!!]).
' This model comes in handy where the RGB model can't help, for
' instance, classifying similar colors, classifying colors by
' levels of darkness, sorting colors, etc.
'
'======================================================================
' Warning:
'======================================================================
' Because of the differences between the two color models,
' converting between RGB and HSB values is not a transitive
' operation, that is, given an RGB value converted to HSB, when
' converting back to RGB the result may be different from the
' original. And Vice-versa.
' This is "by design"... ;-))
Check Branco's site for more (incl. cool code): The HSB Color Model
Jump to RGBToHSL, HSLToRGB