00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkWeightedMeanCalculator.h,v $ 00005 Language: C++ 00006 Date: $Date: 2003/12/09 16:53:08 $ 00007 Version: $Revision: 1.6 $ 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 "itkVector.h" 00026 #include "itkFunctionBase.h" 00027 #include "itkSampleAlgorithmBase.h" 00028 00029 namespace itk{ 00030 namespace Statistics{ 00031 00043 template< class TSample > 00044 class WeightedMeanCalculator : 00045 public SampleAlgorithmBase< TSample > 00046 { 00047 public: 00049 typedef WeightedMeanCalculator Self; 00050 typedef SampleAlgorithmBase< TSample > Superclass ; 00051 typedef SmartPointer<Self> Pointer; 00052 typedef SmartPointer<const Self> ConstPointer; 00053 00055 itkTypeMacro(WeightedMeanCalculator, SampleAlgorithmBase); 00056 itkNewMacro(Self) ; 00057 00058 itkStaticConstMacro(MeasurementVectorSize, unsigned int, 00059 TSample::MeasurementVectorSize); 00060 00061 typedef typename TSample::MeasurementVectorType MeasurementVectorType ; 00062 00064 typedef Vector< double, itkGetStaticConstMacro(MeasurementVectorSize) > OutputType ; 00065 00067 typedef Array< double > WeightArrayType ; 00068 00070 void SetWeights(WeightArrayType* array) ; 00071 00073 WeightArrayType* GetWeights() ; 00074 00076 typedef FunctionBase< MeasurementVectorType, double > WeightFunctionType ; 00077 00081 void SetWeightFunction(WeightFunctionType* func) ; 00082 00084 WeightFunctionType* GetWeightFunction() ; 00085 00087 OutputType* GetOutput() ; 00088 00089 protected: 00090 WeightedMeanCalculator() ; 00091 virtual ~WeightedMeanCalculator() {} 00092 void PrintSelf(std::ostream& os, Indent indent) const; 00093 00095 void GenerateData() ; 00096 00097 private: 00098 WeightArrayType* m_Weights ; 00099 WeightFunctionType* m_WeightFunction ; 00100 OutputType m_Output ; 00101 } ; // end of class 00102 00103 } // end of namespace Statistics 00104 } // end of namespace itk 00105 00106 #ifndef ITK_MANUAL_INSTANTIATION 00107 #include "itkWeightedMeanCalculator.txx" 00108 #endif 00109 00110 #endif 00111