21 #ifndef otbAlphaBlendingFunctor_h
22 #define otbAlphaBlendingFunctor_h
24 #include "itkRGBAPixel.h"
45 template <
class TInputPixel1,
class TInputPixel2,
class TOutputPixel>
63 m_Alpha = a < 0.0 ? 0.0 : (a > 1.0 ? 1.0 : a);
71 virtual inline OutputPixelType operator()(InputPixel1Type input1, InputPixel2Type input2)
const = 0;
77 template <
class TInputPixel1,
class TInputPixel2,
class TOutputPixel>
95 double alpha = this->GetAlpha();
97 resp =
static_cast<OutputPixelType>(std::floor(0.5 + (1.0 - alpha) *
static_cast<double>(input1) + alpha *
static_cast<double>(input2)));
105 template <
class TInputInternalPixel1,
class TInputInternalPixel2,
class TOutputInternalPixel>
106 class ITK_EXPORT
AlphaBlendingFunctor<
itk::RGBAPixel<TInputInternalPixel1>, itk::RGBAPixel<TInputInternalPixel2>, itk::RGBAPixel<TOutputInternalPixel>>
107 :
public AlphaBlendingFunctorBase<itk::RGBAPixel<TInputInternalPixel1>, itk::RGBAPixel<TInputInternalPixel2>, itk::RGBAPixel<TOutputInternalPixel>>
127 resp.Fill(itk::NumericTraits<InternalOutputPixelType>::max());
128 double alpha =
static_cast<double>(input2.GetAlpha()) / 255.0 * this->GetAlpha();
131 std::floor(0.5 + (1.0 - alpha) *
static_cast<double>(input1.GetRed()) + alpha *
static_cast<double>(input2.GetRed()))));
133 std::floor(0.5 + (1.0 - alpha) *
static_cast<double>(input1.GetGreen()) + alpha *
static_cast<double>(input2.GetGreen()))));
135 std::floor(0.5 + (1.0 - alpha) *
static_cast<double>(input1.GetBlue()) + alpha *
static_cast<double>(input2.GetBlue()))));