20 #include <itkCenteredRigid2DTransform.h>
21 #include <itkCenteredTransformInitializer.h>
48 template <
class TPixelType,
unsigned int VImageDimension>
50 itk::Image<TPixelType, VImageDimension> *itkImage1)
52 if (VImageDimension == 2)
54 typedef typename itk::Image<TPixelType, 2> FixedImage2DType;
55 typedef typename itk::Image<TPixelType, 2> MovingImage2DType;
63 movingImageToItk->Update();
68 transformPointer->SetIdentity();
69 if (
m_Controls.m_CenterForInitializerCenteredRigid2D->isChecked())
71 typedef typename itk::CenteredRigid2DTransform<double> CenteredRigid2DTransformType;
73 typename itk::CenteredTransformInitializer<CenteredRigid2DTransformType, FixedImage2DType, MovingImage2DType>
74 TransformInitializerType;
76 transformInitializer->SetFixedImage(fixedImage2D);
77 transformInitializer->SetMovingImage(movingImage2D);
78 transformInitializer->SetTransform(transformPointer);
79 if (
m_Controls.m_MomentsCenteredRigid2D->isChecked())
81 transformInitializer->MomentsOn();
85 transformInitializer->GeometryOn();
87 transformInitializer->InitializeTransform();
89 transformPointer->SetAngle(
m_Controls.m_AngleCenteredRigid2D->text().toFloat());
90 m_CenterX = transformPointer->GetCenter()[0];
91 m_CenterY = transformPointer->GetCenter()[1];
93 return transformPointer.GetPointer();
100 itk::Array<double> transformValues;
101 transformValues.SetSize(9);
102 transformValues.fill(0);
103 transformValues[0] =
m_Controls.m_UseOptimizerScalesCenteredRigid2D->isChecked();
104 transformValues[1] =
m_Controls.m_RotationScaleCenteredRigid2D->text().toDouble();
105 transformValues[2] =
m_Controls.m_CenterXScaleCenteredRigid2D->text().toDouble();
106 transformValues[3] =
m_Controls.m_CenterYScaleCenteredRigid2D->text().toDouble();
107 transformValues[4] =
m_Controls.m_TranslationXScaleCenteredRigid2D->text().toDouble();
108 transformValues[5] =
m_Controls.m_TranslationYScaleCenteredRigid2D->text().toDouble();
109 transformValues[6] =
m_Controls.m_AngleCenteredRigid2D->text().toFloat();
110 transformValues[7] =
m_Controls.m_CenterForInitializerCenteredRigid2D->isChecked();
111 transformValues[8] =
m_Controls.m_MomentsCenteredRigid2D->isChecked();
112 return transformValues;
117 m_Controls.m_UseOptimizerScalesCenteredRigid2D->setChecked(transformValues[0]);
118 m_Controls.m_RotationScaleCenteredRigid2D->setText(QString::number(transformValues[1]));
119 m_Controls.m_CenterXScaleCenteredRigid2D->setText(QString::number(transformValues[2]));
120 m_Controls.m_CenterYScaleCenteredRigid2D->setText(QString::number(transformValues[3]));
121 m_Controls.m_TranslationXScaleCenteredRigid2D->setText(QString::number(transformValues[4]));
122 m_Controls.m_TranslationYScaleCenteredRigid2D->setText(QString::number(transformValues[5]));
123 m_Controls.m_AngleCenteredRigid2D->setText(QString::number(transformValues[6]));
124 m_Controls.m_CenterForInitializerCenteredRigid2D->setChecked(transformValues[7]);
125 m_Controls.m_MomentsCenteredRigid2D->setChecked(transformValues[8]);
126 m_Controls.m_GeometryCenteredRigid2D->setChecked(!transformValues[8]);
131 return "CenteredRigid2D";
137 QValidator *validatorLineEditInputFloat =
new QDoubleValidator(0, 20000000, 8,
this);
138 m_Controls.m_AngleCenteredRigid2D->setValidator(validatorLineEditInputFloat);
139 m_Controls.m_RotationScaleCenteredRigid2D->setValidator(validatorLineEditInputFloat);
140 m_Controls.m_CenterXScaleCenteredRigid2D->setValidator(validatorLineEditInputFloat);
141 m_Controls.m_CenterYScaleCenteredRigid2D->setValidator(validatorLineEditInputFloat);
142 m_Controls.m_TranslationXScaleCenteredRigid2D->setValidator(validatorLineEditInputFloat);
143 m_Controls.m_TranslationYScaleCenteredRigid2D->setValidator(validatorLineEditInputFloat);
148 itk::Array<double> scales;
151 if (
m_Controls.m_UseOptimizerScalesCenteredRigid2D->isChecked())
153 scales[0] =
m_Controls.m_RotationScaleCenteredRigid2D->text().toDouble();
154 scales[1] =
m_Controls.m_CenterXScaleCenteredRigid2D->text().toDouble();
155 scales[2] =
m_Controls.m_CenterYScaleCenteredRigid2D->text().toDouble();
156 scales[3] =
m_Controls.m_TranslationXScaleCenteredRigid2D->text().toDouble();
157 scales[4] =
m_Controls.m_TranslationYScaleCenteredRigid2D->text().toDouble();
163 vtkTransform *vtktransform,
164 itk::Array<double> transformParams)
170 vtktransform->PostMultiply();
171 vtktransform->Translate(-transformParams[1], -transformParams[2], 0);
172 vtktransform->RotateZ(angle);
173 vtktransform->Translate(transformParams[1], transformParams[2], 0);
174 vtktransform->Translate(transformParams[3], transformParams[4], 0);
175 vtktransform->PreMultiply();
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.