<div dir="ltr"><div>Marcel Schenderlein <marcel.schenderlein@...> writes:</div><div>> </div><div>> it seems to me as if there is a bug in itk::EuclideanDistancePointMetric </div><div>> or at least a misconception. Correct me if I am wrong. I do not have the </div><div>> full Insight into ITK yet </div><div>> </div><div>> I came across this when I wanted to use this metric together with an </div><div>> itk::Rigid3DPerspectiveTransform and the </div><div>> itk::PointSetToPointSetRegistrationMethod to do 3D-2D point </div><div>> registration. The bug will not be noticed when two point sets of the </div><div>> same dimensionality would be used.</div><div>> </div><div>> BUG:</div><div>> -------</div><div>> In the itk::EuclideanDistancePointMetric class there is a single </div><div>> iterator type used for both FixedPointSet and MovingPointSet (typedef </div><div>> typename Superclass::PointIterator PointIterator) in the method </div><div>> GetValue(...) at lines 76,77</div><div>> </div><div>>  > PointIterator pointItr = movingPointSet->GetPoints()->Begin();</div><div>>  > PointIterator pointEnd = movingPointSet->GetPoints()->End();</div><div>> </div><div>> and lines 118,119</div><div>> </div><div>>  > PointIterator pointItr2 = fixedPointSet->GetPoints()->Begin();</div><div>>  > PointIterator pointEnd2 = fixedPointSet->GetPoints()->End();</div><div>> </div><div>> in itkEuclideanDistancePointMetric.txx. The problem that arises is that </div><div>> if I use this metric with an itk::PointSet< double, 2 > as </div><div>> FixedPointSetType and and itk::PointSet< double, 3 > as the </div><div>> MovingPointSetType (as I would do for 3D-2D registration) then the </div><div>> compiler complains about the lines 76,77 because PointIterator is </div><div>> actually a FixedPointSetType::PointsContainer::ConstIterator (from </div><div>> itk::PointSetToPointSetMetric). Note that the lines 118,119 work </div><div>> perfectly but the naming of the iterator does not point to the type used.</div><div>> I did the following to fix this:</div><div>> </div><div>> FIX:</div><div>> --------------------------------</div><div>> I introduced two new iterators (itkEuclideanDistancePointMetric.h):</div><div>> </div><div>>  > typedef typename FixedPointSetType::PointsContainer::ConstIterator </div><div>> FixedPointIterator;</div><div>>  > typedef typename MovingPointSetType::PointsContainer::ConstIterator </div><div>> MovingPointIterator;</div><div>> </div><div>> The iterator PointIterator is obsolete then.</div><div>> </div><div>> I also had to change the distance map part of the template </div><div>> declaration(?) (itkEuclideanDistancePointMetric.h). The dimension of the </div><div>> distance map has to be of type TFixedPointSet instead of </div><div>> TMovingPointSet, since the moving points are transformed (into the </div><div>> FixedPointType) and then compared to the fixed points. So it is now:</div><div>> </div><div>>  > template < class TFixedPointSet, class TMovingPointSet,</div><div>>  >  class TDistanceMap = ::itk::Image<unsigned short,</div><div>>  >  ::itk::GetPointSetDimension<TFixedPointSet>::PointDimension> ></div><div>>  > class ITK_EXPORT EuclideanDistancePointMetric :</div><div>> </div><div>> In the definition of GetValue(...) (itkEuclideanDistancePointMetric.txx) </div><div>> I changed the lines 76,77 to</div><div>> </div><div>>  > MovingPointIterator pointItr = movingPointSet->GetPoints()->Begin();</div><div>>  > MovingPointIterator pointEnd = movingPointSet->GetPoints()->End();</div><div>> </div><div>> and lines 118,119 to</div><div>> </div><div>>  > FixedPointIterator pointItr2 = fixedPointSet->GetPoints()->Begin();</div><div>>  > FixedPointIterator pointEnd2 = fixedPointSet->GetPoints()->End();</div><div>> </div><div>> After that it compiles well and the registration seems to work. I have </div><div>> not testet the fix with point sets of the same dimensionality but </div><div>> looking at the code I see no reason why it should not still work this way.</div><div><br></div><div><br></div><div>I'm looking at a current ITK master and see the same problem. Marcel's patch </div><div>seems to work for me. Is it agreed that this is a bug and that Marcel's </div><div>solution is the correct one?</div><div><br></div><div>Thanks,</div><div>Taylor</div></div>