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>;
171 #ifndef OTB_MANUAL_INSTANTIATION
Function object to convert HSV value to RGB.
~HSVToRGBFunctor()=default
TRGBPixel operator()(double h, double s, double v) const
HSVToRGBFunctor()=default
Function object which maps a scalar value into a rainbow RGB pixel value.
void operator=(const Self &)=delete
ScalarToRainbowRGBPixelFunctor(const Self &)=delete
RGBPixelType HSVToRGB(double h, double s, double v) const
~ScalarToRainbowRGBPixelFunctor()=default
itk::SmartPointer< const Self > ConstPointer
HSVToRGBFunctorType m_HSVToRGBFunctor
typename RGBPixelType::ComponentType RGBComponentType
itk::SmartPointer< Self > Pointer
itk::Function::ColormapFunction< TScalar, TRGBPixel > Superclass
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.