20 #include <itkCenteredTransformInitializer.h>
21 #include <itkVersorTransform.h>
48 template <
class TPixelType,
unsigned int VImageDimension>
49 itk::Object::Pointer QmitkVersorTransformView::GetTransform2(itk::Image<TPixelType, VImageDimension> *itkImage1)
51 if (VImageDimension == 3)
53 typedef typename itk::Image<TPixelType, 3> FixedImage3DType;
54 typedef typename itk::Image<TPixelType, 3> MovingImage3DType;
62 movingImageToItk->Update();
66 transformPointer->SetIdentity();
67 typedef typename itk::VersorTransform<double> VersorTransformType;
68 if (
m_Controls.m_CenterForInitializerVersor->isChecked())
70 typedef typename itk::CenteredTransformInitializer<VersorTransformType, FixedImage3DType, MovingImage3DType>
71 TransformInitializerType;
73 transformInitializer->SetFixedImage(fixedImage);
74 transformInitializer->SetMovingImage(movingImage);
75 transformInitializer->SetTransform(transformPointer);
78 transformInitializer->MomentsOn();
82 transformInitializer->GeometryOn();
84 transformInitializer->InitializeTransform();
86 m_CenterX = transformPointer->GetCenter()[0];
87 m_CenterY = transformPointer->GetCenter()[1];
88 m_CenterZ = transformPointer->GetCenter()[2];
90 return transformPointer.GetPointer();
97 itk::Array<double> transformValues;
98 transformValues.SetSize(6);
99 transformValues.fill(0);
100 transformValues[0] =
m_Controls.m_UseOptimizerScalesVersor->isChecked();
101 transformValues[1] =
m_Controls.m_ScalesVersorTransformScale1->text().toDouble();
102 transformValues[2] =
m_Controls.m_ScalesVersorTransformScale2->text().toDouble();
103 transformValues[3] =
m_Controls.m_ScalesVersorTransformScale3->text().toDouble();
104 transformValues[4] =
m_Controls.m_CenterForInitializerVersor->isChecked();
105 transformValues[5] =
m_Controls.m_MomentsVersor->isChecked();
106 return transformValues;
111 m_Controls.m_UseOptimizerScalesVersor->setChecked(transformValues[0]);
112 m_Controls.m_ScalesVersorTransformScale1->setText(QString::number(transformValues[1]));
113 m_Controls.m_ScalesVersorTransformScale2->setText(QString::number(transformValues[2]));
114 m_Controls.m_ScalesVersorTransformScale3->setText(QString::number(transformValues[3]));
115 m_Controls.m_CenterForInitializerVersor->setChecked(transformValues[4]);
116 m_Controls.m_MomentsVersor->setChecked(transformValues[5]);
117 m_Controls.m_GeometryVersor->setChecked(!transformValues[5]);
128 QValidator *validatorLineEditInputFloat =
new QDoubleValidator(0, 20000000, 8,
this);
129 m_Controls.m_ScalesVersorTransformScale1->setValidator(validatorLineEditInputFloat);
130 m_Controls.m_ScalesVersorTransformScale2->setValidator(validatorLineEditInputFloat);
131 m_Controls.m_ScalesVersorTransformScale3->setValidator(validatorLineEditInputFloat);
136 itk::Array<double> scales;
139 if (
m_Controls.m_UseOptimizerScalesVersor->isChecked())
141 scales[0] =
m_Controls.m_ScalesVersorTransformScale1->text().toDouble();
142 scales[1] =
m_Controls.m_ScalesVersorTransformScale2->text().toDouble();
143 scales[2] =
m_Controls.m_ScalesVersorTransformScale3->text().toDouble();
149 vtkTransform *vtktransform,
150 itk::Array<double> transformParams)
155 versorTransform->SetParameters(transformParams);
156 itk::Matrix<double, 3, 3> Matrix = versorTransform->GetMatrix();
157 for (
int i = 0; i < 3; i++)
159 for (
int j = 0; j < 3; j++)
161 vtkmatrix->SetElement(i, j, Matrix[i][j]);
165 float translation[4];
170 vtkmatrix->MultiplyPoint(center, translation);
171 vtkmatrix->SetElement(0, 3, -translation[0] + center[0]);
172 vtkmatrix->SetElement(1, 3, -translation[1] + center[1]);
173 vtkmatrix->SetElement(2, 3, -translation[2] + center[2]);
174 vtktransform->SetMatrix(vtkmatrix);
itk::SmartPointer< Self > Pointer
#define AccessFixedDimensionByItk(mitkImage, itkImageTypeFunction, dimension)
Access a mitk-image with known dimension by an itk-image.
TransformType
Unique integer value for every transform.
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.