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
24namespace itk
25{
49template <typename TInputImage, typename TCoordinate = float>
51 : public ImageFunction<TInputImage, bool, TCoordinate>
52{
53public:
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
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
157
160 itkGetConstReferenceMacro(Covariance, CovarianceMatrixType);
161
162protected:
165 void
166 PrintSelf(std::ostream & os, Indent indent) const override;
167
168private:
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.
181 CovarianceMatrixType m_Covariance{};
182};
183} // end namespace itk
184
185#ifndef ITK_MANUAL_INSTANTIATION
186# include "itkMahalanobisDistanceThresholdImageFunction.hxx"
187#endif
188
189#endif
Evaluates a function of an image at specified position.
typename InputImageType::IndexType IndexType
Control indentation during Print() invocation.
Definition: itkIndent.h:50
Light weight base class for most itk classes.
Returns true if the pixel value of a vector image has a Mahalanobis distance below the value specifie...
~MahalanobisDistanceThresholdImageFunction() override=default
virtual double EvaluateDistance(const PointType &point) const
bool EvaluateAtContinuousIndex(const ContinuousIndexType &index) const override
bool EvaluateAtIndex(const IndexType &index) const override
void SetCovariance(const CovarianceMatrixType &covariance)
void SetMean(const MeanVectorType &mean)
typename MahalanobisDistanceFunctionType::Pointer MahalanobisDistanceFunctionPointer
virtual double EvaluateDistanceAtIndex(const IndexType &index) const
void PrintSelf(std::ostream &os, Indent indent) const override
bool Evaluate(const PointType &point) const override
A templated class holding a geometric point in n-Dimensional space.
Definition: itkPoint.h:54
MahalanobisDistanceMembershipFunction models class membership using Mahalanobis distance.
SmartPointer< Self > Pointer
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
*par Constraints *The filter 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