ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkMorphSDTHelperImageFilter.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 itkMorphSDTHelperImageFilter_h
19 #define itkMorphSDTHelperImageFilter_h
20 
22 #include "itkMath.h"
23 
24 namespace itk
25 {
35 namespace Function
36 {
37 template< class TInput1, class TInput2 = TInput1, class TInput3 = TInput1, class TOutput = TInput1 >
39 {
40 public:
43  void SetVal(double i) { m_Val = i; }
44  bool operator!=(const MorphSDTHelper &) const
45  {
46  return false;
47  }
48 
49  bool operator==(const MorphSDTHelper & other) const
50  {
51  return !( *this != other );
52  }
53 
54  inline TOutput operator()(const TInput1 & A, const TInput2 & B, const TInput3 & C)
55  {
56  // A should be the output of the erosion, B the dilation, C the mask
57  if ( C > 0 )
58  {
59  // inside the mask
60  return static_cast< TOutput >( std::sqrt( (double)A + m_Val ) );
61  }
62  else
63  {
64  // outside the mask
65  return static_cast< TOutput >( -std::sqrt(m_Val - (double)B) );
66  }
67  }
68 
69 private:
70  double m_Val;
71 };
72 }
73 
74 template< class TInputImage1, class TInputImage2 = TInputImage1, class TInputImage3 = TInputImage1,
75  class TOutputImage = TInputImage1 >
76 class ITK_EXPORT MorphSDTHelperImageFilter:
77  public
78  TernaryFunctorImageFilter< TInputImage1, TInputImage2, TInputImage3, TOutputImage,
79  Function::MorphSDTHelper<
80  typename TInputImage1::PixelType,
81  typename TInputImage2::PixelType,
82  typename TInputImage3::PixelType,
83  typename TOutputImage::PixelType > >
84 {
85 public:
86  ITK_DISALLOW_COPY_AND_ASSIGN(MorphSDTHelperImageFilter);
87 
90  using Superclass = TernaryFunctorImageFilter< TInputImage1, TInputImage2, TInputImage3, TOutputImage,
92  typename TInputImage1::PixelType,
93  typename TInputImage2::PixelType,
94  typename TInputImage3::PixelType,
95  typename TOutputImage::PixelType >
96  >;
97 
100 
102  itkNewMacro(Self);
103 
105  itkTypeMacro(MorphSDTHelperImageFilter,
107 
108  void SetVal(double val)
109  {
110  this->GetFunctor().SetVal(val);
111  this->Modified();
112  }
113 
114 #ifdef ITK_USE_CONCEPT_CHECKING
115 
116  itkConceptMacro( Input1ConvertibleToOutputCheck,
117  ( Concept::Convertible< typename TInputImage1::PixelType,
118  typename TOutputImage::PixelType > ) );
119  itkConceptMacro( Input2ConvertibleToOutputCheck,
120  ( Concept::Convertible< typename TInputImage2::PixelType,
121  typename TOutputImage::PixelType > ) );
122  itkConceptMacro( GreaterThanComparable,
123  ( Concept::GreaterThanComparable< typename TInputImage3::PixelType,
124  typename TInputImage3::PixelType > ) );
125 
127 #endif
128 protected:
131 };
132 } // end namespace itk
134 
135 #endif
bool operator==(const MorphSDTHelper &other) const
bool operator!=(const MorphSDTHelper &) const
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Implements pixel-wise generic operation of three images.
Base class for all process objects that output image data.
Implements a pixel-wise operator to form a signed distance transform.
#define itkConceptMacro(name, concept)
TOutput operator()(const TInput1 &A, const TInput2 &B, const TInput3 &C)