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 "itkKernelFunction.h"
21 #include "vnl/vnl_math.h"
22 
23 
24 namespace itk
25 {
26 
42 template <unsigned int VSplineOrder = 3>
43 class ITK_EXPORT BSplineSecondOrderDerivativeKernelFunction2 : public KernelFunction
44 {
45 public:
48  typedef KernelFunction Superclass;
49  typedef SmartPointer<Self> Pointer;
50 
52  itkNewMacro(Self);
53 
55  itkTypeMacro(BSplineSecondOrderDerivativeKernelFunction2, KernelFunction);
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 protected:
75 
76  void PrintSelf(std::ostream& os, Indent indent) const
77  {
78  Superclass::PrintSelf( os, indent );
79  os << indent << "Spline Order: " << SplineOrder << std::endl;
80  }
81 
82 private:
83  BSplineSecondOrderDerivativeKernelFunction2(const Self&); //purposely not implemented
84  void operator=(const Self&); //purposely not implemented
85 
87  struct DispatchBase {};
88  template<unsigned int>
89  struct Dispatch : DispatchBase {};
90 
134  inline double Evaluate ( const Dispatch<2>&, const double& u) const
135  {
136  double absValue = vnl_math_abs( u );
137 
138  if ( absValue < 0.5 )
139  {
140  return -2.0;
141  }
142  else if ( absValue == 0.5 )
143  {
144  return -0.5;
145  }
146  else if ( absValue < 1.5 )
147  {
148  return 1.0;
149  }
150  else if ( absValue == 1.5 )
151  {
152  return 0.5;
153  }
154  else
155  {
156  return 0.0;
157  }
158 
159  }
160 
162  inline double Evaluate ( const Dispatch<3>&, const double& u) const
163  {
164  const double absValue = vnl_math_abs( u );
165 
166  if ( absValue < 1.0 )
167  {
168  return vnl_math_sgn0( u ) * ( 3.0 * u ) - 2.0;
169  }
170  else if ( absValue < 2.0 )
171  {
172  return -vnl_math_sgn( u ) * u + 2.0;
173  }
174  else
175  {
176  return 0.0;
177  }
178 
179  }
180 
182  inline double Evaluate ( const DispatchBase&, const double&) const
183  {
184  itkExceptionMacro("Evaluate not implemented for spline\
185  order " << SplineOrder);
186  return 0.0; // This is to avoid compiler warning about missing
187  // return statement. It should never be evaluated.
188  }
189 
190 };
191 
192 
193 } // end namespace itk
194 
195 #endif


Generated on 21-03-2014 for elastix by doxygen 1.8.1.2 elastix logo