20 #include <itkCenteredTransformInitializer.h>
21 #include <itkScaleSkewVersor3DTransform.h>
47 template <
class TPixelType,
unsigned int VImageDimension>
49 itk::Image<TPixelType, VImageDimension> *itkImage1)
51 if (VImageDimension == 3)
53 typedef typename itk::Image<TPixelType, 3> FixedImageType;
54 typedef typename itk::Image<TPixelType, 3> MovingImageType;
62 movingImageToItk->Update();
67 transformPointer->SetIdentity();
68 if (
m_Controls.m_CenterForInitializerScaleSkewVersorRigid3D->isChecked())
70 typedef typename itk::ScaleSkewVersor3DTransform<double> ScaleSkewVersor3DTransformType;
72 typename itk::CenteredTransformInitializer<ScaleSkewVersor3DTransformType, FixedImageType, MovingImageType>
73 TransformInitializerType;
75 transformInitializer->SetFixedImage(fixedImage);
76 transformInitializer->SetMovingImage(movingImage);
77 transformInitializer->SetTransform(transformPointer);
78 if (
m_Controls.m_MomentsScaleSkewVersorRigid3D->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(18);
101 transformValues.fill(0);
102 transformValues[0] =
m_Controls.m_UseOptimizerScalesScaleSkewVersorRigid3DTransform->isChecked();
103 transformValues[1] =
m_Controls.m_ScalesScaleSkewVersorRigid3DTransformScale1->text().toDouble();
104 transformValues[2] =
m_Controls.m_ScalesScaleSkewVersorRigid3DTransformScale2->text().toDouble();
105 transformValues[3] =
m_Controls.m_ScalesScaleSkewVersorRigid3DTransformScale3->text().toDouble();
106 transformValues[4] =
m_Controls.m_ScalesScaleSkewVersorRigid3DTransformScaleTranslationX->text().toDouble();
107 transformValues[5] =
m_Controls.m_ScaleScaleSkewVersorRigid3DTransformScaleTranslationY->text().toDouble();
108 transformValues[6] =
m_Controls.m_ScalesScaleSkewVersorRigid3DTransformScaleTranslationZ->text().toDouble();
109 transformValues[7] =
m_Controls.m_ScalesScaleSkewVersorRigid3DTransformScale7->text().toDouble();
110 transformValues[8] =
m_Controls.m_ScalesScaleSkewVersorRigid3DTransformScale8->text().toDouble();
111 transformValues[9] =
m_Controls.m_ScalesScaleSkewVersorRigid3DTransformScale9->text().toDouble();
112 transformValues[10] =
m_Controls.m_ScalesScaleSkewVersorRigid3DTransformScale10->text().toDouble();
113 transformValues[11] =
m_Controls.m_ScalesScaleSkewVersorRigid3DTransformScale11->text().toDouble();
114 transformValues[12] =
m_Controls.m_ScalesScaleSkewVersorRigid3DTransformScale12->text().toDouble();
115 transformValues[13] =
m_Controls.m_ScalesScaleSkewVersorRigid3DTransformScale13->text().toDouble();
116 transformValues[14] =
m_Controls.m_ScalesScaleSkewVersorRigid3DTransformScale14->text().toDouble();
117 transformValues[15] =
m_Controls.m_ScalesScaleSkewVersorRigid3DTransformScale15->text().toDouble();
118 transformValues[16] =
m_Controls.m_CenterForInitializerScaleSkewVersorRigid3D->isChecked();
119 transformValues[17] =
m_Controls.m_MomentsScaleSkewVersorRigid3D->isChecked();
120 return transformValues;
125 m_Controls.m_UseOptimizerScalesScaleSkewVersorRigid3DTransform->setChecked(transformValues[0]);
126 m_Controls.m_ScalesScaleSkewVersorRigid3DTransformScale1->setText(QString::number(transformValues[1]));
127 m_Controls.m_ScalesScaleSkewVersorRigid3DTransformScale2->setText(QString::number(transformValues[2]));
128 m_Controls.m_ScalesScaleSkewVersorRigid3DTransformScale3->setText(QString::number(transformValues[3]));
129 m_Controls.m_ScalesScaleSkewVersorRigid3DTransformScaleTranslationX->setText(QString::number(transformValues[4]));
130 m_Controls.m_ScaleScaleSkewVersorRigid3DTransformScaleTranslationY->setText(QString::number(transformValues[5]));
131 m_Controls.m_ScalesScaleSkewVersorRigid3DTransformScaleTranslationZ->setText(QString::number(transformValues[6]));
132 m_Controls.m_ScalesScaleSkewVersorRigid3DTransformScale7->setText(QString::number(transformValues[7]));
133 m_Controls.m_ScalesScaleSkewVersorRigid3DTransformScale8->setText(QString::number(transformValues[8]));
134 m_Controls.m_ScalesScaleSkewVersorRigid3DTransformScale9->setText(QString::number(transformValues[9]));
135 m_Controls.m_ScalesScaleSkewVersorRigid3DTransformScale10->setText(QString::number(transformValues[10]));
136 m_Controls.m_ScalesScaleSkewVersorRigid3DTransformScale11->setText(QString::number(transformValues[11]));
137 m_Controls.m_ScalesScaleSkewVersorRigid3DTransformScale12->setText(QString::number(transformValues[12]));
138 m_Controls.m_ScalesScaleSkewVersorRigid3DTransformScale13->setText(QString::number(transformValues[13]));
139 m_Controls.m_ScalesScaleSkewVersorRigid3DTransformScale14->setText(QString::number(transformValues[14]));
140 m_Controls.m_ScalesScaleSkewVersorRigid3DTransformScale15->setText(QString::number(transformValues[15]));
141 m_Controls.m_CenterForInitializerScaleSkewVersorRigid3D->setChecked(transformValues[16]);
142 m_Controls.m_MomentsScaleSkewVersorRigid3D->setChecked(transformValues[17]);
143 m_Controls.m_GeometryScaleSkewVersorRigid3D->setChecked(!transformValues[17]);
148 return "ScaleSkewVersor3D";
154 QValidator *validatorLineEditInputFloat =
new QDoubleValidator(0, 20000000, 8,
this);
155 m_Controls.m_ScalesScaleSkewVersorRigid3DTransformScale1->setValidator(validatorLineEditInputFloat);
156 m_Controls.m_ScalesScaleSkewVersorRigid3DTransformScale2->setValidator(validatorLineEditInputFloat);
157 m_Controls.m_ScalesScaleSkewVersorRigid3DTransformScale3->setValidator(validatorLineEditInputFloat);
158 m_Controls.m_ScalesScaleSkewVersorRigid3DTransformScaleTranslationX->setValidator(validatorLineEditInputFloat);
159 m_Controls.m_ScaleScaleSkewVersorRigid3DTransformScaleTranslationY->setValidator(validatorLineEditInputFloat);
160 m_Controls.m_ScalesScaleSkewVersorRigid3DTransformScaleTranslationZ->setValidator(validatorLineEditInputFloat);
161 m_Controls.m_ScalesScaleSkewVersorRigid3DTransformScale7->setValidator(validatorLineEditInputFloat);
162 m_Controls.m_ScalesScaleSkewVersorRigid3DTransformScale8->setValidator(validatorLineEditInputFloat);
163 m_Controls.m_ScalesScaleSkewVersorRigid3DTransformScale9->setValidator(validatorLineEditInputFloat);
164 m_Controls.m_ScalesScaleSkewVersorRigid3DTransformScale10->setValidator(validatorLineEditInputFloat);
165 m_Controls.m_ScalesScaleSkewVersorRigid3DTransformScale11->setValidator(validatorLineEditInputFloat);
166 m_Controls.m_ScalesScaleSkewVersorRigid3DTransformScale12->setValidator(validatorLineEditInputFloat);
167 m_Controls.m_ScalesScaleSkewVersorRigid3DTransformScale13->setValidator(validatorLineEditInputFloat);
168 m_Controls.m_ScalesScaleSkewVersorRigid3DTransformScale14->setValidator(validatorLineEditInputFloat);
169 m_Controls.m_ScalesScaleSkewVersorRigid3DTransformScale15->setValidator(validatorLineEditInputFloat);
174 itk::Array<double> scales;
177 if (
m_Controls.m_UseOptimizerScalesScaleSkewVersorRigid3DTransform->isChecked())
179 scales[0] =
m_Controls.m_ScalesScaleSkewVersorRigid3DTransformScale1->text().toDouble();
180 scales[1] =
m_Controls.m_ScalesScaleSkewVersorRigid3DTransformScale2->text().toDouble();
181 scales[2] =
m_Controls.m_ScalesScaleSkewVersorRigid3DTransformScale3->text().toDouble();
182 scales[3] =
m_Controls.m_ScalesScaleSkewVersorRigid3DTransformScaleTranslationX->text().toDouble();
183 scales[4] =
m_Controls.m_ScaleScaleSkewVersorRigid3DTransformScaleTranslationY->text().toDouble();
184 scales[5] =
m_Controls.m_ScalesScaleSkewVersorRigid3DTransformScaleTranslationZ->text().toDouble();
185 scales[6] =
m_Controls.m_ScalesScaleSkewVersorRigid3DTransformScale7->text().toDouble();
186 scales[7] =
m_Controls.m_ScalesScaleSkewVersorRigid3DTransformScale8->text().toDouble();
187 scales[8] =
m_Controls.m_ScalesScaleSkewVersorRigid3DTransformScale9->text().toDouble();
188 scales[9] =
m_Controls.m_ScalesScaleSkewVersorRigid3DTransformScale10->text().toDouble();
189 scales[10] =
m_Controls.m_ScalesScaleSkewVersorRigid3DTransformScale11->text().toDouble();
190 scales[11] =
m_Controls.m_ScalesScaleSkewVersorRigid3DTransformScale12->text().toDouble();
191 scales[12] =
m_Controls.m_ScalesScaleSkewVersorRigid3DTransformScale13->text().toDouble();
192 scales[13] =
m_Controls.m_ScalesScaleSkewVersorRigid3DTransformScale14->text().toDouble();
193 scales[14] =
m_Controls.m_ScalesScaleSkewVersorRigid3DTransformScale15->text().toDouble();
199 vtkTransform *vtktransform,
200 itk::Array<double> transformParams)
205 versorTransform->SetParameters(transformParams);
206 itk::Matrix<double, 3, 3> Matrix = versorTransform->GetMatrix();
207 for (
int i = 0; i < 3; i++)
209 for (
int j = 0; j < 3; j++)
211 vtkmatrix->SetElement(i, j, Matrix[i][j]);
215 float translation[4];
220 vtkmatrix->MultiplyPoint(center, translation);
221 vtkmatrix->SetElement(0, 3, -translation[0] + center[0] + transformParams[3]);
222 vtkmatrix->SetElement(1, 3, -translation[1] + center[1] + transformParams[4]);
223 vtkmatrix->SetElement(2, 3, -translation[2] + center[2] + transformParams[5]);
224 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.