ITK  5.4.0
Insight Toolkit
itkVectorThresholdSegmentationLevelSetFunction.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 itkVectorThresholdSegmentationLevelSetFunction_h
19#define itkVectorThresholdSegmentationLevelSetFunction_h
20
22#include "itkNumericTraits.h"
24namespace itk
25{
57template <typename TImageType, typename TFeatureImageType>
59 : public SegmentationLevelSetFunction<TImageType, TFeatureImageType>
60{
61public:
62 ITK_DISALLOW_COPY_AND_MOVE(VectorThresholdSegmentationLevelSetFunction);
63
69 using FeatureImageType = TFeatureImageType;
70
72 itkNewMacro(Self);
73
75 itkOverrideGetNameOfClassMacro(VectorThresholdSegmentationLevelSetFunction);
76
78 using typename Superclass::ImageType;
79 using typename Superclass::ScalarValueType;
80 using typename Superclass::FeatureScalarType;
81 using typename Superclass::RadiusType;
82
84 static constexpr unsigned int ImageDimension = Superclass::ImageDimension;
85
87 using FeatureImagePixelType = typename FeatureImageType::PixelType;
88 static constexpr unsigned int NumberOfComponents = FeatureImagePixelType::Dimension;
89
94
96 void
97 SetMean(const MeanVectorType & mean)
98 {
99 m_Mahalanobis->SetMean(mean);
100 }
101 const MeanVectorType &
102 GetMean() const
103 {
104 return m_Mahalanobis->GetMean();
105 }
108 void
110 {
111 m_Mahalanobis->SetCovariance(cov);
112 }
113 const CovarianceMatrixType &
115 {
116 return m_Mahalanobis->GetCovariance();
117 }
118
120 void
122 {
123 m_Threshold = thr;
124 }
125
126 ScalarValueType
128 {
129 return m_Threshold;
130 }
131
132 void
134
135 void
136 Initialize(const RadiusType & r) override
137 {
138 Superclass::Initialize(r);
139
140 this->SetAdvectionWeight(ScalarValueType{});
141 this->SetPropagationWeight(-1.0 * NumericTraits<ScalarValueType>::OneValue());
142 this->SetCurvatureWeight(NumericTraits<ScalarValueType>::OneValue());
143 }
144
145protected:
147 {
148 MeanVectorType mean(NumberOfComponents);
149 CovarianceMatrixType covariance(NumberOfComponents, NumberOfComponents);
150
151 mean.Fill(typename FeatureScalarType::ValueType{});
152 covariance.Fill(typename FeatureScalarType::ValueType{});
153
154 m_Mahalanobis = MahalanobisFunctionType::New();
155 m_Mahalanobis->SetMean(mean);
156 m_Mahalanobis->SetCovariance(covariance);
157
158 this->SetAdvectionWeight(0.0);
159 this->SetPropagationWeight(1.0);
160 this->SetThreshold(1.8);
161 }
162
164
165 void
166 PrintSelf(std::ostream & os, Indent indent) const override
167 {
168 Superclass::PrintSelf(os, indent);
169 os << indent << "MahalanobisFunction: " << m_Mahalanobis << std::endl;
170 os << indent << "ThresholdValue: " << m_Threshold << std::endl;
171 }
172
174 ScalarValueType m_Threshold{};
175};
176} // end namespace itk
177
178#ifndef ITK_MANUAL_INSTANTIATION
179# include "itkVectorThresholdSegmentationLevelSetFunction.hxx"
180#endif
181
182#endif
typename ConstNeighborhoodIterator< TImageType >::RadiusType RadiusType
Control indentation during Print() invocation.
Definition: itkIndent.h:50
Light weight base class for most itk classes.
Define additional traits for native types such as int or float.
MahalanobisDistanceMembershipFunction models class membership using Mahalanobis distance.
This function is used in VectorThresholdSegmentationLevelSetImageFilter to segment structures in imag...
void PrintSelf(std::ostream &os, Indent indent) const override
typename MahalanobisFunctionType::CovarianceMatrixType CovarianceMatrixType
~VectorThresholdSegmentationLevelSetFunction() override=default
static Pointer New()
SmartPointer< Self > Pointer
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....