ITK  5.4.0
Insight Toolkit
itkCannySegmentationLevelSetFunction.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
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  * https://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_MOVE(CannySegmentationLevelSetFunction);
40 
46  using FeatureImageType = TFeatureImageType;
47 
49  itkNewMacro(Self);
50 
52  itkOverrideGetNameOfClassMacro(CannySegmentationLevelSetFunction);
53 
55  using typename Superclass::ImageType;
56  using typename Superclass::ScalarValueType;
57  using typename Superclass::VectorImageType;
58  using typename Superclass::FeatureScalarType;
59  using typename Superclass::RadiusType;
60 
62  static constexpr unsigned int ImageDimension = Superclass::ImageDimension;
63 
65  void
66  SetThreshold(ScalarValueType v)
67  {
68  m_Threshold = v;
69  }
70  ScalarValueType
71  GetThreshold() const
72  {
73  return m_Threshold;
74  }
78  void
79  SetVariance(double v)
80  {
81  m_Variance = v;
82  }
83  double
84  GetVariance() const
85  {
86  return m_Variance;
87  }
92  void
93  CalculateSpeedImage() override;
94 
97  void
98  CalculateAdvectionImage() override;
99 
102  virtual void
103  CalculateDistanceImage();
104 
105  void
106  Initialize(const RadiusType & r) override
107  {
108  Superclass::Initialize(r);
109 
110  this->SetAdvectionWeight(-1.0 * NumericTraits<ScalarValueType>::OneValue());
111  this->SetPropagationWeight(-1.0 * NumericTraits<ScalarValueType>::OneValue());
112  this->SetCurvatureWeight(NumericTraits<ScalarValueType>::OneValue());
113  }
114 
115  ImageType *
117  {
118  return m_Canny->GetOutput();
119  }
120 
121 protected:
123  {
124  m_Variance = 0.0;
125  m_Threshold = ScalarValueType{};
129  }
130 
131  ~CannySegmentationLevelSetFunction() override = default;
132 
133 private:
134  ScalarValueType m_Variance{};
135  double m_Threshold{};
136 
138 
140 
142 
146  template <typename DummyImagePointerType>
147  void
148  AssignCannyInput(typename FeatureImageType::Pointer & feature, DummyImagePointerType &)
149  {
150  m_Caster->SetInput(feature);
151  m_Canny->SetInput(m_Caster->GetOutput());
152  }
153 
157  void
159  {
160  m_Canny->SetInput(feature);
161  }
162 };
163 } // end namespace itk
166 #ifndef ITK_MANUAL_INSTANTIATION
167 # include "itkCannySegmentationLevelSetFunction.hxx"
168 #endif
169 
170 #endif
itk::CannyEdgeDetectionImageFilter::New
static Pointer New()
itk::CannySegmentationLevelSetFunction::GetVariance
double GetVariance() const
Definition: itkCannySegmentationLevelSetFunction.h:84
itkCannyEdgeDetectionImageFilter.h
Pointer
SmartPointer< Self > Pointer
Definition: itkAddImageFilter.h:93
itk::CastImageFilter
Casts input pixels to output pixel type.
Definition: itkCastImageFilter.h:100
itk::FiniteDifferenceFunction::RadiusType
typename ConstNeighborhoodIterator< TImageType >::RadiusType RadiusType
Definition: itkFiniteDifferenceFunction.h:97
itk::CannySegmentationLevelSetFunction::GetCannyImage
ImageType * GetCannyImage()
Definition: itkCannySegmentationLevelSetFunction.h:116
itk::CannySegmentationLevelSetFunction::FeatureImageType
TFeatureImageType FeatureImageType
Definition: itkCannySegmentationLevelSetFunction.h:46
itk::SmartPointer< Self >
itkCastImageFilter.h
itk::CannySegmentationLevelSetFunction::AssignCannyInput
void AssignCannyInput(typename FeatureImageType::Pointer &feature, DummyImagePointerType &)
Definition: itkCannySegmentationLevelSetFunction.h:148
itk::DanielssonDistanceMapImageFilter
This filter computes the distance map of the input image as an approximation with pixel accuracy to t...
Definition: itkDanielssonDistanceMapImageFilter.h:59
itk::CannySegmentationLevelSetFunction::SetVariance
void SetVariance(double v)
Definition: itkCannySegmentationLevelSetFunction.h:79
itk::CannySegmentationLevelSetFunction::SetThreshold
void SetThreshold(ScalarValueType v)
Definition: itkCannySegmentationLevelSetFunction.h:66
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:55
itkSegmentationLevelSetFunction.h
itk::CannySegmentationLevelSetFunction
A refinement of the standard level-set function which computes a speed term and advection term based ...
Definition: itkCannySegmentationLevelSetFunction.h:35
itk::CannyEdgeDetectionImageFilter
This filter is an implementation of a Canny edge detector for scalar-valued images.
Definition: itkCannyEdgeDetectionImageFilter.h:88
itk::CannySegmentationLevelSetFunction::GetThreshold
ScalarValueType GetThreshold() const
Definition: itkCannySegmentationLevelSetFunction.h:71
itk::CastImageFilter::New
static Pointer New()
itk::NumericTraits
Define additional traits for native types such as int or float.
Definition: itkNumericTraits.h:59
itkDanielssonDistanceMapImageFilter.h
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::DanielssonDistanceMapImageFilter::New
static Pointer New()
itk::SegmentationLevelSetFunction
Definition: itkSegmentationLevelSetFunction.h:47
itk::CannySegmentationLevelSetFunction::AssignCannyInput
void AssignCannyInput(typename FeatureImageType::Pointer &feature, typename FeatureImageType::Pointer &)
Definition: itkCannySegmentationLevelSetFunction.h:158
itk::CannySegmentationLevelSetFunction::Initialize
void Initialize(const RadiusType &r) override
Definition: itkCannySegmentationLevelSetFunction.h:106
itk::CannySegmentationLevelSetFunction::CannySegmentationLevelSetFunction
CannySegmentationLevelSetFunction()
Definition: itkCannySegmentationLevelSetFunction.h:122