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]);
Base class for all radiometric indices.
itk::VariableLengthVector< InputType > PixelType
void SetBandsIndices(const std::map< BandNameType, vcl_size_t > &indicesMap)
BandIndicesContainer m_BandIndices
An array storing the required status for each band.
double Value(BandNameType band, const itk::VariableLengthVector< TInput > &input) const
TInput InputType
Types for input/output.
std::array< vcl_size_t, NumberOfBands > BandIndicesContainer
An array storing the indice for each band.
std::set< BandNameType > GetRequiredBands() const
std::array< bool, NumberOfBands > RequiredBandsContainer
An array storing the required status for each band.
vcl_size_t GetBandIndex(BandNameType band) const
void SetBandIndex(BandNameType band, vcl_size_t index)
virtual TOutput operator()(const itk::VariableLengthVector< TInput > &input) const =0
RequiredBandsContainer m_RequiredBands
An array storing the required status for each band.
vcl_size_t UncheckedBandIndex(BandNameType band) const
RadiometricIndex()=delete
An array storing the required status for each band.
RadiometricIndex(const std::set< BandNameType > &requiredBands)
virtual ~RadiometricIndex()=default
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.