00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkWeightedMeanCalculator.h,v $ 00005 Language: C++ 00006 Date: $Date: 2005-07-26 15:55:07 $ 00007 Version: $Revision: 1.7 $ 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 00018 #ifndef __itkWeightedMeanCalculator_h 00019 #define __itkWeightedMeanCalculator_h 00020 00021 #include <vnl/vnl_vector.h> 00022 #include <vnl/vnl_matrix.h> 00023 00024 #include "itkArray.h" 00025 #include "itkFunctionBase.h" 00026 #include "itkSampleAlgorithmBase.h" 00027 00028 namespace itk{ 00029 namespace Statistics{ 00030 00049 template< class TSample > 00050 class WeightedMeanCalculator : 00051 public SampleAlgorithmBase< TSample > 00052 { 00053 public: 00055 typedef WeightedMeanCalculator Self; 00056 typedef SampleAlgorithmBase< TSample > Superclass ; 00057 typedef SmartPointer<Self> Pointer; 00058 typedef SmartPointer<const Self> ConstPointer; 00059 00061 itkTypeMacro(WeightedMeanCalculator, SampleAlgorithmBase); 00062 itkNewMacro(Self) ; 00064 00066 typedef typename Superclass::MeasurementVectorSizeType MeasurementVectorSizeType; 00067 00068 typedef typename TSample::MeasurementVectorType MeasurementVectorType ; 00069 00071 typedef Array< double > OutputType; 00072 00074 typedef Array< double > WeightArrayType ; 00075 00077 void SetWeights(WeightArrayType* array) ; 00078 00080 WeightArrayType* GetWeights() ; 00081 00083 typedef FunctionBase< MeasurementVectorType, double > WeightFunctionType ; 00084 00088 void SetWeightFunction(WeightFunctionType* func) ; 00089 00091 WeightFunctionType* GetWeightFunction() ; 00092 00094 OutputType* GetOutput() ; 00095 00096 protected: 00097 WeightedMeanCalculator() ; 00098 virtual ~WeightedMeanCalculator() {} 00099 void PrintSelf(std::ostream& os, Indent indent) const; 00100 00102 void GenerateData() ; 00103 00104 private: 00105 WeightArrayType* m_Weights ; 00106 WeightFunctionType* m_WeightFunction ; 00107 OutputType m_Output ; 00108 } ; // end of class 00109 00110 } // end of namespace Statistics 00111 } // end of namespace itk 00112 00113 #ifndef ITK_MANUAL_INSTANTIATION 00114 #include "itkWeightedMeanCalculator.txx" 00115 #endif 00116 00117 #endif 00118 00119