DGtal  1.3.beta
Public Types | Public Member Functions | Data Fields
DGtal::QuantifiedColorMap< TColorMap > Struct Template Reference

Aim: A modifier class that quantifies any colormap into a given number of colors. It is particularly useful when rendering colored objects, since for instance blender is very slow to load many different materials. More...

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

Public Types

using ColorMap = TColorMap
 
using Self = QuantifiedColorMap< ColorMap >
 
using Value = typename ColorMap::Value
 

Public Member Functions

 BOOST_CONCEPT_ASSERT ((concepts::CColorMap< TColorMap >))
 
 QuantifiedColorMap (Clone< ColorMap > colormap, int nb=50)
 
Color operator() (const Value &value) const
 

Data Fields

ColorMap myColorMap
 the colormap that is quantified More...
 
int myNbColors
 the maximum number of colors More...
 

Detailed Description

template<typename TColorMap>
struct DGtal::QuantifiedColorMap< TColorMap >

Aim: A modifier class that quantifies any colormap into a given number of colors. It is particularly useful when rendering colored objects, since for instance blender is very slow to load many different materials.

Description of template class 'QuantifiedColorMap'

Template Parameters
TColorMapan arbitrary model of concepts::CColorMap.

Definition at line 66 of file QuantifiedColorMap.h.

Member Typedef Documentation

◆ ColorMap

template<typename TColorMap >
using DGtal::QuantifiedColorMap< TColorMap >::ColorMap = TColorMap

Definition at line 69 of file QuantifiedColorMap.h.

◆ Self

template<typename TColorMap >
using DGtal::QuantifiedColorMap< TColorMap >::Self = QuantifiedColorMap< ColorMap >

Definition at line 70 of file QuantifiedColorMap.h.

◆ Value

template<typename TColorMap >
using DGtal::QuantifiedColorMap< TColorMap >::Value = typename ColorMap::Value

Definition at line 71 of file QuantifiedColorMap.h.

Constructor & Destructor Documentation

◆ QuantifiedColorMap()

template<typename TColorMap >
DGtal::QuantifiedColorMap< TColorMap >::QuantifiedColorMap ( Clone< ColorMap colormap,
int  nb = 50 
)
inline

Constructor from colormap and nb colors

Parameters
[in]colormapthe colormap to quantify in nb colors.
[in]nbthe targeted maximum number of colors (default is 50).

Definition at line 79 of file QuantifiedColorMap.h.

80  : myColorMap( colormap ), myNbColors( nb )
81  {}

Member Function Documentation

◆ BOOST_CONCEPT_ASSERT()

template<typename TColorMap >
DGtal::QuantifiedColorMap< TColorMap >::BOOST_CONCEPT_ASSERT ( (concepts::CColorMap< TColorMap >)  )

◆ operator()()

template<typename TColorMap >
Color DGtal::QuantifiedColorMap< TColorMap >::operator() ( const Value value) const
inline

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

Parameters
valueA value within the value range.
Returns
A color whose brightness linearly depends on the position of [value] within the current range.

Definition at line 88 of file QuantifiedColorMap.h.

89  {
90  const Value rel = ( value - myColorMap.min() )
91  / ( myColorMap.max() - myColorMap.min() );
92  const Value qrel = round( myNbColors * rel ) / myNbColors;
93  const Value outv = qrel * ( myColorMap.max() - myColorMap.min() )
94  + myColorMap.min();
95  return myColorMap( outv );
96  }

References DGtal::QuantifiedColorMap< TColorMap >::myColorMap, and DGtal::QuantifiedColorMap< TColorMap >::myNbColors.

Field Documentation

◆ myColorMap

template<typename TColorMap >
ColorMap DGtal::QuantifiedColorMap< TColorMap >::myColorMap

the colormap that is quantified

Definition at line 101 of file QuantifiedColorMap.h.

Referenced by DGtal::QuantifiedColorMap< TColorMap >::operator()().

◆ myNbColors

template<typename TColorMap >
int DGtal::QuantifiedColorMap< TColorMap >::myNbColors

the maximum number of colors

Definition at line 103 of file QuantifiedColorMap.h.

Referenced by DGtal::QuantifiedColorMap< TColorMap >::operator()().


The documentation for this struct was generated from the following file:
DGtal::QuantifiedColorMap::myColorMap
ColorMap myColorMap
the colormap that is quantified
Definition: QuantifiedColorMap.h:101
DGtal::QuantifiedColorMap::myNbColors
int myNbColors
the maximum number of colors
Definition: QuantifiedColorMap.h:103
Value
double Value
Definition: testSimpleRandomAccessRangeFromPoint.cpp:38