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) ; 00065 00067 typedef std::vector<MeasurementType> OutputType ; 00068 00070 const OutputType& GetOutput() ; 00071 00073 itkSetClampMacro(NumberOfThresholds, unsigned long, 1, NumericTraits<unsigned long>::max() ); 00074 itkGetMacro(NumberOfThresholds,unsigned long); 00075 00076 protected: 00077 OtsuMultipleThresholdsCalculator() ; 00078 virtual ~OtsuMultipleThresholdsCalculator() {} 00079 void PrintSelf(std::ostream& os, Indent indent) const; 00080 00082 void GenerateData() ; 00083 00085 bool IncrementThresholds(InstanceIdentifierVectorType& thresholdIds, MeanType totalMean, MeanVectorType& classMean, FrequencyVectorType& classFrequency); 00086 00087 private: 00089 unsigned long m_NumberOfThresholds; 00090 OutputType m_Output ; 00091 00092 } ; // end of class 00093 00094 } // end of namespace itk 00095 00096 #ifndef ITK_MANUAL_INSTANTIATION 00097 #include "itkOtsuMultipleThresholdsCalculator.txx" 00098 #endif 00099 00100 #endif