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