[Insight-users] Using VersorRigid3DTransform
Luis Ibanez
luis.ibanez at kitware.com
Thu Jun 3 02:37:42 EDT 2004
Hi Bsson,
Please us the CenteredTransformInitializer class in
order to initialize the VersorRigid3DTransform.
You will find an example on how to do this initialization
in the file:
Insight/Examples/Registration/
ImageRegistration8.cxxx
The fact that your two volumes may have different pixel
spacing shouldn't produce any problem.
Regards,
Luis
--------------
¼Õº¸¼± wrote:
> Dear ITK users,
>
>
>
> I am trying to use ITK for a registration process. Using
> VersorRigid3DTransform (itk:: VersorRigid3DTransform), a series of exam
> success, but other is fail. Source code is below...
>
> =========== source start ===================
>
> UINT ThreadStartRegistration(LPVOID infoIn)
>
> {
>
> CMyDoc* pDoc = (CMyDoc*)infoIn;
>
> CMyView* pAutoView = pDoc->GetMyView();
>
> typedef float InternalPixelType;
>
> typedef itk::Image<InternalPixelType,3>
> InternalImageType;
>
>
>
> typedef
> itk::VersorRigid3DTransform<double>
> TransformType;
>
> typedef
> itk::VersorRigid3DTransformOptimizer
> OptimizerType;
>
> typedef
> itk::MattesMutualInformationImageToImageMetric<InternalImageType,InternalImageType>
> MetricType;
>
> typedef
> itk::LinearInterpolateImageFunction<InternalImageType,double>
> InterpolatorType;
>
> typedef
> itk::ImageRegistrationMethod<InternalImageType,InternalImageType>
> RegistrationType;
>
>
>
> MetricType::Pointer metric = MetricType::New();
>
> OptimizerType::Pointer optimizer =
> OptimizerType::New();
>
> InterpolatorType::Pointer interpolator =
> InterpolatorType::New();
>
> RegistrationType::Pointer registration =
> RegistrationType::New();
>
> TransformType::Pointer transform =
> TransformType::New();
>
>
>
> unsigned long iNumSamples =
>
>
> pDoc->m_sizePrimary3DImage[0]*pDoc->m_sizePrimary3DImage[1]*pDoc->m_sizePrimary3DImage[2]*2/100;
> // 3 percentage of total pixels
>
> metric->SetNumberOfSpatialSamples(iNumSamples);
>
>
>
> registration->SetMetric(metric);
>
> registration->SetOptimizer(optimizer);
>
> registration->SetInterpolator(interpolator);
>
> registration->SetTransform( transform );
>
>
>
> typedef
> itk::NormalizeImageFilter<ImageType,InternalImageType> NormalizeFilterType;
>
> NormalizeFilterType::Pointer fixedNormalizer =
> NormalizeFilterType::New();
>
> NormalizeFilterType::Pointer movingNormalizer =
> NormalizeFilterType::New();
>
>
>
> fixedNormalizer->SetInput(pDoc->m_Primary3DImage.GetPointer());
>
>
> movingNormalizer->SetInput(pDoc->m_Secondary3DImage.GetPointer());
>
>
>
> registration->SetFixedImage(fixedNormalizer->GetOutput());
>
> registration->SetMovingImage(movingNormalizer->GetOutput());
>
>
>
>
> registration->SetFixedImageRegion(pDoc->m_Primary3DImage.GetPointer()->GetBufferedRegion());
>
>
>
> itk::Point<double,3> initialCenter =
> pDoc->m_transformMomentCenter->GetCenter();
>
> itk::Vector<double,3> initialTranslation =
> pDoc->m_3DTransformManualMode->GetOffset();
>
> transform->SetCenter(initialCenter);
>
> transform->SetTranslation(initialTranslation);
>
>
>
> typedef TransformType::VersorType VersorType;
>
> typedef VersorType::VectorType VectorType;
>
> VersorType rotation;
>
> VectorType axis;
>
>
>
> axis[0] = 0.0;
>
> axis[1] = 0.0;
>
> axis[2] = 1.0;
>
>
>
> const double angle = 0;
>
> rotation.Set(axis,angle);
>
> transform->SetRotation(rotation);
>
>
>
>
> registration->SetInitialTransformParameters(transform->GetParameters());
>
>
>
> typedef OptimizerType::ScalesType
> OptimizerScalesType;
>
> OptimizerScalesType
> optimizerScales(transform->GetNumberOfParameters());
>
>
>
> const double translationScale =
>
> 1.0 / (10.0 *
> pDoc->m_vSpacingPrimary3DImage[0]*pDoc->m_sizePrimary3DImage[0]);
>
> optimizerScales[0] = 1.0;
>
> optimizerScales[1] = 1.0;
>
> optimizerScales[2] = 1.0;
>
> optimizerScales[3] = translationScale;
>
> optimizerScales[4] = translationScale;
>
> optimizerScales[5] = translationScale;
>
>
>
> optimizer->SetScales(optimizerScales);
>
>
>
> optimizer->SetMaximumStepLength(1.0);
>
> optimizer->SetMinimumStepLength(0.005);
>
>
>
> optimizer->SetNumberOfIterations(50);
>
>
>
> CCommandIterationUpdate::Pointer observer =
> CCommandIterationUpdate::New();
>
> observer->SetDocument(pDoc);
>
> optimizer->AddObserver( itk::IterationEvent(), observer );
>
>
>
> try
>
> {
>
> registration->StartRegistration();
>
> }
>
> catch( itk::ExceptionObject & err )
>
> {
>
> TRACE("ExceptionObject caught !\n");
>
> return 0;
>
> }
>
> return 0;
>
> }
>
> =========== source end ===================
>
>
>
> I suspect pixel spacing of series. A case of success series is both have
> same pixel spacing, but other is different. What do you think about it?
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
More information about the Insight-users
mailing list