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.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkBSplineSecondOrderDerivativeKernelFunction2.h,v $
00005   Language:  C++
00006   Date:      $Date: 2008-06-25 11:00:19 $
00007   Version:   $Revision: 1.7 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012      This software is distributed WITHOUT ANY WARRANTY; without even
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00014      PURPOSE.  See the above copyright notices for more information.
00015 
00016 =========================================================================*/
00017 #ifndef __itkBSplineSecondOrderDerivativeKernelFunction2_h
00018 #define __itkBSplineSecondOrderDerivativeKernelFunction2_h
00019 
00020 #include "itkKernelFunction.h"
00021 #include "vnl/vnl_math.h"
00022 
00023 
00024 namespace itk
00025 {
00026 
00042 template <unsigned int VSplineOrder = 3>
00043 class ITK_EXPORT BSplineSecondOrderDerivativeKernelFunction2 : public KernelFunction
00044 {
00045 public:
00047   typedef BSplineSecondOrderDerivativeKernelFunction2 Self;
00048   typedef KernelFunction                  Superclass;
00049   typedef SmartPointer<Self>              Pointer;
00050 
00052   itkNewMacro(Self);
00053 
00055   itkTypeMacro(BSplineSecondOrderDerivativeKernelFunction2, KernelFunction);
00056 
00058   itkStaticConstMacro(SplineOrder, unsigned int, VSplineOrder);
00059 
00060 //  /** Evaluate the function. */
00061 //  inline double Evaluate( const double & u ) const
00062 //    {
00063 //    return ( m_KernelFunction->Evaluate( u + 0.5 ) -
00064 //      m_KernelFunction->Evaluate( u - 0.5 ) );
00065 //    }
00067   inline double Evaluate( const double & u ) const
00068   {
00069     return this->Evaluate( Dispatch<VSplineOrder>(), u );
00070   }
00071 
00072 protected:
00073   BSplineSecondOrderDerivativeKernelFunction2(){};
00074   ~BSplineSecondOrderDerivativeKernelFunction2(){};
00075 
00076   void PrintSelf(std::ostream& os, Indent indent) const
00077     {
00078     Superclass::PrintSelf( os, indent );
00079     os << indent  << "Spline Order: " << SplineOrder << std::endl;
00080     }
00081 
00082 private:
00083   BSplineSecondOrderDerivativeKernelFunction2(const Self&); //purposely not implemented
00084   void operator=(const Self&); //purposely not implemented
00085 
00087   struct DispatchBase {};
00088   template<unsigned int>
00089   struct Dispatch : DispatchBase {};
00090 
00134   inline double Evaluate ( const Dispatch<2>&, const double& u) const
00135   {
00136     double absValue = vnl_math_abs( u );
00137 
00138     if ( absValue < 0.5 )
00139     {
00140       return -2.0;
00141     }
00142     else if ( absValue == 0.5 )
00143     {
00144       return -0.5;
00145     }
00146     else if ( absValue < 1.5 )
00147     {
00148       return 1.0;
00149     }
00150     else if ( absValue == 1.5 )
00151     {
00152       return 0.5;
00153     }
00154     else
00155     {
00156       return 0.0;
00157     }
00158 
00159   }
00160 
00162   inline double Evaluate ( const Dispatch<3>&, const double& u) const
00163   {
00164     const double absValue = vnl_math_abs( u );
00165 
00166     if ( absValue < 1.0 )
00167     {
00168       return vnl_math_sgn0( u ) * ( 3.0 * u ) - 2.0;
00169     }
00170     else if ( absValue < 2.0 )
00171     {
00172       return -vnl_math_sgn( u ) * u + 2.0;
00173     }
00174     else
00175     {
00176       return 0.0;
00177     }
00178 
00179   }
00180 
00182   inline double Evaluate ( const DispatchBase&, const double&) const
00183   {
00184     itkExceptionMacro("Evaluate not implemented for spline\
00185                       order " << SplineOrder);
00186     return 0.0; // This is to avoid compiler warning about missing
00187     // return statement.  It should never be evaluated.
00188   }
00189 
00190 };
00191 
00192 
00193 } // end namespace itk
00194 
00195 #endif


Generated on 11-05-2012 for elastix by doxygen 1.7.6.1 elastix logo