23 #ifndef otbFlexibleDistanceWithMissingValue_hxx
24 #define otbFlexibleDistanceWithMissingValue_hxx
27 #include "itkNumericTraits.h"
35 template <
class TVector>
39 return Superclass::Evaluate(x1, x2);
41 if (itk::NumericTraits<TVector>::GetLength(x1) != itk::NumericTraits<TVector>::GetLength(x2))
43 itkExceptionMacro(<<
"Vector lengths must be equal.");
46 double temp, distance = itk::NumericTraits<double>::Zero;
48 for (
unsigned int i = 0; i < x1.Size(); ++i)
50 if (!this->IsMissingValue(x1[i]) && !this->IsMissingValue(x2[i]))
52 temp = std::pow(std::abs(std::pow(x1[i], this->Alpha) - std::pow(x2[i], this->Alpha)), this->Beta);
60 template <
class TVector>
64 return Superclass::Evaluate(x);
68 if (measurementVectorSize == 0)
70 itkExceptionMacro(<<
"Please set the MeasurementVectorSize first");
73 itk::Statistics::MeasurementVectorTraits::Assert(this->GetOrigin(), measurementVectorSize,
74 "EuclideanDistanceMetric::Evaluate Origin and input vector have different lengths");
76 double temp, distance = itk::NumericTraits<double>::Zero;
78 for (
unsigned int i = 0; i < measurementVectorSize; ++i)
80 if (!this->IsMissingValue(this->GetOrigin()[i]) && !this->IsMissingValue(x[i]))
82 temp = std::pow(std::abs(std::pow(this->GetOrigin()[i], this->Alpha) - std::pow(x[i], this->Alpha)), this->Beta);
90 template <
class TVector>
94 return Superclass::Evaluate(a, b);
97 if (this->IsMissingValue(a) || this->IsMissingValue(b))
100 double temp = std::pow(std::abs(std::pow(a, this->Alpha) - std::pow(b, this->Alpha)), this->Beta);
104 template <
class TVector>
111 template <
class TVector>
114 if ((Alpha == 1.0) && (Beta == 2.0))