ITK  4.13.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< typename TImageType, typename TFeatureImageType = TImageType >
35 class ITK_TEMPLATE_EXPORT CannySegmentationLevelSetFunction:
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 
65  { m_Threshold = v; }
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() ITK_OVERRIDE;
80 
83  virtual void CalculateAdvectionImage() ITK_OVERRIDE;
84 
87  virtual void CalculateDistanceImage();
88 
89  virtual void Initialize(const RadiusType & r) ITK_OVERRIDE
90  {
91  Superclass::Initialize(r);
92 
93  this->SetAdvectionWeight(-1.0 * NumericTraits< ScalarValueType >::OneValue());
94  this->SetPropagationWeight(-1.0 * NumericTraits< ScalarValueType >::OneValue());
95  this->SetCurvatureWeight(NumericTraits< ScalarValueType >::OneValue());
96  }
97 
99  { return m_Canny->GetOutput(); }
100 
101 protected:
103  {
104  m_Variance = 0.0;
109  }
110 
111  virtual ~CannySegmentationLevelSetFunction() ITK_OVERRIDE {}
112 
113  ITK_DISALLOW_COPY_AND_ASSIGN(CannySegmentationLevelSetFunction);
114 
115 private:
117  double m_Threshold;
118 
120 
122 
124 
128  template <typename 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
Light weight base class for most itk classes.
void AssignCannyInput(typename FeatureImageType::Pointer &feature, DummyImagePointerType &)
static Pointer New()
ConstNeighborhoodIterator< TImageType >::RadiusType RadiusType
CastImageFilter< FeatureImageType, ImageType >::Pointer m_Caster
void AssignCannyInput(typename FeatureImageType::Pointer &feature, typename FeatureImageType::Pointer &)
A refinement of the standard level-set function which computes a speed term and advection term based ...
DanielssonDistanceMapImageFilter< ImageType, ImageType >::Pointer m_Distance
Define additional traits for native types such as int or float.
SegmentationLevelSetFunction< TImageType, TFeatureImageType > Superclass
This filter computes the distance map of the input image as an approximation with pixel accuracy to t...
Casts input pixels to output pixel type.
CannyEdgeDetectionImageFilter< ImageType, ImageType >::Pointer m_Canny
This filter is an implementation of a Canny edge detector for scalar-valued images.