DGtal  1.0.beta
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes
DGtal::GrayscaleColorMap< PValue > Class Template Reference

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

Public Types

typedef PValue Value
 

Public Member Functions

 GrayscaleColorMap (const PValue &min, const PValue &max)
 
Color operator() (const PValue &value) const
 
 ~GrayscaleColorMap ()
 
 GrayscaleColorMap (const GrayscaleColorMap &other)
 
GrayscaleColorMapoperator= (const GrayscaleColorMap &other)
 
void selfDisplay (std::ostream &out) const
 
bool isValid () const
 
const PValue & min () const
 
const PValue & max () const
 

Static Public Member Functions

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

Protected Member Functions

 GrayscaleColorMap ()
 

Protected Attributes

PValue myMin
 
PValue myMax
 

Detailed Description

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

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 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 "GrayscaleColorMap.h"
// ...
{
GrayscaleColorMap<float> grayShade(0.0f,1.0f);
Color white = grayShade(1.0f);
Color gray1 = grayShade(0.5f);
// Or, equivalently:
Color gray2 = GrayscaleColorMap<float>::getColor(0.0f,1.0f,0.5f);
}
Template Parameters
PValueThe type of the range values.
Examples:
geometry/volumes/distance/distancetransform2D.cpp, geometry/volumes/distance/toricdomainvolumetric.cpp, and images/exampleConstImageAdapter.cpp.

Definition at line 93 of file GrayscaleColorMap.h.

Member Typedef Documentation

template<typename PValue>
typedef PValue DGtal::GrayscaleColorMap< PValue >::Value

Definition at line 98 of file GrayscaleColorMap.h.

Constructor & Destructor Documentation

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

Constructor.

Parameters
minThe lower bound of the value range.
maxThe upper bound of the value range.
template<typename PValue>
DGtal::GrayscaleColorMap< PValue >::~GrayscaleColorMap ( )

Destructor.

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

Copy constructor.

Parameters
otherthe object to clone.
template<typename PValue>
DGtal::GrayscaleColorMap< PValue >::GrayscaleColorMap ( )
protected

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

Member Function Documentation

template<typename PValue>
static Color DGtal::GrayscaleColorMap< PValue >::getColor ( const PValue &  min,
const PValue &  max,
const PValue &  value 
)
static

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

Parameters
minThe lower bound of the value range.
maxThe upper bound of the value range.
valueA 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 PValue>
bool DGtal::GrayscaleColorMap< PValue >::isValid ( ) const

Checks the validity/consistency of the object.

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

Returns the upper bound of the value range.

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

Returns the lower bound of the value range.

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

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

Parameters
valueA 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 PValue>
GrayscaleColorMap& DGtal::GrayscaleColorMap< PValue >::operator= ( const GrayscaleColorMap< PValue > &  other)

Assignment.

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

Writes/Displays the object on an output stream.

Parameters
outthe output stream where the object is written.

Field Documentation

template<typename PValue>
PValue DGtal::GrayscaleColorMap< PValue >::myMax
protected

The lower bound of the value range.

Definition at line 195 of file GrayscaleColorMap.h.

template<typename PValue>
PValue DGtal::GrayscaleColorMap< PValue >::myMin
protected

The lower bound of the value range.

Definition at line 194 of file GrayscaleColorMap.h.


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