The C++ interface for colorspace. More...

array colorspace (const array &image, const af_cspace_t to, const af_cspace_t from)

Detailed Description

The C++ interface for colorspace.

Convert an input image to to RGB, HSV or Grayscale format.

RGB (Red, Green, Blue) is the most common format used in computer imaging. RGB stores individual values for red, green and blue, and hence the 3 values per pixel. A combination of these three values produces the gamut of unique colors.

HSV (Hue, Saturation, Value), also known as HSB (hue, saturation, brightness), is often used by artists because it is more natural to think about a color in terms of hue and saturation than in terms of additive or subtractive color components (as in RGB). HSV is a transformation of an RGB colorspace, and its components and colorimetry are relative to the RGB colorspace from which it was derived. Like RGB, HSV also uses 3 values per pixel.

Grayscale is a single channel color space where 0 represents black and 1 (in normalized case) represents white.

YCbCr - Y′ is the luma component and CB and CR are the blue-difference and red-difference chroma components. Y′ (with prime) is distinguished from Y, which is luminance, meaning that light intensity is nonlinearly encoded based on gamma corrected RGB primaries.

You can read more about color spaces and sample images at: here.

Function Documentation

array af::colorspace ( const array &  image,
const af_cspace_t  to,
const af_cspace_t  from 
[in]imageinput image, dimensions {M,N,3} or {M, N}
[in]toDesired Colorspace format. Can be one of "af_rgb", "af_hsv", "af_gray", "af_ycrcb"
[in]fromCurrent Colorspace format. Can be one of "af_rgb", "af_hsv", "af_gray"
color converted image
For grayscale, colors are averaged using I = 0.2126 * R + 0.7152 * G + 0.0722 * B
For all 3 channel conversions, input range should be normalized [0-1]
For all 3 channel conversions, output range will be normalized [0-1]