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

DGtal::GrayscaleColorMap< PValueType > Class Template Reference

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

#include <GrayScaleColorMap.h>

Public Types

typedef PValueType ValueType

Public Member Functions

 GrayscaleColorMap (const PValueType &min, const PValueType &max)
LibBoard::Color operator() (const PValueType &value) const
 ~GrayscaleColorMap ()
 GrayscaleColorMap (const GrayscaleColorMap &other)
GrayscaleColorMapoperator= (const GrayscaleColorMap &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 PValueType &min, const PValueType &max, const PValueType &value)

Protected Member Functions

 GrayscaleColorMap ()

Protected Attributes

PValueType myMin
PValueType myMax

Detailed Description

template<typename PValueType>
class DGtal::GrayscaleColorMap< PValueType >

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

Description of template class 'GrayscaleColorMap'

The GrayscaleColorMap 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 "GrayscaleColorMap.h"
 // ...
 {
   GrayscaleColorMap<float> grayShade(0.0f,1.0f);
   LibBoard::Color white = grayShade(1.0f);
   LibBoard::Color gray1 = grayShade(0.5f);
   // Or, equivalently:
   LibBoard::Color gray2 = GrayscaleColorMap<float>::getColor(0.0f,1.0f,0.5f);
 }
Template Parameters:
PValueType The type of the range values.
Examples:

distancetransform2D.cpp.


Member Typedef Documentation

template<typename PValueType>
typedef PValueType DGtal::GrayscaleColorMap< PValueType >::ValueType

Constructor & Destructor Documentation

template<typename PValueType>
DGtal::GrayscaleColorMap< PValueType >::GrayscaleColorMap ( const PValueType &  min,
const PValueType &  max 
)

Constructor.

Parameters:
min The lower bound of the value range.
max The upper bound of the value range.
template<typename PValueType>
DGtal::GrayscaleColorMap< PValueType >::~GrayscaleColorMap (  ) 

Destructor.

template<typename PValueType>
DGtal::GrayscaleColorMap< PValueType >::GrayscaleColorMap ( const GrayscaleColorMap< PValueType > &  other  ) 

Copy constructor.

Parameters:
other the object to clone.
template<typename PValueType>
DGtal::GrayscaleColorMap< PValueType >::GrayscaleColorMap (  )  [protected]

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


Member Function Documentation

template<typename PValueType>
static LibBoard::Color DGtal::GrayscaleColorMap< PValueType >::getColor ( const PValueType &  min,
const PValueType &  max,
const PValueType &  value 
) [static]

Computes the gray level associated with a value in a given range.

Parameters:
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 gray level (as a Color) which linearly depends on the position of [value] within the range [min]..[max].
template<typename PValueType>
bool DGtal::GrayscaleColorMap< PValueType >::isValid (  )  const

Checks the validity/consistency of the object.

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

Returns the upper bound of the value range.

Returns:
The upper bound of the value range.
template<typename PValueType>
const PValueType& DGtal::GrayscaleColorMap< PValueType >::min (  )  const

Returns the lower bound of the value range.

Returns:
The lower bound of the value range.
template<typename PValueType>
LibBoard::Color DGtal::GrayscaleColorMap< PValueType >::operator() ( const PValueType &  value  )  const

Computes the gray level associated with a value in a given range.

Parameters:
value A value within the value range.
Returns:
A gray level (as a Color) which linearly depends on the position of [value] within the current range.
template<typename PValueType>
GrayscaleColorMap& DGtal::GrayscaleColorMap< PValueType >::operator= ( const GrayscaleColorMap< PValueType > &  other  ) 

Assignment.

Parameters:
other the object to copy.
Returns:
a reference on 'this'.
template<typename PValueType>
void DGtal::GrayscaleColorMap< PValueType >::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>
PValueType DGtal::GrayscaleColorMap< PValueType >::myMax [protected]

The lower bound of the value range.

template<typename PValueType>
PValueType DGtal::GrayscaleColorMap< PValueType >::myMin [protected]

The lower bound of the value range.


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