DGtal  0.9.2
ColorBrightnessColorMap.h
1 
17 #pragma once
18 
30 #if defined(ColorBrightnessColorMap_RECURSES)
31 #error Recursive header files inclusion detected in ColorBrightnessColorMap.h
32 #else // defined(ColorBrightnessColorMap_RECURSES)
33 
34 #define ColorBrightnessColorMap_RECURSES
35 
36 #if !defined ColorBrightnessColorMap_h
37 
38 #define ColorBrightnessColorMap_h
39 
41 // Inclusions
42 #include <iostream>
43 #include "DGtal/base/Common.h"
44 #include "Board/Board.h"
45 #include "DGtal/io/Color.h"
47 
48 #ifndef DGTAL_RGB2INT
49 #define DGTAL_RGB2INT(R,G,B) (((R)<<16)|((G)<<8)|(B))
50 #define DGTAL_RED_COMPONENT(I) (((I)>>16)&0xFF)
51 #define DGTAL_GREEN_COMPONENT(I) (((I)>>8)&0xFF)
52 #define DGTAL_BLUE_COMPONENT(I) ((I)&0xFF)
53 #endif
54 
55 namespace DGtal
56 {
57 
59  // template class ColorBrightnessColorMap
88  template <typename PValue, int PDefaultColor = DGTAL_RGB2INT( 255, 255, 255 ) >
90  {
91  public:
92 
93  typedef PValue Value;
94 
95  // ----------------------- Standard services ------------------------------
96  public:
97 
105  ColorBrightnessColorMap( const PValue & min,
106  const PValue & max,
107  const Color color
108  = Color( DGTAL_RED_COMPONENT( PDefaultColor ),
109  DGTAL_GREEN_COMPONENT( PDefaultColor ),
110  DGTAL_BLUE_COMPONENT( PDefaultColor ) ) );
111 
119  Color operator()( const PValue & value ) const;
120 
125 
131 
138 
139  // ----------------------- Interface --------------------------------------
140  public:
141 
146  void selfDisplay ( std::ostream & out ) const;
147 
152  bool isValid() const;
153 
159  const PValue & min() const;
160 
166  const PValue & max() const;
167 
168  // ----------------------- Static methods ---------------------------------
169 
170 
181  static Color getColor( const Color color,
182  const PValue & min,
183  const PValue & max,
184  const PValue & value );
185 
186  // ------------------------- Protected Datas ------------------------------
187  private:
188 
189  // ------------------------- Private Datas --------------------------------
190  private:
191 
192  // ------------------------- Hidden services ------------------------------
193  protected:
194 
195  PValue myMin;
196  PValue myMax;
204 
205  // ------------------------- Internals ------------------------------------
206  private:
207 
218  static void HSVtoRGB( double & r, double & g, double & b,
219  double h, const double s, const double v);
220 
231  static void RGBtoHSV( double & h, double & s, double & v,
232  const unsigned char r,
233  const unsigned char g,
234  const unsigned char b );
235 
236  }; // end of class ColorBrightnessColorMap
237 
238 
245  template <typename PValue, int PDefaultColor>
246  std::ostream&
247  operator<< ( std::ostream & out, const ColorBrightnessColorMap<PValue,PDefaultColor> & object );
248 
249 } // namespace DGtal
250 
251 
253 // Includes inline functions.
254 #include "DGtal/io/colormaps/ColorBrightnessColorMap.ih"
255 
256 // //
258 
259 #endif // !defined ColorBrightnessColorMap_h
260 
261 #undef ColorBrightnessColorMap_RECURSES
262 #endif // else defined(ColorBrightnessColorMap_RECURSES)
Aim: This class template may be used to (linearly) convert scalar values in a given range into a colo...
const PValue & min() const
static void HSVtoRGB(double &r, double &g, double &b, double h, const double s, const double v)
Color operator()(const PValue &value) const
const PValue & max() const
static void RGBtoHSV(double &h, double &s, double &v, const unsigned char r, const unsigned char g, const unsigned char b)
void selfDisplay(std::ostream &out) const
DGtal is the top-level namespace which contains all DGtal functions and types.
Structure representing an RGB triple with alpha component.
Definition: Color.h:66
static Color getColor(const Color color, const PValue &min, const PValue &max, const PValue &value)
ColorBrightnessColorMap & operator=(const ColorBrightnessColorMap &other)