20 #include <itkCenteredTransformInitializer.h>
21 #include <itkFixedCenterOfRotationAffineTransform.h>
49 template <
class TPixelType,
unsigned int VImageDimension>
51 itk::Image<TPixelType, VImageDimension> *itkImage1)
53 typedef typename itk::Image<TPixelType, VImageDimension> FixedImageType;
54 typedef typename itk::Image<TPixelType, VImageDimension> MovingImageType;
62 movingImageToItk->Update();
65 typedef typename itk::FixedCenterOfRotationAffineTransform<double, VImageDimension> CenteredAffineTransformType;
68 transformPointer->SetIdentity();
69 if (
m_Controls.m_CenterForInitializerFixedCenterOfRotationAffine->isChecked())
71 typedef typename itk::FixedCenterOfRotationAffineTransform<double, VImageDimension>
72 FixedCenterOfRotationAffineTransformType;
73 typedef typename itk::
74 CenteredTransformInitializer<FixedCenterOfRotationAffineTransformType, FixedImageType, MovingImageType>
75 TransformInitializerType;
77 transformInitializer->SetFixedImage(fixedImage);
78 transformInitializer->SetMovingImage(movingImage);
79 transformInitializer->SetTransform(transformPointer);
80 if (
m_Controls.m_MomentsFixedCenterOfRotationAffine->isChecked())
82 transformInitializer->MomentsOn();
86 transformInitializer->GeometryOn();
88 m_CenterX = transformPointer->GetCenter()[0];
89 m_CenterY = transformPointer->GetCenter()[1];
90 m_CenterZ = transformPointer->GetCenter()[2];
91 transformInitializer->InitializeTransform();
94 return transformPointer.GetPointer();
99 itk::Array<double> transformValues;
100 transformValues.SetSize(15);
101 transformValues.fill(0);
102 transformValues[0] =
m_Controls.m_UseOptimizerScalesFixedCenterOfRotationAffine->isChecked();
103 transformValues[1] =
m_Controls.m_ScalesFixedCenterOfRotationAffineTransformScale1->text().toDouble();
104 transformValues[2] =
m_Controls.m_ScalesFixedCenterOfRotationAffineTransformScale2->text().toDouble();
105 transformValues[3] =
m_Controls.m_ScalesFixedCenterOfRotationAffineTransformScale3->text().toDouble();
106 transformValues[4] =
m_Controls.m_ScalesFixedCenterOfRotationAffineTransformScale4->text().toDouble();
107 transformValues[5] =
m_Controls.m_ScalesFixedCenterOfRotationAffineTransformScale5->text().toDouble();
108 transformValues[6] =
m_Controls.m_ScalesFixedCenterOfRotationAffineTransformScale6->text().toDouble();
109 transformValues[7] =
m_Controls.m_ScalesFixedCenterOfRotationAffineTransformScale7->text().toDouble();
110 transformValues[8] =
m_Controls.m_ScalesFixedCenterOfRotationAffineTransformScale8->text().toDouble();
111 transformValues[9] =
m_Controls.m_ScalesFixedCenterOfRotationAffineTransformScale9->text().toDouble();
112 transformValues[10] =
m_Controls.m_ScalesFixedCenterOfRotationAffineTransformScaleTranslationX->text().toDouble();
113 transformValues[11] =
m_Controls.m_ScalesFixedCenterOfRotationAffineTransformScaleTranslationY->text().toDouble();
114 transformValues[12] =
m_Controls.m_ScalesFixedCenterOfRotationAffineTransformScaleTranslationZ->text().toDouble();
115 transformValues[13] =
m_Controls.m_CenterForInitializerFixedCenterOfRotationAffine->isChecked();
116 transformValues[14] =
m_Controls.m_MomentsFixedCenterOfRotationAffine->isChecked();
117 return transformValues;
122 m_Controls.m_UseOptimizerScalesFixedCenterOfRotationAffine->setChecked(transformValues[0]);
123 m_Controls.m_ScalesFixedCenterOfRotationAffineTransformScale1->setText(QString::number(transformValues[1]));
124 m_Controls.m_ScalesFixedCenterOfRotationAffineTransformScale2->setText(QString::number(transformValues[2]));
125 m_Controls.m_ScalesFixedCenterOfRotationAffineTransformScale3->setText(QString::number(transformValues[3]));
126 m_Controls.m_ScalesFixedCenterOfRotationAffineTransformScale4->setText(QString::number(transformValues[4]));
127 m_Controls.m_ScalesFixedCenterOfRotationAffineTransformScale5->setText(QString::number(transformValues[5]));
128 m_Controls.m_ScalesFixedCenterOfRotationAffineTransformScale6->setText(QString::number(transformValues[6]));
129 m_Controls.m_ScalesFixedCenterOfRotationAffineTransformScale7->setText(QString::number(transformValues[7]));
130 m_Controls.m_ScalesFixedCenterOfRotationAffineTransformScale8->setText(QString::number(transformValues[8]));
131 m_Controls.m_ScalesFixedCenterOfRotationAffineTransformScale9->setText(QString::number(transformValues[9]));
132 m_Controls.m_ScalesFixedCenterOfRotationAffineTransformScaleTranslationX->setText(
133 QString::number(transformValues[10]));
134 m_Controls.m_ScalesFixedCenterOfRotationAffineTransformScaleTranslationY->setText(
135 QString::number(transformValues[11]));
136 m_Controls.m_ScalesFixedCenterOfRotationAffineTransformScaleTranslationZ->setText(
137 QString::number(transformValues[12]));
138 m_Controls.m_CenterForInitializerFixedCenterOfRotationAffine->setChecked(transformValues[13]);
139 m_Controls.m_MomentsFixedCenterOfRotationAffine->setChecked(transformValues[14]);
140 m_Controls.m_GeometryFixedCenterOfRotationAffine->setChecked(!transformValues[14]);
145 return "FixedCenterOfRotationAffine";
151 QValidator *validatorLineEditInputFloat =
new QDoubleValidator(0, 20000000, 8,
this);
152 m_Controls.m_ScalesFixedCenterOfRotationAffineTransformScale1->setValidator(validatorLineEditInputFloat);
153 m_Controls.m_ScalesFixedCenterOfRotationAffineTransformScale2->setValidator(validatorLineEditInputFloat);
154 m_Controls.m_ScalesFixedCenterOfRotationAffineTransformScale3->setValidator(validatorLineEditInputFloat);
155 m_Controls.m_ScalesFixedCenterOfRotationAffineTransformScale4->setValidator(validatorLineEditInputFloat);
156 m_Controls.m_ScalesFixedCenterOfRotationAffineTransformScale5->setValidator(validatorLineEditInputFloat);
157 m_Controls.m_ScalesFixedCenterOfRotationAffineTransformScale6->setValidator(validatorLineEditInputFloat);
158 m_Controls.m_ScalesFixedCenterOfRotationAffineTransformScale7->setValidator(validatorLineEditInputFloat);
159 m_Controls.m_ScalesFixedCenterOfRotationAffineTransformScale8->setValidator(validatorLineEditInputFloat);
160 m_Controls.m_ScalesFixedCenterOfRotationAffineTransformScale9->setValidator(validatorLineEditInputFloat);
161 m_Controls.m_ScalesFixedCenterOfRotationAffineTransformScaleTranslationX->setValidator(validatorLineEditInputFloat);
162 m_Controls.m_ScalesFixedCenterOfRotationAffineTransformScaleTranslationY->setValidator(validatorLineEditInputFloat);
163 m_Controls.m_ScalesFixedCenterOfRotationAffineTransformScaleTranslationZ->setValidator(validatorLineEditInputFloat);
168 itk::Array<double> scales;
171 if (
m_Controls.m_UseOptimizerScalesFixedCenterOfRotationAffine->isChecked())
173 scales[0] =
m_Controls.m_ScalesFixedCenterOfRotationAffineTransformScale1->text().toDouble();
174 scales[1] =
m_Controls.m_ScalesFixedCenterOfRotationAffineTransformScale2->text().toDouble();
175 scales[2] =
m_Controls.m_ScalesFixedCenterOfRotationAffineTransformScale3->text().toDouble();
176 scales[3] =
m_Controls.m_ScalesFixedCenterOfRotationAffineTransformScale4->text().toDouble();
177 scales[4] =
m_Controls.m_ScalesFixedCenterOfRotationAffineTransformScale5->text().toDouble();
178 scales[5] =
m_Controls.m_ScalesFixedCenterOfRotationAffineTransformScale6->text().toDouble();
179 scales[6] =
m_Controls.m_ScalesFixedCenterOfRotationAffineTransformScale7->text().toDouble();
180 scales[7] =
m_Controls.m_ScalesFixedCenterOfRotationAffineTransformScale8->text().toDouble();
181 scales[8] =
m_Controls.m_ScalesFixedCenterOfRotationAffineTransformScale9->text().toDouble();
182 scales[9] =
m_Controls.m_ScalesFixedCenterOfRotationAffineTransformScaleTranslationX->text().toDouble();
183 scales[10] =
m_Controls.m_ScalesFixedCenterOfRotationAffineTransformScaleTranslationY->text().toDouble();
184 scales[11] =
m_Controls.m_ScalesFixedCenterOfRotationAffineTransformScaleTranslationZ->text().toDouble();
190 vtkTransform *vtktransform,
191 itk::Array<double> transformParams)
196 for (
unsigned int i = 0; i <
m_FixedImage->GetDimension(); i++)
198 for (
unsigned int j = 0; j <
m_FixedImage->GetDimension(); j++)
200 vtkmatrix->SetElement(i, j, transformParams[m]);
205 float translation[4];
210 vtkmatrix->MultiplyPoint(center, translation);
213 vtkmatrix->SetElement(0, 3, -translation[0] + center[0] + transformParams[4]);
214 vtkmatrix->SetElement(1, 3, -translation[1] + center[1] + transformParams[5]);
218 vtkmatrix->SetElement(0, 3, -translation[0] + center[0] + transformParams[9]);
219 vtkmatrix->SetElement(1, 3, -translation[1] + center[1] + transformParams[10]);
220 vtkmatrix->SetElement(2, 3, -translation[2] + center[2] + transformParams[11]);
222 vtktransform->SetMatrix(vtkmatrix);
233 m_Controls.m_ScalesFixedCenterOfRotationAffineTransformScale7->hide();
234 m_Controls.m_ScalesFixedCenterOfRotationAffineTransformScale8->hide();
235 m_Controls.m_ScalesFixedCenterOfRotationAffineTransformScale9->hide();
236 m_Controls.m_ScalesFixedCenterOfRotationAffineTransformScaleTranslationX->hide();
237 m_Controls.m_ScalesFixedCenterOfRotationAffineTransformScaleTranslationY->hide();
238 m_Controls.m_ScalesFixedCenterOfRotationAffineTransformScaleTranslationZ->hide();
239 m_Controls.textLabel2_7_2_2->setText(
"Translation Scale X:");
240 m_Controls.textLabel3_6_2_2->setText(
"Translation Scale Y:");
251 m_Controls.m_ScalesFixedCenterOfRotationAffineTransformScale7->show();
252 m_Controls.m_ScalesFixedCenterOfRotationAffineTransformScale8->show();
253 m_Controls.m_ScalesFixedCenterOfRotationAffineTransformScale9->show();
254 m_Controls.m_ScalesFixedCenterOfRotationAffineTransformScaleTranslationX->show();
255 m_Controls.m_ScalesFixedCenterOfRotationAffineTransformScaleTranslationY->show();
256 m_Controls.m_ScalesFixedCenterOfRotationAffineTransformScaleTranslationZ->show();
257 m_Controls.textLabel2_7_2_2->setText(
"Scale 5:");
258 m_Controls.textLabel3_6_2_2->setText(
"Scale 6:");
itk::SmartPointer< Self > Pointer
TransformType
Unique integer value for every transform.
#define AccessByItk(mitkImage, itkImageTypeFunction)
Access a MITK image by an ITK image.
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.