21 #ifndef otbCompacityPathFunction_hxx
22 #define otbCompacityPathFunction_hxx
25 #include "itkNumericTraits.h"
32 template <
class TInputPath,
class TOutput>
35 this->Superclass::PrintSelf(os, indent);
38 template <
class TInputPath,
class TOutput>
50 vertexList = path.GetVertexList();
51 nbPath = vertexList->Size();
55 for (
int i = 0; i < nbPath; ++i)
57 cindex = vertexList->GetElement(i);
61 if (i == (nbPath - 1))
63 cindex = vertexList->GetElement(0);
67 cindex = vertexList->GetElement(i + 1);
74 Norm = std::sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
86 itkExceptionMacro(<<
"CompacityPathFunction::Evaluate() FAILED -- path must contains at least 3 points");
90 Compacity = Surface / (Perimeter * Perimeter);
91 Compacity *= (4. * acos(-1.0));
96 template <
class TInputPath,
class TOutput>
99 if (!this->GetInputPath())
102 return static_cast<OutputType>(itk::NumericTraits<OutputType>::max());
105 OutputType Result = Evaluate(*(this->GetInputPath()));