Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
QmitkMattesMutualInformationMetricView.cpp
Go to the documentation of this file.
1 /*===================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
18 #include "mitkImageAccessByItk.h"
19 #include <itkMattesMutualInformationImageToImageMetric.h>
20 
23 {
24 }
25 
27 {
28 }
29 
31 {
33 }
34 
36 {
37  if (m_MovingImage.IsNotNull())
38  {
39  AccessByItk(m_MovingImage, GetMetric2);
40  return m_MetricObject;
41  }
42  return nullptr;
43 }
44 
45 template <class TPixelType, unsigned int VImageDimension>
46 itk::Object::Pointer QmitkMattesMutualInformationMetricView::GetMetric2(
47  itk::Image<TPixelType, VImageDimension> * /*itkImage1*/)
48 {
49  typedef typename itk::Image<TPixelType, VImageDimension> FixedImageType;
50  typedef typename itk::Image<TPixelType, VImageDimension> MovingImageType;
53  bool useSampling = m_Controls.m_UseSamplingMattesMutualInformation->isChecked();
54  if (useSampling)
55  {
56  // set the number of samples to use
57  MetricPointer->SetNumberOfSpatialSamples(
58  m_Controls.m_NumberOfSpatialSamplesMattesMutualInformation->text().toInt());
59  }
60  else
61  {
62  MetricPointer->UseAllPixelsOn();
63  }
64  MetricPointer->SetNumberOfHistogramBins(m_Controls.m_NumberOfHistogramBinsMattesMutualInformation->text().toInt());
65  MetricPointer->ReinitializeSeed(76926294);
66  MetricPointer->SetComputeGradient(m_Controls.m_ComputeGradient->isChecked());
67  m_MetricObject = MetricPointer.GetPointer();
68  return MetricPointer.GetPointer();
69 }
70 
72 {
73  itk::Array<double> metricValues;
74  metricValues.SetSize(4);
75  metricValues.fill(0);
76  metricValues[0] = m_Controls.m_ComputeGradient->isChecked();
77  metricValues[1] = m_Controls.m_UseSamplingMattesMutualInformation->isChecked();
78  metricValues[2] = m_Controls.m_NumberOfSpatialSamplesMattesMutualInformation->text().toInt();
79  metricValues[3] = m_Controls.m_NumberOfHistogramBinsMattesMutualInformation->text().toInt();
80  return metricValues;
81 }
82 
84 {
85  m_Controls.m_ComputeGradient->setChecked(metricValues[0]);
86  m_Controls.m_UseSamplingMattesMutualInformation->setChecked(metricValues[1]);
87  m_Controls.m_NumberOfSpatialSamplesMattesMutualInformation->setText(QString::number(metricValues[2]));
88  m_Controls.m_NumberOfHistogramBinsMattesMutualInformation->setText(QString::number(metricValues[3]));
89 }
90 
92 {
93  return "MattesMutualInformation";
94 }
95 
97 {
98  m_Controls.setupUi(parent);
99  QValidator *validatorLineEditInput = new QIntValidator(0, 20000000, this);
100  m_Controls.m_NumberOfSpatialSamplesMattesMutualInformation->setValidator(validatorLineEditInput);
101  m_Controls.m_NumberOfHistogramBinsMattesMutualInformation->setValidator(validatorLineEditInput);
102 }
103 
105 {
106  return true;
107 }
itk::SmartPointer< Self > Pointer
virtual itk::Array< double > GetMetricParameters() override
QmitkMattesMutualInformationMetricView(QWidget *parent=nullptr, Qt::WindowFlags f=nullptr)
virtual mitk::MetricParameters::MetricType GetMetricType() override
#define AccessByItk(mitkImage, itkImageTypeFunction)
Access a MITK image by an ITK image.
MetricType
Unique integer value for every metric.
Ui::QmitkMattesMutualInformationMetricControls m_Controls
virtual void SetMetricParameters(itk::Array< double > metricValues) override
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.