21 #ifndef otbMaskMuParserFunctor_hxx
22 #define otbMaskMuParserFunctor_hxx
31 template <
class TInputPixel>
37 template <
class TInputPixel>
42 template <
class TInputPixel>
47 if (p.Size() != m_NbOfBands)
49 this->SetNumberOfBands(p.GetSize());
53 for (
unsigned int i = 0; i < m_NbOfBands; ++i)
55 m_AImage[i] =
static_cast<double>(p[i]);
60 for (
unsigned int i = 0; i < m_NbOfBands; ++i)
64 m_Intensity = m_Intensity / (
static_cast<double>(m_NbOfBands));
66 m_SpectralAngle = m_SpectralAngleFunctor(p, m_SpectralAngleReferencePixel);
68 value = m_Parser->Eval();
70 return static_cast<bool>(value);
73 template <
class TInputPixel>
76 return this->m_Parser->GetVar();
79 template <
class TInputPixel>
82 return this->m_Parser->GetFunList();
86 template <
class TInputPixel>
89 m_Expression = expression;
90 m_Parser->SetExpr(m_Expression);
94 template <
class TInputPixel>
100 template <
class TInputPixel>
103 m_NbOfBands = NbOfBands;
104 std::ostringstream varName;
106 m_AImage.resize(NbOfBands, 0.0);
108 for (
unsigned int i = 0; i < NbOfBands; ++i)
110 varName <<
"b" << i + 1;
111 m_Parser->DefineVar(varName.str(), &(m_AImage[i]));
116 m_Parser->DefineVar(
"intensity", &m_Intensity);
117 m_Parser->DefineVar(
"spectralAngle", &m_SpectralAngle);
121 template <
class TInputPixel>
124 m_SpectralAngleReferencePixel = refPixel;
128 template <
class TInputPixel>
131 return m_Parser->CheckExpr();