ITK  4.6.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 "vnl/vnl_math.h"
22 
23 namespace itk
24 {
25 
35 namespace Function {
36 
37 template< class TInput, class 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  double a1 = static_cast<double>( A[0] );
77  double a2 = static_cast<double>( A[1] );
78  double a3 = static_cast<double>( A[2] );
79 
80  double l1 = vnl_math_abs( a1 );
81  double l2 = vnl_math_abs( a2 );
82  double l3 = vnl_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 < vnl_math::eps || l3 < vnl_math::eps )
140  {
141  return tubularness;
142  }
143 
144  const double Rs = l2 / l3;
145  const double Rb = l1 / vcl_sqrt( l2 * l3 );
146  const double Rn = vcl_sqrt( l3*l3 + l2*l2 + l1*l1 );
147 
148  tubularness = ( 1.0 - vcl_exp( - ( Rs * Rs ) / ( 2.0 * m_Alpha * m_Alpha ) ) );
149  tubularness *= ( vcl_exp( - ( Rb * Rb ) / ( 2.0 * m_Beta * m_Beta ) ) );
150  tubularness *= ( 1.0 - vcl_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 <class TInputImage, class TOutputImage>
183  public
184 UnaryFunctorImageFilter<TInputImage,TOutputImage,
185  Function::Tubularness< typename TInputImage::PixelType,
186  typename TOutputImage::PixelType> >
187 {
188 public:
191  typedef UnaryFunctorImageFilter<
192  TInputImage,TOutputImage,
194  typename TInputImage::PixelType,
195  typename TOutputImage::PixelType> > Superclass;
198 
200  itkNewMacro(Self);
201 
203  itkTypeMacro(FrangiTubularnessImageFilter,
205 
207  void SetSheetnessNormalization( double value )
208  {
209  this->GetFunctor().SetAlpha( value );
210  }
211 
213  void SetBloobinessNormalization( double value )
214  {
215  this->GetFunctor().SetBeta( value );
216  }
217 
219  void SetNoiseNormalization( double value )
220  {
221  this->GetFunctor().SetGamma( value );
222  }
223 
226  void SetBrightBackground( bool value )
227  {
228  this->GetFunctor().SetBrightBackground( value );
229  }
230 
231 
232 #ifdef ITK_USE_CONCEPT_CHECKING
233 
234  typedef typename TInputImage::PixelType InputPixelType;
235  itkConceptMacro(BracketOperatorsCheck,
237  itkConceptMacro(DoubleConvertibleToOutputCheck,
239 
241 #endif
242 
243 protected:
246 
247 private:
248  FrangiTubularnessImageFilter(const Self&); //purposely not implemented
249  void operator=(const Self&); //purposely not implemented
250 
251 };
252 
253 } // end namespace itk
254 
255 
256 #endif
UnaryFunctorImageFilter< TInputImage, TOutputImage, Function::Tubularness< typename TInputImage::PixelType, typename TOutputImage::PixelType > > Superclass
bool operator==(const Tubularness &other) const
const Tubularness & operator=(const Tubularness &one)
Base class for all process objects that output image data.
bool operator!=(const Tubularness &) const
Computes a measure of CrestLines from the Hessian Eigenvalues.
Implements pixel-wise generic operation on one image.
#define itkConceptMacro(name, concept)