last update 20 Sep 2009 |
#include <cvrMergeYCbCrToImage.h>
Public Member Functions | |
mergeYCbCrToImage (void) | |
~mergeYCbCrToImage () | |
const std::string & | name () const |
mergeYCbCrToImage & | copy (const mergeYCbCrToImage &other) |
mergeYCbCrToImage & | operator= (const mergeYCbCrToImage &other) |
virtual mergeYCbCrToImage * | clone () const |
virtual mergeYCbCrToImage * | newInstance () 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_ |
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:
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.
cvr::mergeYCbCrToImage::mergeYCbCrToImage | ( | void | ) |
Constructor.
cvr::mergeYCbCrToImage::~mergeYCbCrToImage | ( | ) |
Destructor.
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.
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.
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.
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] |
mergeYCbCrToImage& cvr::mergeYCbCrToImage::copy | ( | const mergeYCbCrToImage & | other | ) |
virtual void cvr::mergeYCbCrToImage::initializeLUTs | ( | ) | [protected, virtual] |
Initialize the Look-Up-Tables.
const std::string& cvr::mergeYCbCrToImage::name | ( | ) | const [virtual] |
virtual mergeYCbCrToImage* cvr::mergeYCbCrToImage::newInstance | ( | ) | const [virtual] |
mergeYCbCrToImage& cvr::mergeYCbCrToImage::operator= | ( | const mergeYCbCrToImage & | other | ) |
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