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) ; 00063 00065 typedef typename Superclass::MeasurementVectorSizeType MeasurementVectorSizeType; 00066 00067 typedef typename TSample::MeasurementVectorType MeasurementVectorType ; 00068 00070 typedef Array< double > OutputType; 00071 00073 typedef Array< double > WeightArrayType ; 00074 00076 void SetWeights(WeightArrayType* array) ; 00077 00079 WeightArrayType* GetWeights() ; 00080 00082 typedef FunctionBase< MeasurementVectorType, double > WeightFunctionType ; 00083 00087 void SetWeightFunction(WeightFunctionType* func) ; 00088 00090 WeightFunctionType* GetWeightFunction() ; 00091 00093 OutputType* GetOutput() ; 00094 00095 protected: 00096 WeightedMeanCalculator() ; 00097 virtual ~WeightedMeanCalculator() {} 00098 void PrintSelf(std::ostream& os, Indent indent) const; 00099 00101 void GenerateData() ; 00102 00103 private: 00104 WeightArrayType* m_Weights ; 00105 WeightFunctionType* m_WeightFunction ; 00106 OutputType m_Output ; 00107 } ; // end of class 00108 00109 } // end of namespace Statistics 00110 } // end of namespace itk 00111 00112 #ifndef ITK_MANUAL_INSTANTIATION 00113 #include "itkWeightedMeanCalculator.txx" 00114 #endif 00115 00116 #endif 00117