CVR-Lib last update 20 Sep 2009

cvr::hueLUT Class Reference
[Color Analysis]

Following class provides a mono-state object that contains a 0.5MB Look-up Table to accelerate the computation of hues. More...

#include <cvrHueLUT.h>

Inheritance diagram for cvr::hueLUT:

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

Collaboration graph
[legend]

List of all members.

Public Member Functions

 hueLUT ()
float operator() (const int r, const int g) const
virtual const std::string & name () const
virtual hueLUTclone () const
virtual hueLUTnewInstance () const

Protected Types

typedef const float * cfloatptr_

Static Protected Member Functions

static void constructHueLUT ()

Static Protected Attributes

static const cfloatptr_hueLUT_


Detailed Description

Following class provides a mono-state object that contains a 0.5MB Look-up Table to accelerate the computation of hues.

The hue is defined in terms of the RGB components and rgb chromaticities as

\[ \begin{aligned} H &= \arccos\left(\frac{\frac{1}{2}\left[(R-G) + (R-B)\right]} {\sqrt{(R-G)^2+(R-B)(G-B))}}\right) \\ &= \arccos\left(\frac{\frac{1}{2}\left[(r-g) + (r-b)\right]} {\sqrt{(r-g)^2+(r-b)(g-b))}}\right) \\ &= \arccos\left[\frac{3r-1} {2\sqrt{3r^2+3g^2+3rg-3r-3g+1}}\right] \end{aligned} \]

where for the last equation it was used the fact that $ r=1-g-b $.

Note: This class normalizes the hue to be in the range [0,1] which is more practical for the CVR-Lib than the typical 0..360 degrees definition.

The LUT uses the fact that r+g+b=255 and thus only takes r and g as inputs, where r,g, and b are the chromaticity values obtained by normalization as r=R/(R+G+B), g=G/(R+G+B). These values need to be multiplied by 511, which is the last index the LUT takes. Note that r+g<512, and r,g >= 0

As a mono-state class, only one instance of the LUT array will be created.


Member Typedef Documentation

typedef const float* cvr::hueLUT::cfloatptr_ [protected]

Type required to create the LUT as a const structure.


Constructor & Destructor Documentation

cvr::hueLUT::hueLUT (  ) 

Construct the class Here, the LUT will be build just once (if not already done).

The first time you construct this class, it will take about 0.15 seconds to build the LUT.


Member Function Documentation

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

Returns a pointer to a clone of the parameters.

Implements cvr::object.

static void cvr::hueLUT::constructHueLUT (  )  [static, protected]

Construct a hue LUT.

It assumes that r,g>=0 and r+g<512. The 0.5MB memory required should not be a problem in modern PCs anymore!.

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

Returns the name of this class.

Implements cvr::object.

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

Returns a pointer to a clone of the parameters.

Implements cvr::object.

float cvr::hueLUT::operator() ( const int  r,
const int  g 
) const [inline]

return the hue for (r,g).

r,g >=0 and r+g<512

Parameters:
r red component
g green component
Returns:
hue between 0 and 1

References hueLUT_.


Member Data Documentation

const cfloatptr_* cvr::hueLUT::hueLUT_ [static, protected]

The hueLUT with floats.

Referenced by operator()().


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

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