[Insight-users] Thin-Plate Spline Image Registration
Dav
masslawi at gmail.com
Wed Sep 22 10:29:07 EDT 2010
Greetings dear members,I am trying to register pair of CT images using the Thin-Plate Spline (TPS) transform and the following source code is the section related to TPS registration:
**********************************************************************************************************const unsigned int
Dimension = 2;
typedef short PixelType;
typedef
itk::Image< PixelType, Dimension >
FixedImageType;
typedef
itk::Image< PixelType, Dimension >
MovingImageType;
typedef double CoordinateRepType;
typedef
itk::ThinPlateSplineKernelTransform< CoordinateRepType, Dimension>
TransformType;
typedef
itk::ImageRegistrationMethod< FixedImageType, MovingImageType > RegistrationType;
typedef itk::Point< CoordinateRepType, Dimension
> PointType;
typedef TransformType::PointSetType PointSetType;
typedef PointSetType::Pointer PointSetPointer;
typedef PointSetType::PointIdentifier PointIdType;
typedef
itk::RegularStepGradientDescentOptimizer
OptimizerType;
typedef
itk::MutualInformationImageToImageMetric< FixedImageType, MovingImageType
> MetricType;
typedef itk::
LinearInterpolateImageFunction< MovingImageType, double> InterpolatorType;
OptimizerType::Pointer optimizer = OptimizerType::New();
InterpolatorType::Pointer interpolator
= InterpolatorType::New();
RegistrationType::Pointer registration
= RegistrationType::New();
MetricType::Pointer metric
= MetricType::New();
//------------------------------------------------------------------------------------------------------//
PointSetType::Pointer sourceLandMarks =
PointSetType::New();
PointSetType::Pointer targetLandMarks = PointSetType::New();
PointType p1;
PointType p2;
PointSetType::PointsContainer::Pointer
sourceLandMarkContainer = sourceLandMarks->GetPoints();
PointSetType::PointsContainer::Pointer
targetLandMarkContainer = targetLandMarks->GetPoints();
PointIdType id = itk::NumericTraits<
PointIdType >::Zero;
// Read in the list
of landmarks
std::ifstream infile;
infile.open( argv[1] );
while
(!infile.eof())
{
infile >> p1[0] >> p1[1] >> p2[0] >>
p2[1];
sourceLandMarkContainer->InsertElement(
id, p1 );
targetLandMarkContainer->InsertElement(
id++, p2 );
}
infile.close();
TransformType::Pointer tps =
TransformType::New();
tps->SetSourceLandmarks(sourceLandMarks);
tps->SetTargetLandmarks(targetLandMarks);
tps->ComputeWMatrix();
//-------------------------------------------------------------------------------------------------------//
registration->SetOptimizer( optimizer );
registration->SetTransform( tps
);
registration->SetInterpolator( interpolator
);
registration->SetMetric( metric );
typedef
itk::ImageFileReader< FixedImageType
> FixedImageReaderType;
typedef
itk::ImageFileReader< MovingImageType > MovingImageReaderType;
FixedImageReaderType::Pointer fixedImageReader = FixedImageReaderType::New();
MovingImageReaderType::Pointer
movingImageReader = MovingImageReaderType::New();
fixedImageReader->SetFileName( argv[2] );
movingImageReader->SetFileName( argv[3] );
registration->SetFixedImage( fixedImageReader->GetOutput() );
registration->SetMovingImage( movingImageReader->GetOutput() );
fixedImageReader->Update();
registration->SetFixedImageRegion(
fixedImageReader->GetOutput()->GetBufferedRegion() );
typedef
RegistrationType::ParametersType ParametersType;
ParametersType initialParameters(
tps->GetNumberOfParameters() );
initialParameters = tps->GetParameters();
std::cout << "
TPS Parameters = " << tps->GetParameters() <<
std::endl;
std::cout << "
TPS Parameters = " << initialParameters << std::endl;
registration->SetInitialTransformParameters( initialParameters );
optimizer->SetNumberOfIterations( 200 );
optimizer->SetRelaxationFactor( 0.9 );
try
{
registration->StartRegistration();
std::cout << "Optimizer
stop condition: "
<<
registration->GetOptimizer()->GetStopConditionDescription()
<< std::endl;
}
catch(
itk::ExceptionObject & err )
{
std::cout << "ExceptionObject
caught !" << std::endl;
std::cout << err << std::endl;
return
EXIT_FAILURE;
}*********************************************************************************************************
This code is suppose to register two CT images with predefined landmarks which are the TPS transformation parameters. The code compiles just fine however in time of execution I get the following error: *********************************************************************************************************Location: "const class itk::Array2D<double>
&__thiscall itk::KernelTransform<double,2>::GetJacobian(const class
itk::Point<double,2> &) const"
File: e:\research programs\[][ir] itk\insighttoolkit-3.18.0\code\common\itkKernelTransform.txx
Line: 455
Description: itk::ERROR: ThinPlateSplineKernelTransform(01571248):
GetJacobian must be implemented in subclasses of KernelTransform.***************************************************************************The used landmark file is similar to what have been used for the ThinPlateSplineWarp example in the ITK framework and I don't think that is the cause of error. My guess is that the parameters initialization of the registration method is not configured properly but I don't know how to correct that. I would appreciate any help to solve this issue.Best regards,Davoud.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20100922/206ff9ea/attachment-0001.htm>
More information about the Insight-users
mailing list