Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Private Member Functions

DGtal::HueShadeColorMap< PValueType, DefaultCycles > Class Template Reference

Aim: This class template may be used to (linearly) convert scalar values in a given range into a color in a cyclic hue shade colormap, maybe aka rainbow color map. This color map is suitable, for example, to colorize distance functions. By default, only one hue cycle is used. More...

#include <HueShadeColorMap.h>

Public Types

typedef PValueType ValueType

Public Member Functions

 HueShadeColorMap (const PValueType &min, const PValueType &max, const unsigned int cycles=DefaultCycles)
LibBoard::Color operator() (const PValueType &value) const
 ~HueShadeColorMap ()
 HueShadeColorMap (const HueShadeColorMap &other)
HueShadeColorMapoperator= (const HueShadeColorMap &other)
void selfDisplay (std::ostream &out) const
bool isValid () const
const PValueType & min () const
const PValueType & max () const
void setCycles (int cycles)

Static Public Member Functions

static LibBoard::Color getColor (const unsigned int cycles, const PValueType &min, const PValueType &max, const PValueType &value)

Protected Member Functions

 HueShadeColorMap ()

Protected Attributes

PValueType myMin
PValueType myMax
unsigned int myCycles

Static Private Member Functions

static void HSVtoRGB (double &r, double &g, double &b, double h, const double s, const double v)

Detailed Description

template<typename PValueType, int DefaultCycles = 1>
class DGtal::HueShadeColorMap< PValueType, DefaultCycles >

Aim: This class template may be used to (linearly) convert scalar values in a given range into a color in a cyclic hue shade colormap, maybe aka rainbow color map. This color map is suitable, for example, to colorize distance functions. By default, only one hue cycle is used.

Description of template class 'HueShadeColorMap'

