20 #include <itkCenteredSimilarity2DTransform.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_CenterForInitializerCenteredSimilarity2D->isChecked())
71 typedef typename itk::CenteredSimilarity2DTransform<double> CenteredSimilarity2DTransformType;
72 typedef typename itk::
73 CenteredTransformInitializer<CenteredSimilarity2DTransformType, FixedImage2DType, MovingImage2DType>
74 TransformInitializerType;
76 transformInitializer->SetFixedImage(fixedImage2D);
77 transformInitializer->SetMovingImage(movingImage2D);
78 transformInitializer->SetTransform(transformPointer);
79 if (
m_Controls.m_MomentsCenteredSimilarity2D->isChecked())
81 transformInitializer->MomentsOn();
85 transformInitializer->GeometryOn();
87 transformInitializer->InitializeTransform();
89 transformPointer->SetScale(
m_Controls.m_InitialScaleCenteredSimilarity2D->text().toFloat());
90 transformPointer->SetAngle(
m_Controls.m_AngleCenteredSimilarity2D->text().toFloat());
91 m_CenterX = transformPointer->GetCenter()[0];
92 m_CenterY = transformPointer->GetCenter()[1];
94 return transformPointer.GetPointer();
101 itk::Array<double> transformValues;
102 transformValues.SetSize(11);
103 transformValues.fill(0);
104 transformValues[0] =
m_Controls.m_UseOptimizerScalesCenteredSimilarity2D->isChecked();
105 transformValues[1] =
m_Controls.m_ScalesCenteredSimilarity2DTransformScale1->text().toDouble();
106 transformValues[2] =
m_Controls.m_ScalesCenteredSimilarity2DTransformScale2->text().toDouble();
107 transformValues[3] =
m_Controls.m_ScalesCenteredSimilarity2DTransformScale3->text().toDouble();
108 transformValues[4] =
m_Controls.m_ScalesCenteredSimilarity2DTransformScale4->text().toDouble();
109 transformValues[5] =
m_Controls.m_ScalesCenteredSimilarity2DTransformScaleTranslationX->text().toDouble();
110 transformValues[6] =
m_Controls.m_ScalesCenteredSimilarity2DTransformScaleTranslationY->text().toDouble();
111 transformValues[7] =
m_Controls.m_InitialScaleCenteredSimilarity2D->text().toFloat();
112 transformValues[8] =
m_Controls.m_AngleCenteredSimilarity2D->text().toFloat();
113 transformValues[9] =
m_Controls.m_CenterForInitializerCenteredSimilarity2D->isChecked();
114 transformValues[10] =
m_Controls.m_MomentsCenteredSimilarity2D->isChecked();
115 return transformValues;
120 m_Controls.m_UseOptimizerScalesCenteredSimilarity2D->setChecked(transformValues[0]);
121 m_Controls.m_ScalesCenteredSimilarity2DTransformScale1->setText(QString::number(transformValues[1]));
122 m_Controls.m_ScalesCenteredSimilarity2DTransformScale2->setText(QString::number(transformValues[2]));
123 m_Controls.m_ScalesCenteredSimilarity2DTransformScale3->setText(QString::number(transformValues[3]));
124 m_Controls.m_ScalesCenteredSimilarity2DTransformScale4->setText(QString::number(transformValues[4]));
125 m_Controls.m_ScalesCenteredSimilarity2DTransformScaleTranslationX->setText(QString::number(transformValues[5]));
126 m_Controls.m_ScalesCenteredSimilarity2DTransformScaleTranslationY->setText(QString::number(transformValues[6]));
127 m_Controls.m_InitialScaleCenteredSimilarity2D->setText(QString::number(transformValues[7]));
128 m_Controls.m_AngleCenteredSimilarity2D->setText(QString::number(transformValues[8]));
129 m_Controls.m_CenterForInitializerCenteredSimilarity2D->setChecked(transformValues[9]);
130 m_Controls.m_MomentsCenteredSimilarity2D->setChecked(transformValues[10]);
131 m_Controls.m_GeometryCenteredSimilarity2D->setChecked(!transformValues[10]);
136 return "CenteredSimilarity2D";
142 QValidator *validatorLineEditInputFloat =
new QDoubleValidator(0, 20000000, 8,
this);
143 m_Controls.m_ScalesCenteredSimilarity2DTransformScale1->setValidator(validatorLineEditInputFloat);
144 m_Controls.m_ScalesCenteredSimilarity2DTransformScale2->setValidator(validatorLineEditInputFloat);
145 m_Controls.m_ScalesCenteredSimilarity2DTransformScale3->setValidator(validatorLineEditInputFloat);
146 m_Controls.m_ScalesCenteredSimilarity2DTransformScale4->setValidator(validatorLineEditInputFloat);
147 m_Controls.m_ScalesCenteredSimilarity2DTransformScaleTranslationX->setValidator(validatorLineEditInputFloat);
148 m_Controls.m_ScalesCenteredSimilarity2DTransformScaleTranslationY->setValidator(validatorLineEditInputFloat);
153 itk::Array<double> scales;
156 if (
m_Controls.m_UseOptimizerScalesCenteredSimilarity2D->isChecked())
158 scales[0] =
m_Controls.m_ScalesCenteredSimilarity2DTransformScale1->text().toDouble();
159 scales[1] =
m_Controls.m_ScalesCenteredSimilarity2DTransformScale2->text().toDouble();
160 scales[2] =
m_Controls.m_ScalesCenteredSimilarity2DTransformScale3->text().toDouble();
161 scales[3] =
m_Controls.m_ScalesCenteredSimilarity2DTransformScale4->text().toDouble();
162 scales[4] =
m_Controls.m_ScalesCenteredSimilarity2DTransformScaleTranslationX->text().toDouble();
163 scales[5] =
m_Controls.m_ScalesCenteredSimilarity2DTransformScaleTranslationY->text().toDouble();
169 vtkTransform *vtktransform,
170 itk::Array<double> transformParams)
175 vtktransform->PostMultiply();
176 vtktransform->Translate(-transformParams[2], -transformParams[3], 0);
177 vtktransform->Scale(transformParams[0], transformParams[0], 1);
178 vtktransform->RotateZ(angle);
179 vtktransform->Translate(transformParams[2], transformParams[3], 0);
180 vtktransform->Translate(transformParams[4], transformParams[5], 0);
181 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.