18 #ifndef __otbKeyPointSetsMatchingFilter_txx
19 #define __otbKeyPointSetsMatchingFilter_txx
26 template <
class TPo
intSet,
class TDistance>
30 this->SetNumberOfRequiredInputs(2);
31 m_UseBackMatching =
false;
32 m_DistanceThreshold = 0.6;
34 m_DistanceCalculator = DistanceType::New();
37 template <
class TPo
intSet,
class TDistance>
46 template <
class TPo
intSet,
class TDistance>
54 template <
class TPo
intSet,
class TDistance>
63 template <
class TPo
intSet,
class TDistance>
71 template <
class TPo
intSet,
class TDistance>
83 if (ps1->GetNumberOfPoints() == 0 || ps2->GetNumberOfPoints() == 0)
85 itkExceptionMacro(<<
"Empty input pointset !");
96 while (pdIt != ps1->GetPointData()->End()
97 && pIt != ps1->GetPoints()->End())
100 bool matchFound =
false;
101 unsigned int currentIndex = pIt.Index();
113 if (searchResult1.second < m_DistanceThreshold)
116 dataMatch = ps2->GetPointData()->GetElement(searchResult1.first);
117 pointMatch = ps2->GetPoints()->GetElement(searchResult1.first);
120 if (m_UseBackMatching)
126 if (currentIndex == searchResult2.first)
141 landmark->SetPoint1(point);
142 landmark->SetPointData1(data);
143 landmark->SetPoint2(pointMatch);
144 landmark->SetPointData2(dataMatch);
145 landmark->SetLandmarkData(searchResult1.second);
148 landmarks->PushBack(landmark);
155 template <
class TPo
intSet,
class TDistance>
168 unsigned int nearestIndex = 0;
169 double d1 = m_DistanceCalculator->Evaluate(data1, pdIt.Value());
171 double d2 = m_DistanceCalculator->Evaluate(data1, pdIt.Value());
179 double nearestDistance = std::min(d1, d2);
180 double secondNearestDistance = std::max(d1, d2);
181 double distanceValue;
184 while (pdIt != pointset->GetPointData()->End())
187 distanceValue = m_DistanceCalculator->Evaluate(data1, pdIt.Value());
192 if (distanceValue < nearestDistance)
194 secondNearestDistance = nearestDistance;
195 nearestDistance = distanceValue;
196 nearestIndex = pdIt.Index();
200 else if (distanceValue < secondNearestDistance)
202 secondNearestDistance = distanceValue;
208 result.first = nearestIndex;
209 if (secondNearestDistance == 0)
215 result.second = nearestDistance / secondNearestDistance;
223 template <
class TPo
intSet,
class TDistance>
228 Superclass::PrintSelf(os, indent);