RGB to Grayscale colorspace converter. More...

Functions

AFAPI array rgb2gray (const array &in, const float rPercent=0.2126f, const float gPercent=0.7152f, const float bPercent=0.0722f)
 C++ Interface for RGB to gray conversion. More...
 
AFAPI af_err af_rgb2gray (af_array *out, const af_array in, const float rPercent, const float gPercent, const float bPercent)
 C Interface for converting RGB to gray. More...
 

Detailed Description

RGB to Grayscale colorspace converter.

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.

Grayscale is a single channel color space where pixel value ranges from 0 to 1. Zero represents black, one represent white and any value between zero & one is a gray value

The grayscale internsity of a pixel is calculated using the following formula:

\(gray = R*rPercent + G*gPercent + B*bPercent\)


Function Documentation

AFAPI af_err af_rgb2gray ( af_array out,
const af_array  in,
const float  rPercent,
const float  gPercent,
const float  bPercent 
)

C Interface for converting RGB to gray.

Parameters
[out]outis an array in target color space
[in]inis an array in the RGB color space
[in]rPercentis percentage of red channel value contributing to grayscale intensity
[in]gPercentis percentage of green channel value contributing to grayscale intensity
[in]bPercentis percentage of blue channel value contributing to grayscale intensity
Returns
AF_SUCCESS if the color transformation is successful, otherwise an appropriate error code is returned.
Note
in must be three dimensional for RGB to Grayscale conversion.
AFAPI array af::rgb2gray ( const array in,
const float  rPercent = 0.2126f,
const float  gPercent = 0.7152f,
const float  bPercent = 0.0722f 
)

C++ Interface for RGB to gray conversion.

Parameters
[in]inis an array in the RGB colorspace
[in]rPercentis percentage of red channel value contributing to grayscale intensity
[in]gPercentis percentage of green channel value contributing to grayscale intensity
[in]bPercentis percentage of blue channel value contributing to grayscale intensity
Returns
array in Grayscale colorspace
Note
in must be three dimensional for RGB to Grayscale conversion.