18 #ifndef __otbNNearestPointsLinearInterpolateDeformationFieldGenerator_txx
19 #define __otbNNearestPointsLinearInterpolateDeformationFieldGenerator_txx
30 template <
class TPo
intSet,
class TDeformationField>
37 defaultValue.Fill(this->GetDefaultValue());
38 outputPtr->Allocate();
39 outputPtr->FillBuffer(defaultValue);
42 IteratorType it(outputPtr, outputPtr->GetRequestedRegion());
44 for (it.GoToBegin(); !it.IsAtEnd(); ++it)
47 IndexVectorType indexVector = this->GenerateNearestValidPointsPointSet(it.GetIndex(), m_NumberOfPoints);
49 double xdeformation, ydeformation, normalization;
54 for (
typename IndexVectorType::iterator indexIt = indexVector.begin(); indexIt != indexVector.end(); ++indexIt)
57 point[0] =
static_cast<double>(this->GetPointSet()->GetPoints()->GetElement(*indexIt)[0]);
58 point[1] =
static_cast<double>(this->GetPointSet()->GetPoints()->GetElement(*indexIt)[1]);
59 double distance = this->EuclideanDistance(index, point);
64 xdeformation += this->GetPointSet()->GetPointData()->GetElement((*indexIt))[1] / distance;
65 ydeformation += this->GetPointSet()->GetPointData()->GetElement((*indexIt))[2] / distance;
66 normalization += 1 / distance;
69 if (normalization > 0)
71 pixel[0] =
static_cast<ValueType>(xdeformation / normalization);
72 pixel[1] =
static_cast<ValueType>(ydeformation / normalization);
84 template <
class TPo
intSet,
class TDeformationField>
89 Superclass::PrintSelf(os, indent);