DGtal  1.5.beta
BasicColorToScalarFunctors.h
1 
17 #pragma once
18 
31 #if defined(ColorToScalarFunctors_RECURSES)
32 #error Recursive header files inclusion detected in ColorToScalarFunctors.h
33 #else // defined(ColorToScalarFunctors_RECURSES)
35 #define ColorToScalarFunctors_RECURSES
36 
37 #if !defined ColorToScalarFunctors_h
39 #define ColorToScalarFunctors_h
40 
42 // Inclusions
43 #include <iostream>
44 #include "DGtal/base/Common.h"
45 #include "DGtal/io/Color.h"
47 
48 namespace DGtal
49 {
50  namespace functors
51  {
57  struct RedChannel
58  {
59  inline
60  unsigned char operator() (const Color &aCol) const
61  {
62  return aCol.red();
63  }
64  };
65 
71  struct BlueChannel
72  {
73  inline
74  unsigned char operator() (const Color &aCol) const
75  {
76  return aCol.blue();
77  }
78  };
79 
85  struct GreenChannel
86  {
87  inline
88  unsigned char operator() (const Color &aCol) const
89  {
90  return aCol.green();
91  }
92  };
93 
99  struct MeanChannels
100  {
101  inline
102  unsigned char operator() (const Color &aCol) const
103  {
104  return static_cast<unsigned char>( ((int)aCol.green() + (int)aCol.blue() + (int)aCol.red()) / 3);
105  }
106  };
107 
112  template<typename TValue>
114  {
115  typedef TValue Value;
116 
117  inline
118  Value operator() (const Color &aCol) const
119  {
120  return static_cast<Value> (aCol.getRGB());
121  }
122  };
123 
124  } //namespace functors
125 } // namespace DGtal
126 
127  // //
129 
130 #endif // !defined ColorToScalarFunctors_h
131 
132 #undef ColorToScalarFunctors_RECURSES
133 #endif // else defined(ColorToScalarFunctors_RECURSES)
Structure representing an RGB triple with alpha component.
Definition: Color.h:68
DGtal::uint32_t getRGB() const
void green(const unsigned char aGreenValue)
void red(const unsigned char aRedValue)
void blue(const unsigned char aBlueValue)
DGtal is the top-level namespace which contains all DGtal functions and types.
unsigned char operator()(const Color &aCol) const
Value operator()(const Color &aCol) const
unsigned char operator()(const Color &aCol) const
unsigned char operator()(const Color &aCol) const
unsigned char operator()(const Color &aCol) const