1 /*===================================================================
3 The Medical Imaging Interaction Toolkit (MITK)
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
13 See LICENSE.txt or http://www.mitk.org for details.
15 ===================================================================*/
17 /*===================================================================
19 This file is based heavily on a corresponding ITK filter.
21 ===================================================================*/
22 #ifndef _itkMITKScalarImageToHistogramGenerator_txx
23 #define _itkMITKScalarImageToHistogramGenerator_txx
25 #include "itkDefaultConvertPixelTraits.h"
26 #include "itkMITKScalarImageToHistogramGenerator.h"
32 template <class TImage, class TMeasurementType>
33 MITKScalarImageToHistogramGenerator<TImage, TMeasurementType>::MITKScalarImageToHistogramGenerator()
35 m_ImageToListAdaptor = AdaptorType::New();
36 m_HistogramGenerator = GeneratorType::New();
37 m_HistogramGenerator->SetInput(m_ImageToListAdaptor);
40 template <class TImage, class TMeasurementType>
41 void MITKScalarImageToHistogramGenerator<TImage, TMeasurementType>::SetInput(const ImageType *image)
43 m_ImageToListAdaptor->SetImage(image);
46 template <class TImage, class TMeasurementType>
47 const typename MITKScalarImageToHistogramGenerator<TImage, TMeasurementType>::HistogramType *
48 MITKScalarImageToHistogramGenerator<TImage, TMeasurementType>::GetOutput() const
50 return m_HistogramGenerator->GetOutput();
53 template <class TImage, class TMeasurementType>
54 void MITKScalarImageToHistogramGenerator<TImage, TMeasurementType>::Compute()
56 m_HistogramGenerator->Update();
59 template <class TImage, class TMeasurementType>
60 void MITKScalarImageToHistogramGenerator<TImage, TMeasurementType>::SetNumberOfBins(unsigned int numberOfBins)
62 typename HistogramType::SizeType size;
63 size.SetSize(itk::DefaultConvertPixelTraits<typename TImage::PixelType>::GetNumberOfComponents());
64 size.Fill(numberOfBins);
65 m_HistogramGenerator->SetHistogramSize(size);
68 template <class TImage, class TMeasurementType>
69 void MITKScalarImageToHistogramGenerator<TImage, TMeasurementType>::SetMarginalScale(double marginalScale)
71 m_HistogramGenerator->SetMarginalScale(marginalScale);
74 template <class TImage, class TMeasurementType>
75 void MITKScalarImageToHistogramGenerator<TImage, TMeasurementType>::PrintSelf(std::ostream &os, Indent indent) const
77 Superclass::PrintSelf(os, indent);
78 os << "ImageToListSample adaptor = " << m_ImageToListAdaptor << std::endl;
79 os << "HistogramGenerator = " << m_HistogramGenerator << std::endl;
82 } // end of namespace Statistics
83 } // end of namespace itk