KWStyle - itkDerivativeOperator.txx
 
Matrix View
Description

1 /*=========================================================================
2
3   Program:   Insight Segmentation & Registration Toolkit
4   Module:    $RCSfile: itkDerivativeOperator.txx.html,v $
5   Language:  C++
6   Date:      $Date: 2006/01/17 19:15:34 $
7   Version:   $Revision: 1.4 $
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 DEF #ifndef _itkDerivativeOperator_txx
18 DEF #define _itkDerivativeOperator_txx
19 #include "itkDerivativeOperator.h"
20
21 #include "itkNumericTraits.h"
22
23 namespace itk
24 {
25
26 template <class TPixel, unsigned int VDimension, class TAllocator>
27 typename DerivativeOperator<TPixel, VDimension, TAllocator>
28 ::CoefficientVector
29 DerivativeOperator<TPixel, VDimension, TAllocator>
30 ::GenerateCoefficients()
31 {
32   unsigned int i;
33   unsigned int j;
34   typedef typename NumericTraits<PixelType>::RealType PixelRealType;  
35   PixelRealType previous;
36   PixelRealType next;
37   const unsigned int w = 2*((m_Order + 1)/2) + 1;
38   CoefficientVector coeff(w);
39
40   coeff[w/2] = 1.0;
41   for (i = 0; i < m_Order/2; i++)
42     {
43     previous = coeff[1] - 2 * coeff[0];
44     for (j = 1; j < w - 1; j++)
45       {
46       next =coeff[j - 1]  + coeff[j + 1] - 2*coeff[j];
47       coeff[j-1] = previous;
48       previous = next;
49       }
50     next = coeff[j - 1] - 2*coeff[j];
51     coeff[j-1] = previous;
52     coeff[j] = next;      
53     }
54   for (i = 0; i < m_Order%2; i++)    
55     {
56     previous =  0.5 * coeff[1];
57     for (j = 1; j < w - 1; j++)
58       {
59       next = -0.5*coeff[j - 1] + 0.5*coeff[j + 1];
60       coeff[j-1] = previous;
61       previous = next;
62       }
63     next = -0.5 * coeff[j - 1];
64     coeff[j-1] = previous;
65     coeff[j] = next;      
66     }
67
68   return coeff;
69 }
70
71 // namespace itk
72
73 #endif
74

Generated by KWStyle 1.0b on Tuesday January,17 at 02:14:05PM
© Kitware Inc.