From adce50ec8d2a5e381b52016b30d5cc62e5e45113 Mon Sep 17 00:00:00 2001
From: Julien Michel <julien.michel@orfeo-toolbox.org>
Date: Thu, 11 Apr 2019 14:20:47 +0000
Subject: [PATCH] ENH: Use existing enum and add a template parameter to define
 band enum

---
 ...ometricAttributesLabelMapFilterExample.cxx |   4 +-
 ...lRAndBAndNIRVegetationIndexImageFilter.cxx |   6 +-
 ...lRAndGAndNIRVegetationIndexImageFilter.cxx |   6 +-
 .../Simulation/LAIFromNDVIImageTransform.cxx  |   4 +-
 .../AppIndices/app/otbRadiometricIndices.cxx  |  19 ++-
 .../otbUrbanAreaDetectionImageFilter.h        |   8 +-
 .../Radiometry/Indices/include/otbBandName.h  |   5 +-
 .../include/otbBuiltUpIndicesFunctor.h        |  12 +-
 .../include/otbNDVIDataNodeFeatureFunction.h  |   8 +-
 .../Indices/include/otbRadiometricIndice.h    |  30 ++---
 .../Indices/include/otbSoilIndicesFunctor.h   |  26 ++--
 .../include/otbVegetationIndicesFunctor.h     | 116 +++++++++---------
 .../Indices/include/otbWaterIndicesFunctor.h  |  38 +++---
 .../otbLAIFromNDVILogarithmicFunctorTest.cxx  |   4 +-
 ...tbLAIFromReflectancesLinearFunctorTest.cxx |   5 +-
 ...educeSpectralResponseClassifierRAndNIR.hxx |   4 +-
 16 files changed, 149 insertions(+), 146 deletions(-)

diff --git a/Examples/OBIA/RadiometricAttributesLabelMapFilterExample.cxx b/Examples/OBIA/RadiometricAttributesLabelMapFilterExample.cxx
index 907254a6bd..4b17f87c7e 100644
--- a/Examples/OBIA/RadiometricAttributesLabelMapFilterExample.cxx
+++ b/Examples/OBIA/RadiometricAttributesLabelMapFilterExample.cxx
@@ -166,8 +166,8 @@ int main(int argc, char* argv[])
   //  In our case, statistics are computed on the NDVI coefficient on each label object.
   NDVIImageFilterType::Pointer ndviImageFilter = NDVIImageFilterType::New();
 
-  ndviImageFilter->GetFunctor().SetBandIndex(otb::Functor::Band::RED,3);
-  ndviImageFilter->GetFunctor().SetBandIndex(otb::Functor::Band::NIR,4);
+  ndviImageFilter->GetFunctor().SetBandIndex(CommonBandNames::RED,3);
+  ndviImageFilter->GetFunctor().SetBandIndex(CommonBandNames::NIR,4);
   ndviImageFilter->SetInput(vreader->GetOutput());
 
   ImageToVectorImageCastFilterType::Pointer ndviVectorImageFilter = ImageToVectorImageCastFilterType::New();
diff --git a/Examples/Radiometry/ARVIMultiChannelRAndBAndNIRVegetationIndexImageFilter.cxx b/Examples/Radiometry/ARVIMultiChannelRAndBAndNIRVegetationIndexImageFilter.cxx
index 5b02d07a01..6fdd9cfce9 100644
--- a/Examples/Radiometry/ARVIMultiChannelRAndBAndNIRVegetationIndexImageFilter.cxx
+++ b/Examples/Radiometry/ARVIMultiChannelRAndBAndNIRVegetationIndexImageFilter.cxx
@@ -133,9 +133,9 @@ int main(int argc, char* argv[])
   writer->SetFileName(argv[2]);
 
   // The three used index bands (red, blue and NIR) are declared.
-  filter->GetFunctor().SetBandIndex(otb::Functor::Band::RED,::atoi(argv[5]));
-  filter->GetFunctor().SetBandIndex(otb::Functor::Band::GREEN,::atoi(argv[6]));
-  filter->GetFunctor().SetBandIndex(otb::Functor::Band::NIR,::atoi(argv[7]));
+  filter->GetFunctor().SetBandIndex(CommonBandNames::RED,::atoi(argv[5]));
+  filter->GetFunctor().SetBandIndex(CommonBandNames::GREEN,::atoi(argv[6]));
+  filter->GetFunctor().SetBandIndex(CommonBandNames::NIR,::atoi(argv[7]));
 
   // The filter input is linked to the reader output and
   // the filter output is linked to the writer input.
diff --git a/Examples/Radiometry/AVIMultiChannelRAndGAndNIRVegetationIndexImageFilter.cxx b/Examples/Radiometry/AVIMultiChannelRAndGAndNIRVegetationIndexImageFilter.cxx
index 21f9dfaaf7..5d740c7ae7 100644
--- a/Examples/Radiometry/AVIMultiChannelRAndGAndNIRVegetationIndexImageFilter.cxx
+++ b/Examples/Radiometry/AVIMultiChannelRAndGAndNIRVegetationIndexImageFilter.cxx
@@ -119,9 +119,9 @@ int main(int argc, char* argv[])
 
   // The three used index bands (red, green and NIR) are declared.
 
-  filter->GetFunctor().SetBandIndex(otb::Functor::Band::RED,::atoi(argv[5]));
-  filter->GetFunctor().SetBandIndex(otb::Functor::Band::GREEN,::atoi(argv[6]));
-  filter->GetFunctor().SetBandIndex(otb::Functor::Band::NIR,::atoi(argv[7]));
+  filter->GetFunctor().SetBandIndex(CommonBandNames::RED,::atoi(argv[5]));
+  filter->GetFunctor().SetBandIndex(CommonBandNames::GREEN,::atoi(argv[6]));
+  filter->GetFunctor().SetBandIndex(CommonBandNames::NIR,::atoi(argv[7]));
 
   // The filter input is linked to the reader output and
   // the filter output is linked to the writer input.
diff --git a/Examples/Simulation/LAIFromNDVIImageTransform.cxx b/Examples/Simulation/LAIFromNDVIImageTransform.cxx
index 8c2aebccae..016be8536a 100644
--- a/Examples/Simulation/LAIFromNDVIImageTransform.cxx
+++ b/Examples/Simulation/LAIFromNDVIImageTransform.cxx
@@ -96,8 +96,8 @@ int main(int argc, char* argv[])
   //
   unsigned int redChannel = static_cast<unsigned int>(atoi(argv[5]));
   unsigned int nirChannel = static_cast<unsigned int>(atoi(argv[6]));
