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