ITK  4.3.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< class TImageType, class 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;
78  typedef typename Superclass::ScalarValueType ScalarValueType;
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,
89  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 
105  void SetThreshold(ScalarValueType thr)
106  {
107  m_Threshold = thr;
108  }
109 
110  ScalarValueType GetThreshold()
111  {
112  return m_Threshold;
113  }
114 
115  virtual void CalculateSpeedImage();
116 
117  virtual void Initialize(const RadiusType & r)
118  {
119  Superclass::Initialize(r);
120 
121  this->SetAdvectionWeight(NumericTraits< ScalarValueType >::Zero);
122  this->SetPropagationWeight(-1.0 * NumericTraits< ScalarValueType >::One);
123  this->SetCurvatureWeight(NumericTraits< ScalarValueType >::One);
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  VectorThresholdSegmentationLevelSetFunction(const Self &); //purposely not
147  // implemented
148  void operator=(const Self &); //purposely not
149 
150  // implemented
151 
152  void PrintSelf(std::ostream & os, Indent indent) const
153  {
154  Superclass::PrintSelf(os, indent);
155  os << indent << "MahalanobisFunction: " << m_Mahalanobis << std::endl;
156  os << indent << "ThresholdValue: " << m_Threshold << std::endl;
157  }
158 
161 };
162 } // end namespace itk
163 
164 #ifndef ITK_MANUAL_INSTANTIATION
165 #include "itkVectorThresholdSegmentationLevelSetFunction.hxx"
166 #endif
167 
168 #endif
169