18 #include "itkRegularStepGradientDescentOptimizer.h"
21 #include "ui_QmitkDemonsRegistrationViewControls.h"
25 #include <qfiledialog.h>
26 #include <qmessagebox.h>
27 #include <qvalidator.h>
34 m_MovingNode(nullptr),
35 m_ResultImage(nullptr),
36 m_ResultDeformationField(nullptr)
40 QValidator *validatorHistogramLevels =
new QIntValidator(1, 20000000,
this);
41 m_Controls.m_NumberOfHistogramLevels->setValidator(validatorHistogramLevels);
43 QValidator *validatorMatchPoints =
new QIntValidator(1, 20000000,
this);
44 m_Controls.m_NumberOfMatchPoints->setValidator(validatorMatchPoints);
46 QValidator *validatorIterations =
new QIntValidator(1, 20000000,
this);
47 m_Controls.m_Iterations->setValidator(validatorIterations);
49 QValidator *validatorStandardDeviation =
new QDoubleValidator(0, 20000000, 2,
this);
50 m_Controls.m_StandardDeviation->setValidator(validatorStandardDeviation);
59 return atoi(
m_Controls.m_Iterations->text().toLatin1());
64 return atof(
m_Controls.m_StandardDeviation->text().toLatin1());
86 if (!((fimageRegion.GetSize(0) >= mimageRegion.GetSize(0)) &&
87 (fimageRegion.GetSize(1) >= mimageRegion.GetSize(1)) && (fimageRegion.GetSize(2) >= mimageRegion.GetSize(2))))
89 QMessageBox::information(
90 nullptr,
"Registration",
"Fixed image must be equal or bigger in size than moving image.");
93 if (
m_Controls.m_RegistrationSelection->currentIndex() == 0)
96 registration->SetSaveDeformationField(
false);
97 registration->SetSaveResult(
false);
98 registration->SetReferenceImage(fimage);
99 registration->SetNumberOfIterations(atoi(
m_Controls.m_Iterations->text().toLatin1()));
100 registration->SetStandardDeviation(atof(
m_Controls.m_StandardDeviation->text().toLatin1()));
101 if (
m_Controls.m_UseHistogramMatching->isChecked())
104 histogramMatching->SetReferenceImage(fimage);
105 histogramMatching->SetInput(mimage);
106 histogramMatching->SetNumberOfHistogramLevels(atoi(
m_Controls.m_NumberOfHistogramLevels->text().toLatin1()));
107 histogramMatching->SetNumberOfMatchPoints(atoi(
m_Controls.m_NumberOfMatchPoints->text().toLatin1()));
108 histogramMatching->SetThresholdAtMeanIntensity(
m_Controls.m_ThresholdAtMeanIntensity->isChecked());
109 histogramMatching->Update();
111 if (histimage.IsNotNull())
113 registration->SetInput(histimage);
117 registration->SetInput(mimage);
122 registration->SetInput(mimage);
126 registration->Update();
128 catch (itk::ExceptionObject &excpt)
130 QMessageBox::information(
this,
"Registration exception", excpt.GetDescription(), QMessageBox::Ok);
139 else if (
m_Controls.m_RegistrationSelection->currentIndex() == 1)
142 registration->SetSaveDeformationField(
false);
143 registration->SetSaveResult(
false);
144 registration->SetReferenceImage(fimage);
145 registration->SetNumberOfIterations(atoi(
m_Controls.m_Iterations->text().toLatin1()));
146 registration->SetStandardDeviation(atof(
m_Controls.m_StandardDeviation->text().toLatin1()));
147 if (
m_Controls.m_UseHistogramMatching->isChecked())
150 histogramMatching->SetReferenceImage(fimage);
151 histogramMatching->SetInput(mimage);
152 histogramMatching->SetNumberOfHistogramLevels(atoi(
m_Controls.m_NumberOfHistogramLevels->text().toLatin1()));
153 histogramMatching->SetNumberOfMatchPoints(atoi(
m_Controls.m_NumberOfMatchPoints->text().toLatin1()));
154 histogramMatching->SetThresholdAtMeanIntensity(
m_Controls.m_ThresholdAtMeanIntensity->isChecked());
155 histogramMatching->Update();
157 if (histimage.IsNotNull())
159 registration->SetInput(histimage);
163 registration->SetInput(mimage);
168 registration->SetInput(mimage);
172 registration->Update();
174 catch (itk::ExceptionObject &excpt)
176 QMessageBox::information(
this,
"Registration exception", excpt.GetDescription(), QMessageBox::Ok);
202 m_Controls.numberOfHistogramLevels->setEnabled(
true);
203 m_Controls.m_NumberOfHistogramLevels->setEnabled(
true);
204 m_Controls.numberOfMatchPoints->setEnabled(
true);
205 m_Controls.m_NumberOfMatchPoints->setEnabled(
true);
206 m_Controls.thresholdAtMeanIntensity->setEnabled(
true);
207 m_Controls.m_ThresholdAtMeanIntensity->setEnabled(
true);
211 m_Controls.numberOfHistogramLevels->setEnabled(
false);
212 m_Controls.m_NumberOfHistogramLevels->setEnabled(
false);
213 m_Controls.numberOfMatchPoints->setEnabled(
false);
214 m_Controls.m_NumberOfMatchPoints->setEnabled(
false);
215 m_Controls.thresholdAtMeanIntensity->setEnabled(
false);
216 m_Controls.m_ThresholdAtMeanIntensity->setEnabled(
false);
void Progress(unsigned int steps=1)
Sets the current amount of progress to current progress + steps.
static Pointer New()
Method for creation through the object factory.
itk::SmartPointer< Self > Pointer
mitk::DataNode::Pointer m_MovingNode
static Pointer New()
Method for creation through the object factory.
Ui::QmitkDemonsRegistrationViewControls m_Controls
mitk::Image::Pointer m_ResultDeformationField
int GetNumberOfIterations()
void UseHistogramMatching(bool useHM)
static Pointer New()
Method for creation through the object factory.
mitk::DataNode::Pointer m_FixedNode
static ProgressBar * GetInstance()
static method to get the GUI dependent ProgressBar-instance so the methods for steps to do and progre...
Image::Pointer ImportItkImage(const itk::SmartPointer< ItkOutputImageType > &itkimage, const BaseGeometry *geometry=nullptr, bool update=true)
Imports an itk::Image (with a specific type) as an mitk::Image.Instantiates instance of ITKImageImpor...
~QmitkDemonsRegistrationView()
void SetFixedNode(mitk::DataNode *fixedNode)
itk::ImageRegion< RegionDimension > RegionType
Image class for storing images.
void SetMovingNode(mitk::DataNode *movingNode)
mitk::Image::Pointer GetResultImage()
mitk::Image::Pointer GetResultDeformationfield()
QmitkDemonsRegistrationView(QWidget *parent=nullptr, Qt::WindowFlags f=nullptr)
mitk::Image::Pointer m_ResultImage
float GetStandardDeviation()
void CalculateTransformation()
Class for nodes of the DataTree.