ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkMahalanobisDistanceThresholdImageFunction.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 itkMahalanobisDistanceThresholdImageFunction_h
19 #define itkMahalanobisDistanceThresholdImageFunction_h
20 
21 #include "itkImageFunction.h"
23 
24 namespace itk
25 {
48 template< typename TInputImage, typename TCoordRep = float >
50  public ImageFunction< TInputImage, bool, TCoordRep >
51 {
52 public:
53  ITK_DISALLOW_COPY_AND_ASSIGN(MahalanobisDistanceThresholdImageFunction);
54 
60 
63 
65  itkNewMacro(Self);
66 
68  using InputImageType = typename Superclass::InputImageType;
69 
71  using PixelType = typename TInputImage::PixelType;
72 
74  static constexpr unsigned int ImageDimension = Superclass::ImageDimension;
75 
77  using PointType = typename Superclass::PointType;
78 
80  using IndexType = typename Superclass::IndexType;
81 
83  using ContinuousIndexType = typename Superclass::ContinuousIndexType;
84 
86  using CovarianceMatrixType = vnl_matrix< double >;
87 
89  using MeanVectorType = vnl_vector< double >;
90 
99  bool Evaluate(const PointType & point) const override;
100 
109  bool EvaluateAtContinuousIndex(
110  const ContinuousIndexType & index) const override;
111 
120  bool EvaluateAtIndex(const IndexType & index) const override;
121 
126  virtual double EvaluateDistance(const PointType & point) const;
127 
132  virtual double EvaluateDistanceAtIndex(const IndexType & index) const;
133 
135  itkGetConstReferenceMacro(Threshold, double);
136  itkSetMacro(Threshold, double);
138 
141  void SetMean(const MeanVectorType & mean);
142 
145  itkGetConstReferenceMacro(Mean, MeanVectorType);
146 
149  void SetCovariance(const CovarianceMatrixType & cov);
150 
153  itkGetConstReferenceMacro(Covariance, CovarianceMatrixType);
154 
155 protected:
157  ~MahalanobisDistanceThresholdImageFunction() override = default;
158  void PrintSelf(std::ostream & os, Indent indent) const override;
159 
160 private:
161  double m_Threshold;
162 
163  // This is intended only for Image of Vector pixel type.
165 
168 
169  // Cached versions of the mean and covariance to manage the
170  // difference in vector/matrix types between this class and the
171  // membership function used internally.
174 };
175 } // end namespace itk
176 
177 #ifndef ITK_MANUAL_INSTANTIATION
178 #include "itkMahalanobisDistanceThresholdImageFunction.hxx"
179 #endif
180 
181 #endif
Light weight base class for most itk classes.
MahalanobisDistanceMembershipFunction models class membership using Mahalanobis distance.
Returns true if the pixel value of a vector image has a Mahalanobis distance below the value specifie...
Control indentation during Print() invocation.
Definition: itkIndent.h:49
typename MahalanobisDistanceFunctionType::Pointer MahalanobisDistanceFunctionPointer
Evaluates a function of an image at specified position.