ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkVectorThresholdSegmentationLevelSetFunction.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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 
66  using Superclass =
70  using FeatureImageType = TFeatureImageType;
71 
73  itkNewMacro(Self);
74 
77 
79  using ImageType = typename Superclass::ImageType;
81  using FeatureScalarType = typename Superclass::FeatureScalarType;
82  using RadiusType = typename Superclass::RadiusType;
83 
85  static constexpr unsigned int ImageDimension = Superclass::ImageDimension;
86 
88  using FeatureImagePixelType = typename FeatureImageType::PixelType;
89  static constexpr unsigned int NumberOfComponents = FeatureImagePixelType::Dimension;
90 
95 
97  void SetMean(const MeanVectorType & mean) { m_Mahalanobis->SetMean(mean); }
98  const MeanVectorType & GetMean() const { return m_Mahalanobis->GetMean(); }
100 
101  void SetCovariance(const CovarianceMatrixType & cov) { m_Mahalanobis->SetCovariance(cov); }
102  const CovarianceMatrixType & GetCovariance() const { return m_Mahalanobis->GetCovariance(); }
103 
106  {
107  m_Threshold = thr;
108  }
109 
111  {
112  return m_Threshold;
113  }
114 
115  void CalculateSpeedImage() override;
116 
117  void Initialize(const RadiusType & r) override
118  {
119  Superclass::Initialize(r);
120 
121  this->SetAdvectionWeight(NumericTraits< ScalarValueType >::ZeroValue());
122  this->SetPropagationWeight(-1.0 * NumericTraits< ScalarValueType >::OneValue());
123  this->SetCurvatureWeight(NumericTraits< ScalarValueType >::OneValue());
124  }
125 
126 protected:
128  {
129  MeanVectorType mean(NumberOfComponents);
130  CovarianceMatrixType covariance(NumberOfComponents, NumberOfComponents);
131 
134 
135  m_Mahalanobis = MahalanobisFunctionType::New();
136  m_Mahalanobis->SetMean(mean);
137  m_Mahalanobis->SetCovariance(covariance);
138 
139  this->SetAdvectionWeight(0.0);
140  this->SetPropagationWeight(1.0);
141  this->SetThreshold(1.8);
142  }
143 
144  ~VectorThresholdSegmentationLevelSetFunction() override = default;
145 
146  void PrintSelf(std::ostream & os, Indent indent) const override
147  {
148  Superclass::PrintSelf(os, indent);
149  os << indent << "MahalanobisFunction: " << m_Mahalanobis << std::endl;
150  os << indent << "ThresholdValue: " << m_Threshold << std::endl;
151  }
152 
155 };
156 } // end namespace itk
157 
158 #ifndef ITK_MANUAL_INSTANTIATION
159 #include "itkVectorThresholdSegmentationLevelSetFunction.hxx"
160 #endif
161 
162 #endif
Light weight base class for most itk classes.
typename FeatureImageType::PixelType FeatureScalarType
Define numeric traits for std::vector.
MahalanobisDistanceMembershipFunction models class membership using Mahalanobis distance.
typename ConstNeighborhoodIterator< TImageType >::RadiusType RadiusType
typename MahalanobisFunctionType::CovarianceMatrixType CovarianceMatrixType
This function is used in VectorThresholdSegmentationLevelSetImageFilter to segment structures in imag...
Control indentation during Print() invocation.
Definition: itkIndent.h:49
typename Superclass::ScalarValueType ScalarValueType
void PrintSelf(std::ostream &os, Indent indent) const override