ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkLocalStructureImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Insight Segmentation & Registration Toolkit
4  Module: itkLocalStructureImageFilter.h
5  Language: C++
6  Date: $Date$
7  Version: $Revision$
8 
9  Copyright (c) Insight Software Consortium. All rights reserved.
10  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
11 
12  This software is distributed WITHOUT ANY WARRANTY; without even
13  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14  PURPOSE. See the above copyright notices for more information.
15 
16 =========================================================================*/
17 #ifndef itkLocalStructureImageFilter_h
18 #define itkLocalStructureImageFilter_h
19 
21 #include "itkMath.h"
22 
23 namespace itk
24 {
25 
47 namespace Function {
48 
49 template< typename TInput, typename TOutput>
51 {
52 public:
54  {
55  m_Alpha = 0.25; // suggested value in the paper
56  m_Gamma = 0.50; // suggested value in the paper;
57  }
59  bool operator!=( const LocalStructure & ) const
60  {
61  return false;
62  }
63  bool operator==( const LocalStructure & other ) const
64  {
65  return !(*this != other);
66  }
67  inline TOutput operator()( const TInput & A )
68  {
69  auto a1 = static_cast<double>( A[0] );
70  auto a2 = static_cast<double>( A[1] );
71  auto a3 = static_cast<double>( A[2] );
72 
73  double l1 = itk::Math::abs( a1 );
74  double l2 = itk::Math::abs( a2 );
75  double l3 = itk::Math::abs( a3 );
76 
77  //
78  // Sort the values by their absolute value.
79  //
80  if( l2 > l3 )
81  {
82  double tmpl = l3;
83  l3 = l2;
84  l2 = tmpl;
85  double tmpa = a3;
86  a3 = a2;
87  a2 = tmpa;
88  }
89 
90  if( l1 > l2 )
91  {
92  double tmp = l1;
93  l1 = l2;
94  l2 = tmp;
95  double tmpa = a1;
96  a1 = a2;
97  a2 = tmpa;
98  }
99 
100  if( l2 > l3 )
101  {
102  double tmp = l3;
103  l3 = l2;
104  l2 = tmp;
105  double tmpa = a3;
106  a3 = a2;
107  a2 = tmpa;
108  }
109 
110  //
111  // Avoid divisions by zero.
112  //
113  if( l3 < itk::Math::eps )
114  {
115  return 0.0;
116  }
117 
118  const double L3 = itk::Math::abs( static_cast<double>( a3 ) );
119  const double W = WeightFunctionOmega( a2, a3 );
120  const double F = WeightFunctionOmega( a1, a3 );
121 
122  const double sheetness = L3 * W * F;
123 
124  return static_cast<TOutput>( sheetness );
125  }
126  inline double WeightFunctionOmega( double ls, double lt ) const
127  {
128  if( ls <= 0.0 && lt <= ls )
129  {
130  return ( 1 + std::pow( ls / itk::Math::abs( lt ), m_Gamma ) );
131  }
132  const double abslt = itk::Math::abs( lt );
133  if( ls > 0.0 && abslt / m_Gamma > ls )
134  {
135  return std::pow( 1 - m_Alpha * ls / itk::Math::abs( lt ), m_Gamma );
136  }
137  return 0.0;
138  }
139  inline double WeightFunctionPhi( double ls, double lt ) const
140  {
141  if( ls < 0.0 && lt <= ls )
142  {
143  return std::pow( ( ls / lt ), m_Gamma );
144  }
145  return 0.0;
146  }
147 
148  void SetAlpha( double value )
149  {
150  this->m_Alpha = value;
151  }
152 
153  void SetGamma( double value )
154  {
155  this->m_Gamma = value;
156  }
157 
158 private:
159  double m_Alpha;
160  double m_Gamma;
161 };
162 }
163 
164 template <typename TInputImage, typename TOutputImage>
165 class ITK_TEMPLATE_EXPORT LocalStructureImageFilter :
166  public
167 UnaryFunctorImageFilter<TInputImage,TOutputImage,
168  Function::LocalStructure< typename TInputImage::PixelType,
169  typename TOutputImage::PixelType> >
170 {
171 public:
172  ITK_DISALLOW_COPY_AND_ASSIGN(LocalStructureImageFilter);
173 
177  TInputImage,TOutputImage,
179  typename TInputImage::PixelType,
180  typename TOutputImage::PixelType> >;
183 
185  itkNewMacro(Self);
186 
188  itkTypeMacro(LocalStructureImageFilter,
190 
192  void SetAlpha( double value )
193  {
194  this->GetFunctor().SetAlpha( value );
195  }
196 
198  void SetGamma( double value )
199  {
200  this->GetFunctor().SetGamma( value );
201  }
202 
203 
204 #ifdef ITK_USE_CONCEPT_CHECKING
205 
206  using InputPixelType = typename TInputImage::PixelType;
207  itkConceptMacro(BracketOperatorsCheck,
209  itkConceptMacro(DoubleConvertibleToOutputCheck,
211 
213 #endif
214 
215 protected:
218 };
219 
220 } // end namespace itk
221 
222 
223 #endif
bool operator==(const LocalStructure &other) const
double WeightFunctionOmega(double ls, double lt) const
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Base class for all process objects that output image data.
double WeightFunctionPhi(double ls, double lt) const
typename TInputImage::PixelType InputPixelType
static constexpr double eps
Definition: itkMath.h:94
Implements pixel-wise generic operation on one image.
#define itkConceptMacro(name, concept)
Computes local similarity to geometrical structures using second derivative operations.
bool operator!=(const LocalStructure &) const