-  filter->GetFunctor().SetBandIndex(otb::Functor::Band::RED,redChannel);
-  filter->GetFunctor().SetBandIndex(otb::Functor::Band::NIR,nirChannel);
+  filter->GetFunctor().SetBandIndex(CommonBandNames::RED,redChannel);
+  filter->GetFunctor().SetBandIndex(CommonBandNames::NIR,nirChannel);
 
   //  The invocation of the \code{Update()} method triggers the
   //  execution of the pipeline.
diff --git a/Modules/Applications/AppIndices/app/otbRadiometricIndices.cxx b/Modules/Applications/AppIndices/app/otbRadiometricIndices.cxx
index ad007da65d..20d2ac2c3e 100644
--- a/Modules/Applications/AppIndices/app/otbRadiometricIndices.cxx
+++ b/Modules/Applications/AppIndices/app/otbRadiometricIndices.cxx
@@ -157,7 +157,6 @@ private:
     m_Map.push_back({"list.mndwi","Water::MNDWI",new otb::Functor::MNDWI<InputType,OutputType>()});
     m_Map.push_back({"list.ndpi","Water::NDPI",new otb::Functor::NDPI<InputType,OutputType>()});
     m_Map.push_back({"list.ndpi","Water::NDTI",new otb::Functor::NDTI<InputType,OutputType>()});
-    m_Map.push_back({"list.srwi","Water::SRWI",new otb::Functor::SRWI<InputType,OutputType>()});
     m_Map.push_back({"list.si","Soil::RI",new otb::Functor::RI<InputType,OutputType>()});
     m_Map.push_back({"list.ci","Soil::CI",new otb::Functor::CI<InputType,OutputType>()});
     m_Map.push_back({"list.bi","Soil::BI",new otb::Functor::BI<InputType,OutputType>()});
@@ -171,9 +170,9 @@ private:
   }
 
   // Compute required bands for selected indices
