<DIV> 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> </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> </DIV>
<DIV>// define the types for computing deform field</DIV>
<DIV><FONT color="#008000"><FONT color="#000000"> typedef itk::Point< float, ImageDimension > PointType; <BR>typedef itk::Vector< float, ImageDimension > VectorType;<BR>typedef itk::Image< VectorType, ImageDimension > DeformationFieldType;<BR>DeformationFieldType::Pointer field = DeformationFieldType::New();<BR>field->SetRegions( fixedRegion );<BR>field->SetOrigin( fixedOrigin );<BR>field->SetSpacing( fixedSpacing );<BR>field->SetDirection( fixedDirection );<BR>field->Allocate();<BR>typedef itk::ImageRegionIterator< DeformationFieldType > 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 is right<BR>while( ! fi.IsAtEnd() )<BR>{<BR>index = fi.GetIndex();<BR>field->TransformIndexToPhysicalPoint( index, fixedPoint );<BR>movingPoint = bsplineTransform->TransformPoint( fixedPoint );<BR>displacement = fixedPoint -movingPoint ;<BR>fi.Set( displacement );<BR>//std::cout<<displacement<<std::endl;<BR>++fi;</FONT></FONT></DIV>
<DIV>
<P><FONT color="#000000">}</FONT></P>
<P><FONT color="#000000">typedef itk::WarpImageFilter< FixedImageType, <BR>FixedImageType, <BR>DeformationFieldType > DeformFilterType;<BR>DeformFilterType::Pointer filter = DeformFilterType::New();<BR></FONT><FONT color="#000000">// fiil the deform filter,such as SetInterpolator,SetOutputSpacing,....</FONT></P>
<P><FONT color="#000000">typedef itk::LinearInterpolateImageFunction< <BR>FixedImageType, double > InterpolatorType1;<BR>InterpolatorType1::Pointer interpolator1 = InterpolatorType1::New();<BR>filter->SetInterpolator( interpolator1 );<BR>filter->SetOutputSpacing( field->GetSpacing() );<BR>filter->SetOutputOrigin( field->GetOrigin() );<BR>filter->SetDeformationField( field );<BR>filter->SetInput( fixedReader->GetOutput() );</FONT></P>
<P><FONT color="#000000">//define the writer </FONT></P>
<P><FONT color="#000000">typedef itk::ImageFileWriter< FixedImageType > WriterType;<BR>WriterType::Pointer writer = WriterType::New();<BR>writer->SetFileName( argv[5] );<BR>writer->SetInput( filter->GetOutput() );<BR> // try the wrap filter and get the result<BR>try<BR>{<BR>writer->Update();<BR>}<BR>catch( itk::ExceptionObject & excp )<BR>{<BR>std::cerr << "Exception thrown " << std::endl;<BR>std::cerr << excp << std::endl;<BR>}<BR></FONT></P>
<P><FONT color="#000000"> </FONT></P></DIV><br><!-- footer --><br><span title="neteasefooter"/><hr/>
<a href="http://love.mail.163.com/valentine/main.do">免费送你和爱人去新加坡过情人节!</a>
</span>