[ VIGRA Homepage | Class Index | Function Index | File Index | Main Page ]
![]() |
Color Space Conversions | ![]() |
---|
Convert between RGB, R'G'B', XYZ, L*a*b*, L*u*v*, Y'PbPr, Y'CbCr, Y'IQ, and Y'UV color spaces.
#include "vigra/colorconversions.hxx"
Namespace: vigra
When you want to perform a color conversion, you must first know in which color space the data are given. Although this sounds trivial, it is quite often done wrong in practice, because the distinction between RGB and R'G'B' is frequently overlooked: nowadays, most images are stored in R'G'B' space, and treating them as RGB leads to wrong results. RGB and R'G'B' are related by a so called gamma correction:
(where usually
). In practice, you can distinguish the two kinds of red, green, and blue by displaying the images: if they look too dark, they are probably RGB, if they are OK, they are likely R'G'B'. (However, this may also be misleading: Some graphics cards and display programs silently apply a gamma correction to every image, so that RGB appears correct and R'G'B' is too bright.) The distinction between RGB and R'G'B' is important because some conversions start at RGB (XYZ, L*a*b*, L*u*v*), while others start at R'G'B' (Y'PbPr, Y'CbCr, Y'IQ, and Y'UV). The names of VIGRA's color conversion functors always make clear to which color space they must be applied.
In addition VIGRA provides a polar coordinate interface to several color spaces (L*a*b*, L*u*v*, Y'PbPr, Y'CbCr, Y'IQ, and Y'UV). This interface makes use of the fact that these color spaces are conceptually similar: they represent colors by a "brightness" coordinate (L* or Y') and a pair of "chromaticity" coordinates that span a plane of colors with equal brightness. The polar representation transforms chroma coordinates into a color "angle" (similar to hue in the HSV system) and a "saturation". The polar coordinates are normalized so that a color angle of 0 degrees is always associated with red (green is at about 120 degrees, blue at about 240 degrees - exact values differ between color spaces). A saturation of 1 is the highest saturation that any RGB color in the unit cube can have after transformation into the respective color space, and saturation 0 corresponds to gray. Polar coordinates provide a more intuitive interface to color specification by users and make different color spaces somewhat comparable.
© Ullrich Köthe (koethe@informatik.uni-hamburg.de) |
html generated using doxygen and Python
|