20 #include <itkCenteredTransformInitializer.h>
21 #include <itkSimilarity3DTransform.h>
48 template <
class TPixelType,
unsigned int VImageDimension>
49 itk::Object::Pointer QmitkSimilarity3DTransformView::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 if (
m_Controls.m_CenterForInitializerSimilarity3D->isChecked())
69 typedef typename itk::Similarity3DTransform<double> Similarity3DTransformType;
70 typedef typename itk::CenteredTransformInitializer<Similarity3DTransformType, FixedImage3DType, MovingImage3DType>
71 TransformInitializerType;
73 transformInitializer->SetFixedImage(fixedImage);
74 transformInitializer->SetMovingImage(movingImage);
75 transformInitializer->SetTransform(transformPointer);
76 if (
m_Controls.m_MomentsSimilarity3D->isChecked())
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(10);
99 transformValues.fill(0);
100 transformValues[0] =
m_Controls.m_UseOptimizerScalesSimilarity3D->isChecked();
101 transformValues[1] =
m_Controls.m_ScalesSimilarity3DTransformScale1->text().toDouble();
102 transformValues[2] =
m_Controls.m_ScalesSimilarity3DTransformScale2->text().toDouble();
103 transformValues[3] =
m_Controls.m_ScalesSimilarity3DTransformScale3->text().toDouble();
104 transformValues[4] =
m_Controls.m_ScalesSimilarity3DTransformScale4->text().toDouble();
105 transformValues[5] =
m_Controls.m_ScalesSimilarity3DTransformScaleTranslationX->text().toDouble();
106 transformValues[6] =
m_Controls.m_ScalesSimilarity3DTransformScaleTranslationY->text().toDouble();
107 transformValues[7] =
m_Controls.m_ScalesSimilarity3DTransformScaleTranslationZ->text().toDouble();
108 transformValues[8] =
m_Controls.m_CenterForInitializerSimilarity3D->isChecked();
109 transformValues[9] =
m_Controls.m_MomentsSimilarity3D->isChecked();
110 return transformValues;
115 m_Controls.m_UseOptimizerScalesSimilarity3D->setChecked(transformValues[0]);
116 m_Controls.m_ScalesSimilarity3DTransformScale1->setText(QString::number(transformValues[1]));
117 m_Controls.m_ScalesSimilarity3DTransformScale2->setText(QString::number(transformValues[2]));
118 m_Controls.m_ScalesSimilarity3DTransformScale3->setText(QString::number(transformValues[3]));
119 m_Controls.m_ScalesSimilarity3DTransformScale4->setText(QString::number(transformValues[4]));
120 m_Controls.m_ScalesSimilarity3DTransformScaleTranslationX->setText(QString::number(transformValues[5]));
121 m_Controls.m_ScalesSimilarity3DTransformScaleTranslationY->setText(QString::number(transformValues[6]));
122 m_Controls.m_ScalesSimilarity3DTransformScaleTranslationZ->setText(QString::number(transformValues[7]));
123 m_Controls.m_CenterForInitializerSimilarity3D->setChecked(transformValues[8]);
124 m_Controls.m_MomentsSimilarity3D->setChecked(transformValues[9]);
125 m_Controls.m_GeometrySimilarity3D->setChecked(!transformValues[9]);
130 return "Similarity3D";
136 QValidator *validatorLineEditInputFloat =
new QDoubleValidator(0, 20000000, 8,
this);
137 m_Controls.m_ScalesSimilarity3DTransformScale1->setValidator(validatorLineEditInputFloat);
138 m_Controls.m_ScalesSimilarity3DTransformScale2->setValidator(validatorLineEditInputFloat);
139 m_Controls.m_ScalesSimilarity3DTransformScale3->setValidator(validatorLineEditInputFloat);
140 m_Controls.m_ScalesSimilarity3DTransformScale4->setValidator(validatorLineEditInputFloat);
141 m_Controls.m_ScalesSimilarity3DTransformScaleTranslationX->setValidator(validatorLineEditInputFloat);
142 m_Controls.m_ScalesSimilarity3DTransformScaleTranslationY->setValidator(validatorLineEditInputFloat);
143 m_Controls.m_ScalesSimilarity3DTransformScaleTranslationZ->setValidator(validatorLineEditInputFloat);
148 itk::Array<double> scales;
151 if (
m_Controls.m_UseOptimizerScalesSimilarity3D->isChecked())
153 scales[0] =
m_Controls.m_ScalesSimilarity3DTransformScale1->text().toDouble();
154 scales[1] =
m_Controls.m_ScalesSimilarity3DTransformScale2->text().toDouble();
155 scales[2] =
m_Controls.m_ScalesSimilarity3DTransformScale3->text().toDouble();
156 scales[3] =
m_Controls.m_ScalesSimilarity3DTransformScale4->text().toDouble();
157 scales[4] =
m_Controls.m_ScalesSimilarity3DTransformScaleTranslationX->text().toDouble();
158 scales[5] =
m_Controls.m_ScalesSimilarity3DTransformScaleTranslationY->text().toDouble();
159 scales[6] =
m_Controls.m_ScalesSimilarity3DTransformScaleTranslationZ->text().toDouble();
165 vtkTransform *vtktransform,
166 itk::Array<double> transformParams)
171 similarityTransform->SetParameters(transformParams);
172 itk::Matrix<double, 3, 3> Matrix = similarityTransform->GetMatrix();
173 for (
int i = 0; i < 3; i++)
175 for (
int j = 0; j < 3; j++)
177 vtkmatrix->SetElement(i, j, Matrix[i][j]);
181 float translation[4];
186 vtkmatrix->MultiplyPoint(center, translation);
187 vtkmatrix->SetElement(0, 3, -translation[0] + center[0] + transformParams[4]);
188 vtkmatrix->SetElement(1, 3, -translation[1] + center[1] + transformParams[5]);
189 vtkmatrix->SetElement(2, 3, -translation[2] + center[2] + transformParams[6]);
190 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.