20 #include <itkAffineTransform.h>
21 #include <itkCenteredTransformInitializer.h>
48 template <
class TPixelType,
class MovingPixelType,
unsigned int VImageDimension>
49 itk::Object::Pointer QmitkAffineTransformView::GetTransform2(itk::Image<TPixelType, VImageDimension> *itkImage1,
50 itk::Image<MovingPixelType, VImageDimension> *itkImage2)
52 typedef typename itk::Image<TPixelType, VImageDimension> FixedImageType;
53 typedef typename itk::Image<MovingPixelType, VImageDimension> MovingImageType;
66 transformPointer->SetIdentity();
67 if (
m_Controls.m_CenterForInitializerAffine->isChecked())
69 typedef typename itk::AffineTransform<double, VImageDimension> AffineTransformType;
70 typedef typename itk::CenteredTransformInitializer<AffineTransformType, FixedImageType, MovingImageType>
71 TransformInitializerType;
73 transformInitializer->SetFixedImage(fixedImage);
74 transformInitializer->SetMovingImage(movingImage);
75 transformInitializer->SetTransform(transformPointer);
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();
95 itk::Array<double> transformValues;
96 transformValues.SetSize(15);
97 transformValues.fill(0);
98 transformValues[0] =
m_Controls.m_UseOptimizerScalesAffine->isChecked();
99 transformValues[1] =
m_Controls.m_ScalesAffineTransformScale1->text().toDouble();
100 transformValues[2] =
m_Controls.m_ScalesAffineTransformScale2->text().toDouble();
101 transformValues[3] =
m_Controls.m_ScalesAffineTransformScale3->text().toDouble();
102 transformValues[4] =
m_Controls.m_ScalesAffineTransformScale4->text().toDouble();
103 transformValues[5] =
m_Controls.m_ScalesAffineTransformScale5->text().toDouble();
104 transformValues[6] =
m_Controls.m_ScalesAffineTransformScale6->text().toDouble();
105 transformValues[7] =
m_Controls.m_ScalesAffineTransformScale7->text().toDouble();
106 transformValues[8] =
m_Controls.m_ScalesAffineTransformScale8->text().toDouble();
107 transformValues[9] =
m_Controls.m_ScalesAffineTransformScale9->text().toDouble();
108 transformValues[10] =
m_Controls.m_ScalesAffineTransformScaleTranslationX->text().toDouble();
109 transformValues[11] =
m_Controls.m_ScalesAffineTransformScaleTranslationY->text().toDouble();
110 transformValues[12] =
m_Controls.m_ScalesAffineTransformScaleTranslationZ->text().toDouble();
111 transformValues[13] =
m_Controls.m_CenterForInitializerAffine->isChecked();
112 transformValues[14] =
m_Controls.m_MomentsAffine->isChecked();
113 return transformValues;
118 m_Controls.m_UseOptimizerScalesAffine->setChecked(transformValues[0]);
119 m_Controls.m_ScalesAffineTransformScale1->setText(QString::number(transformValues[1]));
120 m_Controls.m_ScalesAffineTransformScale2->setText(QString::number(transformValues[2]));
121 m_Controls.m_ScalesAffineTransformScale3->setText(QString::number(transformValues[3]));
122 m_Controls.m_ScalesAffineTransformScale4->setText(QString::number(transformValues[4]));
123 m_Controls.m_ScalesAffineTransformScale5->setText(QString::number(transformValues[5]));
124 m_Controls.m_ScalesAffineTransformScale6->setText(QString::number(transformValues[6]));
125 m_Controls.m_ScalesAffineTransformScale7->setText(QString::number(transformValues[7]));
126 m_Controls.m_ScalesAffineTransformScale8->setText(QString::number(transformValues[8]));
127 m_Controls.m_ScalesAffineTransformScale9->setText(QString::number(transformValues[9]));
128 m_Controls.m_ScalesAffineTransformScaleTranslationX->setText(QString::number(transformValues[10]));
129 m_Controls.m_ScalesAffineTransformScaleTranslationY->setText(QString::number(transformValues[11]));
130 m_Controls.m_ScalesAffineTransformScaleTranslationZ->setText(QString::number(transformValues[12]));
131 m_Controls.m_CenterForInitializerAffine->setChecked(transformValues[13]);
132 m_Controls.m_MomentsAffine->setChecked(transformValues[14]);
133 m_Controls.m_GeometryAffine->setChecked(!transformValues[14]);
144 QValidator *validatorLineEditInputFloat =
new QDoubleValidator(0, 20000000, 8,
this);
145 m_Controls.m_ScalesAffineTransformScale1->setValidator(validatorLineEditInputFloat);
146 m_Controls.m_ScalesAffineTransformScale2->setValidator(validatorLineEditInputFloat);
147 m_Controls.m_ScalesAffineTransformScale3->setValidator(validatorLineEditInputFloat);
148 m_Controls.m_ScalesAffineTransformScale4->setValidator(validatorLineEditInputFloat);
149 m_Controls.m_ScalesAffineTransformScale5->setValidator(validatorLineEditInputFloat);
150 m_Controls.m_ScalesAffineTransformScale6->setValidator(validatorLineEditInputFloat);
151 m_Controls.m_ScalesAffineTransformScale7->setValidator(validatorLineEditInputFloat);
152 m_Controls.m_ScalesAffineTransformScale8->setValidator(validatorLineEditInputFloat);
153 m_Controls.m_ScalesAffineTransformScale9->setValidator(validatorLineEditInputFloat);
154 m_Controls.m_ScalesAffineTransformScaleTranslationX->setValidator(validatorLineEditInputFloat);
155 m_Controls.m_ScalesAffineTransformScaleTranslationY->setValidator(validatorLineEditInputFloat);
156 m_Controls.m_ScalesAffineTransformScaleTranslationZ->setValidator(validatorLineEditInputFloat);
161 itk::Array<double> scales;
164 scales[0] =
m_Controls.m_ScalesAffineTransformScale1->text().toDouble();
165 scales[1] =
m_Controls.m_ScalesAffineTransformScale2->text().toDouble();
166 scales[2] =
m_Controls.m_ScalesAffineTransformScale3->text().toDouble();
167 scales[3] =
m_Controls.m_ScalesAffineTransformScale4->text().toDouble();
168 scales[4] =
m_Controls.m_ScalesAffineTransformScale5->text().toDouble();
169 scales[5] =
m_Controls.m_ScalesAffineTransformScale6->text().toDouble();
170 scales[6] =
m_Controls.m_ScalesAffineTransformScale7->text().toDouble();
171 scales[7] =
m_Controls.m_ScalesAffineTransformScale8->text().toDouble();
172 scales[8] =
m_Controls.m_ScalesAffineTransformScale9->text().toDouble();
173 scales[9] =
m_Controls.m_ScalesAffineTransformScaleTranslationX->text().toDouble();
174 scales[10] =
m_Controls.m_ScalesAffineTransformScaleTranslationY->text().toDouble();
175 scales[11] =
m_Controls.m_ScalesAffineTransformScaleTranslationZ->text().toDouble();
180 vtkTransform *vtktransform,
181 itk::Array<double> transformParams)
188 for (
unsigned int i = 0; i <
m_FixedImage->GetDimension(); i++)
190 for (
unsigned int j = 0; j <
m_FixedImage->GetDimension(); j++)
192 vtkmatrix->SetElement(i, j, transformParams[m]);
204 std::cout <<
"rotation center: " << center[0] <<
" " << center[1] <<
" " << center[2] << std::endl;
206 float translation[4];
207 vtkmatrix->MultiplyPoint(center, translation);
210 vtkmatrix->SetElement(0, 3, -translation[0] + center[0] + transformParams[4]);
211 vtkmatrix->SetElement(1, 3, -translation[1] + center[1] + transformParams[5]);
215 vtkmatrix->SetElement(0, 3, -translation[0] + center[0] + transformParams[9]);
216 vtkmatrix->SetElement(1, 3, -translation[1] + center[1] + transformParams[10]);
217 vtkmatrix->SetElement(2, 3, -translation[2] + center[2] + transformParams[11]);
221 vtktransform->SetMatrix(vtkmatrix);
232 m_Controls.m_ScalesAffineTransformScale7->hide();
233 m_Controls.m_ScalesAffineTransformScale8->hide();
234 m_Controls.m_ScalesAffineTransformScale9->hide();
235 m_Controls.m_ScalesAffineTransformScaleTranslationX->hide();
236 m_Controls.m_ScalesAffineTransformScaleTranslationY->hide();
237 m_Controls.m_ScalesAffineTransformScaleTranslationZ->hide();
238 m_Controls.textLabel2_7->setText(
"Translation Scale X:");
239 m_Controls.textLabel3_6->setText(
"Translation Scale Y:");
250 m_Controls.m_ScalesAffineTransformScale7->show();
251 m_Controls.m_ScalesAffineTransformScale8->show();
252 m_Controls.m_ScalesAffineTransformScale9->show();
253 m_Controls.m_ScalesAffineTransformScaleTranslationX->show();
254 m_Controls.m_ScalesAffineTransformScaleTranslationY->show();
255 m_Controls.m_ScalesAffineTransformScaleTranslationZ->show();
itk::SmartPointer< Self > Pointer
TransformType
Unique integer value for every transform.
#define AccessTwoImagesFixedDimensionByItk(mitkImage1, mitkImage2, itkImageTypeFunction, dimension)
Access two mitk-images with known dimension by itk-images.
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.