CVR-Lib last update 20 Sep 2009

cvr::splitImageToYUV Class Reference
[Color Analysis]

Computes the YUV values from a given RGB color representation (rgbaPixel). More...

#include <cvrSplitImageToYUV.h>

Inheritance diagram for cvr::splitImageToYUV:

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

Collaboration graph
[legend]

List of all members.

Public Member Functions

 splitImageToYUV ()
 splitImageToYUV (const splitImageToYUV &other)
virtual ~splitImageToYUV ()
const std::string & name () const
splitImageToYUVcopy (const splitImageToYUV &other)
splitImageToYUVoperator= (const splitImageToYUV &other)
virtual splitImageToYUVclone () const
virtual splitImageToYUVnewInstance () const
virtual bool apply (const rgbaPixel &pixel, float &c1, float &c2, float &c3) const
virtual bool apply (const rgbaPixel &pixel, ubyte &c1, ubyte &c2, ubyte &c3) const
virtual bool apply (const matrix< rgbaPixel > &img, matrix< float > &c1, matrix< float > &c2, matrix< float > &c3) const
virtual bool apply (const matrix< rgbaPixel > &img, matrix< ubyte > &c1, matrix< ubyte > &c2, matrix< ubyte > &c3) const


Detailed Description

Computes the YUV values from a given RGB color representation (rgbaPixel).

In the literature, technical and scientific, there is a confusion between the color spaces YUV, YCrCb 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 YCrCb (ITU-RS601 or CCIR-601). Other devices use the YPbPr, but the "real" YUV is usually not employed.

The CVR-Lib provides all three spaces:

This functor splits an RGB images into the color space YUV as described in the Poynton reference given above.

\[ \begin{bmatrix} Y \\ U \\ V \end{bmatrix} = \begin{bmatrix} 0.299 & 0.587 & 0.114 \\ -0.147141189 & -0.288869157 & 0.436010346 \\ 0.614975383 & -0.514965121 & -0.100010262 \end{bmatrix} \begin{bmatrix} R \\ G \\ B \end{bmatrix} \]

Here, RGB are values in the intervall [0,1]. Within this range, the excursion for Y is also from 0.0 to 1.0, the excursion of U is from -0.436 to 0.436 and V varies from -0.615 to 0.615. These ranges are respected in the implentation for float types (cvr::channel).

If you use ubyte (cvr::matrix<ubyte>), then the values for U and V are linearly mapped from 0 to 1, which results in the mapping

 Y =  0.299*R + 0.587*G + 0.114*B
 U = -0.169*R - 0.331*G + 0.500*B + 128.0
 V =  0.500*R - 0.419*G - 0.081*B + 128.0

The former mapping is equivalent to the color space YPbPr scaled in such a way that "black" is mapped to Y=0 and "white" to Y=255, and the Pb and Pr channels, which acquire values from -0.5 to 0.5, are linearly mapped to the inteval [0,255] as well. In other words, for ubyte operations it is equivalent to use this functor or cvr::splitImageToYPbPr (which is maybe better named as the value ratios are at least kept there).


Constructor & Destructor Documentation

cvr::splitImageToYUV::splitImageToYUV (  ) 

default constructor

cvr::splitImageToYUV::splitImageToYUV ( const splitImageToYUV other  ) 

copy constructor

Parameters:
other the object to be copied

virtual cvr::splitImageToYUV::~splitImageToYUV (  )  [virtual]

destructor


Member Function Documentation

virtual bool cvr::splitImageToYUV::apply ( const matrix< rgbaPixel > &  img,
matrix< ubyte > &  c1,
matrix< ubyte > &  c2,
matrix< ubyte > &  c3 
) const [virtual]

Split image into 8-bit channels.

N.B.: when casting the transformation result to unsigned shorts (8-bit channel) major rounding errors will occur.

As a result, the merging operation might produce negative values or values > 1, which are truncated subsequently. When accurate Y, U and V values are required, prefer float values.

virtual bool cvr::splitImageToYUV::apply ( const matrix< rgbaPixel > &  img,
matrix< float > &  c1,
matrix< float > &  c2,
matrix< float > &  c3 
) const [virtual]

split pixel into float channels

virtual bool cvr::splitImageToYUV::apply ( const rgbaPixel pixel,
ubyte c1,
ubyte c2,
ubyte c3 
) const [inline, virtual]

Split pixel into 8-bit values (between 0 and 255).

N.B.: when casting the transformation result to unsigned shorts (8-bit channel) major rounding errors will occur.

As a result, the merging operation might produce negative values or values > 1, which are truncated subsequently.

When accurate Y, U and V values are required, prefer float values

Implements cvr::splitImage.

virtual bool cvr::splitImageToYUV::apply ( const rgbaPixel pixel,
float &  c1,
float &  c2,
float &  c3 
) const [inline, virtual]

split pixel into float values (between 0 and 1)

Implements cvr::splitImage.

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

returns a pointer to a clone of this functor.

Implements cvr::splitImage.

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

copy data of "other" functor.

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

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

returns the name of this type ("splitImageToYUV")

Implements cvr::functor.

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

Returns a pointer to a new instance of this functor.

Implements cvr::splitImage.

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

alias for copy member

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


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

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