[Insight-users] Pointset to image registration
tony hakki
tony2007vtk at yahoo.com
Mon Feb 5 10:21:03 EST 2007
Hello
I need really urgent help, here is my code about pointset to image registration. I comleted ,it seems that everything ok,but when run it i gives break or continue error. The reason of this code is the lastest line "registrationMethod->StartRegistration();". How can understand if the registration works correctly? It seems everthing is ok? Please help me..
Here is my code:
// Registration part
const unsigned int Dimension = 3;
typedef float PixelType;
typedef itk::PointSet< PixelType, Dimension > FixedPointSetType;
typedef itk::Image< PixelType, Dimension > MovingImageType;
//-----------------------------------------------------------
// Set up a Transform
//-----------------------------------------------------------
typedef double CoordinateRepresentationType;
typedef itk::TranslationTransform<
CoordinateRepresentationType,
Dimension > TransformType;
TransformType::Pointer transform = TransformType::New();
//------------------------------------------------------------
// Optimizer Type
typedef itk::RegularStepGradientDescentOptimizer OptimizerType;
OptimizerType::Pointer optimizer = OptimizerType::New();
//-----------------------------------------------------------
// Set up Metric
//-----------------------------------------------------------
typedef itk::NormalizedCorrelationPointSetToImageMetric<
FixedPointSetType,
MovingImageType > MetricType;
typedef MetricType::TransformType TransformBaseType;
typedef TransformBaseType::ParametersType ParametersType;
typedef TransformBaseType::JacobianType JacobianType;
MetricType::Pointer metric = MetricType::New();
//------------------------------------------------------------
// Set up an Interpolator
//------------------------------------------------------------
typedef itk::LinearInterpolateImageFunction<
MovingImageType,
double > InterpolatorType;
InterpolatorType::Pointer interpolator = InterpolatorType::New();
//------------------------------------------------------------
//RegistrationMethod
typedef itk::PointSetToImageRegistrationMethod<
FixedPointSetType,
MovingImageType > RegistrationType;
RegistrationType::Pointer registrationMethod = RegistrationType::New();
// Scale the translation components of the Transform in the Optimizer
OptimizerType::ScalesType scales( transform->GetNumberOfParameters() );
scales.Fill( 1.0 );
unsigned long numberOfIterations = 50;
//double translationScale = 1.0; // not used
double maximumStepLenght = 1.0; // no step will be larger than this
double minimumStepLenght = 0.01; // convergence criterion
double gradientTolerance = 1e-6; // convergence criterion
optimizer->SetScales( scales );
optimizer->SetNumberOfIterations( numberOfIterations );
optimizer->SetMinimumStepLength( minimumStepLenght );
optimizer->SetMaximumStepLength( maximumStepLenght );
optimizer->SetGradientMagnitudeTolerance( gradientTolerance );
optimizer->MinimizeOn();
// Start from an Identity transform (in a normal case, the user
// can probably provide a better guess than the identity...
transform->SetIdentity();
registrationMethod->SetInitialTransformParameters( transform->GetParameters() );
//Reading .RAW dataSet
typedef itk::ImageFileReader< MovingImageType > ReaderType;
typedef itk::RawImageIO<PixelType,Dimension> ImageIOType;
ImageIOType::Pointer RawIO = ImageIOType::New();
ReaderType::Pointer rawreader = ReaderType::New();
rawreader->SetFileName(filename);
// Connect all the components required for Registration
//------------------------------------------------------
registrationMethod->SetMetric( metric );
registrationMethod->SetOptimizer( optimizer );
registrationMethod->SetTransform( transform );
registrationMethod->SetFixedPointSet(mesh.GetPointer());
registrationMethod->SetMovingImage(rawreader->GetOutput());
registrationMethod->SetInterpolator(interpolator);
//------------------------------------------------------------
// 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;
}
registrationMethod->StartRegistration(); //Here gives break or continue error and it also says:
Unhandled exception at 0x7c812a5b in nfinity.exe: Microsoft C++ exception: itk::ExceptionObject at memory location 0x0012ea7c..
____________________________________________________________________________________
No need to miss a message. Get email on-the-go
with Yahoo! Mail for Mobile. Get started.
http://mobile.yahoo.com/mail
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20070205/f69730e6/attachment.htm
More information about the Insight-users
mailing list