ITK  4.13.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 "vnl/vnl_math.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 >( vcl_sqrt( (double)A + m_Val ) );
61  }
62  else
63  {
64  // outside the mask
65  return static_cast< TOutput >( -vcl_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:
88  typedef TernaryFunctorImageFilter< TInputImage1, TInputImage2, TInputImage3, TOutputImage,
90  typename TInputImage1::PixelType,
91  typename TInputImage2::PixelType,
92  typename TInputImage3::PixelType,
93  typename TOutputImage::PixelType >
95 
98 
100  itkNewMacro(Self);
101 
103  itkTypeMacro(MorphSDTHelperImageFilter,
105 
106  void SetVal(double val)
107  {
108  this->GetFunctor().SetVal(val);
109  this->Modified();
110  }
111 
112 #ifdef ITK_USE_CONCEPT_CHECKING
113 
114  itkConceptMacro( Input1ConvertibleToOutputCheck,
115  ( Concept::Convertible< typename TInputImage1::PixelType,
116  typename TOutputImage::PixelType > ) );
117  itkConceptMacro( Input2ConvertibleToOutputCheck,
118  ( Concept::Convertible< typename TInputImage2::PixelType,
119  typename TOutputImage::PixelType > ) );
120  itkConceptMacro( GreaterThanComparable,
121  ( Concept::GreaterThanComparable< typename TInputImage3::PixelType,
122  typename TInputImage3::PixelType > ) );
123 
125 #endif
126 protected:
129 private:
130  ITK_DISALLOW_COPY_AND_ASSIGN(MorphSDTHelperImageFilter);
131 };
132 } // end namespace itk
134 
135 #endif
bool operator==(const MorphSDTHelper &other) const
bool operator!=(const MorphSDTHelper &) const
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.
TernaryFunctorImageFilter< TInputImage1, TInputImage2, TInputImage3, TOutputImage, Function::MorphSDTHelper< typename TInputImage1::PixelType, typename TInputImage2::PixelType, typename TInputImage3::PixelType, typename TOutputImage::PixelType > > Superclass
#define itkConceptMacro(name, concept)
TOutput operator()(const TInput1 &A, const TInput2 &B, const TInput3 &C)