[Insight-users] incorrect warpped RT image with resample deformed field
Hsiang-Chi Kuo
kuoxgx at gmail.com
Mon Nov 9 00:24:02 EST 2009
Hi Luis,
I am trying to warp a RT dose image file with a deformation field obtained
from Demon registration. The original deformation field has resolution of
1mmx1mmx2.5mm. The dose image file has resolution of 2.5mmx2.5mmx2.5mm. I
applied VectorResampleImageFilter to resample the deformation filed with the
same resolution, size and origin as those of the dose image. ( I checked the
old and new deformed image in para view, they look alike.) After I warp the
dose image with the new deformation file, the new deform dose image look
good at the z direction, however, the displacement of the dose image at x
and y direction did not look the same as the displacement in the x and y
direction of the deformation field. Following is my code the resample the
deformed field and wrap the deformed filed with the original dose image. It
looks like my code only do a good job in the z direction where no resample
of the resolution (and position) is needed. Anything wrong in my code?
Thanks a lot for any of your input,
Howard.
typedef float ComponentType;
typedef itk::Vector< ComponentType, 3 > vectorPixelType;
typedef itk::Image< vectorPixelType, 3 > deFormImageType;
//typedef itk::Image< ComponentType, Dimension > ComponentImageType;
typedef itk::ImageFileReader< deFormImageType > deFormReaderType;
deFormReaderType::Pointer deFormReader = deFormReaderType::New();
deFormReader->SetFileName( argv[2] );
try
{
deFormReader->Update();
}
catch( itk::ExceptionObject & excp )
{
std::cerr << "Problem reading image file : " << argv[1] << std::endl;
std::cerr << excp << std::endl;
return -1;
}
std::cout << "Read 2 ok" << std::endl;
typedef itk::VectorResampleImageFilter<deFormImageType,deFormImageType>
FilterType;
FilterType::Pointer resampleFilter = FilterType::New();
typedef itk::IdentityTransform< double, Dimension > TransformType;
TransformType::Pointer transform = TransformType::New();
resampleFilter->SetTransform( transform );
typedef
itk::VectorLinearInterpolateNearestNeighborExtrapolateImageFunction<
deFormImageType, double > InterpolatorType;
InterpolatorType::Pointer vectorInterpolator = InterpolatorType::New();
resampleFilter->SetDefaultPixelValue( 0.0 );
InputImageType::Pointer fixedImage = reader->GetOutput();
InputImageType::SpacingType spacing;
spacing[0] = 2.5; // pixel spacing in millimeters along X
spacing[1] = 2.5; // pixel spacing in millimeters along Y
spacing[2] = 2.5; // pixel spacing in millimeters along Z
// typedef InputImageType::SpacingType SpacingType;
typedef InputImageType::PointType OriginType;
typedef InputImageType::RegionType RegionType;
typedef InputImageType::SizeType SizeType;
// const SpacingType spacing= fixedImage->GetSpacing();
const OriginType origin= fixedImage->GetOrigin();
const RegionType region= fixedImage->GetLargestPossibleRegion();
const SizeType size= region.GetSize();
resampleFilter->SetInterpolator( vectorInterpolator );
resampleFilter->SetOutputOrigin( origin );
resampleFilter->SetOutputSpacing( spacing );
resampleFilter->SetSize( size );
resampleFilter->SetInput( deFormReader->GetOutput() );
typedef itk::WarpImageFilter< InputImageType, InputImageType,
deFormImageType > WarperType;
typedef itk::LinearInterpolateImageFunction< InputImageType, double >
LinearInterpolatorType;
WarperType::Pointer warper = WarperType::New();
LinearInterpolatorType::Pointer interpolator =
LinearInterpolatorType::New();
warper->SetInput( fixedImage );
warper->SetInterpolator( interpolator );
warper->SetOutputSpacing( fixedImage->GetSpacing() );
warper->SetOutputOrigin( fixedImage->GetOrigin() );
warper->SetDeformationField( resampleFilter->GetOutput() );
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20091109/38b2f0e8/attachment-0001.htm>
More information about the Insight-users
mailing list