The HueShadeColorMap can be used either as a functor object (the value range is given at the object's construction) which converts a value into a LibBoard::Color structure, or it can be used through a static method taking both the range and the value as parameters.

The code below shows a possible use of this class.

 #include "Board/Color.h"
 #include "HueShadeColorMap.h"
 // ...
 {
   HueShadeColorMap<float>    hueShade(0.0f,1.0f);
   HueShadeColorMap<float,10> hueShadeBis(0.0f,1.0f);     // Ten cycles.
   HueShadeColorMap<float>    hueShadeTer(0.0f,1.0f,10);  // Idem.
   LibBoard::Color red = hueShade(1.0f);
   LibBoard::Color lightBlue1 = hueShade(0.5f);
   // Or, equivalently:
   LibBoard::Color lightBlue2 = HueShadeColorMap<float>::getColor(0.0f,1.0f,0.5f);
 }
Template Parameters:
PValueType The type of the range values.
DefaultCycles The default number of cycles (used as a default parameter by the constructor).
Examples:

distancetransform2D.cpp.


Member Typedef Documentation

template<typename PValueType, int DefaultCycles = 1>
typedef PValueType DGtal::HueShadeColorMap< PValueType, DefaultCycles >::ValueType

Constructor & Destructor Documentation

template<typename PValueType, int DefaultCycles = 1>
DGtal::HueShadeColorMap< PValueType, DefaultCycles >::HueShadeColorMap ( const PValueType &  min,
const PValueType &  max,
const unsigned int  cycles = DefaultCycles 
)

Constructor.

Parameters:
min The lower bound of the value range.
max The upper bound of the value range.
cycles The number of cycles in the colormap.
template<typename PValueType, int DefaultCycles = 1>
DGtal::HueShadeColorMap< PValueType, DefaultCycles >::~HueShadeColorMap (  ) 

Destructor.

template<typename PValueType, int DefaultCycles = 1>
DGtal::HueShadeColorMap< PValueType, DefaultCycles >::HueShadeColorMap ( const HueShadeColorMap< PValueType, DefaultCycles > &  other  ) 

Copy constructor.

Parameters:
other the object to clone.
template<typename PValueType, int DefaultCycles = 1>
DGtal::HueShadeColorMap< PValueType, DefaultCycles >::HueShadeColorMap (  )  [protected]

Constructor. Forbidden by default (protected to avoid g++ warnings).


Member Function Documentation

template<typename PValueType, int DefaultCycles = 1>
static LibBoard::Color DGtal::HueShadeColorMap< PValueType, DefaultCycles >::getColor ( const unsigned int  cycles,
const PValueType &  min,
const PValueType &  max,
const PValueType &  value 
) [static]

Computes the color associated with a value in a given range.

Parameters:
cycles The number of (rainbow) cycles.
min The lower bound of the value range.
max The upper bound of the value range.
value A value within the value range.
Returns:
A color whose hue linearly depends on the position of [value] within the range [min]..[max].
template<typename PValueType, int DefaultCycles = 1>
static void DGtal::HueShadeColorMap< PValueType, DefaultCycles >::HSVtoRGB ( double &  r,
double &  g,
double &  b,
double  h,
const double  s,
const double  v 
) [static, private]

Converts a color from the HSV (Hue,Saturation,Value) space to the RGB space.

Parameters:
r The red component (out).
g The green component (out).
b The blue component (out).
h The hue of the color in [0..360)
s The saturation of the color in [0..1].
v The value of the color in [0..1].
template<typename PValueType, int DefaultCycles = 1>
bool DGtal::HueShadeColorMap< PValueType, DefaultCycles >::isValid (  )  const

Checks the validity/consistency of the object.

Returns:
'true' if the object is valid, 'false' otherwise.
template<typename PValueType, int DefaultCycles = 1>
const PValueType& DGtal::HueShadeColorMap< PValueType, DefaultCycles >::max (  )  const

Returns the upper bound of the value range.

Returns:
The upper bound of the value range.
template<typename PValueType, int DefaultCycles = 1>
const PValueType& DGtal::HueShadeColorMap< PValueType, DefaultCycles >::min (  )  const

Returns the lower bound of the value range.

Returns:
The lower bound of the value range.
template<typename PValueType, int DefaultCycles = 1>
LibBoard::Color DGtal::HueShadeColorMap< PValueType, DefaultCycles >::operator() ( const PValueType &  value  )  const

Computes the color associated with a value in a given range.

Parameters:
value A value within the value range.
Returns:
A color whose hue linearly depends on the position of [value] within the current range.
template<typename PValueType, int DefaultCycles = 1>
HueShadeColorMap& DGtal::HueShadeColorMap< PValueType, DefaultCycles >::operator= ( const HueShadeColorMap< PValueType, DefaultCycles > &  other  ) 

Assignment.

Parameters:
other the object to copy.
Returns:
a reference on 'this'.
template<typename PValueType, int DefaultCycles = 1>
void DGtal::HueShadeColorMap< PValueType, DefaultCycles >::selfDisplay ( std::ostream &  out  )  const

Writes/Displays the object on an output stream.

Parameters:
out the output stream where the object is written.
template<typename PValueType, int DefaultCycles = 1>
void DGtal::HueShadeColorMap< PValueType, DefaultCycles >::setCycles ( int  cycles  ) 

Sets the number of cycles of hue shade.

Parameters:
cycles Number of cycles.

Field Documentation

template<typename PValueType, int DefaultCycles = 1>
unsigned int DGtal::HueShadeColorMap< PValueType, DefaultCycles >::myCycles [protected]

The number of cycles in the color map.

template<typename PValueType, int DefaultCycles = 1>
PValueType DGtal::HueShadeColorMap< PValueType, DefaultCycles >::myMax [protected]

The lower bound of the value range.

template<typename PValueType, int DefaultCycles = 1>
PValueType DGtal::HueShadeColorMap< PValueType, DefaultCycles >::myMin [protected]

The lower bound of the value range.


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