20 #include <itkCenteredTransformInitializer.h>
21 #include <itkQuaternionRigidTransform.h>
48 template <
class TPixelType,
unsigned int VImageDimension>
50 itk::Image<TPixelType, VImageDimension> *itkImage1)
52 if (VImageDimension == 3)
54 typedef typename itk::Image<TPixelType, 3> FixedImageType;
55 typedef typename itk::Image<TPixelType, 3> MovingImageType;
63 movingImageToItk->Update();
68 transformPointer->SetIdentity();
69 typedef typename itk::QuaternionRigidTransform<double> QuaternionRigidTransformType;
70 if (
m_Controls.m_CenterForInitializerQuaternionRigid->isChecked())
72 typedef typename itk::CenteredTransformInitializer<QuaternionRigidTransformType, FixedImageType, MovingImageType>
73 TransformInitializerType;
75 transformInitializer->SetFixedImage(fixedImage);
76 transformInitializer->SetMovingImage(movingImage);
77 transformInitializer->SetTransform(transformPointer);
78 if (
m_Controls.m_MomentsQuaternionRigid->isChecked())
80 transformInitializer->MomentsOn();
84 transformInitializer->GeometryOn();
86 transformInitializer->InitializeTransform();
88 m_CenterX = transformPointer->GetCenter()[0];
89 m_CenterY = transformPointer->GetCenter()[1];
90 m_CenterZ = transformPointer->GetCenter()[2];
92 return transformPointer.GetPointer();
99 itk::Array<double> transformValues;
100 transformValues.SetSize(10);
101 transformValues.fill(0);
102 transformValues[0] =
m_Controls.m_UseOptimizerScalesQuaternionRigid->isChecked();
103 transformValues[1] =
m_Controls.m_ScalesQuaternionRigidTransformScale1->text().toDouble();
104 transformValues[2] =
m_Controls.m_ScalesQuaternionRigidTransformScale2->text().toDouble();
105 transformValues[3] =
m_Controls.m_ScalesQuaternionRigidTransformScale3->text().toDouble();
106 transformValues[4] =
m_Controls.m_ScalesQuaternionRigidTransformScale4->text().toDouble();
107 transformValues[5] =
m_Controls.m_ScalesQuaternionRigidTransformScaleTranslationX->text().toDouble();
108 transformValues[6] =
m_Controls.m_ScalesQuaternionRigidTransformScaleTranslationY->text().toDouble();
109 transformValues[7] =
m_Controls.m_ScalesQuaternionRigidTransformScaleTranslationZ->text().toDouble();
110 transformValues[8] =
m_Controls.m_CenterForInitializerQuaternionRigid->isChecked();
111 transformValues[9] =
m_Controls.m_MomentsQuaternionRigid->isChecked();
112 return transformValues;
117 m_Controls.m_UseOptimizerScalesQuaternionRigid->setChecked(transformValues[0]);
118 m_Controls.m_ScalesQuaternionRigidTransformScale1->setText(QString::number(transformValues[1]));
119 m_Controls.m_ScalesQuaternionRigidTransformScale2->setText(QString::number(transformValues[2]));
120 m_Controls.m_ScalesQuaternionRigidTransformScale3->setText(QString::number(transformValues[3]));
121 m_Controls.m_ScalesQuaternionRigidTransformScale4->setText(QString::number(transformValues[4]));
122 m_Controls.m_ScalesQuaternionRigidTransformScaleTranslationX->setText(QString::number(transformValues[5]));
123 m_Controls.m_ScalesQuaternionRigidTransformScaleTranslationY->setText(QString::number(transformValues[6]));
124 m_Controls.m_ScalesQuaternionRigidTransformScaleTranslationZ->setText(QString::number(transformValues[7]));
125 m_Controls.m_CenterForInitializerQuaternionRigid->setChecked(transformValues[8]);
126 m_Controls.m_MomentsQuaternionRigid->setChecked(transformValues[9]);
127 m_Controls.m_GeometryQuaternionRigid->setChecked(!transformValues[9]);
132 return "QuaternionRigid";
138 QValidator *validatorLineEditInputFloat =
new QDoubleValidator(0, 20000000, 8,
this);
139 m_Controls.m_ScalesQuaternionRigidTransformScale1->setValidator(validatorLineEditInputFloat);
140 m_Controls.m_ScalesQuaternionRigidTransformScale2->setValidator(validatorLineEditInputFloat);
141 m_Controls.m_ScalesQuaternionRigidTransformScale3->setValidator(validatorLineEditInputFloat);
142 m_Controls.m_ScalesQuaternionRigidTransformScale4->setValidator(validatorLineEditInputFloat);
143 m_Controls.m_ScalesQuaternionRigidTransformScaleTranslationX->setValidator(validatorLineEditInputFloat);
144 m_Controls.m_ScalesQuaternionRigidTransformScaleTranslationY->setValidator(validatorLineEditInputFloat);
145 m_Controls.m_ScalesQuaternionRigidTransformScaleTranslationZ->setValidator(validatorLineEditInputFloat);
150 itk::Array<double> scales;
153 if (
m_Controls.m_UseOptimizerScalesQuaternionRigid->isChecked())
155 scales[0] =
m_Controls.m_ScalesQuaternionRigidTransformScale1->text().toDouble();
156 scales[1] =
m_Controls.m_ScalesQuaternionRigidTransformScale2->text().toDouble();
157 scales[2] =
m_Controls.m_ScalesQuaternionRigidTransformScale3->text().toDouble();
158 scales[3] =
m_Controls.m_ScalesQuaternionRigidTransformScale4->text().toDouble();
159 scales[4] =
m_Controls.m_ScalesQuaternionRigidTransformScaleTranslationX->text().toDouble();
160 scales[5] =
m_Controls.m_ScalesQuaternionRigidTransformScaleTranslationY->text().toDouble();
161 scales[6] =
m_Controls.m_ScalesQuaternionRigidTransformScaleTranslationZ->text().toDouble();
167 vtkTransform *vtktransform,
168 itk::Array<double> transformParams)
173 quaternionTransform->SetParameters(transformParams);
174 itk::Matrix<double, 3, 3> Matrix = quaternionTransform->GetMatrix();
175 for (
int i = 0; i < 3; i++)
177 for (
int j = 0; j < 3; j++)
179 vtkmatrix->SetElement(i, j, Matrix[i][j]);
183 float translation[4];
188 vtkmatrix->MultiplyPoint(center, translation);
189 vtkmatrix->SetElement(0, 3, -translation[0] + center[0] + transformParams[4]);
190 vtkmatrix->SetElement(1, 3, -translation[1] + center[1] + transformParams[5]);
191 vtkmatrix->SetElement(2, 3, -translation[2] + center[2] + transformParams[6]);
192 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.