Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
QmitkMutualInformationHistogramMetricView.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 <itkMutualInformationHistogramImageToImageMetric.h>
20 
21 #include "QValidator"
22 
25 {
26 }
27 
29 {
30 }
31 
33 {
35 }
36 
38 {
39  if (m_MovingImage.IsNotNull())
40  {
41  AccessByItk(m_MovingImage, GetMetric2);
42  return m_MetricObject;
43  }
44  return nullptr;
45 }
46 
47 template <class TPixelType, unsigned int VImageDimension>
48 itk::Object::Pointer QmitkMutualInformationHistogramMetricView::GetMetric2(
49  itk::Image<TPixelType, VImageDimension> * /*itkImage1*/)
50 {
51  typedef typename itk::Image<TPixelType, VImageDimension> FixedImageType;
52  typedef typename itk::Image<TPixelType, VImageDimension> MovingImageType;
55  unsigned int nBins = m_Controls.m_NumberOfHistogramBinsMutualInformationHistogram->text().toInt();
56  typename itk::MutualInformationHistogramImageToImageMetric<FixedImageType, MovingImageType>::HistogramType::SizeType
57  histogramSize;
58  histogramSize[0] = nBins;
59  histogramSize[1] = nBins;
60  MetricPointer->SetHistogramSize(histogramSize);
61  MetricPointer->SetComputeGradient(m_Controls.m_ComputeGradient->isChecked());
62  m_MetricObject = MetricPointer.GetPointer();
63  return MetricPointer.GetPointer();
64 }
65 
67 {
68  itk::Array<double> metricValues;
69  metricValues.SetSize(2);
70  metricValues.fill(0);
71  metricValues[0] = m_Controls.m_ComputeGradient->isChecked();
72  metricValues[1] = m_Controls.m_NumberOfHistogramBinsMutualInformationHistogram->text().toInt();
73  return metricValues;
74 }
75 
77 {
78  m_Controls.m_ComputeGradient->setChecked(metricValues[0]);
79  m_Controls.m_NumberOfHistogramBinsMutualInformationHistogram->setText(QString::number(metricValues[1]));
80 }
81 
83 {
84  return "MutualInformationHistogram";
85 }
86 
88 {
89  m_Controls.setupUi(parent);
90  QValidator *validatorLineEditInput = new QIntValidator(0, 20000000, this);
91  m_Controls.m_NumberOfHistogramBinsMutualInformationHistogram->setValidator(validatorLineEditInput);
92 }
93 
95 {
96  return false;
97 }
itk::SmartPointer< Self > Pointer
Ui::QmitkMutualInformationHistogramMetricControls m_Controls
QmitkMutualInformationHistogramMetricView(QWidget *parent=nullptr, Qt::WindowFlags f=nullptr)
#define AccessByItk(mitkImage, itkImageTypeFunction)
Access a MITK image by an ITK image.
virtual void SetMetricParameters(itk::Array< double > metricValues) override
MetricType
Unique integer value for every metric.
virtual mitk::MetricParameters::MetricType GetMetricType() override
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.