From da11eed491a4de7d798317849dbc8534888dfddc Mon Sep 17 00:00:00 2001 From: Julien Malik <julien.malik@c-s.fr> Date: Thu, 19 May 2011 20:23:43 +0200 Subject: [PATCH] ENH: various improvements to radiometric indices needed to wrap them * make sure there is a == and != operator * remove the 'const' from the non-static const members since they are not default-copiable --- Code/Radiometry/otbBuiltUpIndicesFunctor.h | 11 ++++++++ Code/Radiometry/otbSoilIndicesFunctor.h | 22 ++++++++++++++++ Code/Radiometry/otbVegetationIndicesFunctor.h | 26 ++++++++++++++----- Code/Radiometry/otbWaterIndicesFunctor.h | 21 +++++++++++---- 4 files changed, 68 insertions(+), 12 deletions(-) diff --git a/Code/Radiometry/otbBuiltUpIndicesFunctor.h b/Code/Radiometry/otbBuiltUpIndicesFunctor.h index 0666fc8864..fee3980eb8 100644 --- a/Code/Radiometry/otbBuiltUpIndicesFunctor.h +++ b/Code/Radiometry/otbBuiltUpIndicesFunctor.h @@ -47,6 +47,17 @@ public: /// input images typedef itk::VariableLengthVector<TInput1> InputVectorType; + //operators != + bool operator !=(const TM4AndTM5IndexBase&) const + { + return true; + } + //operator == + bool operator ==(const TM4AndTM5IndexBase& other) const + { + return !(*this != other); + } + // Operator on vector pixel type inline TOutput operator ()(const InputVectorType& inputVector) const { diff --git a/Code/Radiometry/otbSoilIndicesFunctor.h b/Code/Radiometry/otbSoilIndicesFunctor.h index 5aacb53935..36d40e0ddb 100644 --- a/Code/Radiometry/otbSoilIndicesFunctor.h +++ b/Code/Radiometry/otbSoilIndicesFunctor.h @@ -50,6 +50,17 @@ public: /// input images typedef itk::VariableLengthVector<TInput1> InputVectorType; + //operators != + bool operator !=(const GAndRIndexBase&) const + { + return true; + } + //operator == + bool operator ==(const GAndRIndexBase& other) const + { + return !(*this != other); + } + // Operator on vector pixel type inline TOutput operator ()(const InputVectorType& inputVector) const { @@ -141,6 +152,17 @@ public: /// input images typedef itk::VariableLengthVector<TInput1> InputVectorType; + //operators != + bool operator !=(const GAndRAndNirIndexBase&) const + { + return true; + } + //operator == + bool operator ==(const GAndRAndNirIndexBase& other) const + { + return !(*this != other); + } + // Operator on vector pixel type inline TOutput operator ()(const InputVectorType& inputVector) const { diff --git a/Code/Radiometry/otbVegetationIndicesFunctor.h b/Code/Radiometry/otbVegetationIndicesFunctor.h index 0ba9490595..b7bbae4840 100644 --- a/Code/Radiometry/otbVegetationIndicesFunctor.h +++ b/Code/Radiometry/otbVegetationIndicesFunctor.h @@ -51,13 +51,14 @@ public: //operators != bool operator !=(const RAndNIRIndexBase&) const { - return false; + return true; } //operator == bool operator ==(const RAndNIRIndexBase& other) const { return !(*this != other); } + // Operator on vector pixel type inline TOutput operator ()(const InputVectorType& inputVector) const { @@ -155,7 +156,7 @@ public: //operators != bool operator !=(const RAndBAndNIRIndexBase&) const { - return false; + return true; } //operator == @@ -279,6 +280,17 @@ public: /// input images typedef itk::VariableLengthVector<TInput1> InputVectorType; + //operators != + bool operator !=(const RAndGAndNIRIndexBase&) const + { + return true; + } + //operator == + bool operator ==(const RAndGAndNIRIndexBase& other) const + { + return !(*this != other); + } + // Operator on vector pixel type inline TOutput operator ()(const InputVectorType& inputVector) { @@ -369,7 +381,7 @@ protected: // This method must be reimplemented in subclasses to actually // compute the index value virtual TOutput Evaluate(const TInput1& r, const TInput2& g, const TInput3& nir) const = 0; - const double m_EpsilonToBeConsideredAsZero; + double m_EpsilonToBeConsideredAsZero; private: unsigned int m_RedIndex; @@ -747,7 +759,7 @@ protected: private: /** Slope of soil line */ double m_S; - const NDVIFunctorType m_NDVIfunctor; + NDVIFunctorType m_NDVIfunctor; WDVIFunctorType m_WDVIfunctor; }; @@ -1234,7 +1246,7 @@ protected: } } private: - const NDVIFunctorType m_NDVIfunctor; + NDVIFunctorType m_NDVIfunctor; }; /** \class LAIFromNDVILogarithmic @@ -1313,7 +1325,7 @@ protected: } } private: - const NDVIFunctorType m_NDVIfunctor; + NDVIFunctorType m_NDVIfunctor; double m_NdviSoil; double m_NdviInf; double m_ExtinctionCoefficient; @@ -1378,7 +1390,7 @@ protected: return (static_cast<TOutput>(m_RedCoef*r+m_NirCoef*nir)); } private: - const NDVIFunctorType m_NDVIfunctor; + NDVIFunctorType m_NDVIfunctor; double m_RedCoef; double m_NirCoef; }; diff --git a/Code/Radiometry/otbWaterIndicesFunctor.h b/Code/Radiometry/otbWaterIndicesFunctor.h index 3fbe86a1ca..fbc94f095f 100644 --- a/Code/Radiometry/otbWaterIndicesFunctor.h +++ b/Code/Radiometry/otbWaterIndicesFunctor.h @@ -47,6 +47,17 @@ public: /// input images typedef itk::VariableLengthVector<TInput1> InputVectorType; + //operators != + bool operator !=(const WaterIndexBase&) const + { + return true; + } + //operator == + bool operator ==(const WaterIndexBase& other) const + { + return !(*this != other); + } + // Operator on vector pixel type inline TOutput operator ()(const InputVectorType& inputVector) const { @@ -247,7 +258,7 @@ protected: } private: // Water Index Classic Functor - const WIFunctorType m_WIFunctor; + WIFunctorType m_WIFunctor; }; /** \class NDWI2 @@ -330,7 +341,7 @@ protected: } private: // Water Index Classic Functor - const WIFunctorType m_WIFunctor; + WIFunctorType m_WIFunctor; }; /** \class MNDWI @@ -413,7 +424,7 @@ protected: } private: // Water Index Classic Functor - const WIFunctorType m_WIFunctor; + WIFunctorType m_WIFunctor; }; /** \class NDPI @@ -496,7 +507,7 @@ protected: } private: // Water Index Classic Functor - const WIFunctorType m_WIFunctor; + WIFunctorType m_WIFunctor; }; /** \class NDTI @@ -581,7 +592,7 @@ protected: } private: // Water Index Classic Functor - const WIFunctorType m_WIFunctor; + WIFunctorType m_WIFunctor; }; /** \class WaterSqrtSpectralAngleFunctor -- GitLab