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

DGtal::ColorBrightnessColorMap< PValueType, PDefaultColor > Class Template Reference

Aim: This class template may be used to (linearly) convert scalar values in a given range into a color with given lightness. More...

#include <ColorBrightnessColorMap.h>

Collaboration diagram for DGtal::ColorBrightnessColorMap< PValueType, PDefaultColor >:
Collaboration graph
[legend]

Public Types

typedef PValueType ValueType

Public Member Functions

 ColorBrightnessColorMap (const PValueType &min, const PValueType &max, const LibBoard::Color color=LibBoard::Color(DGTAL_RED_COMPONENT(PDefaultColor), DGTAL_GREEN_COMPONENT(PDefaultColor), DGTAL_BLUE_COMPONENT(PDefaultColor)))
LibBoard::Color operator() (const PValueType &value) const
 ~ColorBrightnessColorMap ()
 ColorBrightnessColorMap (const ColorBrightnessColorMap &other)
ColorBrightnessColorMapoperator= (const ColorBrightnessColorMap &other)
void selfDisplay (std::ostream &out) const
bool isValid () const
const PValueType & min () const
const PValueType & max () const

Static Public Member Functions

static LibBoard::Color getColor (const LibBoard::Color color, const PValueType &min, const PValueType &max, const PValueType &value)

Protected Member Functions

 ColorBrightnessColorMap ()

Protected Attributes

PValueType myMin
PValueType myMax
LibBoard::Color myColor

Static Private Member Functions

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

Detailed Description

template<typename PValueType, int PDefaultColor = DGTAL_RGB2INT( 255, 255, 255 )>
class DGtal::ColorBrightnessColorMap< PValueType, PDefaultColor >

Aim: This class template may be used to (linearly) convert scalar values in a given range into a color with given lightness.

Description of template class 'ColorBrightnessColorMap'

