<DIV>&nbsp;I use the bspline deform field (which is computed from the bapline registration algorithm) to wrap the image to the new image.</DIV>
<DIV>When I use the the bspline parameters, the result is ok.</DIV>
<DIV>when using the defor field, the result is wrong.</DIV>
<DIV>Below is the code, id there is some thing wrong? </DIV>
<DIV>thnanks</DIV>
<DIV>&nbsp;</DIV>
<DIV>assuming the bsplineTransform is computed and I will compute the deform field and warp to a new image.</DIV>
<DIV>help me check the code and many thanks to your help</DIV>
<DIV>&nbsp;</DIV>
<DIV>// define the&nbsp; types for computing deform field</DIV>
<DIV><FONT color="#008000"><FONT color="#000000">&nbsp;typedef itk::Point&lt; float, ImageDimension &gt; PointType;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>typedef itk::Vector&lt; float, ImageDimension &gt; VectorType;<BR>typedef itk::Image&lt; VectorType, ImageDimension &gt; DeformationFieldType;<BR>DeformationFieldType::Pointer field = DeformationFieldType::New();<BR>field-&gt;SetRegions( fixedRegion );<BR>field-&gt;SetOrigin( fixedOrigin );<BR>field-&gt;SetSpacing( fixedSpacing );<BR>field-&gt;SetDirection( fixedDirection );<BR>field-&gt;Allocate();<BR>typedef itk::ImageRegionIterator&lt; DeformationFieldType &gt; FieldIterator;<BR>FieldIterator fi( field, fixedRegion );<BR>fi.GoToBegin();<BR>TransformType::InputPointType fixedPoint;<BR>TransformType::OutputPointType movingPoint;<BR>DeformationFieldType::IndexType index;<BR>VectorType displacement;</FONT></FONT></DIV>
<DIV><FONT color="#008000"><FONT color="#000000">// getting the deform field, I have see the result the computed displacement&nbsp; is right<BR>while( ! fi.IsAtEnd() )<BR>{<BR>index = fi.GetIndex();<BR>field-&gt;TransformIndexToPhysicalPoint( index, fixedPoint );<BR>movingPoint = bsplineTransform-&gt;TransformPoint( fixedPoint );<BR>displacement = fixedPoint -movingPoint ;<BR>fi.Set( displacement );<BR>//std::cout&lt;&lt;displacement&lt;&lt;std::endl;<BR>++fi;</FONT></FONT></DIV>
<DIV>
<P><FONT color="#000000">}</FONT></P>
<P><FONT color="#000000">typedef itk::WarpImageFilter&lt; FixedImageType, <BR>FixedImageType, <BR>DeformationFieldType &gt; DeformFilterType;<BR>DeformFilterType::Pointer filter = DeformFilterType::New();<BR></FONT><FONT color="#000000">//&nbsp; fiil the deform filter,such as SetInterpolator,SetOutputSpacing,....</FONT></P>
<P><FONT color="#000000">typedef itk::LinearInterpolateImageFunction&lt; <BR>FixedImageType, double &gt; InterpolatorType1;<BR>InterpolatorType1::Pointer interpolator1 = InterpolatorType1::New();<BR>filter-&gt;SetInterpolator( interpolator1 );<BR>filter-&gt;SetOutputSpacing( field-&gt;GetSpacing() );<BR>filter-&gt;SetOutputOrigin( field-&gt;GetOrigin() );<BR>filter-&gt;SetDeformationField( field );<BR>filter-&gt;SetInput( fixedReader-&gt;GetOutput() );</FONT></P>
<P><FONT color="#000000">//define the writer </FONT></P>
<P><FONT color="#000000">typedef itk::ImageFileWriter&lt; FixedImageType &gt; WriterType;<BR>WriterType::Pointer writer = WriterType::New();<BR>writer-&gt;SetFileName( argv[5] );<BR>writer-&gt;SetInput( filter-&gt;GetOutput() );<BR>&nbsp;// try the wrap filter and get the result<BR>try<BR>{<BR>writer-&gt;Update();<BR>}<BR>catch( itk::ExceptionObject &amp; excp )<BR>{<BR>std::cerr &lt;&lt; "Exception thrown " &lt;&lt; std::endl;<BR>std::cerr &lt;&lt; excp &lt;&lt; std::endl;<BR>}<BR></FONT></P>
<P><FONT color="#000000">&nbsp;</FONT></P></DIV><br><!-- footer --><br><span title="neteasefooter"/><hr/>
<a href="http://love.mail.163.com/valentine/main.do">免费送你和爱人去新加坡过情人节!</a>
</span>