ITK  4.3.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 
101 protected:
103  {
104  m_Variance = 0.0;
109  }
110 
112 
113  CannySegmentationLevelSetFunction(const Self &); //purposely not implemented
114  void operator=(const Self &); //purposely not implemented
115 
116 private:
118  double m_Threshold;
119 
121 
123 
125 
129  template <class DummyImagePointerType>
130  void AssignCannyInput(typename FeatureImageType::Pointer &feature,
131  DummyImagePointerType &)
132  {
133  m_Caster->SetInput(feature);
134  m_Canny->SetInput( m_Caster->GetOutput() );
135  }
136 
140  void AssignCannyInput(typename FeatureImageType::Pointer &feature,
141  typename FeatureImageType::Pointer &)
142  {
143  m_Canny->SetInput(feature);
144  }
145 };
146 } // end namespace itk
148 
149 #ifndef ITK_MANUAL_INSTANTIATION
150 #include "itkCannySegmentationLevelSetFunction.hxx"
151 #endif
152 
153 #endif
154