ITK  5.2.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  * 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 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_ASSIGN(VectorThresholdSegmentationLevelSetFunction);
63 
69  using FeatureImageType = TFeatureImageType;
70 
72  itkNewMacro(Self);
73 
76 
78  using ImageType = typename Superclass::ImageType;
80  using FeatureScalarType = typename Superclass::FeatureScalarType;
81  using RadiusType = 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  }
107 
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(NumericTraits<ScalarValueType>::ZeroValue());
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 
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 
175 };
176 } // end namespace itk
177 
178 #ifndef ITK_MANUAL_INSTANTIATION
179 # include "itkVectorThresholdSegmentationLevelSetFunction.hxx"
180 #endif
181 
182 #endif
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::FiniteDifferenceFunction::ImageType
TImageType ImageType
Definition: itkFiniteDifferenceFunction.h:82
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:59
itkSegmentationLevelSetFunction.h
itk::SegmentationLevelSetFunction::FeatureScalarType
typename FeatureImageType::PixelType FeatureScalarType
Definition: itkSegmentationLevelSetFunction.h:69
itk::SegmentationLevelSetFunction::ScalarValueType
typename Superclass::ScalarValueType ScalarValueType
Definition: itkSegmentationLevelSetFunction.h:67
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:58
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: itkAnnulusOperator.h:24
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:88
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
itk::VectorThresholdSegmentationLevelSetFunction::m_Mahalanobis
MahalanobisFunctionPointer m_Mahalanobis
Definition: itkVectorThresholdSegmentationLevelSetFunction.h:173
itk::VectorThresholdSegmentationLevelSetFunction::VectorThresholdSegmentationLevelSetFunction
VectorThresholdSegmentationLevelSetFunction()
Definition: itkVectorThresholdSegmentationLevelSetFunction.h:146
itk::VectorThresholdSegmentationLevelSetFunction::m_Threshold
ScalarValueType m_Threshold
Definition: itkVectorThresholdSegmentationLevelSetFunction.h:174
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:62