ITK  5.0.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:
39  ITK_DISALLOW_COPY_AND_ASSIGN(CannySegmentationLevelSetFunction);
40 
46  using FeatureImageType = TFeatureImageType;
47 
49  itkNewMacro(Self);
50 
53 
55  using ImageType = typename Superclass::ImageType;
57  using VectorImageType = typename Superclass::VectorImageType;
58  using FeatureScalarType = typename Superclass::FeatureScalarType;
59  using RadiusType = typename Superclass::RadiusType;
60 
62  static constexpr unsigned int ImageDimension = Superclass::ImageDimension;
63 
66  { m_Threshold = v; }
68  { return m_Threshold; }
70 
72  void SetVariance(double v)
73  { m_Variance = v; }
74  double GetVariance() const
75  { return m_Variance; }
77 
80  void CalculateSpeedImage() override;
81 
84  void CalculateAdvectionImage() override;
85 
88  virtual void CalculateDistanceImage();
89 
90  void Initialize(const RadiusType & r) override
91  {
92  Superclass::Initialize(r);
93 
94  this->SetAdvectionWeight(-1.0 * NumericTraits< ScalarValueType >::OneValue());
95  this->SetPropagationWeight(-1.0 * NumericTraits< ScalarValueType >::OneValue());
96  this->SetCurvatureWeight(NumericTraits< ScalarValueType >::OneValue());
97  }
98 
100  { return m_Canny->GetOutput(); }
101 
102 protected:
104  {
105  m_Variance = 0.0;
110  }
111 
112  ~CannySegmentationLevelSetFunction() override = default;
113 
114 private:
116  double m_Threshold;
117 
119 
121 
123 
127  template <typename DummyImagePointerType>
128  void AssignCannyInput(typename FeatureImageType::Pointer &feature,
129  DummyImagePointerType &)
130  {
131  m_Caster->SetInput(feature);
132  m_Canny->SetInput( m_Caster->GetOutput() );
133  }
134 
138  void AssignCannyInput(typename FeatureImageType::Pointer &feature,
139  typename FeatureImageType::Pointer &)
140  {
141  m_Canny->SetInput(feature);
142  }
143 };
144 } // end namespace itk
146 
147 #ifndef ITK_MANUAL_INSTANTIATION
148 #include "itkCannySegmentationLevelSetFunction.hxx"
149 #endif
150 
151 #endif
Light weight base class for most itk classes.
void AssignCannyInput(typename FeatureImageType::Pointer &feature, DummyImagePointerType &)
Define numeric traits for std::vector.
static Pointer New()
CastImageFilter< FeatureImageType, ImageType >::Pointer m_Caster
typename Superclass::ScalarValueType ScalarValueType
typename Superclass::VectorImageType VectorImageType
typename ConstNeighborhoodIterator< TImageType >::RadiusType RadiusType
typename Superclass::FeatureScalarType FeatureScalarType
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
This filter computes the distance map of the input image as an approximation with pixel accuracy to t...
typename Superclass::ScalarValueType ScalarValueType
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.