ITK
4.1.0
Insight Segmentation and Registration Toolkit
|
00001 /*========================================================================= 00002 * 00003 * Copyright Insight Software Consortium 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); 00006 * you may not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0.txt 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 * 00017 *=========================================================================*/ 00018 #ifndef __itkOtsuMultipleThresholdsCalculator_h 00019 #define __itkOtsuMultipleThresholdsCalculator_h 00020 00021 #include "itkHistogramAlgorithmBase.h" 00022 #include "itkHistogram.h" 00023 00024 namespace itk 00025 { 00040 template< class TInputHistogram > 00041 class ITK_EXPORT OtsuMultipleThresholdsCalculator: 00042 public HistogramAlgorithmBase< TInputHistogram > 00043 { 00044 public: 00046 typedef OtsuMultipleThresholdsCalculator Self; 00047 typedef HistogramAlgorithmBase< TInputHistogram > Superclass; 00048 typedef SmartPointer< Self > Pointer; 00049 typedef SmartPointer< const Self > ConstPointer; 00050 00051 typedef typename TInputHistogram::MeasurementType MeasurementType; 00052 typedef typename TInputHistogram::AbsoluteFrequencyType FrequencyType; 00053 00054 typedef typename NumericTraits< MeasurementType >::RealType MeanType; 00055 typedef typename NumericTraits< MeasurementType >::RealType VarianceType; 00056 00057 typedef std::vector< MeanType > MeanVectorType; 00058 typedef std::vector< FrequencyType > FrequencyVectorType; 00059 00060 typedef typename TInputHistogram::InstanceIdentifier InstanceIdentifierType; 00061 typedef std::vector< InstanceIdentifierType > InstanceIdentifierVectorType; 00062 00064 itkTypeMacro(OtsuMultipleThresholdsCalculator, HistogramAlgorithmsBase); 00065 itkNewMacro(Self); 00067 00069 typedef std::vector< MeasurementType > OutputType; 00070 00072 const OutputType & GetOutput(); 00073 00075 itkSetClampMacro( NumberOfThresholds, SizeValueType, 1, NumericTraits< SizeValueType >::max() ); 00076 itkGetConstMacro(NumberOfThresholds, SizeValueType); 00077 protected: 00078 OtsuMultipleThresholdsCalculator(); 00079 virtual ~OtsuMultipleThresholdsCalculator() {} 00080 void PrintSelf(std::ostream & os, Indent indent) const; 00082 00084 void GenerateData(); 00085 00087 bool IncrementThresholds(InstanceIdentifierVectorType & thresholdIds, 00088 MeanType totalMean, 00089 MeanVectorType & classMean, 00090 FrequencyVectorType & classFrequency); 00091 00092 private: 00094 SizeValueType m_NumberOfThresholds; 00095 OutputType m_Output; 00096 }; // end of class 00097 } // end of namespace itk 00098 00099 #ifndef ITK_MANUAL_INSTANTIATION 00100 #include "itkOtsuMultipleThresholdsCalculator.hxx" 00101 #endif 00102 00103 #endif 00104