ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkMorphSDTHelperImageFilter.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 itkMorphSDTHelperImageFilter_h
19#define itkMorphSDTHelperImageFilter_h
20
22#include "itkMath.h"
23
24namespace itk
25{
35namespace Function
36{
37template <typename TInput1, typename TInput2 = TInput1, typename TInput3 = TInput1, typename TOutput = TInput1>
39{
40public:
41 MorphSDTHelper() = default;
42 ~MorphSDTHelper() = default;
43 void
44 SetVal(double i)
45 {
46 m_Val = i;
47 }
48 bool
50 {
51 return false;
52 }
53
54 bool
55 operator==(const MorphSDTHelper & other) const
56 {
57 return !(*this != other);
58 }
59
60 TOutput
61 operator()(const TInput1 & A, const TInput2 & B, const TInput3 & C)
62 {
63 // A should be the output of the erosion, B the dilation, C the mask
64 if (C > 0)
65 {
66 // inside the mask
67 return static_cast<TOutput>(std::sqrt((double)A + m_Val));
68 }
69 else
70 {
71 // outside the mask
72 return static_cast<TOutput>(-std::sqrt(m_Val - (double)B));
73 }
74 }
75
76private:
77 double m_Val;
78};
79} // namespace Function
80
81template <typename TInputImage1,
82 typename TInputImage2 = TInputImage1,
83 typename TInputImage3 = TInputImage1,
84 typename TOutputImage = TInputImage1>
85class ITK_TEMPLATE_EXPORT MorphSDTHelperImageFilter
86 : public TernaryFunctorImageFilter<TInputImage1,
87 TInputImage2,
88 TInputImage3,
89 TOutputImage,
90 Function::MorphSDTHelper<typename TInputImage1::PixelType,
91 typename TInputImage2::PixelType,
92 typename TInputImage3::PixelType,
93 typename TOutputImage::PixelType>>
94{
95public:
96 ITK_DISALLOW_COPY_AND_MOVE(MorphSDTHelperImageFilter);
97
101 TInputImage2,
102 TInputImage3,
103 TOutputImage,
104 Function::MorphSDTHelper<typename TInputImage1::PixelType,
105 typename TInputImage2::PixelType,
106 typename TInputImage3::PixelType,
107 typename TOutputImage::PixelType>>;
108
111
113 itkNewMacro(Self);
114
116 itkOverrideGetNameOfClassMacro(MorphSDTHelperImageFilter);
117
118 void
119 SetVal(double val)
120 {
121 this->GetFunctor().SetVal(val);
122 this->Modified();
123 }
124
125 itkConceptMacro(Input1ConvertibleToOutputCheck,
127 itkConceptMacro(Input2ConvertibleToOutputCheck,
129 itkConceptMacro(GreaterThanComparable,
131
132protected:
134 virtual ~MorphSDTHelperImageFilter() = default;
135};
136} // end namespace itk
137
138#endif
bool operator!=(const MorphSDTHelper &) const
bool operator==(const MorphSDTHelper &other) const
TOutput operator()(const TInput1 &A, const TInput2 &B, const TInput3 &C)
TernaryFunctorImageFilter< TInputImage1, TInputImage2, TInputImage3, TOutputImage, Function::MorphSDTHelper< typename TInputImage1::PixelType, typename TInputImage2::PixelType, typename TInputImage3::PixelType, typename TOutputImage::PixelType > > Superclass
virtual ~MorphSDTHelperImageFilter()=default
virtual void Modified() const
Implements transparent reference counting.
#define itkConceptMacro(name, conceptType)
Compile-time check that a template argument satisfies an itk::Concept.
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....