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>
This functor computes the spectral angle according to a reference pixel.
TOutputValue operator()(TInput const &inPix) const
TInput GetReferencePixel() const
~SpectralAngleFunctor()=default
void SetReferencePixel(TInput const &ref)
This functor computes the spectral angle according to a vector of reference pixel.
void SetReferencePixels(std::vector< TReference > ref)
SpectralAngleMapperFunctor()=default
vcl_size_t OutputSize(...) const
TOutput operator()(const TInput &inPix) const
std::vector< TReference > m_ReferencePixels
std::vector< double > m_ReferenceNorm
std::vector< TReference > const & GetReferencePixels() const
virtual ~SpectralAngleMapperFunctor()=default
TOutput ComputeSpectralAngle(TInput const &input, typename TInput ::ValueType const &inputNorm, TReference const &reference, typename TReference::ValueType refNorm)
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.