Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "QmitkMutualInformationMetricView.h"
00019 #include <itkMutualInformationImageToImageMetric.h>
00020 #include "mitkImageAccessByItk.h"
00021
00022 QmitkMutualInformationMetricView::QmitkMutualInformationMetricView(QWidget* parent, Qt::WindowFlags f ) : QmitkRigidRegistrationMetricsGUIBase (parent, f)
00023 {
00024
00025 }
00026
00027 QmitkMutualInformationMetricView::~QmitkMutualInformationMetricView()
00028 {
00029 }
00030
00031 itk::Object::Pointer QmitkMutualInformationMetricView::GetMetric()
00032 {
00033 if (m_MovingImage.IsNotNull())
00034 {
00035 AccessByItk(m_MovingImage, GetMetric2);
00036 return m_MetricObject;
00037 }
00038 return NULL;
00039 }
00040
00041 template < class TPixelType, unsigned int VImageDimension >
00042 itk::Object::Pointer QmitkMutualInformationMetricView::GetMetric2(itk::Image<TPixelType, VImageDimension>* )
00043 {
00044 typedef typename itk::Image< TPixelType, VImageDimension > FixedImageType;
00045 typedef typename itk::Image< TPixelType, VImageDimension > MovingImageType;
00046 typename itk::MutualInformationImageToImageMetric<FixedImageType, MovingImageType>::Pointer MetricPointer = itk::MutualInformationImageToImageMetric<FixedImageType, MovingImageType>::New();
00047 MetricPointer->SetNumberOfSpatialSamples(m_Controls.m_NumberOfSpatialSamplesMutualInformation->text().toInt());
00048 MetricPointer->SetFixedImageStandardDeviation(m_Controls.m_FixedImageStandardDeviationMutualInformation->text().toFloat());
00049 MetricPointer->SetMovingImageStandardDeviation(m_Controls.m_MovingImageStandardDeviationMutualInformation->text().toFloat());
00050 MetricPointer->SetComputeGradient(m_Controls.m_ComputeGradient->isChecked());
00051 m_MetricObject = MetricPointer.GetPointer();
00052 return MetricPointer.GetPointer();
00053 }
00054
00055 itk::Array<double> QmitkMutualInformationMetricView::GetMetricParameters()
00056 {
00057 itk::Array<double> metricValues;
00058 metricValues.SetSize(4);
00059 metricValues.fill(0);
00060 metricValues[0] = m_Controls.m_ComputeGradient->isChecked();
00061 metricValues[1] = m_Controls.m_NumberOfSpatialSamplesMutualInformation->text().toInt();
00062 metricValues[2] = m_Controls.m_FixedImageStandardDeviationMutualInformation->text().toFloat();
00063 metricValues[3] = m_Controls.m_MovingImageStandardDeviationMutualInformation->text().toFloat();
00064 return metricValues;
00065 }
00066
00067 void QmitkMutualInformationMetricView::SetMetricParameters(itk::Array<double> metricValues)
00068 {
00069 m_Controls.m_ComputeGradient->setChecked(metricValues[0]);
00070 m_Controls.m_NumberOfSpatialSamplesMutualInformation->setText(QString::number(metricValues[1]));
00071 m_Controls.m_FixedImageStandardDeviationMutualInformation->setText(QString::number(metricValues[2]));
00072 m_Controls.m_MovingImageStandardDeviationMutualInformation->setText(QString::number(metricValues[3]));
00073 }
00074
00075 QString QmitkMutualInformationMetricView::GetName()
00076 {
00077 return "MutualInformation";
00078 }
00079
00080 void QmitkMutualInformationMetricView::SetupUI(QWidget* parent)
00081 {
00082 m_Controls.setupUi(parent);
00083 QValidator* validatorLineEditInput = new QIntValidator(0, 20000000, this);
00084 m_Controls.m_NumberOfSpatialSamplesMutualInformation->setValidator(validatorLineEditInput);
00085 QValidator* validatorLineEditInputFloat = new QDoubleValidator(0, 20000000, 8, this);
00086 m_Controls.m_FixedImageStandardDeviationMutualInformation->setValidator(validatorLineEditInputFloat);
00087 m_Controls.m_MovingImageStandardDeviationMutualInformation->setValidator(validatorLineEditInputFloat);
00088 }