[Insight-users] Is tehere a documentation about pointsettoimageregistration

tony hakki tony2007vtk at yahoo.com
Wed May 9 05:22:22 EDT 2007


hello,
is there a available source/documentation  which is talking about PointSetToImageRegistration. As far as I checked it out ItkSoftwareGuide.pdf doesn't include enough knowledge about that topic. For example I haven't found out that how can I use last registration paremeters at  the end of the registration process,and also there is no knowledge about 3D PointSetToImageRegistration. I tried to implement 3D PointSetToImageRegistration and It doesn't work. 
my inputs:
1-STL I converted it itkmesh form then itk pointset
2-raw image which is DimSize = 329 527 181 and resolution = 0.200068 0.200068 0.200068  and 60 MB

here is my code ,Could someone ,who is expert on pointsettoimageregistration pocesss, checked  out my code?

// Registration part
// Here I have  itk mesh and I convert it to pointset
const unsigned int Dimension = 3;
typedef unsigned short PixelType;
typedef itk::PointSet< float, Dimension > FixedPointSetType;
typedef itk::Image< PixelType, Dimension > MovingImageType;
typedef FixedPointSetType::PointsContainer PointsContainer;
PointsContainer::Pointer pointsContainer = PointsContainer::New();
pointsContainer = input_mesh->GetPoints();
itk::PointSet<float, 3>::Pointer pointSet = itk::PointSet<float,3>::New();
pointSet->SetPoints(pointsContainer);
unsigned long pointId = 0;
typedef FMeshType::PointsContainer::Iterator PointsIterator;
//itk::PointSet<float, 3>::Pointer pointSet = itk::PointSet<float,3>::New();
PointsIterator pointIterator = input_mesh->GetPoints()->Begin(); 
PointsIterator end = input_mesh->GetPoints()->End();
while( pointIterator != end ) 
{
FMeshType::PointType p = pointIterator.Value(); // access the point
std::cout << p << std::endl; // print the point
pointSet->SetPoint( pointId, p );// advance to next point
pointSet->SetPointData( pointId, pointSet->GetBufferedRegion() );
++pointIterator; 
++pointId;
}
//-----------------------------------------------------------
// Set up a Transform
//-----------------------------------------------------------
typedef itk::VersorRigid3DTransform< double > TransformType;
TransformType::Pointer transform = TransformType::New();
//------------------------------------------------------------
// Optimizer Type
//-----------------------------------------------------------
typedef itk::VersorRigid3DTransformOptimizer  OptimizerType;
OptimizerType::Pointer optimizer = OptimizerType::New();
 
//------------------------------------------------------------
// Set up an Interpolator
//------------------------------------------------------------
typedef itk::LinearInterpolateImageFunction< 
MovingImageType,
double > InterpolatorType;
InterpolatorType::Pointer interpolator = InterpolatorType::New();
//-----------------------------------------------------------
// Set up Metric
//-----------------------------------------------------------
typedef itk::NormalizedCorrelationPointSetToImageMetric< 
FixedPointSetType, 
MovingImageType > MetricType;
typedef MetricType::TransformType TransformBaseType;
typedef TransformBaseType::ParametersType ParametersType;
MetricType::Pointer metric = MetricType::New();
//-----------------------------------------------------------
//RegistrationMethod
//-----------------------------------------------------------
typedef itk::PointSetToImageRegistrationMethod< 
FixedPointSetType,
MovingImageType > RegistrationType;
RegistrationType::Pointer registrationMethod = RegistrationType::New();

// Scale the translation components of the Transform in the Optimizer
typedef OptimizerType::ScalesType OptimizerScalesType;
OptimizerScalesType optimizerScales( transform->GetNumberOfParameters() );
const double translationScale = 1.0 / 1000.0;
optimizerScales[0] = 1.0;
optimizerScales[1] = 1.0;
optimizerScales[2] = 1.0;
optimizerScales[3] = translationScale;
optimizerScales[4] = translationScale;
optimizerScales[5] = translationScale;
optimizer->SetMaximumStepLength( 1.00 );
optimizer->SetMinimumStepLength( 0.001 );
optimizer->SetNumberOfIterations( 500 );
optimizer->SetRelaxationFactor( 0.90 );
optimizer->SetGradientMagnitudeTolerance( 0.05 );
optimizer->MinimizeOn();
 

 
// can probably provide a better guess than the identity...
transform->SetIdentity();
registrationMethod->SetInitialTransformParameters( transform->GetParameters() );
RegistrationType::ParametersType initialParameters( 
transform->GetNumberOfParameters() );
initialParameters.Fill( 0.0 );
initialParameters[3] = 1.0;
 
 
// Connect all the components required for Registration
//------------------------------------------------------
registrationMethod->SetMetric( metric );
registrationMethod->SetOptimizer( optimizer );
registrationMethod->SetFixedPointSet(pointSet);
registrationMethod->SetMovingImage(input);
registrationMethod->SetInterpolator(interpolator);
registrationMethod->SetTransform( transform );
//------------------------------------------------------------
// Set up transform parameters
//------------------------------------------------------------
ParametersType parameters( transform->GetNumberOfParameters() );
// initialize the offset/vector part
for( unsigned int k = 0; k <Dimension; k++ )
{
parameters[k]= 0.0f;
}
try 
{
registrationMethod->SetInitialTransformParameters( initialParameters );
registrationMethod->StartRegistration();
}
catch( itk::ExceptionObject & e )
{
std::cout << e << std::endl;
}
 
 
OptimizerType::ParametersType finalParameters =registrationMethod->GetLastTransformParameters();
const unsigned int nmbrOfIterations = optimizer->GetCurrentIteration();
const double bestValue = optimizer->GetValue();

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20070509/92dd0de4/attachment-0001.html


More information about the Insight-users mailing list