[Insight-users] if there are somethings wrong with deform image using deform fields?

Han D. F jlu_hdf at 126.com
Thu Jan 29 12:17:30 EST 2009


 I use the bspline deform field (which is computed from the bapline registration algorithm) to wrap the image to the new image.
When I use the the bspline parameters, the result is ok.
when using the defor field, the result is wrong.
Below is the code, id there is some thing wrong? 
thnanks
 
assuming the bsplineTransform is computed and I will compute the deform field and warp to a new image.
help me check the code and many thanks to your help
 
// define the  types for computing deform field
 typedef itk::Point< float, ImageDimension > PointType;      
typedef itk::Vector< float, ImageDimension > VectorType;
typedef itk::Image< VectorType, ImageDimension > DeformationFieldType;
DeformationFieldType::Pointer field = DeformationFieldType::New();
field->SetRegions( fixedRegion );
field->SetOrigin( fixedOrigin );
field->SetSpacing( fixedSpacing );
field->SetDirection( fixedDirection );
field->Allocate();
typedef itk::ImageRegionIterator< DeformationFieldType > FieldIterator;
FieldIterator fi( field, fixedRegion );
fi.GoToBegin();
TransformType::InputPointType fixedPoint;
TransformType::OutputPointType movingPoint;
DeformationFieldType::IndexType index;
VectorType displacement;
// getting the deform field, I have see the result the computed displacement  is right
while( ! fi.IsAtEnd() )
{
index = fi.GetIndex();
field->TransformIndexToPhysicalPoint( index, fixedPoint );
movingPoint = bsplineTransform->TransformPoint( fixedPoint );
displacement = fixedPoint -movingPoint ;
fi.Set( displacement );
//std::cout<<displacement<<std::endl;
++fi;

}

typedef itk::WarpImageFilter< FixedImageType, 
FixedImageType, 
DeformationFieldType > DeformFilterType;
DeformFilterType::Pointer filter = DeformFilterType::New();
//  fiil the deform filter,such as SetInterpolator,SetOutputSpacing,....

typedef itk::LinearInterpolateImageFunction< 
FixedImageType, double > InterpolatorType1;
InterpolatorType1::Pointer interpolator1 = InterpolatorType1::New();
filter->SetInterpolator( interpolator1 );
filter->SetOutputSpacing( field->GetSpacing() );
filter->SetOutputOrigin( field->GetOrigin() );
filter->SetDeformationField( field );
filter->SetInput( fixedReader->GetOutput() );

//define the writer 

typedef itk::ImageFileWriter< FixedImageType > WriterType;
WriterType::Pointer writer = WriterType::New();
writer->SetFileName( argv[5] );
writer->SetInput( filter->GetOutput() );
 // try the wrap filter and get the result
try
{
writer->Update();
}
catch( itk::ExceptionObject & excp )
{
std::cerr << "Exception thrown " << std::endl;
std::cerr << excp << std::endl;
}


 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20090130/f2d4b0eb/attachment.htm>


More information about the Insight-users mailing list