00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkWeightedCovarianceCalculator.h,v $ 00005 Language: C++ 00006 Date: $Date: 2003/09/10 14:29:48 $ 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 #ifndef __itkWeightedCovarianceCalculator_h 00018 #define __itkWeightedCovarianceCalculator_h 00019 00020 #include "itkVector.h" 00021 #include "itkMatrix.h" 00022 #include "itkSampleAlgorithmBase.h" 00023 00024 namespace itk{ 00025 namespace Statistics{ 00026 00034 template< class TSample > 00035 class WeightedCovarianceCalculator : 00036 public SampleAlgorithmBase< TSample > 00037 { 00038 public: 00040 typedef WeightedCovarianceCalculator Self; 00041 typedef SampleAlgorithmBase< TSample > Superclass ; 00042 typedef SmartPointer<Self> Pointer; 00043 00045 itkTypeMacro(WeightedCovarianceCalculator, SampleAlgorithmBase); 00046 itkNewMacro(Self) ; 00047 00048 itkStaticConstMacro(MeasurementVectorSize, unsigned int, 00049 TSample::MeasurementVectorSize); 00050 00052 typedef typename TSample::MeasurementVectorType MeasurementVectorType ; 00053 00055 typedef FunctionBase< MeasurementVectorType, double > WeightFunctionType ; 00056 00058 typedef Matrix< double, 00059 itkGetStaticConstMacro(MeasurementVectorSize), 00060 itkGetStaticConstMacro(MeasurementVectorSize) > 00061 OutputType ; 00062 00064 typedef Vector< double, itkGetStaticConstMacro(MeasurementVectorSize) > 00065 MeanType ; 00066 00068 typedef Array< double > WeightArrayType ; 00069 00071 void SetWeights(WeightArrayType* array) ; 00072 00074 WeightArrayType* GetWeights() ; 00075 00079 void SetWeightFunction(WeightFunctionType* func) ; 00080 00082 WeightFunctionType* GetWeightFunction() ; 00083 00085 void SetMean(MeanType* mean) ; 00086 00088 MeanType* GetMean() ; 00089 00091 OutputType* GetOutput() ; 00092 00093 protected: 00094 WeightedCovarianceCalculator() ; 00095 virtual ~WeightedCovarianceCalculator() ; 00096 void PrintSelf(std::ostream& os, Indent indent) const; 00097 00099 void GenerateData() ; 00100 00101 void ComputeCovarianceWithGivenMean() ; 00102 00103 void ComputeCovarianceWithoutGivenMean() ; 00104 00105 private: 00106 OutputType* m_Output ; 00107 MeanType* m_Mean ; 00108 MeanType* m_InternalMean ; 00109 WeightArrayType* m_Weights ; 00110 WeightFunctionType* m_WeightFunction ; 00111 } ; // end of class 00112 00113 } // end of namespace Statistics 00114 } // end of namespace itk 00115 00116 #ifndef ITK_MANUAL_INSTANTIATION 00117 #include "itkWeightedCovarianceCalculator.txx" 00118 #endif 00119 00120 #endif 00121