[Insight-developers] itkCenteredVersorTransformInitializer

Richard Beare richard.beare at gmail.com
Mon Jul 2 01:07:38 EDT 2007


Hi everyone,

CenteredVersorTransformInitializer, a descendent of
CenteredTransformInitializer is meant to use image second moments to
initalize a transform angle. However all the current version does is
retrieve the principal axes from the moment calculators in the
superclass.

I've extended it ( see below ) and it seems to do the job on some
simple test images. However I'm not particularly familiar with versor
manipulation so there is a fair chance I've got something wrong,
particularly initializing the versor from the matrix. Do problems jump
out at anyone?

Thanks

template < class TFixedImage, class TMovingImage >
void
CenteredVersorTransformInitializer<TFixedImage, TMovingImage >
::InitializeTransform() const
{
  // Compute moments and initialize center of rotaion and translation
  this->Superclass::InitializeTransform();

  typedef typename Superclass::FixedImageCalculatorType::MatrixType
                                                             FixedMatrixType;
  typedef typename Superclass::MovingImageCalculatorType::MatrixType
                                                            MovingMatrixType;

  FixedMatrixType   fixedPrincipalAxis  =
                              this->GetFixedCalculator()->GetPrincipalAxes();
  MovingMatrixType  movingPrincipalAxis =
                             this->GetMovingCalculator()->GetPrincipalAxes();
  // new stuff from here down
  MovingMatrixType combined;
  combined = movingPrincipalAxis.GetInverse();
  combined *= fixedPrincipalAxis;

  typename TransformType::VersorType V;
  V.Set(combined);

  typename TransformType::ParametersType P = this->m_Transform->GetParameters();
  for (unsigned i = 0; i < 3; i++)
    {
    P[i] = V.GetRight()[i];
    }
  this->m_Transform->SetParameters(P);
}


More information about the Insight-developers mailing list