[Insight-users] Problem with MeanSquaresImageToImageMetric
suresh
suresh " <suresh_kb at rediffmail . com
23 Aug 2002 13:03:06 -0000
Hi friends,
I'm getting a windows illegal operation error while runing the
following code.
I've coded this following the MIRegistration example. I could
not run this.
When i call registration->StartRegistyration() the error is
thrown..
NOTE: The images are of type Image<unsigned short, 3>
*********CODE SNIPPET****************
typedef itk::QuaternionRigidTransform<double>
TransformType;
typedef itk::QuaternionRigidTransformGradientDescentOptimizer
OptimizerType;
typedef itk::LinearInterpolateImageFunction<ImageType,
double> InterpolatorType;
typedef itk::ImageRegistrationMethod<ImageType,ImageType>
RegistrationType1;
typedef itk::MeanSquaresImageToImageMetric<ImageType,
ImageType> MetricType;
MetricType::Pointer metric =
MetricType::New();
TransformType::Pointer transform =
TransformType::New();
OptimizerType::Pointer optimizer =
OptimizerType::New();
InterpolatorType::Pointer interpolator =
InterpolatorType::New();
RegistrationType1::Pointer registration =
RegistrationType1::New();
RegistrationType1::ParametersType
guess(transform->GetNumberOfParameters() );
guess[0] = 0.0; guess[1] = 0.0; guess[2] = 0.0; guess[3] =
1.0;
guess[4] = 20.0; guess[5] = 40.0; guess[6] = 0.0;
ImagePointer fixedImage = BufferToImage(MRI);// built from an
pixel buffer
ImagePointer movingImage = BufferToImage(SPECT);
registration->SetInitialTransformParameters (guess);
//Set translation scale
typedef OptimizerType::ScalesType ScaleType;
ScaleType scales(transform->GetNumberOfParameters());
scales.Fill( 1.0 );
for( unsigned j = 4; j < 7; j++ )
{
scales[j] = 1.0 / vnl_math_sqr(300.0);
}
//Scale parameters
optimizer->SetNumberOfIterations( 1 );
optimizer->SetLearningRate( 0.0000001 );
//set registration parameters
registration->SetMetric(metric);
registration->SetOptimizer(optimizer);
registration->SetTransform(transform);
registration->SetInterpolator(interpolator);
registration->SetFixedImage(fixedImage);
registration->SetMovingImage(movingImage);
// Setup the optimizer
optimizer->SetScales(scales);
registration->StartRegistration();
***********************************************************************
can anybody help me with this.??
Thank you
suresh