Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
QmitkKullbackLeiblerCompareHistogramMetricView.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 <itkKullbackLeiblerCompareHistogramImageToImageMetric.h>
20 
21 #include "QValidator"
22 
24  Qt::WindowFlags f)
26 {
27 }
28 
30 {
31 }
32 
34 {
36 }
37 
39 {
40  if (m_MovingImage.IsNotNull())
41  {
42  AccessByItk(m_MovingImage, GetMetric2);
43  return m_MetricObject;
44  }
45  return nullptr;
46 }
47 
48 template <class TPixelType, unsigned int VImageDimension>
49 itk::Object::Pointer QmitkKullbackLeiblerCompareHistogramMetricView::GetMetric2(
50  itk::Image<TPixelType, VImageDimension> * /*itkImage1*/)
51 {
52  typedef typename itk::Image<TPixelType, VImageDimension> FixedImageType;
53  typedef typename itk::Image<TPixelType, VImageDimension> MovingImageType;
56  unsigned int nBins = m_Controls.m_NumberOfHistogramBinsKullbackLeiblerCompareHistogram->text().toInt();
57  typename itk::KullbackLeiblerCompareHistogramImageToImageMetric<FixedImageType,
58  MovingImageType>::HistogramType::SizeType
59  histogramSize;
60  histogramSize[0] = nBins;
61  histogramSize[1] = nBins;
62  MetricPointer->SetHistogramSize(histogramSize);
63  MetricPointer->SetComputeGradient(m_Controls.m_ComputeGradient->isChecked());
64  m_MetricObject = MetricPointer.GetPointer();
65  return MetricPointer.GetPointer();
66 }
67 
69 {
70  itk::Array<double> metricValues;
71  metricValues.SetSize(2);
72  metricValues.fill(0);
73  metricValues[0] = m_Controls.m_ComputeGradient->isChecked();
74  metricValues[1] = m_Controls.m_NumberOfHistogramBinsKullbackLeiblerCompareHistogram->text().toInt();
75  return metricValues;
76 }
77 
79 {
80  m_Controls.m_ComputeGradient->setChecked(metricValues[0]);
81  m_Controls.m_NumberOfHistogramBinsKullbackLeiblerCompareHistogram->setText(QString::number(metricValues[1]));
82 }
83 
85 {
86  return "KullbackLeiblerCompareHistogram";
87 }
88 
90 {
91  m_Controls.setupUi(parent);
92  QValidator *validatorLineEditInput = new QIntValidator(0, 20000000, this);
93  m_Controls.m_NumberOfHistogramBinsKullbackLeiblerCompareHistogram->setValidator(validatorLineEditInput);
94 }
95 
97 {
98  return false;
99 }
itk::SmartPointer< Self > Pointer
virtual void SetMetricParameters(itk::Array< double > metricValues) override
QmitkKullbackLeiblerCompareHistogramMetricView(QWidget *parent=nullptr, Qt::WindowFlags f=nullptr)
#define AccessByItk(mitkImage, itkImageTypeFunction)
Access a MITK image by an ITK image.
MetricType
Unique integer value for every metric.
Ui::QmitkKullbackLeiblerCompareHistogramMetricControls m_Controls
virtual mitk::MetricParameters::MetricType GetMetricType() override
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.