CVR-Lib last update 20 Sep 2009

cvr::mergeYCbCrToImage Class Reference
[Color Analysis]

Creates RGB values from given YCbCr values by merging float or ubyte values to an rgbPixel, merging channels(floats) or channel8s(ubytes) to an Image. More...

#include <cvrMergeYCbCrToImage.h>

Inheritance diagram for cvr::mergeYCbCrToImage:

Inheritance graph
[legend]
Collaboration diagram for cvr::mergeYCbCrToImage:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 mergeYCbCrToImage (void)
 ~mergeYCbCrToImage ()
const std::string & name () const
mergeYCbCrToImagecopy (const mergeYCbCrToImage &other)
mergeYCbCrToImageoperator= (const mergeYCbCrToImage &other)
virtual mergeYCbCrToImageclone () const
virtual mergeYCbCrToImagenewInstance () const
virtual bool apply (const matrix< float > &Y, const matrix< float > &Cb, const matrix< float > &Cr, image &img) const
virtual bool apply (const matrix< ubyte > &Y, const matrix< ubyte > &Cb, const matrix< ubyte > &Cr, image &img) const
virtual bool apply (const float &Y, const float &Cb, const float &Cr, rgbaPixel &pixel) const
virtual bool apply (const ubyte &Y, const ubyte &Cb, const ubyte &Cr, rgbaPixel &pixel) const

Protected Member Functions

virtual void initializeLUTs ()
ubyte clip (const int val) const

Static Protected Attributes

static const int * lutY_
static const int * lutVr_
static const int * lutUg_
static const int * lutVg_
static const int * lutUb_


Detailed Description

Creates RGB values from given YCbCr values by merging float or ubyte values to an rgbPixel, merging channels(floats) or channel8s(ubytes) to an Image.

In the literature, technical and scientific, there is often confusion among the color spaces YUV, YCbCr and YPbPr. Poynton in http://www.poynton.com/notes/colour_and_gamma/ColorFAQ.html explains that YUV is usually never correctly meant, because the color space normally used for component digital video is the YCbCr (ITU-RS601 or CCIR-601). Other devices use the YPbPr, but the "real" YUV is rarely employed.

The CVR-Lib provides all three spaces:

Here, the inverse transformation of cvr::splitImageToYCbCr is followed:

\[ \begin{bmatrix} R \\ G \\ B \end{bmatrix} = M^{-1} \left( \begin{bmatrix} Y \\ Cb \\ Cr \end{bmatrix} - \begin{bmatrix} 16 \\ 128 \\ 128 \end{bmatrix} \right) \]

where M is the matrix given in cvr::splitImageToYCbCr.

If you know you have a YCbCr space but it was given to you as YUV, then the equivalences are U=Cb and V=Cr.

A way of noticing if you have a YCbCr color space is determining the range of the values of each channel. Y should be in [16,235], while Cr and Cb should be in [16,240]. If you channel Y has values in [0,255] then you should use mergeYPbPrToImage instead.


Constructor & Destructor Documentation

cvr::mergeYCbCrToImage::mergeYCbCrToImage ( void   ) 

Constructor.

cvr::mergeYCbCrToImage::~mergeYCbCrToImage (  ) 

Destructor.


Member Function Documentation

virtual bool cvr::mergeYCbCrToImage::apply ( const ubyte Y,
const ubyte Cb,
const ubyte Cr,
rgbaPixel pixel 
) const [inline, virtual]

Merge the 8-bit-values Y, U and V to a pixel.

Parameters:
Y the Y value, i.e. black&white
Cb the Cb value, chromatic
Cr the Cr value, chromatic
pixel the merged pixel

Implements cvr::mergeImage.

virtual bool cvr::mergeYCbCrToImage::apply ( const float &  Y,
const float &  Cb,
const float &  Cr,
rgbaPixel pixel 
) const [inline, virtual]

Merge the values Y, Cr and Cb to a pixel.

Parameters:
Y the Y value, i.e. black&white
Cb the Cb value, chromatic
Cr the Cr value, chromatic
pixel the merged pixel

Implements cvr::mergeImage.

virtual bool cvr::mergeYCbCrToImage::apply ( const matrix< ubyte > &  Y,
const matrix< ubyte > &  Cb,
const matrix< ubyte > &  Cr,
image img 
) const [virtual]

Merge 8-bit-channels Y, U, V to an image.

Parameters:
Y the Y channel, i.e. black&white
Cb the Cb channel, chromatic
Cr the Cr channel, chromatic
img the image to be splitted

Implements cvr::mergeImage.

virtual bool cvr::mergeYCbCrToImage::apply ( const matrix< float > &  Y,
const matrix< float > &  Cb,
const matrix< float > &  Cr,
image img 
) const [virtual]

Merge channels Y, Cr, Cb to an image.

Parameters:
Y the Y channel, i.e. black&white
Cb the Cb channel, chromatic
Cr the Cr channel, chromatic
img the image to be splitted

Implements cvr::mergeImage.

ubyte cvr::mergeYCbCrToImage::clip ( const int  val  )  const [inline, protected]

Clip function.

Equivalent to min(255,max(0,val)) but maybe faster

virtual mergeYCbCrToImage* cvr::mergeYCbCrToImage::clone (  )  const [virtual]

Returns a pointer to a clone of the functor.

Implements cvr::mergeImage.

mergeYCbCrToImage& cvr::mergeYCbCrToImage::copy ( const mergeYCbCrToImage other  ) 

Copy data of "other" functor.

Parameters:
other the functor to be copied
Returns:
a reference to this functor object

virtual void cvr::mergeYCbCrToImage::initializeLUTs (  )  [protected, virtual]

Initialize the Look-Up-Tables.

const std::string& cvr::mergeYCbCrToImage::name (  )  const [virtual]

Return the name of this type.

Implements cvr::functor.

virtual mergeYCbCrToImage* cvr::mergeYCbCrToImage::newInstance (  )  const [virtual]

Returns a pointer to a new instance of this functor.

Implements cvr::mergeImage.

mergeYCbCrToImage& cvr::mergeYCbCrToImage::operator= ( const mergeYCbCrToImage other  ) 

Alias for copy method.

Parameters:
other the functor to be copied
Returns:
a reference to this functor object


Member Data Documentation

const int* cvr::mergeYCbCrToImage::lutUb_ [static, protected]

Partial results with Cb (equivalent to U) for the blue channel computation.

const int* cvr::mergeYCbCrToImage::lutUg_ [static, protected]

Partial results with Cb (equivalent to U) for the green channel computation.

const int* cvr::mergeYCbCrToImage::lutVg_ [static, protected]

Partial results with Cr (equivalent to V) for the green channel computation.

const int* cvr::mergeYCbCrToImage::lutVr_ [static, protected]

Partial results with Cr (equivalent to V) for the red channel computation.

const int* cvr::mergeYCbCrToImage::lutY_ [static, protected]

Look up tables to accelerate conversion YUV -> RGB.

Partial Y results


The documentation for this class was generated from the following file:

Generated on Sun Sep 20 22:08:51 2009 for CVR-Lib by Doxygen 1.5.8