ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkFrangiTubularnessImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Insight Segmentation & Registration Toolkit
4  Module: itkFrangiTubularnessImageFilter.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 itkFrangiTubularnessImageFilter_h
18 #define itkFrangiTubularnessImageFilter_h
19 
21 #include "itkMath.h"
22 
23 namespace itk
24 {
25 
35 namespace Function {
36 
37 template< typename TInput, typename TOutput>
39 {
40 public:
42  {
43  m_Alpha = 0.5; // suggested value in the paper
44  m_Beta = 0.5; // suggested value in the paper;
45  m_Gamma = 1.0; // suggested value in the paper;
46  m_BrigthForeground = true;
47  }
49  Tubularness( const Tubularness & one )
50  {
51  this->m_Alpha = one.m_Alpha;
52  this->m_Beta = one.m_Beta;
53  this->m_Gamma = one.m_Gamma;
55  }
56  const Tubularness & operator=( const Tubularness & one )
57  {
58  this->m_Alpha = one.m_Alpha;
59  this->m_Beta = one.m_Beta;
60  this->m_Gamma = one.m_Gamma;
62  return *this;
63  }
64  bool operator!=( const Tubularness & ) const
65  {
66  return false;
67  }
68  bool operator==( const Tubularness & other ) const
69  {
70  return !(*this != other);
71  }
72  inline TOutput operator()( const TInput & A )
73  {
74  double tubularness = 0.0;
75 
76  auto a1 = static_cast<double>( A[0] );
77  auto a2 = static_cast<double>( A[1] );
78  auto a3 = static_cast<double>( A[2] );
79 
80  double l1 = itk::Math::abs( a1 );
81  double l2 = itk::Math::abs( a2 );
82  double l3 = itk::Math::abs( a3 );
83 
84  //
85  // Sort the values by their absolute value.
86  //
87  if( l2 > l3 )
88  {
89  double tmpl = l3;
90  l3 = l2;
91  l2 = tmpl;
92  double tmpa = a3;
93  a3 = a2;
94  a2 = tmpa;
95  }
96 
97  if( l1 > l2 )
98  {
99  double tmp = l1;
100  l1 = l2;
101  l2 = tmp;
102  double tmpa = a1;
103  a1 = a2;
104  a2 = tmpa;
105  }
106 
107  if( l2 > l3 )
108  {
109  double tmp = l3;
110  l3 = l2;
111  l2 = tmp;
112  double tmpa = a3;
113  a3 = a2;
114  a2 = tmpa;
115  }
116 
117  if( m_BrigthForeground )
118  {
119  //
120  // Reject dark tubes and dark ridges over bright background
121  //
122  if( a3 > 0.0 )
123  {
124  return tubularness;
125  }
126  }
127  else
128  {
129  //
130  // Reject bright tubes and bright ridges over dark background
131  //
132  if( a3 < 0.0 )
133  {
134  return tubularness;
135  }
136  }
137 
138  // avoid divisions by zero
139  if( l2 < itk::Math::eps || l3 < itk::Math::eps )
140  {
141  return tubularness;
142  }
143 
144  const double Rs = l2 / l3;
145  const double Rb = l1 / std::sqrt( l2 * l3 );
146  const double Rn = std::sqrt( l3*l3 + l2*l2 + l1*l1 );
147 
148  tubularness = ( 1.0 - std::exp( - ( Rs * Rs ) / ( 2.0 * m_Alpha * m_Alpha ) ) );
149  tubularness *= ( std::exp( - ( Rb * Rb ) / ( 2.0 * m_Beta * m_Beta ) ) );
150  tubularness *= ( 1.0 - std::exp( - ( Rn * Rn ) / ( 2.0 * m_Gamma * m_Gamma ) ) );
151 
152  return static_cast<TOutput>( tubularness );
153  }
154 
155  void SetAlpha( double value )
156  {
157  this->m_Alpha = value;
158  }
159  void SetBeta( double value )
160  {
161  this->m_Beta = value;
162  }
163  void SetGamma( double value )
164  {
165  this->m_Gamma = value;
166  }
167  void SetBrightBackground( bool value )
168  {
169  std::cout << "m_BrigthForeground " << value << std::endl;
170  this->m_BrigthForeground;
171  }
172 
173 private:
174  double m_Alpha;
175  double m_Beta;
176  double m_Gamma;
178 };
179 }
180 
181 template <typename TInputImage, typename TOutputImage>
182 class ITK_TEMPLATE_EXPORT FrangiTubularnessImageFilter :
183  public
184 UnaryFunctorImageFilter<TInputImage,TOutputImage,
185  Function::Tubularness< typename TInputImage::PixelType,
186  typename TOutputImage::PixelType> >
187 {
188 public:
189  ITK_DISALLOW_COPY_AND_ASSIGN(FrangiTubularnessImageFilter);
190 
194  TInputImage,TOutputImage,
196  typename TInputImage::PixelType,
197  typename TOutputImage::PixelType> >;
200 
202  itkNewMacro(Self);
203 
205  itkTypeMacro(FrangiTubularnessImageFilter,
207 
209  void SetSheetnessNormalization( double value )
210  {
211  this->GetFunctor().SetAlpha( value );
212  }
213 
215  void SetBloobinessNormalization( double value )
216  {
217  this->GetFunctor().SetBeta( value );
218  }
219 
221  void SetNoiseNormalization( double value )
222  {
223  this->GetFunctor().SetGamma( value );
224  }
225 
228  void SetBrightBackground( bool value )
229  {
230  this->GetFunctor().SetBrightBackground( value );
231  }
232 
233 
234 #ifdef ITK_USE_CONCEPT_CHECKING
235 
236  using InputPixelType = typename TInputImage::PixelType;
237  itkConceptMacro(BracketOperatorsCheck,
239  itkConceptMacro(DoubleConvertibleToOutputCheck,
241 
243 #endif
244 
245 protected:
248 };
249 
250 } // end namespace itk
251 
252 
253 #endif
bool operator==(const Tubularness &other) const
const Tubularness & operator=(const Tubularness &one)
typename TInputImage::PixelType InputPixelType
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.
bool operator!=(const Tubularness &) const
static constexpr double eps
Definition: itkMath.h:94
Computes a measure of CrestLines from the Hessian Eigenvalues.
Implements pixel-wise generic operation on one image.
#define itkConceptMacro(name, concept)