Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
itkMITKScalarImageToHistogramGenerator.txx
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 
17 /*===================================================================
18 
19 This file is based heavily on a corresponding ITK filter.
20 
21 ===================================================================*/
22 #ifndef _itkMITKScalarImageToHistogramGenerator_txx
23 #define _itkMITKScalarImageToHistogramGenerator_txx
24 
25 #include "itkDefaultConvertPixelTraits.h"
26 #include "itkMITKScalarImageToHistogramGenerator.h"
27 
28 namespace itk
29 {
30  namespace Statistics
31  {
32  template <class TImage, class TMeasurementType>
33  MITKScalarImageToHistogramGenerator<TImage, TMeasurementType>::MITKScalarImageToHistogramGenerator()
34  {
35  m_ImageToListAdaptor = AdaptorType::New();
36  m_HistogramGenerator = GeneratorType::New();
37  m_HistogramGenerator->SetInput(m_ImageToListAdaptor);
38  }
39 
40  template <class TImage, class TMeasurementType>
41  void MITKScalarImageToHistogramGenerator<TImage, TMeasurementType>::SetInput(const ImageType *image)
42  {
43  m_ImageToListAdaptor->SetImage(image);
44  }
45 
46  template <class TImage, class TMeasurementType>
47  const typename MITKScalarImageToHistogramGenerator<TImage, TMeasurementType>::HistogramType *
48  MITKScalarImageToHistogramGenerator<TImage, TMeasurementType>::GetOutput() const
49  {
50  return m_HistogramGenerator->GetOutput();
51  }
52 
53  template <class TImage, class TMeasurementType>
54  void MITKScalarImageToHistogramGenerator<TImage, TMeasurementType>::Compute()
55  {
56  m_HistogramGenerator->Update();
57  }
58 
59  template <class TImage, class TMeasurementType>
60  void MITKScalarImageToHistogramGenerator<TImage, TMeasurementType>::SetNumberOfBins(unsigned int numberOfBins)
61  {
62  typename HistogramType::SizeType size;
63  size.SetSize(itk::DefaultConvertPixelTraits<typename TImage::PixelType>::GetNumberOfComponents());
64  size.Fill(numberOfBins);
65  m_HistogramGenerator->SetHistogramSize(size);
66  }
67 
68  template <class TImage, class TMeasurementType>
69  void MITKScalarImageToHistogramGenerator<TImage, TMeasurementType>::SetMarginalScale(double marginalScale)
70  {
71  m_HistogramGenerator->SetMarginalScale(marginalScale);
72  }
73 
74  template <class TImage, class TMeasurementType>
75  void MITKScalarImageToHistogramGenerator<TImage, TMeasurementType>::PrintSelf(std::ostream &os, Indent indent) const
76  {
77  Superclass::PrintSelf(os, indent);
78  os << "ImageToListSample adaptor = " << m_ImageToListAdaptor << std::endl;
79  os << "HistogramGenerator = " << m_HistogramGenerator << std::endl;
80  }
81 
82  } // end of namespace Statistics
83 } // end of namespace itk
84 
85 #endif