00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkOtsuMultipleThresholdsCalculator.h,v $ 00005 Language: C++ 00006 Date: $Date: 2009-05-12 17:26:21 $ 00007 Version: $Revision: 1.8 $ 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 ITK_EXPORT 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 00052 #ifdef ITK_USE_REVIEW_STATISTICS 00053 typedef typename TInputHistogram::AbsoluteFrequencyType FrequencyType; 00054 #else 00055 typedef typename TInputHistogram::FrequencyType FrequencyType; 00056 #endif 00057 00058 typedef typename NumericTraits<MeasurementType>::RealType MeanType; 00059 typedef typename NumericTraits<MeasurementType>::RealType VarianceType; 00060 00061 typedef std::vector<MeanType> MeanVectorType; 00062 typedef std::vector<FrequencyType> FrequencyVectorType; 00063 00064 typedef typename TInputHistogram::InstanceIdentifier InstanceIdentifierType; 00065 typedef std::vector<InstanceIdentifierType> InstanceIdentifierVectorType; 00066 00068 itkTypeMacro(OtsuMultipleThresholdsCalculator, HistogramAlgorithmsBase); 00069 itkNewMacro(Self); 00071 00073 typedef std::vector<MeasurementType> OutputType; 00074 00076 const OutputType& GetOutput(); 00077 00079 itkSetClampMacro(NumberOfThresholds, unsigned long, 1, NumericTraits<unsigned long>::max() ); 00080 itkGetConstMacro(NumberOfThresholds,unsigned long); 00082 00083 protected: 00084 OtsuMultipleThresholdsCalculator(); 00085 virtual ~OtsuMultipleThresholdsCalculator() {} 00086 void PrintSelf(std::ostream& os, Indent indent) const; 00087 00089 void GenerateData(); 00090 00092 bool IncrementThresholds(InstanceIdentifierVectorType& thresholdIds, MeanType totalMean, MeanVectorType& classMean, FrequencyVectorType& classFrequency); 00093 00094 private: 00096 unsigned long m_NumberOfThresholds; 00097 OutputType m_Output; 00098 00099 }; // end of class 00100 00101 } // end of namespace itk 00102 00103 #ifndef ITK_MANUAL_INSTANTIATION 00104 #include "itkOtsuMultipleThresholdsCalculator.txx" 00105 #endif 00106 00107 #endif 00108