ITK  6.0.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"
24 namespace itk
25 {
57 template <typename TImageType, typename TFeatureImageType>
59  : public SegmentationLevelSetFunction<TImageType, TFeatureImageType>
60 {
61 public:
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
133  CalculateSpeedImage() override;
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 
145 protected:
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 
163  ~VectorThresholdSegmentationLevelSetFunction() override = default;
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 
173  MahalanobisFunctionPointer m_Mahalanobis{};
174  ScalarValueType m_Threshold{};
175 };
176 } // end namespace itk
177 
178 #ifndef ITK_MANUAL_INSTANTIATION
179 # include "itkVectorThresholdSegmentationLevelSetFunction.hxx"
180 #endif
181 
182 #endif
Pointer
SmartPointer< Self > Pointer
Definition: itkAddImageFilter.h:93
itk::VectorThresholdSegmentationLevelSetFunction::GetThreshold
ScalarValueType GetThreshold()
Definition: itkVectorThresholdSegmentationLevelSetFunction.h:127
itk::FiniteDifferenceFunction::RadiusType
typename ConstNeighborhoodIterator< TImageType >::RadiusType RadiusType
Definition: itkFiniteDifferenceFunction.h:97
itk::VectorThresholdSegmentationLevelSetFunction::SetThreshold
void SetThreshold(ScalarValueType thr)
Definition: itkVectorThresholdSegmentationLevelSetFunction.h:121
itkMahalanobisDistanceMembershipFunction.h
itk::VectorThresholdSegmentationLevelSetFunction::GetMean
const MeanVectorType & GetMean() const
Definition: itkVectorThresholdSegmentationLevelSetFunction.h:102
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::VectorThresholdSegmentationLevelSetFunction::FeatureImagePixelType
typename FeatureImageType::PixelType FeatureImagePixelType
Definition: itkVectorThresholdSegmentationLevelSetFunction.h:87
itk::VariableSizeMatrix< double >
itk::VectorThresholdSegmentationLevelSetFunction::SetCovariance
void SetCovariance(const CovarianceMatrixType &cov)
Definition: itkVectorThresholdSegmentationLevelSetFunction.h:109
itk::SegmentationLevelSetFunction::FeatureImageType
TFeatureImageType FeatureImageType
Definition: itkSegmentationLevelSetFunction.h:65
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:55
itkSegmentationLevelSetFunction.h
itk::VectorThresholdSegmentationLevelSetFunction::PrintSelf
void PrintSelf(std::ostream &os, Indent indent) const override
Definition: itkVectorThresholdSegmentationLevelSetFunction.h:166
itk::NumericTraits
Define additional traits for native types such as int or float.
Definition: itkNumericTraits.h:60
itk::VectorThresholdSegmentationLevelSetFunction::GetCovariance
const CovarianceMatrixType & GetCovariance() const
Definition: itkVectorThresholdSegmentationLevelSetFunction.h:114
itk::VectorThresholdSegmentationLevelSetFunction::CovarianceMatrixType
typename MahalanobisFunctionType::CovarianceMatrixType CovarianceMatrixType
Definition: itkVectorThresholdSegmentationLevelSetFunction.h:93
itk::LevelSetFunction::ScalarValueType
PixelType ScalarValueType
Definition: itkLevelSetFunction.h:90
itk::VectorThresholdSegmentationLevelSetFunction::MahalanobisFunctionPointer
typename MahalanobisFunctionType::Pointer MahalanobisFunctionPointer
Definition: itkVectorThresholdSegmentationLevelSetFunction.h:91
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::VectorThresholdSegmentationLevelSetFunction::SetMean
void SetMean(const MeanVectorType &mean)
Definition: itkVectorThresholdSegmentationLevelSetFunction.h:97
itk::SegmentationLevelSetFunction
Definition: itkSegmentationLevelSetFunction.h:47
itk::VectorThresholdSegmentationLevelSetFunction::Initialize
void Initialize(const RadiusType &r) override
Definition: itkVectorThresholdSegmentationLevelSetFunction.h:136
itkNumericTraits.h
itk::Statistics::MahalanobisDistanceMembershipFunction::MeanVectorType
MeasurementVectorRealType MeanVectorType
Definition: itkMahalanobisDistanceMembershipFunction.h:89
itk::VectorThresholdSegmentationLevelSetFunction
This function is used in VectorThresholdSegmentationLevelSetImageFilter to segment structures in imag...
Definition: itkVectorThresholdSegmentationLevelSetFunction.h:58
itk::VectorThresholdSegmentationLevelSetFunction::MeanVectorType
typename MahalanobisFunctionType::MeanVectorType MeanVectorType
Definition: itkVectorThresholdSegmentationLevelSetFunction.h:92
New
static Pointer New()
itk::VectorThresholdSegmentationLevelSetFunction::VectorThresholdSegmentationLevelSetFunction
VectorThresholdSegmentationLevelSetFunction()
Definition: itkVectorThresholdSegmentationLevelSetFunction.h:146
itk::GTest::TypedefsAndConstructors::Dimension2::Dimension
constexpr unsigned int Dimension
Definition: itkGTestTypedefsAndConstructors.h:44
itk::Statistics::MahalanobisDistanceMembershipFunction
MahalanobisDistanceMembershipFunction models class membership using Mahalanobis distance.
Definition: itkMahalanobisDistanceMembershipFunction.h:63