DGtal  1.5.beta
DGtal::HueShadeColorMap< PValue, 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 <DGtal/io/colormaps/HueShadeColorMap.h>

Inheritance diagram for DGtal::HueShadeColorMap< PValue, DefaultCycles >:
[legend]

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
 

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);
}
static Color getColor(const unsigned int cycles, const PValue &min, const PValue &max, const PValue &value)
Template Parameters
PValueThe type of the range values.
DefaultCyclesThe default number of cycles (used as a default parameter by the constructor).

Definition at line 90 of file HueShadeColorMap.h.

Member Typedef Documentation

◆ Value

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

Definition at line 95 of file HueShadeColorMap.h.

Constructor & Destructor Documentation

◆ HueShadeColorMap() [1/3]

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.

◆ ~HueShadeColorMap()

template<typename PValue , int DefaultCycles = 1>
DGtal::HueShadeColorMap< PValue, DefaultCycles >::~HueShadeColorMap ( )

Destructor.

◆ HueShadeColorMap() [2/3]

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

Copy constructor.

Parameters
otherthe object to clone.

◆ HueShadeColorMap() [3/3]

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

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

Member Function Documentation

◆ getColor()

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].

◆ isValid()

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.

◆ max()

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.

◆ min()

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.

◆ operator()()

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.

◆ operator=()

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'.

◆ selfDisplay()

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.

◆ setCycles()

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

◆ myCycles

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.

◆ myMax

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.

◆ myMin

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: