18 #ifndef itkLabelToRGBFunctor_h
19 #define itkLabelToRGBFunctor_h
49 template<
typename TLabel,
typename TRGBPixel >
58 using ValueType =
typename TRGBPixel::ValueType;
71 constexpr
size_t numColors = 30;
72 constexpr
unsigned char colors[numColors][3] = {
73 {255, 0, 0}, {0, 205, 0}, {0, 0, 255}, {0, 255, 255},
74 {255, 0, 255}, {255, 127, 0}, {0, 100, 0}, {138, 43, 226},
75 {139, 35, 35}, {0, 0, 128}, {139, 139, 0}, {255, 62, 150},
76 {139, 76, 57}, {0, 134, 139}, {205, 104, 57}, {191, 62, 255},
77 {0, 139, 69}, {199, 21, 133}, {205, 55, 0}, {32, 178, 170},
78 {106, 90, 205}, {255, 20, 147}, {69, 139, 116}, {72, 118, 255},
79 {205, 79, 57}, {0, 0, 205}, {139, 34, 82}, {139, 0, 139},
80 {238, 130, 238}, {139, 0, 0}
83 for (
auto & color : colors)
85 AddColor(color[0], color[1], color[2]);
109 void AddColor(
unsigned char r,
unsigned char g,
unsigned char b)
114 using ValueType =
typename TRGBPixel::ValueType;
118 rgbPixel[0] =
static_cast< ValueType
>(
static_cast< double >( r ) / 255 * m );
119 rgbPixel[1] =
static_cast< ValueType
>(
static_cast< double >( g ) / 255 * m );
120 rgbPixel[2] =
static_cast< ValueType
>(
static_cast< double >( b ) / 255 * m );
133 return static_cast<unsigned int>(
m_Colors.size() );
146 for (
typename std::vector< TRGBPixel >::size_type i = 0; i <
m_Colors.size(); ++i )
158 return !( *
this != other );
void SetBackgroundColor(TRGBPixel rgb)
TRGBPixel m_BackgroundColor
Define numeric traits for std::vector.
bool operator==(const Self &other) const
bool operator!=(const Self &l) const
void SetBackgroundValue(TLabel v)
~LabelToRGBFunctor()=default
std::vector< TRGBPixel > m_Colors
Functor for converting labels into RGB triplets.
unsigned int GetNumberOfColors() const
TRGBPixel operator()(const TLabel &p) const
void AddColor(unsigned char r, unsigned char g, unsigned char b)