ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkGaussianMembershipFunction.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef itkGaussianMembershipFunction_h
19 #define itkGaussianMembershipFunction_h
20 
21 #include "itkMatrix.h"
23 
24 namespace itk
25 {
26 namespace Statistics
27 {
54 template< typename TMeasurementVector >
55 class ITK_TEMPLATE_EXPORT GaussianMembershipFunction:
56  public MembershipFunctionBase< TMeasurementVector >
57 {
58 public:
59  ITK_DISALLOW_COPY_AND_ASSIGN(GaussianMembershipFunction);
60 
66 
68  itkTypeMacro(GaussianMembershipFunction, MembershipFunction);
69  itkNewMacro(Self);
71 
74 
76  using MeasurementVectorType = TMeasurementVector;
77 
79  using MeasurementVectorSizeType = typename Superclass::MeasurementVectorSizeType;
80 
83  using MeasurementVectorRealType = typename itk::NumericTraits< MeasurementVectorType >::RealType;
85 
88 
91  void SetMean(const MeanVectorType & mean);
92 
95  itkGetConstReferenceMacro(Mean, MeanVectorType);
96 
101  void SetCovariance(const CovarianceMatrixType & cov);
102 
103  /* Get the covariance matrix. Covariance matrix is a
104  VariableSizeMatrix of doubles. */
105  itkGetConstReferenceMacro(Covariance, CovarianceMatrixType);
106 
107  /* Get the inverse covariance matrix. Covariance matrix is a
108  VariableSizeMatrix of doubles. */
109  itkGetConstReferenceMacro(InverseCovariance, CovarianceMatrixType);
110 
112  double Evaluate(const MeasurementVectorType & measurement) const override;
113 
117  typename LightObject::Pointer InternalClone() const override;
118 
119 protected:
121  ~GaussianMembershipFunction() override = default;
122  void PrintSelf(std::ostream & os, Indent indent) const override;
123 
124 private:
126  CovarianceMatrixType m_Covariance; // covariance matrix
127 
128  // inverse covariance matrix. automatically calculated
129  // when covariace matirx is set.
131 
132  // pre_factor (normalization term). automatically calculated
133  // when covariace matirx is set.
134  double m_PreFactor;
135 
138 };
139 } // end of namespace Statistics
140 } // end namespace itk
141 
142 #ifndef ITK_MANUAL_INSTANTIATION
143 #include "itkGaussianMembershipFunction.hxx"
144 #endif
145 
146 #endif
Light weight base class for most itk classes.
GaussianMembershipFunction models class membership through a multivariate Gaussian function...
MembershipFunctionBase defines common interfaces for membership functions.
typename itk::NumericTraits< MeasurementVectorType >::RealType MeasurementVectorRealType
Control indentation during Print() invocation.
Definition: itkIndent.h:49
typename Superclass::MeasurementVectorSizeType MeasurementVectorSizeType