[ITK] [ITK-users] bug in EuclideanDistancePointMetric

Taylor Braun-Jones taylor at braun-jones.org
Wed Feb 4 14:22:21 EST 2015


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


I'm looking at a current ITK master and see the same problem. Marcel's
patch
seems to work for me. Is it agreed that this is a bug and that Marcel's
solution is the correct one?

Thanks,
Taylor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20150204/8309977d/attachment.html>
-------------- next part --------------
_____________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/insight-users


More information about the Community mailing list