Skip to content
Snippets Groups Projects
Commit 33de68d8 authored by Otmane Lahlou's avatar Otmane Lahlou
Browse files

ENH : implement != and == operators and make an attribute static const

parent 34590eda
No related branches found
No related tags found
No related merge requests found
...@@ -44,7 +44,17 @@ public: ...@@ -44,7 +44,17 @@ public:
/// Vector pixel type used to support both vector images and multiple /// Vector pixel type used to support both vector images and multiple
/// input images /// input images
typedef itk::VariableLengthVector<TInput1> InputVectorType; typedef itk::VariableLengthVector<TInput1> InputVectorType;
//operators !=
bool operator!=( const RAndNIRIndexBase & ) const
{
return false;
}
//operator ==
bool operator==( const RAndNIRIndexBase & other ) const
{
return !(*this != other);
}
// Operator on vector pixel type // Operator on vector pixel type
inline TOutput operator()(const InputVectorType & inputVector) inline TOutput operator()(const InputVectorType & inputVector)
{ {
...@@ -57,7 +67,7 @@ public: ...@@ -57,7 +67,7 @@ public:
return this->Evaluate(r,nir); return this->Evaluate(r,nir);
}; };
/// Constructor /// Constructor
RAndNIRIndexBase() : m_EpsilonToBeConsideredAsZero(0.0000001), m_RedIndex(3), m_NIRIndex(4) {}; RAndNIRIndexBase() : m_RedIndex(3), m_NIRIndex(4) {}
/// Desctructor /// Desctructor
virtual ~RAndNIRIndexBase() {}; virtual ~RAndNIRIndexBase() {};
...@@ -85,7 +95,7 @@ protected: ...@@ -85,7 +95,7 @@ protected:
// This method must be reimplemented in subclasses to actually // This method must be reimplemented in subclasses to actually
// compute the index value // compute the index value
virtual TOutput Evaluate(const TInput1 & r, const TInput2 & nir) const = 0; virtual TOutput Evaluate(const TInput1 & r, const TInput2 & nir) const = 0;
const double m_EpsilonToBeConsideredAsZero; static const double m_EpsilonToBeConsideredAsZero = 0.0000001;
private: private:
unsigned int m_RedIndex; unsigned int m_RedIndex;
...@@ -109,13 +119,24 @@ public: ...@@ -109,13 +119,24 @@ public:
/// Vector pixel type used to support both vector images and multiple /// Vector pixel type used to support both vector images and multiple
/// input images /// input images
typedef itk::VariableLengthVector<TInput1> InputVectorType; typedef itk::VariableLengthVector<TInput1> InputVectorType;
//operators !=
bool operator!=( const RAndBAndNIRIndexBase& ) const
{
return false;
}
//operator ==
bool operator==( const RAndBAndNIRIndexBase& other ) const
{
return !(*this != other);
}
// Operator on vector pixel type // Operator on vector pixel type
inline TOutput operator()(const InputVectorType & inputVector) inline TOutput operator()(const InputVectorType & inputVector)
{ {
return this->Evaluate(inputVector[m_RedIndex-1],static_cast<TInput2>(inputVector[m_BlueIndex-1]), static_cast<TInput3>(inputVector[m_NIRIndex-1])); return this->Evaluate(inputVector[m_RedIndex-1],static_cast<TInput2>(inputVector[m_BlueIndex-1]), static_cast<TInput3>(inputVector[m_NIRIndex-1]));
} }
// Binary operator // Binary operator
inline TOutput operator()(const TInput1 &r, const TInput2 &b, const TInput2 &nir) inline TOutput operator()(const TInput1 &r, const TInput2 &b, const TInput2 &nir)
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment