[ 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

- RGB/R'G'B'
  linear and non-linear (gamma corrected) additive color

  vigra::RGB2RGBPrimeFunctor
  vigra::RGBPrime2RGBFunctor

- XYZ
  device independent color representation (according to Publication CIE No 15.2 "Colorimetry" and ITU-R Recommendation BT.709)

  vigra::RGB2XYZFunctor
  vigra::RGBPrime2XYZFunctor
  vigra::XYZ2RGBFunctor
  vigra::XYZ2RGBPrimeFunctor

- L*a*b*
  perceptually uniform color representation (according to Publication CIE No 15.2 "Colorimetry" and ITU-R Recommendation BT.709)

  vigra::RGB2LabFunctor
  vigra::RGBPrime2LabFunctor
  vigra::XYZ2LabFunctor
  vigra::Lab2RGBFunctor
  vigra::Lab2RGBPrimeFunctor
  vigra::Lab2XYZFunctor
  vigra::polar2Lab()
  vigra::lab2Polar()

- L*u*v*
  perceptually uniform color representation (according to Publication CIE No 15.2 "Colorimetry" and ITU-R Recommendation BT.709)

  vigra::RGB2LuvFunctor
  vigra::RGBPrime2LuvFunctor
  vigra::XYZ2LuvFunctor
  vigra::Luv2RGBFunctor
  vigra::Luv2RGBPrimeFunctor
  vigra::Luv2XYZFunctor
  vigra::polar2Luv()
  vigra::luv2Polar()

- Y'PbPr and Y'CbCr
  color difference coding (according to ITU-R Recommendation BT. 601)

  vigra::RGBPrime2YPrimePbPrFunctor
  vigra::YPrimePbPr2RGBPrimeFunctor
  vigra::polar2YPrimePbPr()
  vigra::yPrimePbPr2Polar()
  vigra::RGBPrime2YPrimeCbCrFunctor
  vigra::YPrimeCbCr2RGBPrimeFunctor
  vigra::polar2YPrimeCbCr()
  vigra::yPrimeCbCr2Polar()

- Y'UV and Y'IQ
  analog video coding according to NTSC and PAL standards

  vigra::RGBPrime2YPrimeUVFunctor
  vigra::YPrimeUV2RGBPrimeFunctor
  vigra::polar2YPrimeUV()
  vigra::yPrimeUV2Polar()
  vigra::RGBPrime2YPrimeIQFunctor
  vigra::YPrimeIQ2RGBPrimeFunctor
  vigra::polar2YPrimeIQ()
  vigra::yPrimeIQ2Polar()

This module provides conversion from RGB/R'G'B' into more perceptually uniform color spaces. In image analysis, colors are usually converted into another color space in order to get good estimates of perceived color differences by just calculating Euclidean distances between the transformed colors. The L*a*b* and L*u*v* were designed with exactly this application in mind and thus give the best results. But these conversions are also the most computationally demanding. The Y'PbPr color difference space (designed for the coding of digital video) is computationally much cheaper, and almost as good. Y'CbCr represents esentially the same transformation, but the color values are scaled so that they can be stored with 8 bits per channel with minimal loss of information. The other transformations are of lesser interest here: XYZ is a device independent (but not perceptually uniform) color representation, and Y'IQ and Y'UV are the color spaces used by the PAL and NTSC analog video standards. Detailed information about these color spaces and their transformations can be found in Charles Poynton's Color FAQ

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) Cognitive Systems Group, University of Hamburg, Germany | html generated using doxygen and Python VIGRA 1.4.0 (21 Dec 2005)