ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkMahalanobisDistanceMembershipFunction.h
Go to the documentation of this file.
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 __itkMahalanobisDistanceMembershipFunction_h
00019 #define __itkMahalanobisDistanceMembershipFunction_h
00020 
00021 #include "itkVariableSizeMatrix.h"
00022 
00023 #include "itkMembershipFunctionBase.h"
00024 
00025 namespace itk
00026 {
00027 namespace Statistics
00028 {
00061 template< class TVector >
00062 class ITK_EXPORT MahalanobisDistanceMembershipFunction:
00063   public MembershipFunctionBase< TVector >
00064 {
00065 public:
00067   typedef MahalanobisDistanceMembershipFunction Self;
00068   typedef MembershipFunctionBase< TVector >     Superclass;
00069   typedef SmartPointer< Self >                  Pointer;
00070   typedef SmartPointer< const Self >            ConstPointer;
00071 
00073   itkTypeMacro(MahalanobisDistanceMembershipFunction, MembershipFunctionBase);
00074   itkNewMacro(Self);
00076 
00078   typedef typename Superclass::Pointer MembershipFunctionPointer;
00079 
00081   typedef TVector MeasurementVectorType;
00082 
00084   typedef typename Superclass::MeasurementVectorSizeType MeasurementVectorSizeType;
00085 
00088   typedef typename itk::NumericTraits< MeasurementVectorType >::RealType MeasurementVectorRealType;
00089   typedef MeasurementVectorRealType  MeanVectorType;
00090 
00092   typedef VariableSizeMatrix< double > CovarianceMatrixType;
00093 
00096   void SetMean(const MeanVectorType & mean);
00097 
00100   itkGetConstReferenceMacro(Mean, MeanVectorType);
00101 
00105   void SetCovariance(const CovarianceMatrixType & cov);
00106 
00109   itkGetConstReferenceMacro(Covariance, CovarianceMatrixType);
00110 
00116   double Evaluate(const MeasurementVectorType & measurement) const;
00117 
00121   virtual typename LightObject::Pointer InternalClone() const;
00122 
00123 protected:
00124   MahalanobisDistanceMembershipFunction(void);
00125   virtual ~MahalanobisDistanceMembershipFunction(void) {}
00126   void PrintSelf(std::ostream & os, Indent indent) const;
00127 
00128 private:
00129   MeanVectorType       m_Mean;               // mean
00130   CovarianceMatrixType m_Covariance;         // covariance matrix
00131 
00132   // inverse covariance matrix. automatically calculated
00133   // when covariace matirx is set.
00134   CovarianceMatrixType m_InverseCovariance;
00135 
00137   bool m_CovarianceNonsingular;
00138 };
00139 } // end of namespace Statistics
00140 } // end namespace itk
00141 
00142 #ifndef ITK_MANUAL_INSTANTIATION
00143 #include "itkMahalanobisDistanceMembershipFunction.hxx"
00144 #endif
00145 
00146 #endif
00147