]> Creatis software - clitk.git/blob - itk/itkBSplineInterpolateImageFunctionWithLUT.h.original
Debug RTStruct conversion with empty struc
[clitk.git] / itk / itkBSplineInterpolateImageFunctionWithLUT.h.original
1 /* =========================================================================
2                                                                                 
3   @file   itkBSplineInterpolateImageFunctionWithLUT.h
4   @author David Sarrut <david.sarrut@creatis.insa-lyon.fr>
5
6   Copyright (c) 
7   * CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). 
8     All rights reserved. See Doc/License.txt or
9     http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
10   * Léon Bérard cancer center, 28 rue Laënnec, 69373 Lyon cedex 08, France
11   * http://www.creatis.insa-lyon.fr/rio
12                                                                                 
13   This software is distributed WITHOUT ANY WARRANTY; without even the
14   implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15   PURPOSE.  See the above copyright notices for more information.
16                                                                              
17 ========================================================================= */
18
19 #ifndef ITKBSPLINEINTERPOLATEIMAGEFUNCTIONWITHLUT_H
20 #define ITKBSPLINEINTERPOLATEIMAGEFUNCTIONWITHLUT_H
21 #include "itkCastImageFilter.h"
22 #include "itkBSplineWeightsCalculator.h"
23 //#include "clitkTimer.h"
24
25 #include <itkBSplineInterpolateImageFunction.h>
26
27 namespace itk {
28   
29   template <
30     class TImageType, 
31     class TCoordRep = double,
32     class TCoefficientType = double >
33   class ITK_EXPORT BSplineInterpolateImageFunctionWithLUT : 
34     public itk::BSplineInterpolateImageFunction<TImageType,TCoordRep,TCoefficientType> {
35     
36   public: 
37     /** Class typedefs */
38     typedef BSplineInterpolateImageFunctionWithLUT<TImageType,TCoordRep, TCoefficientType> Self;
39     typedef BSplineInterpolateImageFunction<TImageType,TCoordRep, TCoefficientType>  Superclass;
40     typedef SmartPointer<Self> Pointer;
41     typedef SmartPointer<const Self> ConstPointer;
42     typedef typename Superclass::OutputType OutputType;
43     typedef typename Superclass::ContinuousIndexType ContinuousIndexType;
44     typedef typename TImageType::IndexType           IndexType;
45     typedef typename TImageType::IndexValueType      IndexValueType;
46     typedef typename TImageType::SizeType            SizeType;
47     typedef typename TImageType::SpacingType         SpacingType;
48
49     /** New macro for creation of through a Smart Pointer */
50     itkNewMacro(Self);
51     BSplineInterpolateImageFunctionWithLUT();
52
53     /** Setting LUT sampling (one parameters by dimension or a single
54         one for all dim); Default is 10 (for each dim) **/
55     void SetLUTSamplingFactor(int s);
56     void SetLUTSamplingFactors(int * s);
57
58     /** Get/Sets the Spline Order, supports 0th - 5th order
59      *  splines. The default is a 3rd order spline. */
60     void SetSplineOrder(unsigned int SplineOrder);
61
62     //JV this is added to support different degrees over each dimension
63     void SetSplineOrders( SizeType SplineOrders);
64
65     /** Set the input image.  This must be set by the user. */
66     virtual void SetInputImage(const TImageType * inputData);
67     void SetOutputSpacing(const SpacingType & s);
68     void SetInputImageIsCoefficient(bool inputIsCoef) { mInputIsCoef = inputIsCoef; }
69
70     /** Evaluate the function at a ContinuousIndex position.
71         Overwritten for taking LUT into account */  
72     virtual OutputType EvaluateAtContinuousIndex(const ContinuousIndexType & index ) const;
73     
74     /** Static convenient functions to compute BSpline weights for
75         various order, dimension, sampling ... **/
76     static void ComputeBlendingWeights(int dim, int order, int sampling, TCoefficientType * weights);
77
78     /** Timer giving computation time for coefficients computation **/    
79     // const clitk::Timer & GetCoefTimer() const { return mCoefficientTimer; }    
80
81     /** Get estimated error **/
82
83     double GetIntrinsicError() const { return *mIntrinsecError; }
84     long   GetNumberOfError() const { return *mNumberOfError; }
85     double GetIntrinsicErrorMax() const { return *mIntrinsecErrorMax; }
86
87   protected:
88     SizeType               mSupport;            // nb of coef values used for interpolation (order+1) in 1 dimension
89     SizeType               mHalfSupport;        // half size of the previous
90     unsigned int           mSupportSize;        // Total support size for all dimension
91     std::vector<int>       mSupportOffset;      // Memory pointer offset for going from one coef position to the other (inside the whole support)
92     std::vector<IndexType> mSupportIndex;       // nD Index of all support values
93     IndexType              mInputMemoryOffset;  // Memory dimension offsets for input image
94
95     /** Sampling factors for LUT weights **/
96     SizeType               mSamplingFactors;
97     bool                   mWeightsAreUpToDate;
98     SpacingType            mOutputSpacing;
99
100     double                 * mIntrinsecError;
101     double                 * mIntrinsecErrorMax;
102     long                   * mNumberOfError;
103
104     //JV add iscoeff, and splineorders
105     bool                   mInputIsCoef;
106     SizeType mSplineOrders;
107
108     // Filter to compute weights
109     itk::BSplineWeightsCalculator<TCoefficientType,TImageType::ImageDimension> mWeightsCalculator;
110
111     // Convenient functions
112     void UpdatePrecomputedWeights();
113     IndexType GetSampleIndexOfPixelPosition(const ContinuousIndexType & x, IndexType & EvaluateIndex) const;
114
115     // Timing options
116     // clitk::Timer mCoefficientTimer;
117     // clitk::Timer mLUTTimer;
118     bool  mTimerEnabled;
119
120     std::vector<int> mCorrectedSupportOffset;
121     TCoefficientType * coef;
122
123     std::vector<IndexType> mCorrectedSupportIndex;
124
125   }; // end class itkBSplineInterpolateImageFunctionWithLUT
126
127 #include "itkBSplineInterpolateImageFunctionWithLUT.txx"
128
129 } // end namespace
130
131 #endif /* end #define ITKBSPLINEINTERPOLATEIMAGEFUNCTIONWITHLUT_H */
132