DGtal  0.9.4beta
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Private Member Functions
DGtal::HueShadeColorMap< PValue, DefaultCycles > Class Template Reference

#include <DGtal/io/colormaps/HueShadeColorMap.h>

Public Types

typedef PValue Value
 

Public Member Functions

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

Static Public Member Functions

static Color getColor (const unsigned int cycles, const PValue &min, const PValue &max, const PValue &value)
 

Protected Member Functions

 HueShadeColorMap ()
 

Protected Attributes

PValue myMin
 
PValue 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 PValue, int DefaultCycles = 1>
class DGtal::HueShadeColorMap< PValue, 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 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 "DGtal/io/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.
Color red = hueShade(1.0f);
Color lightBlue1 = hueShade(0.5f);
// Or, equivalently:
Color lightBlue2 = HueShadeColorMap<float>::getColor(0.0f,1.0f,0.5f);
}
Template Parameters
PValueThe type of the range values.
DefaultCyclesThe default number of cycles (used as a default parameter by the constructor).
Examples:
geometry/volumes/distance/distancetransform2D.cpp, geometry/volumes/distance/exampleFMM2D.cpp, geometry/volumes/distance/toricdomainvolumetric.cpp, geometry/volumes/distance/voronoimap2D.cpp, graph/graphTraversal.cpp, graph/volDistanceTraversal.cpp, images/exampleConstImageAdapter.cpp, images/exampleTiledImage.cpp, io/viewers/viewer3D-9-3Dimages.cpp, and topology/volBreadthFirstTraversal.cpp.

Definition at line 90 of file HueShadeColorMap.h.

Member Typedef Documentation

template<typename PValue, int DefaultCycles = 1>
typedef PValue DGtal::HueShadeColorMap< PValue, DefaultCycles >::Value

Definition at line 95 of file HueShadeColorMap.h.

Constructor & Destructor Documentation

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

Constructor.

Parameters
minThe lower bound of the value range.
maxThe upper bound of the value range.
cyclesThe number of cycles in the colormap.
template<typename PValue, int DefaultCycles = 1>
DGtal::HueShadeColorMap< PValue, DefaultCycles >::~HueShadeColorMap ( )

Destructor.

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

Copy constructor.

Parameters
otherthe object to clone.
template<typename PValue, int DefaultCycles = 1>
DGtal::HueShadeColorMap< PValue, DefaultCycles >::HueShadeColorMap ( )
protected

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

Member Function Documentation

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

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

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

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

Parameters
rThe red component (out).
gThe green component (out).
bThe blue component (out).
hThe hue of the color in [0..360)
sThe saturation of the color in [0..1].
vThe value of the color in [0..1].
template<typename PValue, int DefaultCycles = 1>
bool DGtal::HueShadeColorMap< PValue, DefaultCycles >::isValid ( ) const

Checks the validity/consistency of the object.

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

Returns the upper bound of the value range.

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

Returns the lower bound of the value range.

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

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

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

Assignment.

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

Writes/Displays the object on an output stream.

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

Sets the number of cycles of hue shade.

Parameters
cyclesNumber of cycles.

Field Documentation

template<typename PValue, int DefaultCycles = 1>
unsigned int DGtal::HueShadeColorMap< PValue, DefaultCycles >::myCycles
protected

The number of cycles in the color map.

Definition at line 204 of file HueShadeColorMap.h.

template<typename PValue, int DefaultCycles = 1>
PValue DGtal::HueShadeColorMap< PValue, DefaultCycles >::myMax
protected

The lower bound of the value range.

Definition at line 203 of file HueShadeColorMap.h.

template<typename PValue, int DefaultCycles = 1>
PValue DGtal::HueShadeColorMap< PValue, DefaultCycles >::myMin
protected

The lower bound of the value range.

Definition at line 202 of file HueShadeColorMap.h.


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