The ColorBrightnessColorMap can be used either as a functor object (the value range is given at the object's construction, together with the reference color) 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 "ColorBrightnessColorMap.h"
 // ...
 {
   ColorBrightnessColorMap<float> blueShade(0.0f,1.0f,LibBoard::Color::Blue);
   LibBoard::Color red = blueShade(1.0f);
   LibBoard::Color blue1 = blueShade(0.5f);
   // Or, equivalently:
   LibBoard::Color blue2 = ColorBrightnessColorMap<float>::getColor(LibBoard::Color::Blue,0.0f,1.0f,0.5f);
 }
Template Parameters:
PValueType The type of the range values.
PDefaultColor The default color as an integer built using the DGTAL_RGB2INT macro.

Member Typedef Documentation

template<typename PValueType, int PDefaultColor = DGTAL_RGB2INT( 255, 255, 255 )>
typedef PValueType DGtal::ColorBrightnessColorMap< PValueType, PDefaultColor >::ValueType

Constructor & Destructor Documentation

template<typename PValueType, int PDefaultColor = DGTAL_RGB2INT( 255, 255, 255 )>
DGtal::ColorBrightnessColorMap< PValueType, PDefaultColor >::ColorBrightnessColorMap ( const PValueType &  min,
const PValueType &  max,
const LibBoard::Color  color = LibBoard::Color(DGTAL_RED_COMPONENT(PDefaultColor), DGTAL_GREEN_COMPONENT(PDefaultColor), DGTAL_BLUE_COMPONENT(PDefaultColor)) 
)

Constructor.

Parameters:
min The lower bound of the value range.
max The upper bound of the value range.
template<typename PValueType, int PDefaultColor = DGTAL_RGB2INT( 255, 255, 255 )>
DGtal::ColorBrightnessColorMap< PValueType, PDefaultColor >::~ColorBrightnessColorMap (  ) 

Destructor.

template<typename PValueType, int PDefaultColor = DGTAL_RGB2INT( 255, 255, 255 )>
DGtal::ColorBrightnessColorMap< PValueType, PDefaultColor >::ColorBrightnessColorMap ( const ColorBrightnessColorMap< PValueType, PDefaultColor > &  other  ) 

Copy constructor.

Parameters:
other the object to clone.
template<typename PValueType, int PDefaultColor = DGTAL_RGB2INT( 255, 255, 255 )>
DGtal::ColorBrightnessColorMap< PValueType, PDefaultColor >::ColorBrightnessColorMap (  )  [protected]

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


Member Function Documentation

template<typename PValueType, int PDefaultColor = DGTAL_RGB2INT( 255, 255, 255 )>
static LibBoard::Color DGtal::ColorBrightnessColorMap< PValueType, PDefaultColor >::getColor ( const LibBoard::Color  color,
const PValueType &  min,
const PValueType &  max,
const PValueType &  value 
) [static]

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

Parameters:
color The color associated with the upper bound.
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 brightness linearly depends on the position of [value] within the range [min]..[max].
template<typename PValueType, int PDefaultColor = DGTAL_RGB2INT( 255, 255, 255 )>
static void DGtal::ColorBrightnessColorMap< PValueType, PDefaultColor >::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 PDefaultColor = DGTAL_RGB2INT( 255, 255, 255 )>
bool DGtal::ColorBrightnessColorMap< PValueType, PDefaultColor >::isValid (  )  const

Checks the validity/consistency of the object.

Returns:
'true' if the object is valid, 'false' otherwise.
template<typename PValueType, int PDefaultColor = DGTAL_RGB2INT( 255, 255, 255 )>
const PValueType& DGtal::ColorBrightnessColorMap< PValueType, PDefaultColor >::max (  )  const

Returns the upper bound of the value range.

Returns:
The upper bound of the value range.
template<typename PValueType, int PDefaultColor = DGTAL_RGB2INT( 255, 255, 255 )>
const PValueType& DGtal::ColorBrightnessColorMap< PValueType, PDefaultColor >::min (  )  const

Returns the lower bound of the value range.

Returns:
The lower bound of the value range.
template<typename PValueType, int PDefaultColor = DGTAL_RGB2INT( 255, 255, 255 )>
LibBoard::Color DGtal::ColorBrightnessColorMap< PValueType, PDefaultColor >::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 brightness linearly depends on the position of [value] within the current range.
template<typename PValueType, int PDefaultColor = DGTAL_RGB2INT( 255, 255, 255 )>
ColorBrightnessColorMap& DGtal::ColorBrightnessColorMap< PValueType, PDefaultColor >::operator= ( const ColorBrightnessColorMap< PValueType, PDefaultColor > &  other  ) 

Assignment.

Parameters:
other the object to copy.
Returns:
a reference on 'this'.
template<typename PValueType, int PDefaultColor = DGTAL_RGB2INT( 255, 255, 255 )>
static void DGtal::ColorBrightnessColorMap< PValueType, PDefaultColor >::RGBtoHSV ( double &  h,
double &  s,
double &  v,
const unsigned char  r,
const unsigned char  g,
const unsigned char  b 
) [static, private]

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

Parameters:
h (out) The hue of the color in [0..360)
s (out) The saturation of the color in [0..1].
v (out) The value of the color in [0..1].
r The red component.
g The green component.
b The blue component.
template<typename PValueType, int PDefaultColor = DGTAL_RGB2INT( 255, 255, 255 )>
void DGtal::ColorBrightnessColorMap< PValueType, PDefaultColor >::selfDisplay ( std::ostream &  out  )  const

Writes/Displays the object on an output stream.

Parameters:
out the output stream where the object is written.

Field Documentation

template<typename PValueType, int PDefaultColor = DGTAL_RGB2INT( 255, 255, 255 )>
LibBoard::Color DGtal::ColorBrightnessColorMap< PValueType, PDefaultColor >::myColor [protected]

The color of the upper bound value.

template<typename PValueType, int PDefaultColor = DGTAL_RGB2INT( 255, 255, 255 )>
PValueType DGtal::ColorBrightnessColorMap< PValueType, PDefaultColor >::myMax [protected]

The lower bound of the value range.

template<typename PValueType, int PDefaultColor = DGTAL_RGB2INT( 255, 255, 255 )>
PValueType DGtal::ColorBrightnessColorMap< PValueType, PDefaultColor >::myMin [protected]

The lower bound of the value range.


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