ITK  6.0.0
Insight Toolkit
itkMahalanobisDistanceThresholdImageFunction.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
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  * https://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 {
49 template <typename TInputImage, typename TCoordinate = float>
51  : public ImageFunction<TInputImage, bool, TCoordinate>
52 {
53 public:
54  ITK_DISALLOW_COPY_AND_MOVE(MahalanobisDistanceThresholdImageFunction);
55 
61 
63  itkOverrideGetNameOfClassMacro(MahalanobisDistanceThresholdImageFunction);
64 
66  itkNewMacro(Self);
67 
69  using typename Superclass::InputImageType;
70 
72  using PixelType = typename TInputImage::PixelType;
73 
75  static constexpr unsigned int ImageDimension = Superclass::ImageDimension;
76 
78  using typename Superclass::PointType;
79 
81  using typename Superclass::IndexType;
82 
84  using typename Superclass::ContinuousIndexType;
85 
87  using CovarianceMatrixType = vnl_matrix<double>;
88 
90  using MeanVectorType = vnl_vector<double>;
91 
100  bool
101  Evaluate(const PointType & point) const override;
102 
111  bool
112  EvaluateAtContinuousIndex(const ContinuousIndexType & index) const override;
113 
122  bool
123  EvaluateAtIndex(const IndexType & index) const override;
124 
129  virtual double
130  EvaluateDistance(const PointType & point) const;
131 
136  virtual double
137  EvaluateDistanceAtIndex(const IndexType & index) const;
138 
140  itkGetConstReferenceMacro(Threshold, double);
141  itkSetMacro(Threshold, double);
146  void
147  SetMean(const MeanVectorType & mean);
148 
151  itkGetConstReferenceMacro(Mean, MeanVectorType);
152 
155  void
156  SetCovariance(const CovarianceMatrixType & covariance);
157 
160  itkGetConstReferenceMacro(Covariance, CovarianceMatrixType);
161 
162 protected:
164  ~MahalanobisDistanceThresholdImageFunction() override = default;
165  void
166  PrintSelf(std::ostream & os, Indent indent) const override;
167 
168 private:
169  double m_Threshold{};
170 
171  // This is intended only for Image of Vector pixel type.
173 
175  MahalanobisDistanceFunctionPointer m_MahalanobisDistanceMembershipFunction{};
176 
177  // Cached versions of the mean and covariance to manage the
178  // difference in vector/matrix types between this class and the
179  // membership function used internally.
180  MeanVectorType m_Mean{};
181  CovarianceMatrixType m_Covariance{};
182 };
183 } // end namespace itk
184 
185 #ifndef ITK_MANUAL_INSTANTIATION
186 # include "itkMahalanobisDistanceThresholdImageFunction.hxx"
187 #endif
188 
189 #endif
Pointer
SmartPointer< Self > Pointer
Definition: itkAddImageFilter.h:93
itkImageFunction.h
itk::MahalanobisDistanceThresholdImageFunction::MahalanobisDistanceFunctionPointer
typename MahalanobisDistanceFunctionType::Pointer MahalanobisDistanceFunctionPointer
Definition: itkMahalanobisDistanceThresholdImageFunction.h:174
itkMahalanobisDistanceMembershipFunction.h
itk::GTest::TypedefsAndConstructors::Dimension2::PointType
ImageBaseType::PointType PointType
Definition: itkGTestTypedefsAndConstructors.h:51
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::MahalanobisDistanceThresholdImageFunction::CovarianceMatrixType
vnl_matrix< double > CovarianceMatrixType
Definition: itkMahalanobisDistanceThresholdImageFunction.h:87
itk::ImageFunction
Evaluates a function of an image at specified position.
Definition: itkImageFunction.h:55
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:55
itk::point
*par Constraints *The filter requires an image with at least two dimensions and a vector *length of at least The theory supports extension to scalar but *the implementation of the itk vector classes do not **The template parameter TRealType must be floating point(float or double) or *a user-defined "real" numerical type with arithmetic operations defined *sufficient to compute derivatives. **\par Performance *This filter will automatically multithread if run with *SetUsePrincipleComponents
itk::MahalanobisDistanceThresholdImageFunction::MeanVectorType
vnl_vector< double > MeanVectorType
Definition: itkMahalanobisDistanceThresholdImageFunction.h:90
itk::MahalanobisDistanceThresholdImageFunction
Returns true if the pixel value of a vector image has a Mahalanobis distance below the value specifie...
Definition: itkMahalanobisDistanceThresholdImageFunction.h:50
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::ContinuousIndex< TCoordinate, Self::ImageDimension >
itk::Point
A templated class holding a geometric point in n-Dimensional space.
Definition: itkPoint.h:53
itk::MahalanobisDistanceThresholdImageFunction::PixelType
typename TInputImage::PixelType PixelType
Definition: itkMahalanobisDistanceThresholdImageFunction.h:72
itk::Statistics::MahalanobisDistanceMembershipFunction
MahalanobisDistanceMembershipFunction models class membership using Mahalanobis distance.
Definition: itkMahalanobisDistanceMembershipFunction.h:63
itk::ImageFunction< TInputImage, bool, TCoordinate >::IndexType
typename InputImageType::IndexType IndexType
Definition: itkImageFunction.h:94