<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman, new york, times, serif;font-size:12pt"><DIV>hello,</DIV>
<DIV>is there a available source/documentation &nbsp;which is talking about PointSetToImageRegistration. As far as I checked it out ItkSoftwareGuide.pdf doesn't include enough knowledge about that topic. For example I haven't found out that how can I use last registration paremeters at&nbsp; the end of the registration process,and also there is no knowledge about 3D PointSetToImageRegistration. I tried to implement 3D PointSetToImageRegistration and It doesn't work. </DIV>
<DIV><STRONG><U>my inputs</U></STRONG>:</DIV>
<DIV>1-STL I converted it itkmesh form then itk pointset</DIV>
<DIV>2-raw image which is <FONT size=2>DimSize = 329 527 181 and <FONT size=2>resolution = 0.200068 0.200068 0.200068&nbsp; and 60 MB</FONT></FONT></DIV>
<DIV><FONT size=2></FONT>&nbsp;</DIV>
<DIV>here is my code ,Could someone ,who is expert on pointsettoimageregistration pocesss, checked&nbsp; out my code?</DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT color=#008000 size=2>
<P>// Registration part</P>
<P><FONT color=#ff0000 size=3><STRONG>// Here I have&nbsp; itk mesh and I convert it to pointset</STRONG></FONT></P></FONT><FONT size=2>
<P></FONT><FONT color=#0000ff size=2>const</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>unsigned</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>int</FONT><FONT size=2> Dimension = 3;</P>
<P></FONT><FONT color=#0000ff size=2>typedef</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>unsigned</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>short</FONT><FONT size=2> PixelType;</P>
<P></FONT><FONT color=#0000ff size=2>typedef</FONT><FONT size=2> itk::PointSet&lt; </FONT><FONT color=#0000ff size=2>float</FONT><FONT size=2>, Dimension &gt; FixedPointSetType;</P>
<P></FONT><FONT color=#0000ff size=2>typedef</FONT><FONT size=2> itk::Image&lt; PixelType, Dimension &gt; MovingImageType;</P>
<P></FONT><FONT color=#0000ff size=2>typedef</FONT><FONT size=2> FixedPointSetType::PointsContainer PointsContainer;</P>
<P>PointsContainer::Pointer pointsContainer = PointsContainer::New();</P>
<P>pointsContainer = input_mesh-&gt;GetPoints();</P>
<P>itk::PointSet&lt;</FONT><FONT color=#0000ff size=2>float</FONT><FONT size=2>, 3&gt;::Pointer pointSet = itk::PointSet&lt;</FONT><FONT color=#0000ff size=2>float</FONT><FONT size=2>,3&gt;::New();</P>
<P>pointSet-&gt;SetPoints(pointsContainer);</P>
<P></FONT><FONT color=#0000ff size=2>unsigned</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>long</FONT><FONT size=2> pointId = 0;</P>
<P></FONT><FONT color=#0000ff size=2>typedef</FONT><FONT size=2> FMeshType::PointsContainer::Iterator PointsIterator;</P>
<P></FONT><FONT color=#008000 size=2>//itk::PointSet&lt;float, 3&gt;::Pointer pointSet = itk::PointSet&lt;float,3&gt;::New();</P></FONT><FONT size=2>
<P>PointsIterator pointIterator = input_mesh-&gt;GetPoints()-&gt;Begin(); </P>
<P>PointsIterator end = input_mesh-&gt;GetPoints()-&gt;End();</P>
<P></FONT><FONT color=#0000ff size=2>while</FONT><FONT size=2>( pointIterator != end ) </P>
<P>{</P>
<P>FMeshType::PointType p = pointIterator.Value(); </FONT><FONT color=#008000 size=2>// access the point</P></FONT><FONT size=2>
<P>std::cout &lt;&lt; p &lt;&lt; std::endl; </FONT><FONT color=#008000 size=2>// print the point</P></FONT><FONT size=2>
<P>pointSet-&gt;SetPoint( pointId, p );</FONT><FONT color=#008000 size=2>// advance to next point</P></FONT><FONT size=2>
<P>pointSet-&gt;SetPointData( pointId, pointSet-&gt;GetBufferedRegion() );</P>
<P>++pointIterator; </P>
<P>++pointId;</P>
<P>}</P>
<P></P>
<P></FONT><FONT color=#008000 size=2>//-----------------------------------------------------------</P></FONT><FONT size=2>
<P></FONT><FONT color=#008000 size=2>// Set up a Transform</P></FONT><FONT size=2>
<P></FONT><FONT color=#008000 size=2>//-----------------------------------------------------------</P></FONT><FONT size=2>
<P></FONT><FONT color=#0000ff size=2>typedef</FONT><FONT size=2> itk::VersorRigid3DTransform&lt; </FONT><FONT color=#0000ff size=2>double</FONT><FONT size=2> &gt; TransformType;</P>
<P>TransformType::Pointer transform = TransformType::New();</P>
<P></P>
<P></P>
<P></FONT><FONT color=#008000 size=2>//------------------------------------------------------------</P></FONT><FONT size=2>
<P></FONT><FONT color=#008000 size=2>// Optimizer Type</P></FONT><FONT size=2>
<P></FONT><FONT color=#008000 size=2>//-----------------------------------------------------------</P></FONT><FONT size=2>
<P></FONT><FONT color=#0000ff size=2>typedef</FONT><FONT size=2> itk::<FONT color=#800000 size=2><FONT color=#000000>VersorRigid3DTransformOptimizer</FONT>&nbsp;</FONT>&nbsp;OptimizerType;</P>
<P>OptimizerType::Pointer optimizer = OptimizerType::New();</P>
<P>&nbsp;</P>
<P></FONT><FONT color=#008000 size=2>//------------------------------------------------------------</P></FONT><FONT size=2>
<P></FONT><FONT color=#008000 size=2>// Set up an Interpolator</P></FONT><FONT size=2>
<P></FONT><FONT color=#008000 size=2>//------------------------------------------------------------</P></FONT><FONT size=2>
<P></FONT><FONT color=#0000ff size=2>typedef</FONT><FONT size=2> itk::LinearInterpolateImageFunction&lt; </P>
<P>MovingImageType,</P>
<P></FONT><FONT color=#0000ff size=2>double</FONT><FONT size=2> &gt; InterpolatorType;</P>
<P>InterpolatorType::Pointer interpolator = InterpolatorType::New();</P>
<P></FONT><FONT color=#008000 size=2>//-----------------------------------------------------------</P></FONT><FONT size=2>
<P></FONT><FONT color=#008000 size=2>// Set up Metric</P></FONT><FONT size=2>
<P></FONT><FONT color=#008000 size=2>//-----------------------------------------------------------</P></FONT><FONT size=2>
<P></FONT><FONT color=#0000ff size=2>typedef</FONT><FONT size=2> itk::NormalizedCorrelationPointSetToImageMetric&lt; </P>
<P>FixedPointSetType, </P>
<P>MovingImageType &gt; MetricType;</P>
<P></FONT><FONT color=#0000ff size=2>typedef</FONT><FONT size=2> MetricType::TransformType TransformBaseType;</P>
<P></FONT><FONT color=#0000ff size=2>typedef</FONT><FONT size=2> TransformBaseType::ParametersType ParametersType;</P>
<P>MetricType::Pointer metric = MetricType::New();</P>
<P></FONT><FONT color=#008000 size=2>//-----------------------------------------------------------</P></FONT><FONT size=2>
<P></FONT><FONT color=#008000 size=2>//RegistrationMethod</P></FONT><FONT size=2>
<P></FONT><FONT color=#008000 size=2>//-----------------------------------------------------------</P></FONT><FONT size=2>
<P></FONT><FONT color=#0000ff size=2>typedef</FONT><FONT size=2> itk::PointSetToImageRegistrationMethod&lt; </P>
<P>FixedPointSetType,</P>
<P>MovingImageType &gt; RegistrationType;</P>
<P>RegistrationType::Pointer registrationMethod = RegistrationType::New();</P></FONT><FONT color=#008000 size=2>
<P>&nbsp;</P></FONT><FONT size=2>
<P></FONT><FONT color=#008000 size=2>// Scale the translation components of the Transform in the Optimizer</P></FONT><FONT size=2>
<P></FONT><FONT color=#0000ff size=2>typedef</FONT><FONT size=2> OptimizerType::ScalesType OptimizerScalesType;</P>
<P>OptimizerScalesType optimizerScales( transform-&gt;GetNumberOfParameters() );</P>
<P></FONT><FONT color=#0000ff size=2>const</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>double</FONT><FONT size=2> translationScale = 1.0 / 1000.0;</P>
<P>optimizerScales[0] = 1.0;</P>
<P>optimizerScales[1] = 1.0;</P>
<P>optimizerScales[2] = 1.0;</P>
<P>optimizerScales[3] = translationScale;</P>
<P>optimizerScales[4] = translationScale;</P>
<P>optimizerScales[5] = translationScale;</P>
<P>optimizer-&gt;SetMaximumStepLength( 1.00 );</P>
<P>optimizer-&gt;SetMinimumStepLength( 0.001 );</P>
<P>optimizer-&gt;SetNumberOfIterations( 500 );</P>
<P>optimizer-&gt;SetRelaxationFactor( 0.90 );</P>
<P>optimizer-&gt;SetGradientMagnitudeTolerance( 0.05 );</P>
<P>optimizer-&gt;MinimizeOn();</P>
<P>&nbsp;</P>
<P></FONT><FONT size=2>&nbsp;</P>
<P>&nbsp;</P>
<P></FONT><FONT color=#008000 size=2>// can probably provide a better guess than the identity...</P></FONT><FONT size=2>
<P>transform-&gt;SetIdentity();</P>
<P></P>
<P></P>
<P></P>
<P></P>
<P>registrationMethod-&gt;SetInitialTransformParameters( transform-&gt;GetParameters() );</P>
<P>RegistrationType::ParametersType initialParameters( </P>
<P>transform-&gt;GetNumberOfParameters() );</P>
<P>initialParameters.Fill( 0.0 );</P>
<P>initialParameters[3] = 1.0;</P>
<P>&nbsp;</P>
<P>&nbsp;</P>
<P></FONT><FONT color=#008000 size=2>// Connect all the components required for Registration</P></FONT><FONT size=2>
<P></FONT><FONT color=#008000 size=2>//------------------------------------------------------</P></FONT><FONT size=2>
<P>registrationMethod-&gt;SetMetric( metric );</P>
<P>registrationMethod-&gt;SetOptimizer( optimizer );</P>
<P>registrationMethod-&gt;SetFixedPointSet(pointSet);</P>
<P>registrationMethod-&gt;SetMovingImage(input);</P>
<P>registrationMethod-&gt;SetInterpolator(interpolator);</P>
<P>registrationMethod-&gt;SetTransform( transform );</P>
<P></FONT><FONT color=#008000 size=2>//------------------------------------------------------------</P></FONT><FONT size=2>
<P></FONT><FONT color=#008000 size=2>// Set up transform parameters</P></FONT><FONT size=2>
<P></FONT><FONT color=#008000 size=2>//------------------------------------------------------------</P></FONT><FONT size=2>
<P>ParametersType parameters( transform-&gt;GetNumberOfParameters() );</P>
<P></FONT><FONT color=#008000 size=2>// initialize the offset/vector part</P></FONT><FONT size=2>
<P></FONT><FONT color=#0000ff size=2>for</FONT><FONT size=2>( </FONT><FONT color=#0000ff size=2>unsigned</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>int</FONT><FONT size=2> k = 0; k &lt;Dimension; k++ )</P>
<P>{</P>
<P>parameters[k]= 0.0f;</P>
<P>}</P>
<P></FONT><FONT color=#0000ff size=2>try</FONT><FONT size=2> </P>
<P>{</P>
<P>registrationMethod-&gt;SetInitialTransformParameters( initialParameters );</P>
<P>registrationMethod-&gt;StartRegistration();</P>
<P>}</P>
<P></FONT><FONT color=#0000ff size=2>catch</FONT><FONT size=2>( itk::ExceptionObject &amp; e )</P>
<P>{</P>
<P>std::cout &lt;&lt; e &lt;&lt; std::endl;</P>
<P>}</P>
<P>&nbsp;</P>
<P>&nbsp;</P>
<P>OptimizerType::ParametersType finalParameters =registrationMethod-&gt;GetLastTransformParameters();</P>
<P></FONT><FONT color=#0000ff size=2>const</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>unsigned</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>int</FONT><FONT size=2> nmbrOfIterations = optimizer-&gt;GetCurrentIteration();</P>
<P></FONT><FONT color=#0000ff size=2>const</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>double</FONT><FONT size=2> bestValue = optimizer-&gt;GetValue();</P></FONT></DIV></div><br>



      <hr size=1>Ahhh...imagining that irresistible "new car" smell?<br> Check out
<a href="http://us.rd.yahoo.com/evt=48245/*http://autos.yahoo.com/new_cars.html;_ylc=X3oDMTE1YW1jcXJ2BF9TAzk3MTA3MDc2BHNlYwNtYWlsdGFncwRzbGsDbmV3LWNhcnM-">new cars at Yahoo! Autos.</a>
</body></html>