20 #include <itkCenteredTransformInitializer.h>
21 #include <itkVersorRigid3DTransform.h>
48 template <
class TPixelType,
unsigned int VImageDimension>
49 itk::Object::Pointer QmitkVersorRigid3DTransformView::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::VersorRigid3DTransform<double> VersorRigid3DTransformType;
68 if (
m_Controls.m_CenterForInitializerVersorRigid3D->isChecked())
71 typename itk::CenteredTransformInitializer<VersorRigid3DTransformType, FixedImage3DType, MovingImage3DType>
72 TransformInitializerType;
74 transformInitializer->SetFixedImage(fixedImage);
75 transformInitializer->SetMovingImage(movingImage);
76 transformInitializer->SetTransform(transformPointer);
77 if (
m_Controls.m_MomentsVersorRigid3D->isChecked())
79 transformInitializer->MomentsOn();
83 transformInitializer->GeometryOn();
85 transformInitializer->InitializeTransform();
87 typedef VersorRigid3DTransformType::VersorType VersorType;
97 const double angle = 0;
99 rotation.Set(axis, angle);
101 transformPointer->SetRotation(rotation);
102 m_CenterX = transformPointer->GetCenter()[0];
103 m_CenterY = transformPointer->GetCenter()[1];
104 m_CenterZ = transformPointer->GetCenter()[2];
106 return transformPointer.GetPointer();
113 itk::Array<double> transformValues;
114 transformValues.SetSize(9);
115 transformValues.fill(0);
116 transformValues[0] =
m_Controls.m_UseOptimizerScalesVersorRigid3D->isChecked();
117 transformValues[1] =
m_Controls.m_ScalesVersorRigid3DTransformScale1->text().toDouble();
118 transformValues[2] =
m_Controls.m_ScalesVersorRigid3DTransformScale2->text().toDouble();
119 transformValues[3] =
m_Controls.m_ScalesVersorRigid3DTransformScale3->text().toDouble();
120 transformValues[4] =
m_Controls.m_ScalesVersorRigid3DTransformScaleTranslationX->text().toDouble();
121 transformValues[5] =
m_Controls.m_ScalesVersorRigid3DTransformScaleTranslationY->text().toDouble();
122 transformValues[6] =
m_Controls.m_ScalesVersorRigid3DTransformScaleTranslationZ->text().toDouble();
123 transformValues[7] =
m_Controls.m_CenterForInitializerVersorRigid3D->isChecked();
124 transformValues[8] =
m_Controls.m_MomentsVersorRigid3D->isChecked();
125 return transformValues;
130 m_Controls.m_UseOptimizerScalesVersorRigid3D->setChecked(transformValues[0]);
131 m_Controls.m_ScalesVersorRigid3DTransformScale1->setText(QString::number(transformValues[1]));
132 m_Controls.m_ScalesVersorRigid3DTransformScale2->setText(QString::number(transformValues[2]));
133 m_Controls.m_ScalesVersorRigid3DTransformScale3->setText(QString::number(transformValues[3]));
134 m_Controls.m_ScalesVersorRigid3DTransformScaleTranslationX->setText(QString::number(transformValues[4]));
135 m_Controls.m_ScalesVersorRigid3DTransformScaleTranslationY->setText(QString::number(transformValues[5]));
136 m_Controls.m_ScalesVersorRigid3DTransformScaleTranslationZ->setText(QString::number(transformValues[6]));
137 m_Controls.m_CenterForInitializerVersorRigid3D->setChecked(transformValues[7]);
138 m_Controls.m_MomentsVersorRigid3D->setChecked(transformValues[8]);
139 m_Controls.m_GeometryVersorRigid3D->setChecked(!transformValues[8]);
144 return "VersorRigid3D";
150 QValidator *validatorLineEditInputFloat =
new QDoubleValidator(0, 20000000, 8,
this);
151 m_Controls.m_ScalesVersorRigid3DTransformScale1->setValidator(validatorLineEditInputFloat);
152 m_Controls.m_ScalesVersorRigid3DTransformScale2->setValidator(validatorLineEditInputFloat);
153 m_Controls.m_ScalesVersorRigid3DTransformScale3->setValidator(validatorLineEditInputFloat);
154 m_Controls.m_ScalesVersorRigid3DTransformScaleTranslationX->setValidator(validatorLineEditInputFloat);
155 m_Controls.m_ScalesVersorRigid3DTransformScaleTranslationY->setValidator(validatorLineEditInputFloat);
156 m_Controls.m_ScalesVersorRigid3DTransformScaleTranslationZ->setValidator(validatorLineEditInputFloat);
161 itk::Array<double> scales;
164 if (
m_Controls.m_UseOptimizerScalesVersorRigid3D->isChecked())
166 scales[0] =
m_Controls.m_ScalesVersorRigid3DTransformScale1->text().toDouble();
167 scales[1] =
m_Controls.m_ScalesVersorRigid3DTransformScale2->text().toDouble();
168 scales[2] =
m_Controls.m_ScalesVersorRigid3DTransformScale3->text().toDouble();
169 scales[3] =
m_Controls.m_ScalesVersorRigid3DTransformScaleTranslationX->text().toDouble();
170 scales[4] =
m_Controls.m_ScalesVersorRigid3DTransformScaleTranslationY->text().toDouble();
171 scales[5] =
m_Controls.m_ScalesVersorRigid3DTransformScaleTranslationZ->text().toDouble();
177 vtkTransform *vtktransform,
178 itk::Array<double> transformParams)
183 versorTransform->SetParameters(transformParams);
184 itk::Matrix<double, 3, 3> Matrix = versorTransform->GetMatrix();
185 for (
int i = 0; i < 3; i++)
187 for (
int j = 0; j < 3; j++)
189 vtkmatrix->SetElement(i, j, Matrix[i][j]);
193 float translation[4];
198 vtkmatrix->MultiplyPoint(center, translation);
199 vtkmatrix->SetElement(0, 3, -translation[0] + center[0] + transformParams[3]);
200 vtkmatrix->SetElement(1, 3, -translation[1] + center[1] + transformParams[4]);
201 vtkmatrix->SetElement(2, 3, -translation[2] + center[2] + transformParams[5]);
202 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.
itk::Vector< float, 3 > VectorType
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.