<div>Hi Luis,</div>
<div><br>Thank you very much. Yes, I declared PointSet as float, Transform as double. But, after I changed the PointSet to double, the compile error is still there. I am using Visual Studio 2005. The compiler gave this:<br>
Error 1 error C2664: 'itk::MatrixOffsetTransformBase<TScalarType,NInputDimensions,NOutputDimensions>::TransformPoint' : cannot convert parameter 1 from 'PointType' to 'const itk::Point<TCoordRep,NPointDimension> &' c:\steven\gdc.cpp 1379
<br>I am not sure whether this is the full error message though.<br> </div>
<div>==========================================<br>The code is like this:<br>IterativeClosestPoint(CString tFixedPointsFile, CString tMovingPointFile, CString tRegisteredPointsFile, double tResultParametre[ ])<br>{<br>//convert filename parametres to char*
</div>
<div>CStringA fixedFileName(tFixedPointsFile);<br>CStringA movingFileName(tMovingPointFile);<br>CStringA registeredFileName(tRegisteredPointsFile);<br><br>int i = 0; int j = 0;<br>double pi = 3.1415926535897932384626;<br>
<br>typedef itk::PointSet< double, Dimension > PointSetType;<br>PointSetType::Pointer fixedPointSet = PointSetType::New();<br>PointSetType::Pointer movingPointSet = PointSetType::New();<br>PointSetType::Pointer registeredPointSet = PointSetType::New();
<br>typedef PointSetType::PointType PointType;<br>PointType fixedPoint;<br>PointType movingPoint;<br>PointType registeredPoint;<br>typedef PointSetType::PointsContainer PointsContainer;<br>PointsContainer::Pointer fixedPointContainer = PointsContainer::New();
<br>PointsContainer::Pointer movingPointContainer = PointsContainer::New();<br>PointsContainer::Pointer registeredPointContainer = PointsContainer::New();<br><br>// Read the file containing coordinates of fixed points.<br>
std::ifstream fixedFile;<br>fixedFile.open( fixedFileName );<br>if( fixedFile.fail() )<br>{<br> return -1;<br>}<br><br>unsigned int pointId = 0;<br>fixedFile >> fixedPoint;<br>while( !fixedFile.eof() )<br>{<br> pointId++;
<br>}<br>fixedPointSet->SetPoints( fixedPointContainer );<br><br>// Read the file containing coordinates of moving points.<br>std::ifstream movingFile;<br>movingFile.open( movingFileName );<br>if( movingFile.fail() )
<br>{<br> return -1;<br>}<br><br>pointId = 0;<br>movingFile >> movingPoint;<br>while( !movingFile.eof() )<br>{<br> movingPointContainer->InsertElement( pointId, movingPoint );<br> movingFile >> movingPoint;
<br> pointId++;<br>}<br>movingPointSet->SetPoints( movingPointContainer );<br><br>// Set up the Metric<br>typedef itk::EuclideanDistancePointMetric< PointSetType, PointSetType> MetricType;<br>typedef MetricType::TransformType TransformBaseType;
<br>typedef TransformBaseType::ParametersType ParametersType;<br>typedef TransformBaseType::JacobianType JacobianType;<br><br>MetricType::Pointer metric = MetricType::New();<br><br>// Set up a Transform
<br>typedef itk::Euler3DTransform< double > TransformType;<br>TransformType::Pointer transform = TransformType::New();<br><br>// Optimizer Type<br>typedef itk::LevenbergMarquardtOptimizer OptimizerType;<br>OptimizerType::Pointer optimizer = OptimizerType::New();
<br>optimizer->SetUseCostFunctionGradient(false);<br><br>// Registration Method<br>typedef itk::PointSetToPointSetRegistrationMethod< PointSetType, PointSetType > RegistrationType;<br><br>RegistrationType::Pointer registration = RegistrationType::New();
<br>// Scale the translation components of the Transform in the Optimizer<br>OptimizerType::ScalesType scales( transform->GetNumberOfParameters() );<br><br>const double translationScale = 1000.0; // dynamic range of translations
<br>const double rotationScale = 1.0; // dynamic range of rotations<br><br>scales[0] = 1.0 / rotationScale;<br>scales[1] = 1.0 / rotationScale;<br>scales[2] = 1.0 / rotationScale;<br>scales[3] = 1.0 / translationScale;
<br>scales[4] = 1.0 / translationScale; <br>scales[5] = 1.0 / translationScale;<br><br>unsigned long numberOfIterations = 2000;<br>double gradientTolerance = 1e-4; // convergence criterion<br>double valueTolerance = 1e-4; // convergence criterion
<br>double epsilonFunction = 1e-5; // convergence criterion<br><br>optimizer->SetScales( scales );<br>optimizer->SetNumberOfIterations( numberOfIterations );<br>optimizer->SetValueTolerance( valueTolerance );
<br>optimizer->SetGradientTolerance( gradientTolerance );<br>optimizer->SetEpsilonFunction( epsilonFunction );<br><br>// Start from an Identity transform (in a normal case, the user <br>// can probably provide a better guess than the identity...
<br>transform->SetIdentity();<br><br>registration->SetInitialTransformParameters( transform->GetParameters() );<br><br>// Connect all the components required for Registration<br>registration->SetMetric( metric );
<br>registration->SetOptimizer( optimizer );<br>registration->SetTransform( transform );<br>registration->SetFixedPointSet( fixedPointSet );<br>registration->SetMovingPointSet( movingPointSet );
<br><br>try <br>{<br> registration->StartRegistration();<br>}<br>catch( itk::ExceptionObject & e )<br>{<br> DisplayITKError(e);<br> return -1;<br>}<br>for(i=0; i<6; i++) //first 3" rotation around x, y, z; last 3: translation
<br>{<br> tResultParametre[i] = transform->GetParameters()[i];<br>}<br><br>//Transform the moving pointset into registered pointset and Write the registered points into registeredFileName<br>//========================
<br>//Method 1: Use TransformMeshFilter<PointSetType, PointSetType, TransformType></div>
<div>//========================<br>//typedef itk::TransformMeshFilter<PointSetType, PointSetType, TransformType> TransformFilterType;<br>//TransformFilterType::Pointer transformfilter= TransformFilterType::New();<br>
//transformfilter->SetInput(movingPointSet);<br>//transformfilter->SetTransform(transform);<br>//try <br>//{<br>// transformfilter->Update();<br>//}<br>//catch( itk::ExceptionObject & e )<br>//{<br>// DisplayITKError(e);
<br>// return -1;<br>//}<br>//registeredPointSet = transformfilter->GetOutput();<br> </div>
<div>//===========================</div>
<div>//Method 2: Use TransformPoint for each individual point</div>
<div>//===========================<br>for(i = 0; i<movingPointSet->GetNumberOfPoints(); i++)<br>{<br> movingPointSet->GetPoint( i, &movingPoint );<br> registeredPoint = transform->TransformPoint( movingPoint );
<br> registeredPointContainer->InsertElement( i, registeredPoint );<br>}<br>registeredPointSet->SetPoints(registeredPointContainer);<br> </div>
<div>//Write the registered pointset into file <br>std::ofstream registeredFile;<br>registeredFile.open( registeredFileName);<br>if( registeredFile.fail() )<br>{<br> return -1;<br>}<br>for(i = 0; i<registeredPointSet->GetNumberOfPoints(); i++)
<br>{<br> registeredPointSet->GetPoint( i, & registeredPoint );<br> for(j = 0; j<Dimension; j++)<br> {<br> registeredFile<<registeredPoint[j]<<"\t";<br> }<br> registeredFile<<endl;
<br>}<br><br>return 1;<br>}</div>
<div>===========================================</div>
<div>The error message given at the beginning of this post is for codes with Method 2 (Use TransformPoint() for each individual point).</div>
<div>When compiling the codes with Method 1 (Use TransformMeshFilter<PointSetType, PointSetType, TransformType>), the error message is:</div>
<div>Error 1 error C2664: 'itk::MatrixOffsetTransformBase<TScalarType,NInputDimensions,NOutputDimensions>::TransformPoint' : cannot convert parameter 1 from 'const itk::Point<TCoordRep,NPointDimension>' to 'const itk::Point<TCoordRep,NPointDimension> &' c:\steven\installation\itk\insighttoolkit-
3.2.0\code\basicfilters\itktransformmeshfilter.txx 95</div>
<div>The codes around the break point in the file "insighttoolkit-3.2.0\code\basicfilters\itktransformmeshfilter.txx" are:</div>
<div>
<p> typename InputPointsContainer::ConstIterator inputPoint = inPoints->Begin();<br> typename OutputPointsContainer::Iterator outputPoint = outPoints->Begin();</p>
<p> while( inputPoint != inPoints->End() ) <br> {<br> outputPoint.Value() = m_Transform->TransformPoint( inputPoint.Value() ); //HERE IS THE ERROR <br> ++inputPoint;<br> ++outputPoint;<br> }</p>
</div>
<div>Could you please help me on this? Thank you again.</div>
<div> </div>
<div>Regards,</div>
<div>Steven<br> </div>
<div><br>On 9/3/07, Luis Ibanez <<a href="mailto:luis.ibanez@kitware.com">luis.ibanez@kitware.com</a>> wrote:<br>> <br>> Hi Steven,<br>> <br>> 1) You didn't posted the full error message to the list.
<br>> <br>> Apparently you cut the part where the compiler tell us what<br>> [TScalarType] you used when instantiating the Transform.<br>> <br>> 2) Most likely you are using a transform instantiated for "double",
<br>> and trying to use it for transforming points whose components<br>> are "float".<br>> <br>> <br>> If that is the case you have two options:<br>> <br>> <br>> A) Declare the PointSet using "double" at a cost in memory
<br>> storage. this may be fine if you are not managing thousands<br>> or millions of points.<br>> <br>> B) Declare the Transform to use "float" as its ScalarType.<br>> <br>> <br>> Option (A) is better if you care about the precision of the
<br>> computations more than the memory allocation.<br>> <br>> <br>> Regards,<br>> <br>> <br>> Luis<br>> <br>> <br>> ---------------------<br>> Steven ITK wrote:<br>> > Hi, ITK Users,
<br>> ><br>> > I have a compiling error when using TransformPoint:<br>> ><br>> > Error 1 error C2664:<br>> > 'itk::MatrixOffsetTransformBase<TScalarType,NInputDimensions,NOutputDimensions>::TransformPoint'
<br>> > : *cannot convert* parameter 1 from *'PointType' to 'const<br>> > itk::Point<TCoordRep,NPointDimension> &' . *<br>> ><br>> > What I am trying to do is testing the example of Iterative Closest Point
<br>> > Registration method (PointSetToPointSetRegistrationMethod). The<br>> > registration is working, but I had the problem to transform the moving<br>> > pointset to registered pointset using the transformation matrix obtained
<br>> > from the reigstration.<br>> ><br>> > Here is my code:<br>> > //type define<br>> > typedef itk::PointSet< float, Dimension > PointSetType;<br>> > PointSetType::Pointer fixedPointSet = PointSetType::New();
<br>> > PointSetType::Pointer movingPointSet = PointSetType::New();<br>> > PointSetType::Pointer registeredPointSet = PointSetType::New();<br>> > typedef PointSetType::PointType PointType;<br>> > PointType fixedPoint;
<br>> > PointType movingPoint;<br>> > PointType registeredPoint;<br>> > typedef PointSetType::PointsContainer PointsContainer;<br>> > PointsContainer::Pointer fixedPointContainer = PointsContainer::New();
<br>> > PointsContainer::Pointer movingPointContainer = PointsContainer::New();<br>> > PointsContainer::Pointer registeredPointContainer = PointsContainer::New();<br>> ><br>> > //Read in moving pointset and fixed pointset
<br>> ><br>> > //do the registration<br>> ><br>> > got the transformation stored in *'transform'*<br>> ><br>> > // transform moving pointset<br>> ><br>> > for(i = 0; i<movingPointSet->GetNumberOfPoints(); i++)
<br>> > {<br>> > movingPointSet->GetPoint( i, &movingPoint );<br>> > *registeredPoint = transform->TransformPoint( movingPoint<br>> > );//error here*<br>> > registeredPointContainer->InsertElement( i, registeredPoint );
<br>> > }<br>> > registeredPointSet->SetPoints(registeredPointContainer);<br>> ><br>> > ==============================================================<br>> > I also tried this, got the similar error:
<br>> > typedef itk::TransformMeshFilter<PointSetType, PointSetType,<br>> > TransformType> TransformFilterType;<br>> > TransformFilterType::Pointer transformfilter= TransformFilterType::New();<br>
> > transformfilter->SetInput(movingPointSet);<br>> > transformfilter->SetTransform(transform);<br>> > try<br>> > {<br>> > transformfilter->Update();<br>> > }<br>> > catch( itk::ExceptionObject & e )
<br>> > {<br>> > DisplayITKError(e);<br>> > return -1;<br>> > }<br>> > registeredPointSet = transformfilter->GetOutput();<br>> ><br>> > ===============================================================
<br>> ><br>> > Can you help me out of this? Thank you.<br>> ><br>> > Steven<br>> ><br>> ><br>> ><br>> ><br>> ><br>> > ------------------------------------------------------------------------
<br>> ><br>> > _______________________________________________<br>> > Insight-users mailing list<br>> > <a href="mailto:Insight-users@itk.org">Insight-users@itk.org</a><br>> > <a href="http://www.itk.org/mailman/listinfo/insight-users">
http://www.itk.org/mailman/listinfo/insight-users</a><br>> <br><br> </div>