21 #ifndef otbSpectralInformationDivergenceFunctor_h
22 #define otbSpectralInformationDivergenceFunctor_h
44 template <
class TInput,
class TReference,
class TOutput>
79 for (
auto const & pixel : ref)
88 for (
unsigned int i = 0; i < input.Size(); i++)
93 throw std::runtime_error(
"Input pixels of the spectral information divergence algorithm should be strictly positive.");
97 return input / std::accumulate(&input[0], &input[input.Size()], 0.0);
102 assert(p.Size() == q.Size());
104 for (
unsigned int i = 0; i < p.Size(); i++)
107 sid += (p[i] - q[i]) * std::log(p[i]/q[i]);
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.