-  std::set<otb::Functor::Band> GetRequiredBands()
+  std::set<CommonBandNames> GetRequiredBands()
   {
-    std::set<otb::Functor::Band> required;
+    std::set<CommonBandNames> required;
    
     for (unsigned int idx = 0; idx < GetSelectedItems("list").size(); ++idx)
         {
@@ -197,13 +196,13 @@ private:
     auto requiredBands = GetRequiredBands();
 
     // Map to store association between bands and indices
-    std::map<otb::Functor::Band,size_t> bandIndicesMap;
+    std::map<CommonBandNames,size_t> bandIndicesMap;
 
     // Lambda that will:
     // - Check if band is required,
     // - Check band index range,
     // - Populate the bandIndicesMap
-    auto bandChecker = [this,requiredBands, nbChan] (std::map<otb::Functor::Band, size_t> & indicesMap, const otb::Functor::Band& band, const std::string & key)
+    auto bandChecker = [this,requiredBands, nbChan] (std::map<CommonBandNames, size_t> & indicesMap, const CommonBandNames& band, const std::string & key)
     {
       if(requiredBands.find(band) != requiredBands.end())
         {
@@ -221,11 +220,11 @@ private:
     };
 
     // Call lambda for each possible band
-    bandChecker(bandIndicesMap,otb::Functor::Band::BLUE,"channels.blue");
-    bandChecker(bandIndicesMap,otb::Functor::Band::GREEN,"channels.green");
-    bandChecker(bandIndicesMap,otb::Functor::Band::RED,"channels.red");
-    bandChecker(bandIndicesMap,otb::Functor::Band::NIR,"channels.nir");
-    bandChecker(bandIndicesMap,otb::Functor::Band::MIR,"channels.mir");
+    bandChecker(bandIndicesMap,CommonBandNames::BLUE,"channels.blue");
+    bandChecker(bandIndicesMap,CommonBandNames::GREEN,"channels.green");
+    bandChecker(bandIndicesMap,CommonBandNames::RED,"channels.red");
+    bandChecker(bandIndicesMap,CommonBandNames::NIR,"channels.nir");
+    bandChecker(bandIndicesMap,CommonBandNames::MIR,"channels.mir");
 
     std::vector<RadiometricIndiceType*> indices;
 
diff --git a/Modules/Detection/UrbanArea/include/otbUrbanAreaDetectionImageFilter.h b/Modules/Detection/UrbanArea/include/otbUrbanAreaDetectionImageFilter.h
index 3c0a086473..73c3c13cc2 100644
--- a/Modules/Detection/UrbanArea/include/otbUrbanAreaDetectionImageFilter.h
+++ b/Modules/Detection/UrbanArea/include/otbUrbanAreaDetectionImageFilter.h
@@ -58,12 +58,12 @@ public:
   VegetationFunctorType GetVegetationFunctor(){ return m_VegetationFunctor; }
   WaterFunctorType GetWaterFunctor(){ return m_WaterFunctor; }
 
-  void SetRedIndex(int id){ m_VegetationFunctor.SetBandIndex(otb::Functor::Band::RED,id); }
-  void SetGreenIndex(int id){ m_WaterFunctor.SetBandIndex(otb::Functor::Band::GREEN,id); }
+  void SetRedIndex(int id){ m_VegetationFunctor.SetBandIndex(CommonBandNames::RED,id); }
+  void SetGreenIndex(int id){ m_WaterFunctor.SetBandIndex(CommonBandNames::GREEN,id); }
   void SetNIRIndex(int id)
   {
-    m_VegetationFunctor.SetBandIndex(otb::Functor::Band::NIR,id);
-    m_WaterFunctor.SetBandIndex(otb::Functor::Band::NIR,id);
+    m_VegetationFunctor.SetBandIndex(CommonBandNames::NIR,id);
+    m_WaterFunctor.SetBandIndex(CommonBandNames::NIR,id);
   }
 
   RadiometricNonWaterNonVegetationIndexFunctor(){}
diff --git a/Modules/Radiometry/Indices/include/otbBandName.h b/Modules/Radiometry/Indices/include/otbBandName.h
index 6bd25a144e..cecd2312b4 100644
--- a/Modules/Radiometry/Indices/include/otbBandName.h
+++ b/Modules/Radiometry/Indices/include/otbBandName.h
@@ -30,8 +30,9 @@ namespace BandName
 * Provides a way to identify bands when passing the parameters
 * to the radiometric functors.*
 */
-enum BandName {BLUE, GREEN, RED, NIR, MIR};
-enum LandsatTMBandNames {TM1, TM2, TM3, TM4, TM5, TM60, TM61, TM62, TM7};
+enum class CommonBandNames {BLUE, GREEN, RED, NIR, MIR, MAX};
+enum class ModisBandNames {M860, M1240,MAX};
+enum LandsatTMBandNames {TM1, TM2, TM3, TM4, TM5, TM60, TM61, TM62, TM7, MAX};
 
 // Note for landsat equivalence
 // http://landsat.gsfc.nasa.gov/news/news-archive/sci_0017.html
diff --git a/Modules/Radiometry/Indices/include/otbBuiltUpIndicesFunctor.h b/Modules/Radiometry/Indices/include/otbBuiltUpIndicesFunctor.h
index 6cb3a21eba..fb901b3d67 100644
--- a/Modules/Radiometry/Indices/include/otbBuiltUpIndicesFunctor.h
+++ b/Modules/Radiometry/Indices/include/otbBuiltUpIndicesFunctor.h
@@ -49,12 +49,12 @@ template <class TInput, class TOutput>
 class NDBI : public RadiometricIndice<TInput,TOutput>
 {
 public:
-  NDBI() : RadiometricIndice<TInput,TOutput>("NDBI",{Band::RED, Band::NIR}) {}
+  NDBI() : RadiometricIndice<TInput,TOutput>("NDBI",{CommonBandNames::RED, CommonBandNames::NIR}) {}
 
   TOutput operator()(const itk::VariableLengthVector<TInput> & input) const override
   {
-    auto red = this->Value(Band::RED,input);
-    auto nir = this->Value(Band::NIR,input);
+    auto red = this->Value(CommonBandNames::RED,input);
+    auto nir = this->Value(CommonBandNames::NIR,input);
 
     if (std::abs(red+nir) < EpsilonToBeConsideredAsZero)
       {
@@ -80,12 +80,12 @@ template <class TInput, class TOutput>
 class ISU : public RadiometricIndice<TInput,TOutput>
 {
 public:
-  ISU()  : RadiometricIndice<TInput,TOutput>("ISU",{Band::RED, Band::NIR}) {}
+  ISU()  : RadiometricIndice<TInput,TOutput>("ISU",{CommonBandNames::RED, CommonBandNames::NIR}) {}
 
   TOutput operator()(const itk::VariableLengthVector<TInput> & input) const override
   {
-    auto red = this->Value(Band::RED,input);
-    auto nir = this->Value(Band::NIR,input);
+    auto red = this->Value(CommonBandNames::RED,input);
+    auto nir = this->Value(CommonBandNames::NIR,input);
 
     if (nir == 0)
       {
diff --git a/Modules/Radiometry/Indices/include/otbNDVIDataNodeFeatureFunction.h b/Modules/Radiometry/Indices/include/otbNDVIDataNodeFeatureFunction.h
index ed1dbdfe63..46e7d2c643 100644
--- a/Modules/Radiometry/Indices/include/otbNDVIDataNodeFeatureFunction.h
+++ b/Modules/Radiometry/Indices/include/otbNDVIDataNodeFeatureFunction.h
@@ -97,22 +97,22 @@ public:
   //TODO replace by metadata parsing
   unsigned int GetREDChannelIndex() const
   {
-    return m_NDVIFunctor.GetBandIndex(Functor::Band::RED)+1;
+    return m_NDVIFunctor.GetBandIndex(CommonBandNames::RED)+1;
   }
 
   void SetREDChannelIndex(unsigned int id)
   {
-    m_NDVIFunctor.SetBandIndex(Functor::Band::RED,id-1);
+    m_NDVIFunctor.SetBandIndex(CommonBandNames::RED,id-1);
   }
 
   unsigned int GetNIRChannelIndex() const
   {
-    return m_NDVIFunctor.GetBandIndex(Functor::Band::NIR)+1;
+    return m_NDVIFunctor.GetBandIndex(CommonBandNames::NIR)+1;
   }
 
   void SetNIRChannelIndex(unsigned int id)
   {
-    m_NDVIFunctor.SetBandIndex(Functor::Band::NIR,id-1);
+    m_NDVIFunctor.SetBandIndex(CommonBandNames::NIR,id-1);
   }
 
 protected:
diff --git a/Modules/Radiometry/Indices/include/otbRadiometricIndice.h b/Modules/Radiometry/Indices/include/otbRadiometricIndice.h
index 24ffab5231..9a7eaa02e3 100644
--- a/Modules/Radiometry/Indices/include/otbRadiometricIndice.h
+++ b/Modules/Radiometry/Indices/include/otbRadiometricIndice.h
@@ -22,26 +22,28 @@
 #define otbRadiometricIndice_h
 
 #include "itkVariableLengthVector.h"
+#include "otbBandName.h"
 #include <array>
 #include <set>
 #include <string>
 #include <map>
 
+using namespace otb::BandName;
+
 namespace otb
 {
 namespace Functor
 {
-enum class Band {COASTAL_BLUE, BLUE, GREEN, RED, RED_EDGE, NIR, SWIR, MIR, MODIS_860,MODIS_1240};
-
-constexpr size_t NumberOfBands = 10;
 constexpr double EpsilonToBeConsideredAsZero = 0.0000001;
 
-
-template <typename TInput, typename TOutput>
+template <typename TInput, typename TOutput, typename TBandNameEnum = CommonBandNames>
 class RadiometricIndice
 {
 public:
-  RadiometricIndice(const std::string & name, const std::set<Band>& requiredBands)
+  using BandNameType = TBandNameEnum;
+  static constexpr size_t NumberOfBands = static_cast<size_t>(BandNameType::MAX);
+
+  RadiometricIndice(const std::string & name, const std::set<BandNameType>& requiredBands)
     : m_RequiredBands(),
       m_BandIndices(),
       m_Name(name)
@@ -57,23 +59,23 @@ public:
   
   ~RadiometricIndice() = default;
   
-  std::set<Band> GetRequiredBands() const
+  std::set<BandNameType> GetRequiredBands() const
   {
-    std::set<Band> resp;
+    std::set<BandNameType> resp;
     for(size_t i = 0; i < NumberOfBands; ++i)
       {
-      resp.insert(static_cast<Band>(i));
+      resp.insert(static_cast<BandNameType>(i));
       }
 
     return resp;
   }
 
-  void SetBandIndex(const Band & band, const size_t & index)
+  void SetBandIndex(const BandNameType & band, const size_t & index)
   {
     m_BandIndices[static_cast<size_t>(band)]=index;
   }
 
-  void SetBandsIndices(const std::map<Band,size_t> & indicesMap)
+  void SetBandsIndices(const std::map<BandNameType,size_t> & indicesMap)
   {
     for(auto it: indicesMap)
       {
@@ -81,7 +83,7 @@ public:
       }
   }
 
-  size_t GetBandIndex(const Band & band) const
+  size_t GetBandIndex(const BandNameType & band) const
   {
     return m_BandIndices[static_cast<size_t>(band)];
   }
@@ -95,13 +97,13 @@ public:
  
 
 protected:
-  size_t BandIndex(const Band & band) const
+  size_t BandIndex(const BandNameType & band) const
   {
     // TODO: Assert if this band is really mandatory for this functor    
     return m_BandIndices[static_cast<size_t>(band)];
   }
   
-  double Value(const Band & band, const itk::VariableLengthVector<TInput> & input) const
+  double Value(const BandNameType & band, const itk::VariableLengthVector<TInput> & input) const
   {
     return static_cast<double>(input[BandIndex(band)]);
   }
diff --git a/Modules/Radiometry/Indices/include/otbSoilIndicesFunctor.h b/Modules/Radiometry/Indices/include/otbSoilIndicesFunctor.h
index 99088644dc..c9f71ccb7e 100644
--- a/Modules/Radiometry/Indices/include/otbSoilIndicesFunctor.h
+++ b/Modules/Radiometry/Indices/include/otbSoilIndicesFunctor.h
@@ -46,12 +46,12 @@ template <class TInput, class TOutput>
 class RI : public RadiometricIndice<TInput,TOutput>
 {
 public:
-  RI() : RadiometricIndice<TInput,TOutput>("RI",{Band::RED, Band::GREEN}) {}
+  RI() : RadiometricIndice<TInput,TOutput>("RI",{CommonBandNames::RED, CommonBandNames::GREEN}) {}
 
   TOutput operator()(const itk::VariableLengthVector<TInput> & input) const override  
   {
-    auto green = this->Value(Band::GREEN,input);
-    auto red = this->Value(Band::RED,input);
+    auto green = this->Value(CommonBandNames::GREEN,input);
+    auto red = this->Value(CommonBandNames::RED,input);
   
     if (std::abs(green) < EpsilonToBeConsideredAsZero)
       {
@@ -80,12 +80,12 @@ template <class TInput, class TOutput>
 class CI : public RadiometricIndice<TInput,TOutput>
 {
 public:
-  CI() : RadiometricIndice<TInput,TOutput>("CI",{Band::RED, Band::GREEN}) {}
+  CI() : RadiometricIndice<TInput,TOutput>("CI",{CommonBandNames::RED, CommonBandNames::GREEN}) {}
 
   TOutput operator()(const itk::VariableLengthVector<TInput> & input) const override
   {
-    auto green = this->Value(Band::GREEN,input);
-    auto red = this->Value(Band::RED,input);
+    auto green = this->Value(CommonBandNames::GREEN,input);
+    auto red = this->Value(CommonBandNames::RED,input);
 
     if (std::abs(green + red) < EpsilonToBeConsideredAsZero)
       {
@@ -110,12 +110,12 @@ template <class TInput, class TOutput>
 class BI : public RadiometricIndice<TInput,TOutput>
 {
 public:
-  BI() : RadiometricIndice<TInput,TOutput>("BI",{Band::RED, Band::GREEN}) {}
+  BI() : RadiometricIndice<TInput,TOutput>("BI",{CommonBandNames::RED, CommonBandNames::GREEN}) {}
 
   TOutput operator()(const itk::VariableLengthVector<TInput> & input) const override
   {
-    auto green = this->Value(Band::GREEN,input);
-    auto red = this->Value(Band::RED,input);
+    auto green = this->Value(CommonBandNames::GREEN,input);
+    auto red = this->Value(CommonBandNames::RED,input);
 
     return (static_cast<TOutput>(std::sqrt((red * red + green * green) / 2.)));
   }
@@ -136,13 +136,13 @@ class BI2 : public RadiometricIndice<TInput,TOutput>
 {
 public:
   
-  BI2() : RadiometricIndice<TInput,TOutput>("BI2",{Band::RED, Band::GREEN, Band::NIR}) {}
+  BI2() : RadiometricIndice<TInput,TOutput>("BI2",{CommonBandNames::RED, CommonBandNames::GREEN, CommonBandNames::NIR}) {}
  
  TOutput operator()(const itk::VariableLengthVector<TInput> & input) const override
   {
-    auto green = this->Value(Band::GREEN,input);
-    auto red = this->Value(Band::RED,input);
-    auto nir = this->Value(Band::NIR,input);
+    auto green = this->Value(CommonBandNames::GREEN,input);
+    auto red = this->Value(CommonBandNames::RED,input);
+    auto nir = this->Value(CommonBandNames::NIR,input);
 
     return (static_cast<TOutput>(std::sqrt((red * red + green * green + nir * nir) / 3.)));
   }
diff --git a/Modules/Radiometry/Indices/include/otbVegetationIndicesFunctor.h b/Modules/Radiometry/Indices/include/otbVegetationIndicesFunctor.h
index 7aed54506b..fcd1a15f0f 100644
--- a/Modules/Radiometry/Indices/include/otbVegetationIndicesFunctor.h
+++ b/Modules/Radiometry/Indices/include/otbVegetationIndicesFunctor.h
@@ -43,12 +43,12 @@ template <class TInput, class TOutput>
 class NDVI : public RadiometricIndice<TInput,TOutput>
 {
 public:
-  NDVI() : RadiometricIndice<TInput,TOutput>("NDVI",{Band::RED, Band::NIR}) {}
+  NDVI() : RadiometricIndice<TInput,TOutput>("NDVI",{CommonBandNames::RED, CommonBandNames::NIR}) {}
 
   TOutput operator()(const itk::VariableLengthVector<TInput> & input) const override
   {
-    auto red = this->Value(Band::RED,input);
-    auto nir = this->Value(Band::NIR,input);
+    auto red = this->Value(CommonBandNames::RED,input);
+    auto nir = this->Value(CommonBandNames::NIR,input);
 
     return static_cast<TOutput>(Compute(red,nir));
   }  
@@ -80,12 +80,12 @@ template <class TInput, class TOutput>
 class RVI : public RadiometricIndice<TInput,TOutput> 
 {
 public:
-  RVI() : RadiometricIndice<TInput,TOutput>("RVI",{Band::RED, Band::NIR}) {}
+  RVI() : RadiometricIndice<TInput,TOutput>("RVI",{CommonBandNames::RED, CommonBandNames::NIR}) {}
 
   TOutput operator()(const itk::VariableLengthVector<TInput> & input) const override
   {
-    auto red = this->Value(Band::RED,input);
-    auto nir = this->Value(Band::NIR,input);
+    auto red = this->Value(CommonBandNames::RED,input);
+    auto nir = this->Value(CommonBandNames::NIR,input);
 
     if (std::abs(red)  < EpsilonToBeConsideredAsZero)
       {
@@ -113,12 +113,12 @@ template <class TInput, class TOutput>
 class PVI : public RadiometricIndice<TInput,TOutput>
 {
 public:
-  PVI() : RadiometricIndice<TInput,TOutput>("PVI",{Band::RED, Band::NIR}) {}
+  PVI() : RadiometricIndice<TInput,TOutput>("PVI",{CommonBandNames::RED, CommonBandNames::NIR}) {}
 
   TOutput operator()(const itk::VariableLengthVector<TInput> & input) const override
   {
-    auto red = this->Value(Band::RED,input);
-    auto nir = this->Value(Band::NIR,input);
+    auto red = this->Value(CommonBandNames::RED,input);
+    auto nir = this->Value(CommonBandNames::NIR,input);
 
     return (static_cast<TOutput>((nir - A * red - B) * C));
   }
@@ -144,12 +144,12 @@ template <class TInput, class TOutput>
 class SAVI : public RadiometricIndice<TInput,TOutput>
 {
 public:
-  SAVI() : RadiometricIndice<TInput,TOutput>("SAVI",{Band::RED, Band::NIR}) {}
+  SAVI() : RadiometricIndice<TInput,TOutput>("SAVI",{CommonBandNames::RED, CommonBandNames::NIR}) {}
 
   TOutput operator()(const itk::VariableLengthVector<TInput> & input) const override
   {
-    auto red = this->Value(Band::RED,input);
-    auto nir = this->Value(Band::NIR,input);
+    auto red = this->Value(CommonBandNames::RED,input);
+    auto nir = this->Value(CommonBandNames::NIR,input);
 
     if (std::abs(nir + red + L)  < EpsilonToBeConsideredAsZero)
       {
@@ -177,12 +177,12 @@ template <class TInput, class TOutput>
 class TSAVI : public RadiometricIndice<TInput,TOutput>
 {
 public:
-  TSAVI() : RadiometricIndice<TInput,TOutput>("TSAVI",{Band::RED, Band::NIR}) {}
+  TSAVI() : RadiometricIndice<TInput,TOutput>("TSAVI",{CommonBandNames::RED, CommonBandNames::NIR}) {}
 
   TOutput operator()(const itk::VariableLengthVector<TInput> & input) const override
   {
-    auto red = this->Value(Band::RED,input);
-    auto nir = this->Value(Band::NIR,input);
+    auto red = this->Value(CommonBandNames::RED,input);
+    auto nir = this->Value(CommonBandNames::NIR,input);
 
     double denominator = A * nir + red + X * (1. + A * A);
 
@@ -215,12 +215,12 @@ class WDVI : public RadiometricIndice<TInput,TOutput>
 {
 public:
   /// Constructor
-  WDVI() : RadiometricIndice<TInput,TOutput>("WDVI",{Band::RED, Band::NIR}) {}
+  WDVI() : RadiometricIndice<TInput,TOutput>("WDVI",{CommonBandNames::RED, CommonBandNames::NIR}) {}
 
   TOutput operator()(const itk::VariableLengthVector<TInput> & input) const override
   {
-    auto red = this->Value(Band::RED,input);
-    auto nir = this->Value(Band::NIR,input);
+    auto red = this->Value(CommonBandNames::RED,input);
+    auto nir = this->Value(CommonBandNames::NIR,input);
 
     return static_cast<TOutput>(Compute(red,nir));
   }
@@ -249,12 +249,12 @@ template <class TInput, class TOutput>
 class MSAVI : public RadiometricIndice<TInput,TOutput>
 {
 public:
-  MSAVI() : RadiometricIndice<TInput,TOutput>("MSAVI",{Band::RED, Band::NIR}) {}
+  MSAVI() : RadiometricIndice<TInput,TOutput>("MSAVI",{CommonBandNames::RED, CommonBandNames::NIR}) {}
 
   TOutput operator()(const itk::VariableLengthVector<TInput> & input) const override
   {
-    auto red = this->Value(Band::RED,input);
-    auto nir = this->Value(Band::NIR,input);
+    auto red = this->Value(CommonBandNames::RED,input);
+    auto nir = this->Value(CommonBandNames::NIR,input);
 
     double ndvi = NDVI<TInput,TOutput>::Compute(red,nir);
     double wdvi = WDVI<TInput,TOutput>::Compute(red, nir);
@@ -291,12 +291,12 @@ class MSAVI2 : public RadiometricIndice<TInput,TOutput>
 {
 public:
 
-  MSAVI2() : RadiometricIndice<TInput,TOutput>("MSAVI2",{Band::RED, Band::NIR}) {}
+  MSAVI2() : RadiometricIndice<TInput,TOutput>("MSAVI2",{CommonBandNames::RED, CommonBandNames::NIR}) {}
 
   TOutput operator()(const itk::VariableLengthVector<TInput> & input) const override
   {
-    auto red = this->Value(Band::RED,input);
-    auto nir = this->Value(Band::NIR,input);
+    auto red = this->Value(CommonBandNames::RED,input);
+    auto nir = this->Value(CommonBandNames::NIR,input);
 
     double sqrt_value = (2 * nir + 1) * (2 * nir + 1) - 8 * (nir - red);
     if (sqrt_value < 0.)
@@ -322,12 +322,12 @@ template <class TInput, class TOutput>
 class GEMI : public RadiometricIndice<TInput,TOutput>
 {
 public:
-  GEMI() : RadiometricIndice<TInput,TOutput>("GEMI",{Band::RED, Band::NIR}) {}
+  GEMI() : RadiometricIndice<TInput,TOutput>("GEMI",{CommonBandNames::RED, CommonBandNames::NIR}) {}
 
   TOutput operator()(const itk::VariableLengthVector<TInput> & input) const override
   {
-    auto red = this->Value(Band::RED,input);
-    auto nir = this->Value(Band::NIR,input);
+    auto red = this->Value(CommonBandNames::RED,input);
+    auto nir = this->Value(CommonBandNames::NIR,input);
 
     double nu;
     double num_nu;
@@ -369,13 +369,13 @@ template <class TInput, class TOutput>
 class AVI: public RadiometricIndice<TInput,TOutput>
 {
 public:
-  AVI() : RadiometricIndice<TInput,TOutput>("AVI",{Band::GREEN, Band::RED, Band::NIR}) {}
+  AVI() : RadiometricIndice<TInput,TOutput>("AVI",{CommonBandNames::GREEN, CommonBandNames::RED, CommonBandNames::NIR}) {}
 
   TOutput operator()(const itk::VariableLengthVector<TInput> & input) const override
   {
-    auto green = this->Value(Band::GREEN,input);
-    auto red   = this->Value(Band::RED,input);
-    auto nir   = this->Value(Band::NIR,input);
+    auto green = this->Value(CommonBandNames::GREEN,input);
+    auto red   = this->Value(CommonBandNames::RED,input);
+    auto nir   = this->Value(CommonBandNames::NIR,input);
 
     constexpr double dfact1 = (LambdaNir - LambdaR) / LambdaR;
     constexpr double dfact2 = (LambdaR - LambdaG) / LambdaR;
@@ -430,13 +430,13 @@ class ARVI : public RadiometricIndice<TInput,TOutput>
 {
 public:
 
-  ARVI(): RadiometricIndice<TInput,TOutput>("ARVI",{Band::BLUE, Band::RED, Band::NIR}) {}
+  ARVI(): RadiometricIndice<TInput,TOutput>("ARVI",{CommonBandNames::BLUE, CommonBandNames::RED, CommonBandNames::NIR}) {}
 
   TOutput operator()(const itk::VariableLengthVector<TInput> & input) const override
   {
-    auto blue  = this->Value(Band::BLUE,input);
-    auto red   = this->Value(Band::RED,input);
-    auto nir   = this->Value(Band::NIR,input);
+    auto blue  = this->Value(CommonBandNames::BLUE,input);
+    auto red   = this->Value(CommonBandNames::RED,input);
+    auto nir   = this->Value(CommonBandNames::NIR,input);
 
     double RHOrb = red - Gamma * (blue - red);
     double denominator = nir + RHOrb;
@@ -466,13 +466,13 @@ class TSARVI : public RadiometricIndice<TInput,TOutput>
 {
 public:
 
-  TSARVI() : RadiometricIndice<TInput,TOutput>("TSARVI",{Band::BLUE, Band::RED, Band::NIR}) {}
+  TSARVI() : RadiometricIndice<TInput,TOutput>("TSARVI",{CommonBandNames::BLUE, CommonBandNames::RED, CommonBandNames::NIR}) {}
 
   TOutput operator()(const itk::VariableLengthVector<TInput> & input) const override
   {
-    auto blue  = this->Value(Band::BLUE,input);
-    auto red   = this->Value(Band::RED,input);
-    auto nir   = this->Value(Band::NIR,input);
+    auto blue  = this->Value(CommonBandNames::BLUE,input);
+    auto red   = this->Value(CommonBandNames::RED,input);
+    auto nir   = this->Value(CommonBandNames::NIR,input);
 
     double dRB = red - Gamma * (blue - red);
     double denominator = dRB + A * nir - A * B + X * (1. + A * A);
@@ -510,13 +510,13 @@ class EVI : public RadiometricIndice<TInput,TOutput>
 {
 public:
 
-  EVI() : RadiometricIndice<TInput,TOutput>("EVI",{Band::BLUE, Band::RED, Band::NIR}) {}
+  EVI() : RadiometricIndice<TInput,TOutput>("EVI",{CommonBandNames::BLUE, CommonBandNames::RED, CommonBandNames::NIR}) {}
 
   TOutput operator()(const itk::VariableLengthVector<TInput> & input) const override
   {
-    auto blue  = this->Value(Band::BLUE,input);
-    auto red   = this->Value(Band::RED,input);
-    auto nir   = this->Value(Band::NIR,input);
+    auto blue  = this->Value(CommonBandNames::BLUE,input);
+    auto red   = this->Value(CommonBandNames::RED,input);
+    auto nir   = this->Value(CommonBandNames::NIR,input);
 
     double denominator = nir + C1 * red - C2 * blue + L;
     if (std::abs(denominator) < EpsilonToBeConsideredAsZero)
@@ -553,12 +553,12 @@ template <class TInput, class TOutput>
 class IPVI : public RadiometricIndice<TInput,TOutput>
 {
 public:
-  IPVI() : RadiometricIndice<TInput,TOutput>("IPVI",{Band::RED, Band::NIR}) {}
+  IPVI() : RadiometricIndice<TInput,TOutput>("IPVI",{CommonBandNames::RED, CommonBandNames::NIR}) {}
 
   TOutput operator()(const itk::VariableLengthVector<TInput> & input) const override
   {
-    auto red   = this->Value(Band::RED,input);
-    auto nir   = this->Value(Band::NIR,input);
+    auto red   = this->Value(CommonBandNames::RED,input);
+    auto nir   = this->Value(CommonBandNames::NIR,input);
 
     if (std::abs(nir + red)  < EpsilonToBeConsideredAsZero)
       {
@@ -585,12 +585,12 @@ template <class TInput, class TOutput>
 class TNDVI : public RadiometricIndice<TInput,TOutput>
 {
 public:
-  TNDVI() : RadiometricIndice<TInput,TOutput>("TNDVI",{Band::RED, Band::NIR}) {}
+  TNDVI() : RadiometricIndice<TInput,TOutput>("TNDVI",{CommonBandNames::RED, CommonBandNames::NIR}) {}
 
   TOutput operator()(const itk::VariableLengthVector<TInput> & input) const override
   {
-    auto red   = this->Value(Band::RED,input);
-    auto nir   = this->Value(Band::NIR,input);
+    auto red   = this->Value(CommonBandNames::RED,input);
+    auto nir   = this->Value(CommonBandNames::NIR,input);
 
     double val = NDVI<TInput,TOutput>::Compute(red,nir) + 0.5;
 
@@ -625,7 +625,7 @@ template <class TInput, class TOutput>
 class LAIFromNDVILogarithmic : public RadiometricIndice<TInput,TOutput>
 {
 public:
-  LAIFromNDVILogarithmic() : RadiometricIndice<TInput,TOutput>("LAIFromNDVILogarithmic",{Band::RED, Band::NIR}),
+  LAIFromNDVILogarithmic() : RadiometricIndice<TInput,TOutput>("LAIFromNDVILogarithmic",{CommonBandNames::RED, CommonBandNames::NIR}),
                              m_NdviSoil(0.1),
                              m_NdviInf(0.89),
                              m_ExtinctionCoefficient(0.71) {}
@@ -662,8 +662,8 @@ public:
 
   TOutput operator()(const itk::VariableLengthVector<TInput> & input) const override
   {
-    auto red   = this->Value(Band::RED,input);
-    auto nir   = this->Value(Band::NIR,input);
+    auto red   = this->Value(CommonBandNames::RED,input);
+    auto nir   = this->Value(CommonBandNames::NIR,input);
 
     double val = NDVI<TInput,TOutput>::Compute(red,nir);
 
@@ -707,7 +707,7 @@ class LAIFromReflectancesLinear : public RadiometricIndice<TInput,TOutput>
 public:
 
 
-  LAIFromReflectancesLinear() : RadiometricIndice<TInput,TOutput>("LAIFromReflectanceLinear",{Band::RED, Band::NIR}),
+  LAIFromReflectancesLinear() : RadiometricIndice<TInput,TOutput>("LAIFromReflectanceLinear",{CommonBandNames::RED, CommonBandNames::NIR}),
                                 m_RedCoef(-17.91),
                                 m_NirCoef(12.26) {}
 
@@ -733,8 +733,8 @@ public:
 
   TOutput operator()(const itk::VariableLengthVector<TInput> & input) const override
   {
-    auto red   = this->Value(Band::RED,input);
-    auto nir   = this->Value(Band::NIR,input);
+    auto red   = this->Value(CommonBandNames::RED,input);
+    auto nir   = this->Value(CommonBandNames::NIR,input);
 
     return (static_cast<TOutput>(m_RedCoef*red+m_NirCoef*nir));
   }
@@ -768,12 +768,12 @@ public:
   {
   public:
     
-    LAIFromNDVIFormosat2Functor(): RadiometricIndice<TInput,TOutput>("LAIFromNDVIFormosat2",{Band::RED, Band::NIR}) {}
+    LAIFromNDVIFormosat2Functor(): RadiometricIndice<TInput,TOutput>("LAIFromNDVIFormosat2",{CommonBandNames::RED, CommonBandNames::NIR}) {}
     
     TOutput operator()(const itk::VariableLengthVector<TInput> & input) const override
     {
-      auto red   = this->Value(Band::RED,input);
-      auto nir   = this->Value(Band::NIR,input);
+      auto red   = this->Value(CommonBandNames::RED,input);
+      auto nir   = this->Value(CommonBandNames::NIR,input);
 
       if (std::abs(nir + red) < EpsilonToBeConsideredAsZero)
         {
diff --git a/Modules/Radiometry/Indices/include/otbWaterIndicesFunctor.h b/Modules/Radiometry/Indices/include/otbWaterIndicesFunctor.h
index ef84fb0f1f..efd780d91a 100644
--- a/Modules/Radiometry/Indices/include/otbWaterIndicesFunctor.h
+++ b/Modules/Radiometry/Indices/include/otbWaterIndicesFunctor.h
@@ -41,16 +41,16 @@ namespace Functor
  * \ingroup OTBIndices
  */
 template <class TInput, class TOutput>
-class SRWI : public RadiometricIndice<TInput,TOutput>
+class SRWI : public RadiometricIndice<TInput,TOutput,ModisBandNames>
 {
 public:
 
-  SRWI() : RadiometricIndice<TInput,TOutput>("SRWI",{Band::MODIS_860, Band::MODIS_1240}) {}
+  SRWI() : RadiometricIndice<TInput,TOutput>("SRWI",{ModisBandNames::M860, ModisBandNames::M1240}) {}
 
   TOutput operator()(const itk::VariableLengthVector<TInput> & input) const override
   {
-    double rho860 = this->Value(Band::MODIS_860,input);
-    double rho1240 = this->Value(Band::MODIS_1240,input);
+    double rho860 = this->Value(ModisBandNames::M860,input);
+    double rho1240 = this->Value(ModisBandNames::M1240,input);
     if (std::abs(rho1240) < EpsilonToBeConsideredAsZero)
       {
       return static_cast<TOutput>(0.);
@@ -78,12 +78,12 @@ class NDWI : public RadiometricIndice<TInput,TOutput>
 {
 public:
 
-  NDWI(): RadiometricIndice<TInput,TOutput>("NDWI",{Band::NIR, Band::MIR}) {}
+  NDWI(): RadiometricIndice<TInput,TOutput>("NDWI",{CommonBandNames::NIR, CommonBandNames::MIR}) {}
 
   TOutput operator()(const itk::VariableLengthVector<TInput> & input) const override
   {
-    auto mir   = this->Value(Band::MIR,input);
-    auto nir   = this->Value(Band::NIR,input);
+    auto mir   = this->Value(CommonBandNames::MIR,input);
+    auto nir   = this->Value(CommonBandNames::NIR,input);
 
         if (std::abs(nir + mir) < EpsilonToBeConsideredAsZero)
       {
@@ -109,12 +109,12 @@ class NDWI2 : public RadiometricIndice<TInput,TOutput>
 {
 public:
 
-  NDWI2() : RadiometricIndice<TInput,TOutput>("NDWI2",{Band::NIR, Band::GREEN}) {}
+  NDWI2() : RadiometricIndice<TInput,TOutput>("NDWI2",{CommonBandNames::NIR, CommonBandNames::GREEN}) {}
 
   TOutput operator()(const itk::VariableLengthVector<TInput> & input) const override
   {
-    auto green   = this->Value(Band::GREEN,input);
-    auto nir   = this->Value(Band::NIR,input);
+    auto green   = this->Value(CommonBandNames::GREEN,input);
+    auto nir   = this->Value(CommonBandNames::NIR,input);
 
     if (std::abs(nir + green) < EpsilonToBeConsideredAsZero)
       {
@@ -139,12 +139,12 @@ template <class TInput, class TOutput>
 class MNDWI : public RadiometricIndice<TInput,TOutput>
 {
 public:
-  MNDWI() : RadiometricIndice<TInput,TOutput>("MNDWI",{Band::MIR, Band::GREEN}) {}
+  MNDWI() : RadiometricIndice<TInput,TOutput>("MNDWI",{CommonBandNames::MIR, CommonBandNames::GREEN}) {}
 
   TOutput operator()(const itk::VariableLengthVector<TInput> & input) const override
   {
-    auto green   = this->Value(Band::GREEN,input);
-    auto mir   = this->Value(Band::MIR,input);
+    auto green   = this->Value(CommonBandNames::GREEN,input);
+    auto mir   = this->Value(CommonBandNames::MIR,input);
 
     if (std::abs(mir + green) < EpsilonToBeConsideredAsZero)
       {
@@ -169,12 +169,12 @@ template <class TInput, class TOutput>
 class NDPI : public RadiometricIndice<TInput,TOutput>
 {
 public:
-  NDPI() : RadiometricIndice<TInput,TOutput>("NDPI",{Band::MIR, Band::GREEN}) {}
+  NDPI() : RadiometricIndice<TInput,TOutput>("NDPI",{CommonBandNames::MIR, CommonBandNames::GREEN}) {}
 
   TOutput operator()(const itk::VariableLengthVector<TInput> & input) const override
   {
-    auto green   = this->Value(Band::GREEN,input);
-    auto mir   = this->Value(Band::MIR,input);
+    auto green   = this->Value(CommonBandNames::GREEN,input);
+    auto mir   = this->Value(CommonBandNames::MIR,input);
 
     if (std::abs(mir + green) < EpsilonToBeConsideredAsZero)
       {
@@ -200,12 +200,12 @@ class NDTI : public RadiometricIndice<TInput,TOutput>
 {
 public:
 
-  NDTI() : RadiometricIndice<TInput,TOutput>("NDPI",{Band::RED, Band::GREEN}) {}
+  NDTI() : RadiometricIndice<TInput,TOutput>("NDPI",{CommonBandNames::RED, CommonBandNames::GREEN}) {}
 
   TOutput operator()(const itk::VariableLengthVector<TInput> & input) const override
   {
-    auto green = this->Value(Band::GREEN,input);
-    auto red   = this->Value(Band::RED,input);
+    auto green = this->Value(CommonBandNames::GREEN,input);
+    auto red   = this->Value(CommonBandNames::RED,input);
 
     if (std::abs(red + green) < EpsilonToBeConsideredAsZero)
       {
diff --git a/Modules/Radiometry/Indices/test/otbLAIFromNDVILogarithmicFunctorTest.cxx b/Modules/Radiometry/Indices/test/otbLAIFromNDVILogarithmicFunctorTest.cxx
index 5a7fedf5d8..2c5ac9ddb9 100644
--- a/Modules/Radiometry/Indices/test/otbLAIFromNDVILogarithmicFunctorTest.cxx
+++ b/Modules/Radiometry/Indices/test/otbLAIFromNDVILogarithmicFunctorTest.cxx
@@ -44,8 +44,8 @@ int otbLAIFromNDVILogarithmic(int itkNotUsed(argc), char * argv[])
   laiFunct.SetNdviSoil(ndviSoil);
   laiFunct.SetExtinctionCoefficient(extCoef);
 
-  laiFunct.SetBandIndex(Band::RED,1);
-  laiFunct.SetBandIndex(Band::NIR,2);
+  laiFunct.SetBandIndex(CommonBandNames::RED,1);
+  laiFunct.SetBandIndex(CommonBandNames::NIR,2);
 
   itk::VariableLengthVector<PixelType> pixel;
   pixel.Reserve(2);
diff --git a/Modules/Radiometry/Indices/test/otbLAIFromReflectancesLinearFunctorTest.cxx b/Modules/Radiometry/Indices/test/otbLAIFromReflectancesLinearFunctorTest.cxx
index 601896a8b0..70d3c75f74 100644
--- a/Modules/Radiometry/Indices/test/otbLAIFromReflectancesLinearFunctorTest.cxx
+++ b/Modules/Radiometry/Indices/test/otbLAIFromReflectancesLinearFunctorTest.cxx
@@ -41,8 +41,9 @@ int otbLAIFromReflectancesLinear(int itkNotUsed(argc), char * argv[])
   laiFunct.SetRedCoef(redCoef);
   laiFunct.SetNirCoef(nirCoef);
 
-  laiFunct.SetBandIndex(Band::RED,1);
-  laiFunct.SetBandIndex(Band::NIR,2);
+  laiFunct.SetBandIndex(CommonBandNames::RED,1);
+  laiFunct.SetBandIndex(CommonBandNames
+::NIR,2);
 
   itk::VariableLengthVector<PixelType> pixel;
   pixel.Reserve(2);
diff --git a/Modules/Radiometry/Simulation/include/otbReduceSpectralResponseClassifierRAndNIR.hxx b/Modules/Radiometry/Simulation/include/otbReduceSpectralResponseClassifierRAndNIR.hxx
index 08d1b1701e..4a35909046 100644
--- a/Modules/Radiometry/Simulation/include/otbReduceSpectralResponseClassifierRAndNIR.hxx
+++ b/Modules/Radiometry/Simulation/include/otbReduceSpectralResponseClassifierRAndNIR.hxx
@@ -53,8 +53,8 @@ namespace otb
     itk::VariableLengthVector<ValuePrecisionType> sr(2);
     sr[0]=(*m_InputReduceSpectralResponse)(m_RBandNumber);
     sr[1]=(*m_InputReduceSpectralResponse)(m_NIRBandNumber);
-    m_Functor.SetBandIndex(otb::Functor::Band::RED,0);
-    m_Functor.SetBandIndex(otb::Functor::Band::NIR,1);
+    m_Functor.SetBandIndex(CommonBandNames::RED,0);
+    m_Functor.SetBandIndex(CommonBandNames::NIR,1);
 
     return m_Functor(sr);
   }
-- 
GitLab