18 #ifndef __otbAlphaBlendingFunctor_h
19 #define __otbAlphaBlendingFunctor_h
39 template<
class TInputPixel1,
class TInputPixel2,
class TOutputPixel>
50 virtual void SetAlpha(
double a)
53 m_Alpha = a<0.0?0.0:(a>1.0?1.0:a);
56 virtual double GetAlpha()
const
61 virtual inline OutputPixelType operator ()(InputPixel1Type input1, InputPixel2Type input2)
const = 0;
67 template<
class TInputPixel1,
class TInputPixel2,
class TOutputPixel>
82 double alpha = this->GetAlpha();
84 resp =
static_cast<OutputPixelType>(vcl_floor(0.5 + (1.0 - alpha) * static_cast<double>(input1)
85 + alpha * static_cast<double>(input2)));
93 template<
class TInputInternalPixel1,
class TInputInternalPixel2,
class TOutputInternalPixel>
98 itk::RGBAPixel<TInputInternalPixel2>,
99 itk::RGBAPixel<TOutputInternalPixel> >
115 resp.
Fill(itk::NumericTraits<InternalOutputPixelType>::max());
116 double alpha =
static_cast<double>(input2.
GetAlpha()) / 255.0 * this->GetAlpha();
118 resp.
SetRed(static_cast<InternalOutputPixelType>(vcl_floor(0.5 +
119 (1.0 - alpha) * static_cast<double>(input1.
GetRed())
120 + alpha * static_cast<double>(input2.
GetRed())
122 resp.
SetGreen(static_cast<InternalOutputPixelType>(vcl_floor(0.5 +
123 (1.0 - alpha) * static_cast<double>(input1.
GetGreen())
124 + alpha * static_cast<double>(input2.
GetGreen())
126 resp.
SetBlue(static_cast<InternalOutputPixelType>(vcl_floor(0.5 +
127 (1.0 - alpha) * static_cast<double>(input1.
GetBlue())
128 + alpha * static_cast<double>(input2.
GetBlue())