예제 #1
0
itk::Object::Pointer QmitkAffineTransformView::GetTransform2(itk::Image<TPixelType, VImageDimension>* /*itkImage1*/)
{
  typedef typename itk::Image< TPixelType, VImageDimension >  FixedImageType;
  typedef typename itk::Image< TPixelType, VImageDimension >  MovingImageType;
  typename FixedImageType::Pointer fixedImage;
  mitk::CastToItkImage(m_FixedImage, fixedImage);
  typename MovingImageType::Pointer movingImage;
  mitk::CastToItkImage(m_MovingImage, movingImage);
  typename itk::AffineTransform< double, VImageDimension>::Pointer transformPointer = itk::AffineTransform< double, VImageDimension>::New();
  transformPointer->SetIdentity();
  if (m_Controls.m_CenterForInitializerAffine->isChecked())
  {
    typedef typename itk::AffineTransform< double, VImageDimension >    AffineTransformType;
    typedef typename itk::CenteredTransformInitializer<AffineTransformType, FixedImageType, MovingImageType> TransformInitializerType;
    typename TransformInitializerType::Pointer transformInitializer = TransformInitializerType::New();
    transformInitializer->SetFixedImage( fixedImage );
    transformInitializer->SetMovingImage( movingImage );
    transformInitializer->SetTransform( transformPointer );
    if (m_Controls.m_MomentsAffine->isChecked())
    {
      transformInitializer->MomentsOn();
    }
    else
    {
      transformInitializer->GeometryOn();
    }
    transformInitializer->InitializeTransform();
  }
  m_CenterX = transformPointer->GetCenter()[0];
  m_CenterY = transformPointer->GetCenter()[1];
  m_CenterZ = transformPointer->GetCenter()[2];
  m_TransformObject = transformPointer.GetPointer();
  return transformPointer.GetPointer();
}
예제 #2
0
itk::Object::Pointer QmitkAffineTransformView::GetTransform2(itk::Image<TPixelType, VImageDimension>* itkImage1)
{
  typedef typename itk::Image< TPixelType, VImageDimension >  FixedImageType;
  typedef typename itk::Image< TPixelType, VImageDimension >  MovingImageType;

  // the fixedImage is the input parameter (fix for Bug #14626)
  typename FixedImageType::Pointer fixedImage = itkImage1;

  // the movingImage type is known, use the ImageToItk filter (fix for Bug #14626)
  typename mitk::ImageToItk<MovingImageType>::Pointer movingImageToItk = mitk::ImageToItk<MovingImageType>::New();
  movingImageToItk->SetInput(m_MovingImage);
  movingImageToItk->Update();
  typename MovingImageType::Pointer movingImage = movingImageToItk->GetOutput();

  typename itk::AffineTransform< double, VImageDimension>::Pointer transformPointer = itk::AffineTransform< double, VImageDimension>::New();
  transformPointer->SetIdentity();
  if (m_Controls.m_CenterForInitializerAffine->isChecked())
  {
    typedef typename itk::AffineTransform< double, VImageDimension >    AffineTransformType;
    typedef typename itk::CenteredTransformInitializer<AffineTransformType, FixedImageType, MovingImageType> TransformInitializerType;
    typename TransformInitializerType::Pointer transformInitializer = TransformInitializerType::New();
    transformInitializer->SetFixedImage( fixedImage );
    transformInitializer->SetMovingImage( movingImage );
    transformInitializer->SetTransform( transformPointer );
    if (m_Controls.m_MomentsAffine->isChecked())
    {
      transformInitializer->MomentsOn();
    }
    else
    {
      transformInitializer->GeometryOn();
    }
    transformInitializer->InitializeTransform();
  }
  m_CenterX = transformPointer->GetCenter()[0];
  m_CenterY = transformPointer->GetCenter()[1];
  m_CenterZ = transformPointer->GetCenter()[2];
  m_TransformObject = transformPointer.GetPointer();
  return transformPointer.GetPointer();
}