]> Creatis software - clitk.git/blob - itk/clitkVectorBSplineInterpolateImageFunctionWithLUT.h
removed headers
[clitk.git] / itk / clitkVectorBSplineInterpolateImageFunctionWithLUT.h
1 #ifndef __clitkVectorBSplineInterpolateImageFunctionWithLUT_h
2 #define __clitkVectorBSplineInterpolateImageFunctionWithLUT_h
3 /* =========================================================================
4                                                                                 
5   @file   clitVectorkBSplineInterpolateImageFunctionWithLUT.h
6   @author jefvdmb@gmail.com
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 "clitkVectorBSplineInterpolateImageFunction.h"
24
25 namespace clitk {
26   
27   template <
28     class TImageType, 
29     class TCoordRep = double,
30     class TCoefficientType = double >
31   class ITK_EXPORT VectorBSplineInterpolateImageFunctionWithLUT : 
32     public VectorBSplineInterpolateImageFunction<TImageType,TCoordRep,TCoefficientType> {
33     
34   public: 
35     /** Class typedefs */
36     typedef VectorBSplineInterpolateImageFunctionWithLUT<TImageType,TCoordRep, TCoefficientType> Self;
37     typedef VectorBSplineInterpolateImageFunction<TImageType,TCoordRep, TCoefficientType>  Superclass;
38     typedef itk::SmartPointer<Self> Pointer;
39     typedef itk::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     typedef TCoefficientType CoefficientDataType;
48     typedef typename Superclass::CoefficientImagePixelType CoefficientImagePixelType;
49     typedef typename Superclass::CoefficientImageType CoefficientImageType;
50
51     /** New macro for creation of through a Smart Pointer */
52     itkNewMacro(Self);
53     
54     /** Setting LUT sampling (one parameters by dimension or a single
55         one for all dim); Default is 10 (for each dim) **/
56     void SetLUTSamplingFactor(const int& s);
57     void SetLUTSamplingFactors(const SizeType& s);
58
59     /** Get/Sets the Spline Order, supports 0th - 5th order
60      *  splines. The default is a 3rd order spline. */
61     void SetSplineOrder(const unsigned int & SplineOrder);
62
63     //JV this is added to support different degrees over each dimension
64     void SetSplineOrders(const  SizeType & SplineOrders);
65
66     /** Set the input image.  This must be set by the user. */
67     virtual void SetInputImage(const TImageType * inputData);
68     //void SetOutputSpacing(const SpacingType & s);
69     //void SetInputImageIsCoefficient(bool inputIsCoef) { mInputIsCoef = inputIsCoef; }
70
71     /** Evaluate the function at a ContinuousIndex position.
72         Overwritten for taking LUT into account */  
73     virtual OutputType EvaluateAtContinuousIndex(const ContinuousIndexType & index ) const;
74     void EvaluateWeightsAtContinuousIndex(const ContinuousIndexType &  x,  const TCoefficientType ** pweights, IndexType & evaluateIndex) const;
75
76     /** Static convenient functions to compute BSpline weights for
77         various order, dimension, sampling ... **/
78     static void ComputeBlendingWeights(int dim, int order, int sampling, TCoefficientType * weights);
79
80     /** Timer giving computation time for coefficients computation **/    
81     // const clitk::Timer & GetCoefTimer() const { return mCoefficientTimer; }    
82
83     /** Get estimated error **/
84
85     double GetIntrinsicError() const { return *mIntrinsecError; }
86     long   GetNumberOfError() const { return *mNumberOfError; }
87     double GetIntrinsicErrorMax() const { return *mIntrinsecErrorMax; }
88
89   protected:
90     VectorBSplineInterpolateImageFunctionWithLUT();
91     ~VectorBSplineInterpolateImageFunctionWithLUT(){;}
92
93     SizeType               mSupport;            // nb of coef values used for interpolation (order+1) in 1 dimension
94     SizeType               mHalfSupport;        // half size of the previous
95     unsigned int           mSupportSize;        // Total support size for all dimension
96     std::vector<int>       mSupportOffset;      // Memory pointer offset for going from one coef position to the other (inside the whole support)
97     std::vector<IndexType> mSupportIndex;       // nD Index of all support values
98     IndexType              mInputMemoryOffset;  // Memory dimension offsets for input image
99
100     /** Sampling factors for LUT weights **/
101     SizeType               mSamplingFactors;
102     bool                   mWeightsAreUpToDate;
103     //SpacingType            mOutputSpacing;
104
105     double                 * mIntrinsecError;
106     double                 * mIntrinsecErrorMax;
107     long                   * mNumberOfError;
108
109     //JV add iscoeff, and splineorders
110     // bool     mInputIsCoef;
111     SizeType mSplineOrders;
112
113     // Filter to compute weights
114     itk::BSplineWeightsCalculator<TCoefficientType,TImageType::ImageDimension> mWeightsCalculator;
115
116     // Convenient functions
117     void UpdatePrecomputedWeights();
118     void UpdateWeightsProperties();
119     IndexType GetSampleIndexOfPixelPosition(const ContinuousIndexType & x, IndexType & EvaluateIndex) const;
120
121     // Timing options
122     // clitk::Timer mCoefficientTimer;
123     // clitk::Timer mLUTTimer;
124     bool  mTimerEnabled;
125
126     //JV threadsafety: everything on the stack
127     //std::vector<int> mCorrectedSupportOffset;
128     //std::vector<IndexType> mCorrectedSupportIndex;
129     TCoefficientType * coef;
130
131   }; // end class clitkVectorBSplineInterpolateImageFunctionWithLUT
132 } // end namespace
133
134 #ifndef ITK_MANUAL_INSTANTIATION
135 #include "clitkVectorBSplineInterpolateImageFunctionWithLUT.txx"
136 #endif
137
138 #endif /* end #define CLITKBSPLINEINTERPOLATEIMAGEFUNCTIONWITHLUT_H */