22 #ifndef otbScalarToRainbowRGBPixelFunctor_h
23 #define otbScalarToRainbowRGBPixelFunctor_h
25 #include "itkColormapFunction.h"
41 template <
class TRGBPixel>
51 const double onethird = 1.0 / 3.0;
52 const double onesixth = 1.0 / 6.0;
53 const double twothird = 2.0 / 3.0;
54 const double fivesixth = 5.0 / 6.0;
58 if (h > onesixth && h <= onethird)
61 r = (onethird - h) / onesixth;
64 else if (h > onethird && h <= 0.5)
67 b = (h - onethird) / onesixth;
70 else if (h > 0.5 && h <= twothird)
73 g = (twothird - h) / onesixth;
76 else if (h > twothird && h <= fivesixth)
79 r = (h - twothird) / onesixth;
82 else if (h > fivesixth && h <= 1.0)
85 b = (1.0 - h) / onesixth;
96 r = (s * r + (1.0 - s));
97 g = (s * g + (1.0 - s));
98 b = (s * b + (1.0 - s));
106 using RGBComponentType =
typename TRGBPixel::ComponentType;
108 ans[0] =
static_cast<RGBComponentType
>(r);
109 ans[1] =
static_cast<RGBComponentType
>(g);
110 ans[2] =
static_cast<RGBComponentType
>(b);
133 template <
class TScalar,
class TRGBPixel = itk::RGBPixel<
unsigned char>>
143 using Superclass = itk::Function::ColormapFunction<TScalar, TRGBPixel>;
158 RGBPixelType HSVToRGB(
double h,
double s,
double v)
const;
162 void operator=(
const Self&) =
delete;
171 #ifndef OTB_MANUAL_INSTANTIATION