ITK  4.2.0
Insight Segmentation and Registration Toolkit
itkCannySegmentationLevelSetFunction.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 __itkCannySegmentationLevelSetFunction_h
19 #define __itkCannySegmentationLevelSetFunction_h
20 
22 #include "itkCastImageFilter.h"
25 
26 namespace itk
27 {
34 template< class TImageType, class TFeatureImageType = TImageType >
36  public SegmentationLevelSetFunction< TImageType, TFeatureImageType >
37 {
38 public:
44  typedef TFeatureImageType FeatureImageType;
45 
47  itkNewMacro(Self);
48 
51 
53  typedef typename Superclass::ImageType ImageType;
55  typedef typename Superclass::VectorImageType VectorImageType;
56  typedef typename Superclass::FeatureScalarType FeatureScalarType;
57  typedef typename Superclass::RadiusType RadiusType;
58 
60  itkStaticConstMacro(ImageDimension, unsigned int,
61  Superclass::ImageDimension);
62 
64  void SetThreshold(ScalarValueType v)
65  { m_Threshold = v; }
66  ScalarValueType GetThreshold() const
67  { return m_Threshold; }
69 
71  void SetVariance(double v)
72  { m_Variance = v; }
73  double GetVariance() const
74  { return m_Variance; }
76 
79  virtual void CalculateSpeedImage();
80 
83  virtual void CalculateAdvectionImage();
84 
87  virtual void CalculateDistanceImage();
88 
89  virtual void Initialize(const RadiusType & r)
90  {
91  Superclass::Initialize(r);
92 
93  this->SetAdvectionWeight(-1.0 * NumericTraits< ScalarValueType >::One);
94  this->SetPropagationWeight(-1.0 * NumericTraits< ScalarValueType >::One);
95  this->SetCurvatureWeight(NumericTraits< ScalarValueType >::One);
96  }
97 
98  ImageType * GetCannyImage()
99  { return m_Canny->GetOutput(); }
100 protected:
102  {
103  m_Variance = 0.0;
108  }
109 
111 
112  CannySegmentationLevelSetFunction(const Self &); //purposely not implemented
113  void operator=(const Self &); //purposely not implemented
114 
115 private:
117  double m_Threshold;
118 
120 
122 
124 
128  template <class DummyImagePointerType>
129  void AssignCannyInput(typename FeatureImageType::Pointer &feature,
130  DummyImagePointerType &)
131  {
132  m_Caster->SetInput(feature);
133  m_Canny->SetInput( m_Caster->GetOutput() );
134  }
135 
139  void AssignCannyInput(typename FeatureImageType::Pointer &feature,
140  typename FeatureImageType::Pointer &)
141  {
142  m_Canny->SetInput(feature);
143  }
144 };
145 } // end namespace itk
147 
148 #ifndef ITK_MANUAL_INSTANTIATION
149 #include "itkCannySegmentationLevelSetFunction.hxx"
150 #endif
151 
152 #endif
153