21 #ifndef otbSpectralAngleFunctor_h
22 #define otbSpectralAngleFunctor_h
34 namespace SpectralAngleDetails
41 template <
class TInput,
class TReference,
class TOutput>
43 TReference
const & reference,
typename TReference::ValueType refNorm)
45 auto minSize = std::min(input.Size(), reference.Size());
46 double scalarProduct = std::inner_product(&input[0], &input[minSize], &reference[0],0. );
47 auto normProd = inputNorm * refNorm;
48 if ((normProd < 1.e-12) || (scalarProduct / normProd > 1))
50 return static_cast<TOutput
>(0.0);
54 return static_cast<TOutput
>(std::acos(scalarProduct / normProd));
66 template <
class TInput,
class TOutputValue>
79 inline TOutputValue
operator()(TInput
const & inPix)
const
81 return SpectralAngleDetails::ComputeSpectralAngle<TInput, TInput, TOutputValue>(inPix, inPix.GetNorm(),
m_ReferencePixel,
m_RefNorm);
105 template <
class TInput,
class TReference,
class TOutput>
117 auto inputNorm = inPix.GetNorm();
121 res[i] = SpectralAngleDetails::ComputeSpectralAngle<TInput, TInput, typename TOutput::ValueType>