[Insight-users] bug in EuclideanDistancePointMetric
Marcel Schenderlein
marcel.schenderlein at uni-ulm.de
Tue Sep 25 07:29:54 EDT 2007
Hi list,
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.
Best regards,
Marcel
--
---------------------------------------------
Dipl.-Ing. Marcel Schenderlein
Institute of Measurement, Control and Microtechnology
Ulm University
Albert Einstein Allee 41
89069 Ulm, Germany
Phone: +49 731 50 26338
FAX: +49 731 50 26301
Mobile: +49 176 21733668
Email: Marcel.Schenderlein at uni-ulm.de
http: www.mrm.e-technik.uni-ulm.de
More information about the Insight-users
mailing list