ITK  4.13.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:
68  typedef TFeatureImageType FeatureImageType;
69 
71  itkNewMacro(Self);
72 
75 
77  typedef typename Superclass::ImageType ImageType;
79  typedef typename Superclass::FeatureScalarType FeatureScalarType;
80  typedef typename Superclass::RadiusType RadiusType;
81 
83  itkStaticConstMacro(ImageDimension, unsigned int,
84  Superclass::ImageDimension);
85 
87  typedef typename FeatureImageType::PixelType FeatureImagePixelType;
88  itkStaticConstMacro(NumberOfComponents, unsigned int,
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  virtual void CalculateSpeedImage() ITK_OVERRIDE;
116 
117  virtual void Initialize(const RadiusType & r) ITK_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 
145 
146  ITK_DISALLOW_COPY_AND_ASSIGN(VectorThresholdSegmentationLevelSetFunction);
147 
148  void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE
149  {
150  Superclass::PrintSelf(os, indent);
151  os << indent << "MahalanobisFunction: " << m_Mahalanobis << std::endl;
152  os << indent << "ThresholdValue: " << m_Threshold << std::endl;
153  }
154 
157 };
158 } // end namespace itk
159 
160 #ifndef ITK_MANUAL_INSTANTIATION
161 #include "itkVectorThresholdSegmentationLevelSetFunction.hxx"
162 #endif
163 
164 #endif
Statistics::MahalanobisDistanceMembershipFunction< FeatureScalarType > MahalanobisFunctionType
SegmentationLevelSetFunction< TImageType, TFeatureImageType > Superclass
Light weight base class for most itk classes.
MahalanobisDistanceMembershipFunction models class membership using Mahalanobis distance.
ConstNeighborhoodIterator< TImageType >::RadiusType RadiusType
This function is used in VectorThresholdSegmentationLevelSetImageFilter to segment structures in imag...
Control indentation during Print() invocation.
Definition: itkIndent.h:49
Define additional traits for native types such as int or float.
void PrintSelf(std::ostream &os, Indent indent) const override