[ITK] [ITK-users] EuclideanDistancePointMetric: Error when comparing Mesh to QuadEdgeMesh

Davis Vigneault davis.vigneault at gmail.com
Thu May 21 06:11:04 EDT 2015


An update: the problem here seems to be that itkPointSetToPointSetMetric
only defines one iterator, which it uses on both the fixed and moving
pointsets.  If I add fixed- and moving-specific iterators and change
EuclideanDistancePointMetric accordingly, the original example compiles and
gives the correct answer.  Is this, in fact, a bug?  If so, I'd be happy to
attempt a patch.

On Thu, May 21, 2015 at 10:43 AM, Davis Vigneault <davis.vigneault at gmail.com
> wrote:

> Thanks very much for the reply, Arnaud!  Yes, I had originally begin with
> the v4 version, but ran into trouble when I tried to use it with
> LevenbergMarquardtOptimizer.
>
> EuclideanDistancePointMetric inherits from MultipleValuedCostFunction,
> wherease EuclideanDistancePointSetToPointSetMetricv4 inherits from
> SingleValuedCostFunctionv4.  To the best that I can tell,
> LevenbergMarquardtOptimizer expects its cost function to inherit from
> MultipleValuedCostFunction.  I tried wrapping
> EuclideanDistancePointSetToPointSetMetricv4 in an adapter class inheriting
> from MultipleValuedCostFunction, where I returned 1 from
> GetNumberOfValues() and wrapped the return of GetValue() in an itk::Array
> length 1.  However, when I did this, I got a warning saying (if I remember
> correctly) that there was a mismatch between the number of unknowns and
> residuals.  I realized that wrapping a "new" cost function class in an
> "old" cost function class was a hacky way to go about it in the first
> place, so I abandoned this method a while ago.
>
> Is there a way to use the v4 version with LevenbergMarquardtOptimizer?  Is
> there a reason that the v3 EuclideanDistanceMetric is multiple valued,
> whereas the v4 metric is single valued?  Is a v4 LevenbergOptimizer in
> development, and will it be single valued or multiple valued?
>
> Apologies in advance if I've been going about this the wrong way--I've
> been using ITK for a while, but am only just beginning to learn about
> optimization/registration.
>
> On Thu, May 21, 2015 at 7:55 AM, Arnaud Gelas <arnaudgelas at gmail.com>
> wrote:
>
>> Hi Davis,
>>
>> If you use the ITKv4 version of Metric, it compiles and works fine!
>>
>>>>
>> Here is the code
>>
>> #include "itkQuadEdgeMesh.h"
>> #include "itkRegularSphereMeshSource.h"
>> #include "itkEuclideanDistancePointSetToPointSetMetricv4.h"
>> #include "itkIdentityTransform.h"
>>
>> typedef itk::Mesh< double, 3 > TFMesh; // If you change this to
>> itk::QuadEdgeMesh, it works
>> typedef itk::QuadEdgeMesh< double, 3 > TMMesh; // Or if you change this
>> to itk::Mesh, it also works
>> typedef itk::RegularSphereMeshSource< TFMesh > TFSource;
>> typedef itk::RegularSphereMeshSource< TMMesh > TMSource;
>> typedef itk::EuclideanDistancePointSetToPointSetMetricv4< TFMesh, TMMesh
>> > TMetric;
>> typedef itk::IdentityTransform< double, 3 > TIdentity;
>>
>> int main(int argc, char ** argv)
>> {
>>
>>  TFSource::Pointer fixed = TFSource::New();
>>  fixed->Update();
>>
>>  TMSource::Pointer moving = TMSource::New();
>>  moving->Update();
>>
>>  TIdentity::Pointer identity = TIdentity::New();
>>
>>  TMetric::Pointer metric = TMetric::New();
>>  metric->SetFixedPointSet( fixed->GetOutput() );
>>  metric->SetMovingPointSet( moving->GetOutput() );
>>  metric->SetTransform( identity );
>>  std::cout << metric->GetValue() << std::endl;
>>
>>  return EXIT_SUCCESS;
>>
>> }
>>
>>
>> > On 20 May 2015, at 18:04, DVigneault <davis.vigneault at gmail.com> wrote:
>> >
>> > All--
>> >
>> > I'm attempting to use itk::EuclideanDistancePointMetric to compare an
>> > itk::Mesh to an itk::QuadEdgeMesh.  This works as expected if templated
>> over
>> > two meshes of the same type (i.e., itk::Mesh and itk::Mesh or
>> > itk::QuadEdgeMesh and itk::QuadEdgeMesh).  However, if I attempt to mix
>> the
>> > two, and compare an itk::Mesh and an itk::QuadEdgeMesh, I get a build
>> error,
>> > copied below, along with a minimal example of the problem.
>> >
>> > I'm having some trouble decoding the error, but it looks to me as
>> though the
>> > filter is having trouble converting between iterator types.  Does this
>> have
>> > something to do with a difference between how itk::Mesh and
>> > itk::QuadEdgeMesh define their iterators?
>> >
>> > Thank you in advance for your help!
>> >
>> > Best,
>> >
>> > --Davis
>> >
>> > #include "itkQuadEdgeMesh.h"
>> > #include "itkRegularSphereMeshSource.h"
>> > #include "itkEuclideanDistancePointMetric.h"
>> > #include "itkIdentityTransform.h"
>> >
>> > typedef itk::Mesh< double, 3 > TFMesh; // If you change this to
>> > itk::QuadEdgeMesh, it works
>> > typedef itk::QuadEdgeMesh< double, 3 > TMMesh; // Or if you change this
>> to
>> > itk::Mesh, it also works
>> > typedef itk::RegularSphereMeshSource< TFMesh > TFSource;
>> > typedef itk::RegularSphereMeshSource< TMMesh > TMSource;
>> > typedef itk::EuclideanDistancePointMetric< TFMesh, TMMesh > TMetric;
>> > typedef itk::IdentityTransform< double, 3 > TIdentity;
>> >
>> > int main(int argc, char ** argv)
>> > {
>> >
>> >  TFSource::Pointer fixed = TFSource::New();
>> >  fixed->Update();
>> >
>> >  TMSource::Pointer moving = TMSource::New();
>> >  moving->Update();
>> >
>> >  TIdentity::Pointer identity = TIdentity::New();
>> >
>> >  TMetric::Pointer metric = TMetric::New();
>> >  metric->SetFixedPointSet( fixed->GetOutput() );
>> >  metric->SetMovingPointSet( moving->GetOutput() );
>> >  metric->SetTransform( identity );
>> >  std::cout << metric->GetValue(identity->GetParameters()) << std::endl;
>> >
>> >  return EXIT_SUCCESS;
>> >
>> > }
>> >
>> >
>> > $ make
>> > Scanning dependencies of target AmoebaOptimization
>> > [100%] Building CXX object
>> > CMakeFiles/AmoebaOptimization.dir/AmoebaOptimization.cxx.o
>> > In file included from
>> > /usr/local/include/ITK-4.7/itkEuclideanDistancePointMetric.h:125:0,
>> >                 from
>> >
>> /home/davis/Developer/oxford/Stebbing_Method/Test/src/AmoebaOptimization.cxx:3:
>> > /usr/local/include/ITK-4.7/itkEuclideanDistancePointMetric.hxx: In
>> > instantiation of ‘itk::EuclideanDistancePointMetric<TFixedPointSet,
>> > TMovingPointSet, TDistanceMap>::MeasureType
>> > itk::EuclideanDistancePointMetric<TFixedPointSet, TMovingPointSet,
>> > TDistanceMap>::GetValue(const TransformParametersType&) const [with
>> > TFixedPointSet = itk::Mesh<double, 3u>; TMovingPointSet =
>> > itk::QuadEdgeMesh<double, 3u>; TDistanceMap = itk::Image<short unsigned
>> int,
>> > 3u>; itk::EuclideanDistancePointMetric<TFixedPointSet, TMovingPointSet,
>> > TDistanceMap>::MeasureType = itk::Array<double>;
>> > itk::EuclideanDistancePointMetric<TFixedPointSet, TMovingPointSet,
>> > TDistanceMap>::TransformParametersType =
>> itk::OptimizerParameters<double>]’:
>> >
>> /home/davis/Developer/oxford/Stebbing_Method/Test/src/AmoebaOptimization.cxx:28:58:
>> > required from here
>> > /usr/local/include/ITK-4.7/itkEuclideanDistancePointMetric.hxx:74:63:
>> error:
>> > conversion from ‘itk::MapContainer<long unsigned int,
>> > itk::QuadEdgeMeshPoint<float, 3u, itk::GeometricalQuadEdge<long
>> > unsigned int, long unsigned int, bool, bool, true> > >::ConstIterator’
>> to
>> > non-scalar type ‘itk::EuclideanDistancePointMetric<itk::Mesh<double,
>> 3u>,
>> > itk::QuadEdgeMesh<double, 3u> >::PointIterator {aka
>> > itk::VectorContainer<long unsigned int, itk::Point<float, 3u>
>> >> ::ConstIterator}’ requested
>> >   PointIterator pointItr = movingPointSet->GetPoints()->Begin();
>> >                                                               ^
>> > /usr/local/include/ITK-4.7/itkEuclideanDistancePointMetric.hxx:75:61:
>> error:
>> > conversion from ‘itk::MapContainer<long unsigned int,
>> > itk::QuadEdgeMeshPoint<float, 3u, itk::GeometricalQuadEdge<long
>> > unsigned int, long unsigned int, bool, bool, true> > >::ConstIterator’
>> to
>> > non-scalar type ‘itk::EuclideanDistancePointMetric<itk::Mesh<double,
>> 3u>,
>> > itk::QuadEdgeMesh<double, 3u> >::PointIterator {aka
>> > itk::VectorContainer<long unsigned int, itk::Point<float, 3u>
>> >> ::ConstIterator}’ requested
>> >   PointIterator pointEnd = movingPointSet->GetPoints()->End();
>> >                                                             ^
>> > make[2]: ***
>> [CMakeFiles/AmoebaOptimization.dir/AmoebaOptimization.cxx.o]
>> > Error 1
>> > make[1]: *** [CMakeFiles/AmoebaOptimization.dir/all] Error 2
>> > make: *** [all] Error 2
>> >
>> >
>> >
>> >
>> > --
>> > View this message in context:
>> http://itk-insight-users.2283740.n2.nabble.com/EuclideanDistancePointMetric-Error-when-comparing-Mesh-to-QuadEdgeMesh-tp7587372.html
>> > Sent from the ITK Insight Users mailing list archive at Nabble.com.
>> > _____________________________________
>> > 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
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20150521/b545214f/attachment-0001.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