go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
itkBSplineSecondOrderDerivativeKernelFunction2.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Insight Segmentation & Registration Toolkit
4  Module: $RCSfile: itkBSplineSecondOrderDerivativeKernelFunction2.h,v $
5  Language: C++
6  Date: $Date: 2008-06-25 11:00:19 $
7  Version: $Revision: 1.7 $
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 __itkBSplineSecondOrderDerivativeKernelFunction2_h
18 #define __itkBSplineSecondOrderDerivativeKernelFunction2_h
19 
20 #include "itkKernelFunctionBase.h"
21 #include "vnl/vnl_math.h"
22 
23 namespace itk
24 {
25 
41 template< unsigned int VSplineOrder = 3 >
43 {
44 public:
45 
49  typedef SmartPointer< Self > Pointer;
50 
52  itkNewMacro( Self );
53 
56 
58  itkStaticConstMacro( SplineOrder, unsigned int, VSplineOrder );
59 
60 // /** Evaluate the function. */
61 // inline double Evaluate( const double & u ) const
62 // {
63 // return ( m_KernelFunction->Evaluate( u + 0.5 ) -
64 // m_KernelFunction->Evaluate( u - 0.5 ) );
65 // }
67  inline double Evaluate( const double & u ) const
68  {
69  return this->Evaluate( Dispatch< VSplineOrder >(), u );
70  }
71 
72 
73 protected:
74 
77 
78  void PrintSelf( std::ostream & os, Indent indent ) const
79  {
80  Superclass::PrintSelf( os, indent );
81  os << indent << "Spline Order: " << SplineOrder << std::endl;
82  }
83 
84 
85 private:
86 
87  BSplineSecondOrderDerivativeKernelFunction2( const Self & ); // purposely not implemented
88  void operator=( const Self & ); // purposely not implemented
89 
91  struct DispatchBase {};
92  template< unsigned int >
93  struct Dispatch : DispatchBase {};
94 
138  inline double Evaluate( const Dispatch< 2 > &, const double & u ) const
139  {
140  double absValue = vnl_math_abs( u );
141 
142  if( absValue < 0.5 )
143  {
144  return -2.0;
145  }
146  else if( absValue == 0.5 )
147  {
148  return -0.5;
149  }
150  else if( absValue < 1.5 )
151  {
152  return 1.0;
153  }
154  else if( absValue == 1.5 )
155  {
156  return 0.5;
157  }
158  else
159  {
160  return 0.0;
161  }
162 
163  }
164 
165 
167  inline double Evaluate( const Dispatch< 3 > &, const double & u ) const
168  {
169  const double absValue = vnl_math_abs( u );
170 
171  if( absValue < 1.0 )
172  {
173  return vnl_math_sgn0( u ) * ( 3.0 * u ) - 2.0;
174  }
175  else if( absValue < 2.0 )
176  {
177  return -vnl_math_sgn( u ) * u + 2.0;
178  }
179  else
180  {
181  return 0.0;
182  }
183 
184  }
185 
186 
188  inline double Evaluate( const DispatchBase &, const double & ) const
189  {
190  itkExceptionMacro( "Evaluate not implemented for spline\
191  order " << SplineOrder );
192  return 0.0; // This is to avoid compiler warning about missing
193  // return statement. It should never be evaluated.
194  }
195 
196 
197 };
198 
199 } // end namespace itk
200 
201 #endif
double Evaluate(const Dispatch< 3 > &, const double &u) const
itkStaticConstMacro(SplineOrder, unsigned int, VSplineOrder)
double Evaluate(const Dispatch< 2 > &, const double &u) const
Derivative of a B-spline kernel used for density estimation and nonparametric regression.


Generated on 27-04-2014 for elastix by doxygen 1.8.6 elastix logo