diff --git a/Data/Baseline/Examples/Radiometry/ARVIMultiChannelRAndBAndNIRVegetationIndex.tif b/Data/Baseline/Examples/Radiometry/ARVIMultiChannelRAndBAndNIRVegetationIndex.tif index 0225c9d196f05cec5b484ecdcc45a096f2f3ce03..4361cfbb8aafbcc98f9c8ac99e40739f62f9aaf1 100644 --- a/Data/Baseline/Examples/Radiometry/ARVIMultiChannelRAndBAndNIRVegetationIndex.tif +++ b/Data/Baseline/Examples/Radiometry/ARVIMultiChannelRAndBAndNIRVegetationIndex.tif @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:42df562a687bdf13d65cacc6da48666b28da72efa79d7d668e607cf82eba4c11 -size 68855 +oid sha256:91667b86ce412524444bde780eee2c7f0baff0c05ecdc5b66a49aca39bc60dda +size 65842 diff --git a/Examples/Radiometry/ARVIMultiChannelRAndBAndNIRVegetationIndexImageFilter.cxx b/Examples/Radiometry/ARVIMultiChannelRAndBAndNIRVegetationIndexImageFilter.cxx index 6fdd9cfce92dbd42829e8a8da03e086ac7ce0c5a..8f0f2d304f9da22018aaca1248d5112069b2f6a0 100644 --- a/Examples/Radiometry/ARVIMultiChannelRAndBAndNIRVegetationIndexImageFilter.cxx +++ b/Examples/Radiometry/ARVIMultiChannelRAndBAndNIRVegetationIndexImageFilter.cxx @@ -134,7 +134,7 @@ int main(int argc, char* argv[]) // The three used index bands (red, blue and NIR) are declared. filter->GetFunctor().SetBandIndex(CommonBandNames::RED,::atoi(argv[5])); - filter->GetFunctor().SetBandIndex(CommonBandNames::GREEN,::atoi(argv[6])); + filter->GetFunctor().SetBandIndex(CommonBandNames::BLUE,::atoi(argv[6])); filter->GetFunctor().SetBandIndex(CommonBandNames::NIR,::atoi(argv[7])); // The filter input is linked to the reader output and diff --git a/Modules/Applications/AppIndices/app/otbRadiometricIndices.cxx b/Modules/Applications/AppIndices/app/otbRadiometricIndices.cxx index 67f911d2fb2eac56a73651a961f02dafeb0eadee..535285cab4010a4969c9461ef29ef2b9429c521e 100644 --- a/Modules/Applications/AppIndices/app/otbRadiometricIndices.cxx +++ b/Modules/Applications/AppIndices/app/otbRadiometricIndices.cxx @@ -94,18 +94,27 @@ private: AddParameter(ParameterType_Int, "channels.blue", "Blue Channel"); SetParameterDescription("channels.blue", "Blue channel index"); SetDefaultParameterInt("channels.blue", 1); + SetMinimumParameterIntValue("channels.blue",1); + AddParameter(ParameterType_Int, "channels.green", "Green Channel"); SetParameterDescription("channels.green", "Green channel index"); SetDefaultParameterInt("channels.green", 1); + SetMinimumParameterIntValue("channels.green",1); + AddParameter(ParameterType_Int, "channels.red", "Red Channel"); SetParameterDescription("channels.red", "Red channel index"); SetDefaultParameterInt("channels.red", 1); + SetMinimumParameterIntValue("channels.red",1); + AddParameter(ParameterType_Int, "channels.nir", "NIR Channel"); SetParameterDescription("channels.nir", "NIR channel index"); SetDefaultParameterInt("channels.nir", 1); + SetMinimumParameterIntValue("channels.nir",1); + AddParameter(ParameterType_Int, "channels.mir", "Mir Channel"); SetParameterDescription("channels.mir", "Mir channel index"); SetDefaultParameterInt("channels.mir", 1); + SetMinimumParameterIntValue("channels.mir",1); AddParameter(ParameterType_ListView, "list", "Available Radiometric Indices"); SetParameterDescription("list", @@ -212,7 +221,7 @@ private: } else { - indicesMap[band] = idx-1; + indicesMap[band] = idx; } } }; diff --git a/Modules/Radiometry/Indices/include/otbNDVIDataNodeFeatureFunction.h b/Modules/Radiometry/Indices/include/otbNDVIDataNodeFeatureFunction.h index 46e7d2c643d044020765ee969849e4afc04f73a7..1097860300f54ec0230ffb0472767088d73ea963 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(CommonBandNames::RED)+1; + return m_NDVIFunctor.GetBandIndex(CommonBandNames::RED); } void SetREDChannelIndex(unsigned int id) { - m_NDVIFunctor.SetBandIndex(CommonBandNames::RED,id-1); + m_NDVIFunctor.SetBandIndex(CommonBandNames::RED,id); } unsigned int GetNIRChannelIndex() const { - return m_NDVIFunctor.GetBandIndex(CommonBandNames::NIR)+1; + return m_NDVIFunctor.GetBandIndex(CommonBandNames::NIR); } void SetNIRChannelIndex(unsigned int id) { - m_NDVIFunctor.SetBandIndex(CommonBandNames::NIR,id-1); + m_NDVIFunctor.SetBandIndex(CommonBandNames::NIR,id); } protected: diff --git a/Modules/Radiometry/Indices/include/otbRadiometricIndice.h b/Modules/Radiometry/Indices/include/otbRadiometricIndice.h index 28d8ce7fb921b7506921d7f99f1ad2a735b82a58..dc45c9d0c8f8c76f13f5889d8b3086a6e2a9b115 100644 --- a/Modules/Radiometry/Indices/include/otbRadiometricIndice.h +++ b/Modules/Radiometry/Indices/include/otbRadiometricIndice.h @@ -117,7 +117,7 @@ public: /** * \param band The band to set (value in TBandNameEnum) - * \param index The index of the band to set + * \param index The index of the band to set (starts at 1 for first band) * \throw runtime_error if band is TBandNameEnum::MAX */ void SetBandIndex(const BandNameType & band, const size_t & index) @@ -131,7 +131,7 @@ public: /** * \param indicesMap a std::map<TBandNameEnum,size_t> containing all - * bands indices to set + * bands indices to set (starts at 1 for first band) * \throw runtime_error if indicesMap contains TBandNameEnum::MAX */ void SetBandsIndices(const std::map<BandNameType,size_t> & indicesMap) @@ -160,7 +160,7 @@ public: * Astract method which will compute the radiometric indice * \param input A itk::VariableLengthVector<TInput> holding the * pixel values for each band - * \return The indice value as TOutput + * \return The indice value as TOutput (starts at 1 for first band) */ virtual TOutput operator()(const itk::VariableLengthVector<TInput> & input) const = 0; @@ -201,7 +201,7 @@ protected: double Value(const BandNameType & band, const itk::VariableLengthVector<TInput> & input) const { assert(m_RequiredBands[band] && "Retrieving value for a band that is not in the required bands list"); - return static_cast<double>(input[UncheckedBandIndex(band)]); + return static_cast<double>(input[UncheckedBandIndex(band)-1]); } private: diff --git a/Modules/Radiometry/Indices/include/otbVegetationIndicesFunctor.h b/Modules/Radiometry/Indices/include/otbVegetationIndicesFunctor.h index 3e7fc70ddeb5686cbfe4ae50fb06f7990bf443b5..860cf367a74cb758f5c87ab2a861dbc8ad7a8041 100644 --- a/Modules/Radiometry/Indices/include/otbVegetationIndicesFunctor.h +++ b/Modules/Radiometry/Indices/include/otbVegetationIndicesFunctor.h @@ -737,8 +737,7 @@ public: { return static_cast<TOutput>(0.); } - - return static_cast<TOutput>(A*((std::exp((nir-red)/((red+nir)*B))-std::exp(C*B)))); + return static_cast<TOutput>(A*(std::exp((nir-red)/(red+nir)*B)-std::exp(C*B))); } static constexpr double A = 0.1519; diff --git a/Modules/Radiometry/Indices/test/otbRadiometricIndicesTest.cxx b/Modules/Radiometry/Indices/test/otbRadiometricIndicesTest.cxx index 2b2a083f8ef9051f9201d8116fc7a00ca872cb6a..853d37297090b62c035f4b78f3dc61b00d0bf8d4 100644 --- a/Modules/Radiometry/Indices/test/otbRadiometricIndicesTest.cxx +++ b/Modules/Radiometry/Indices/test/otbRadiometricIndicesTest.cxx @@ -68,7 +68,7 @@ using namespace otb::Functor; int otbVegetationIndicesTest(int, char**) { - const std::map<CommonBandNames,size_t> bandMap = {{CommonBandNames::BLUE,0},{CommonBandNames::GREEN,1},{CommonBandNames::RED,2},{CommonBandNames::NIR,3}}; + const std::map<CommonBandNames,size_t> bandMap = {{CommonBandNames::BLUE,1},{CommonBandNames::GREEN,2},{CommonBandNames::RED,3},{CommonBandNames::NIR,4}}; // Syntax: CheckResult<Indice Class>("test_name",bandMap,{red_value,nir_value},expected_result) bool res = CheckResult< NDVI<int,double> >("ndvi_null ",bandMap,{0,0,0,0},0.); @@ -90,7 +90,7 @@ int otbVegetationIndicesTest(int, char**) res = res & CheckResult< IPVI<int,double> >("ipvi_pixel",bandMap,{0,0,1,2},0.6666666667); res = res & CheckResult< LAIFromNDVILogarithmic<int,double> >("lailog_pixel",bandMap,{0,0,1,2},0.4930511672); res = res & CheckResult< LAIFromReflectancesLinear<int,double> >("lailog_pixel",bandMap,{0,0,1,2},6.61); - res = res & CheckResult< LAIFromNDVIFormosat2Functor<int,double> >("laifrom_pixel",bandMap,{0,0,1,2},-0.08836147592); + res = res & CheckResult< LAIFromNDVIFormosat2Functor<int,double> >("laifrom_pixel",bandMap,{0,0,1,2},0.3120010659); if(res) { @@ -104,7 +104,7 @@ int otbVegetationIndicesTest(int, char**) int otbWaterIndicesTest(int, char**) { - const std::map<CommonBandNames,size_t> bandMap = {{CommonBandNames::BLUE,0},{CommonBandNames::GREEN,1},{CommonBandNames::RED,2},{CommonBandNames::NIR,3}, {CommonBandNames::MIR,4}}; + const std::map<CommonBandNames,size_t> bandMap = {{CommonBandNames::BLUE,1},{CommonBandNames::GREEN,2},{CommonBandNames::RED,3},{CommonBandNames::NIR,4}, {CommonBandNames::MIR,5}}; // Syntax: CheckResult<Indice Class>("test_name",bandMap,{red_value,nir_value},expected_result) bool res = CheckResult< NDWI<int,double> >("ndwi_null ",bandMap,{0,0,0,0,0},0.); @@ -128,7 +128,7 @@ int otbWaterIndicesTest(int, char**) int otbSoilIndicesTest(int, char**) { - const std::map<CommonBandNames,size_t> bandMap = {{CommonBandNames::BLUE,0},{CommonBandNames::GREEN,1},{CommonBandNames::RED,2},{CommonBandNames::NIR,3}, {CommonBandNames::MIR,4}}; + const std::map<CommonBandNames,size_t> bandMap = {{CommonBandNames::BLUE,1},{CommonBandNames::GREEN,2},{CommonBandNames::RED,3},{CommonBandNames::NIR,4}, {CommonBandNames::MIR,5}}; // Syntax: CheckResult<Indice Class>("test_name",bandMap,{red_value,nir_value},expected_result) bool res = CheckResult< CI<int,double> >("ci_null ",bandMap,{0,0,0,0,0},0.); @@ -148,7 +148,7 @@ int otbSoilIndicesTest(int, char**) int otbBuiltUpIndicesTest(int, char**) { - const std::map<CommonBandNames,size_t> bandMap = {{CommonBandNames::BLUE,0},{CommonBandNames::GREEN,1},{CommonBandNames::RED,2},{CommonBandNames::NIR,3}, {CommonBandNames::MIR,4}}; + const std::map<CommonBandNames,size_t> bandMap = {{CommonBandNames::BLUE,1},{CommonBandNames::GREEN,2},{CommonBandNames::RED,3},{CommonBandNames::NIR,4}, {CommonBandNames::MIR,5}}; // Syntax: CheckResult<Indice Class>("test_name",bandMap,{red_value,nir_value},expected_result) bool res = CheckResult< ISU<int,double> >("isu_null",bandMap,{0,0,0,0,0},0.); @@ -237,7 +237,7 @@ int otbIndicesStackFunctorTest(int, char**) success = false; } - const std::map<CommonBandNames,size_t> bandMap = {{CommonBandNames::BLUE,0},{CommonBandNames::GREEN,1},{CommonBandNames::RED,2},{CommonBandNames::NIR,3}, {CommonBandNames::MIR,4}}; + const std::map<CommonBandNames,size_t> bandMap = {{CommonBandNames::BLUE,1},{CommonBandNames::GREEN,2},{CommonBandNames::RED,3},{CommonBandNames::NIR,4}, {CommonBandNames::MIR,5}}; ndvi.SetBandsIndices(bandMap); ndwi.SetBandsIndices(bandMap);