ITK  6.0.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
26namespace itk
27{
34template <typename TImageType, typename TFeatureImageType = TImageType>
35class ITK_TEMPLATE_EXPORT CannySegmentationLevelSetFunction
36 : public SegmentationLevelSetFunction<TImageType, TFeatureImageType>
37{
38public:
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
67 {
68 m_Threshold = v;
69 }
70 ScalarValueType
72 {
73 return m_Threshold;
74 }
78 void
79 SetVariance(double v)
80 {
81 m_Variance = v;
82 }
83 double
85 {
86 return m_Variance;
87 }
92 void
94
97 void
99
102 virtual void
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
121protected:
123 {
124 m_Variance = 0.0;
125 m_Threshold = ScalarValueType{};
129 }
130
132
133private:
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
This filter is an implementation of a Canny edge detector for scalar-valued images.
A refinement of the standard level-set function which computes a speed term and advection term based ...
~CannySegmentationLevelSetFunction() override=default
void AssignCannyInput(typename FeatureImageType::Pointer &feature, typename FeatureImageType::Pointer &)
void AssignCannyInput(typename FeatureImageType::Pointer &feature, DummyImagePointerType &)
Casts input pixels to output pixel type.
static Pointer New()
This filter computes the distance map of the input image as an approximation with pixel accuracy to t...
typename ConstNeighborhoodIterator< TImageType >::RadiusType RadiusType
Light weight base class for most itk classes.
Define additional traits for native types such as int or float.
SmartPointer< Self > Pointer
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....