21 #ifndef otbRadiometricIndex_h
22 #define otbRadiometricIndex_h
24 #include "itkVariableLengthVector.h"
56 template <
typename TInput,
typename TOutput>
62 using PixelType = itk::VariableLengthVector<InputType>;
72 static constexpr
double Epsilon = 0.0000001;
81 RadiometricIndex(
const std::set<BandNameType>& requiredBands) : m_RequiredBands(), m_BandIndices()
85 throw std::runtime_error(
"TBandNameEnum::MAX can not be used as a required band");
89 m_RequiredBands.fill(
false);
90 m_BandIndices.fill(0);
92 for (
auto b : requiredBands)
94 m_RequiredBands[
static_cast<size_t>(b)] =
true;
104 std::set<BandNameType> resp;
105 for (
size_t i = 0; i < NumberOfBands; ++i)
107 if (m_RequiredBands[i])
126 throw std::runtime_error(
"Can not set index for CommandBandName::MAX");
128 m_BandIndices[
static_cast<size_t>(band)] = index;
139 for (
auto it : indicesMap)
141 SetBandIndex(it.first, it.second);
155 throw std::runtime_error(
"Can not get index for CommandBandName::MAX");
157 return m_BandIndices[
static_cast<size_t>(band)];
167 virtual TOutput operator()(
const itk::VariableLengthVector<TInput>& input)
const = 0;
183 assert(band !=
BandNameType::MAX &&
"Can not retrieve index for band CommandBandName::MAX");
184 return m_BandIndices[
static_cast<size_t>(band)];
206 assert(m_RequiredBands[
static_cast<size_t>(band)] &&
"Retrieving value for a band that is not in the required bands list");
207 return static_cast<double>(input[UncheckedBandIndex(band) - 1]);