18 #ifndef itkLabelToRGBFunctor_h
19 #define itkLabelToRGBFunctor_h
49 template<
typename TLabel,
typename TRGBPixel >
58 typedef typename TRGBPixel::ValueType ValueType;
71 const size_t numColors = 30;
72 const 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 (
size_t i=0; i < numColors; ++i)
85 AddColor(colors[i][0], colors[i][1], colors[i][2]);
109 void AddColor(
unsigned char r,
unsigned char g,
unsigned char b)
114 typedef typename TRGBPixel::ValueType 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
bool operator==(const Self &other) const
bool operator!=(const Self &l) const
void SetBackgroundValue(TLabel v)
std::vector< TRGBPixel > m_Colors
static ITK_CONSTEXPR_FUNC T max(const T &)
static void SetLength(T &m, const unsigned int s)
Functor for converting labels into RGB triplets.
unsigned int GetNumberOfColors() const
Define additional traits for native types such as int or float.
TRGBPixel operator()(const TLabel &p) const
void AddColor(unsigned char r, unsigned char g, unsigned char b)