20 #include <itkCenteredTransformInitializer.h>
21 #include <itkSimilarity2DTransform.h>
48 template <
class TPixelType,
unsigned int VImageDimension>
49 itk::Object::Pointer QmitkSimilarity2DTransformView::GetTransform2(itk::Image<TPixelType, VImageDimension> *itkImage1)
51 if (VImageDimension == 2)
53 typedef typename itk::Image<TPixelType, 2> FixedImage2DType;
54 typedef typename itk::Image<TPixelType, 2> MovingImage2DType;
62 movingImageToItk->Update();
66 transformPointer->SetIdentity();
67 if (
m_Controls.m_CenterForInitializerSimilarity2D->isChecked())
69 typedef typename itk::Similarity2DTransform<double> Similarity2DTransformType;
70 typedef typename itk::CenteredTransformInitializer<Similarity2DTransformType, FixedImage2DType, MovingImage2DType>
71 TransformInitializerType;
73 transformInitializer->SetFixedImage(fixedImage2D);
74 transformInitializer->SetMovingImage(movingImage2D);
75 transformInitializer->SetTransform(transformPointer);
76 if (
m_Controls.m_MomentsSimilarity2D->isChecked())
78 transformInitializer->MomentsOn();
82 transformInitializer->GeometryOn();
84 transformInitializer->InitializeTransform();
86 transformPointer->SetScale(
m_Controls.m_InitialScaleSimilarity2D->text().toFloat());
87 transformPointer->SetAngle(
m_Controls.m_AngleSimilarity2D->text().toFloat());
89 return transformPointer.GetPointer();
96 itk::Array<double> transformValues;
97 transformValues.SetSize(9);
98 transformValues.fill(0);
99 transformValues[0] =
m_Controls.m_UseOptimizerScalesSimilarity2D->isChecked();
100 transformValues[1] =
m_Controls.m_ScalingScaleSimilarity2D->text().toDouble();
101 transformValues[2] =
m_Controls.m_RotationScaleSimilarity2D->text().toDouble();
102 transformValues[3] =
m_Controls.m_TranslationXScaleSimilarity2D->text().toDouble();
103 transformValues[4] =
m_Controls.m_TranslationYScaleSimilarity2D->text().toDouble();
104 transformValues[5] =
m_Controls.m_InitialScaleSimilarity2D->text().toFloat();
105 transformValues[6] =
m_Controls.m_AngleSimilarity2D->text().toFloat();
106 transformValues[7] =
m_Controls.m_CenterForInitializerSimilarity2D->isChecked();
107 transformValues[8] =
m_Controls.m_MomentsSimilarity2D->isChecked();
108 return transformValues;
113 m_Controls.m_UseOptimizerScalesSimilarity2D->setChecked(transformValues[0]);
114 m_Controls.m_ScalingScaleSimilarity2D->setText(QString::number(transformValues[1]));
115 m_Controls.m_RotationScaleSimilarity2D->setText(QString::number(transformValues[2]));
116 m_Controls.m_TranslationXScaleSimilarity2D->setText(QString::number(transformValues[3]));
117 m_Controls.m_TranslationYScaleSimilarity2D->setText(QString::number(transformValues[4]));
118 m_Controls.m_InitialScaleSimilarity2D->setText(QString::number(transformValues[5]));
119 m_Controls.m_AngleSimilarity2D->setText(QString::number(transformValues[6]));
120 m_Controls.m_CenterForInitializerSimilarity2D->setChecked(transformValues[7]);
121 m_Controls.m_MomentsSimilarity2D->setChecked(transformValues[8]);
122 m_Controls.m_GeometrySimilarity2D->setChecked(!transformValues[8]);
127 return "Similarity2D";
133 QValidator *validatorLineEditInputFloat =
new QDoubleValidator(0, 20000000, 8,
this);
134 m_Controls.m_ScalingScaleSimilarity2D->setValidator(validatorLineEditInputFloat);
135 m_Controls.m_RotationScaleSimilarity2D->setValidator(validatorLineEditInputFloat);
136 m_Controls.m_TranslationXScaleSimilarity2D->setValidator(validatorLineEditInputFloat);
137 m_Controls.m_TranslationYScaleSimilarity2D->setValidator(validatorLineEditInputFloat);
142 itk::Array<double> scales;
145 if (
m_Controls.m_UseOptimizerScalesSimilarity2D->isChecked())
147 scales[0] =
m_Controls.m_ScalingScaleSimilarity2D->text().toDouble();
148 scales[1] =
m_Controls.m_RotationScaleSimilarity2D->text().toDouble();
149 scales[2] =
m_Controls.m_TranslationXScaleSimilarity2D->text().toDouble();
150 scales[3] =
m_Controls.m_TranslationYScaleSimilarity2D->text().toDouble();
156 vtkTransform *vtktransform,
157 itk::Array<double> transformParams)
162 vtktransform->PostMultiply();
163 vtktransform->Scale(transformParams[0], transformParams[0], 1);
164 vtktransform->RotateZ(angle);
165 vtktransform->Translate(transformParams[2], transformParams[3], 0);
166 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.