00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkOtsuMultipleThresholdsCalculator.h,v $ 00005 Language: C++ 00006 Date: $Date: 2005-11-25 15:50:35 $ 00007 Version: $Revision: 1.4 $ 00008 00009 Copyright (c) Insight Software Consortium. All rights reserved. 00010 See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 00015 00016 =========================================================================*/ 00017 #ifndef __itkOtsuMultipleThresholdsCalculator_h 00018 #define __itkOtsuMultipleThresholdsCalculator_h 00019 00020 #include "itkHistogramAlgorithmBase.h" 00021 #include "itkHistogram.h" 00022 00023 namespace itk 00024 { 00025 00039 template< class TInputHistogram > 00040 class OtsuMultipleThresholdsCalculator : 00041 public HistogramAlgorithmBase< TInputHistogram > 00042 { 00043 public: 00045 typedef OtsuMultipleThresholdsCalculator Self; 00046 typedef HistogramAlgorithmBase<TInputHistogram> Superclass; 00047 typedef SmartPointer<Self> Pointer; 00048 typedef SmartPointer<const Self> ConstPointer; 00049 00050 typedef typename TInputHistogram::MeasurementType MeasurementType; 00051 typedef typename TInputHistogram::FrequencyType FrequencyType; 00052 00053 typedef typename NumericTraits<MeasurementType>::RealType MeanType; 00054 typedef typename NumericTraits<MeasurementType>::RealType VarianceType; 00055 00056 typedef std::vector<MeanType> MeanVectorType; 00057 typedef std::vector<FrequencyType> FrequencyVectorType; 00058 00059 typedef typename TInputHistogram::InstanceIdentifier InstanceIdentifierType; 00060 typedef std::vector<InstanceIdentifierType> InstanceIdentifierVectorType; 00061 00063 itkTypeMacro(OtsuMultipleThresholdsCalculator, HistogramAlgorithmsBase); 00064 itkNewMacro(Self) ; 00066 00068 typedef std::vector<MeasurementType> OutputType ; 00069 00071 const OutputType& GetOutput() ; 00072 00074 itkSetClampMacro(NumberOfThresholds, unsigned long, 1, NumericTraits<unsigned long>::max() ); 00075 itkGetMacro(NumberOfThresholds,unsigned long); 00077 00078 protected: 00079 OtsuMultipleThresholdsCalculator() ; 00080 virtual ~OtsuMultipleThresholdsCalculator() {} 00081 void PrintSelf(std::ostream& os, Indent indent) const; 00082 00084 void GenerateData() ; 00085 00087 bool IncrementThresholds(InstanceIdentifierVectorType& thresholdIds, MeanType totalMean, MeanVectorType& classMean, FrequencyVectorType& classFrequency); 00088 00089 private: 00091 unsigned long m_NumberOfThresholds; 00092 OutputType m_Output ; 00093 00094 } ; // end of class 00095 00096 } // end of namespace itk 00097 00098 #ifndef ITK_MANUAL_INSTANTIATION 00099 #include "itkOtsuMultipleThresholdsCalculator.txx" 00100 #endif 00101 00102 #endif 00103