DGtal  1.1.0
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)
34 
35 #define ColorToScalarFunctors_RECURSES
36 
37 #if !defined ColorToScalarFunctors_h
38 
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)
DGtal::functors::MeanChannels::operator()
unsigned char operator()(const Color &aCol) const
Definition: BasicColorToScalarFunctors.h:102
DGtal::functors::MeanChannels
Definition: BasicColorToScalarFunctors.h:100
DGtal::Color
Structure representing an RGB triple with alpha component.
Definition: Color.h:67
DGtal::functors::BlueChannel
Definition: BasicColorToScalarFunctors.h:72
DGtal::functors::RedChannel::operator()
unsigned char operator()(const Color &aCol) const
Definition: BasicColorToScalarFunctors.h:60
DGtal::functors::GreenChannel::operator()
unsigned char operator()(const Color &aCol) const
Definition: BasicColorToScalarFunctors.h:88
DGtal::functors::GreenChannel
Definition: BasicColorToScalarFunctors.h:86
DGtal::functors::ColorRGBEncoder::Value
TValue Value
Definition: BasicColorToScalarFunctors.h:115
DGtal::functors::BlueChannel::operator()
unsigned char operator()(const Color &aCol) const
Definition: BasicColorToScalarFunctors.h:74
DGtal::functors::RedChannel
Definition: BasicColorToScalarFunctors.h:58
DGtal::Color::red
void red(const unsigned char aRedValue)
DGtal::functors::ColorRGBEncoder::operator()
Value operator()(const Color &aCol) const
Definition: BasicColorToScalarFunctors.h:118
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition: ClosedIntegerHalfPlane.h:49
DGtal::functors::ColorRGBEncoder
Definition: BasicColorToScalarFunctors.h:114
DGtal::Color::getRGB
DGtal::uint32_t getRGB() const
DGtal::Color::green
void green(const unsigned char aGreenValue)
DGtal::Color::blue
void blue(const unsigned char aBlueValue)