]> Creatis software - clitk.git/blob - itk/itkBSplineInterpolateImageFunctionWithLUT.h
Debug RTStruct conversion with empty struc
[clitk.git] / itk / itkBSplineInterpolateImageFunctionWithLUT.h
1 /*=========================================================================
2   Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
3
4   Authors belong to:
5   - University of LYON              http://www.universite-lyon.fr/
6   - Léon Bérard cancer center       http://www.centreleonberard.fr
7   - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
8
9   This software is distributed WITHOUT ANY WARRANTY; without even
10   the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11   PURPOSE.  See the copyright notices for more information.
12
13   It is distributed under dual licence
14
15   - BSD        See included LICENSE.txt file
16   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ===========================================================================**/
18 #ifndef ITKBSPLINEINTERPOLATEIMAGEFUNCTIONWITHLUT_H
19 #define ITKBSPLINEINTERPOLATEIMAGEFUNCTIONWITHLUT_H
20
21 #include "itkBSplineWeightsCalculator.h"
22 #include <itkBSplineInterpolateImageFunction.h>
23
24 #include "clitkCommon.h"
25
26 namespace itk {
27   
28   template <
29     class TImageType, 
30     class TCoordRep = double,
31     class TCoefficientType = double >
32   class ITK_EXPORT BSplineInterpolateImageFunctionWithLUT : 
33     public itk::BSplineInterpolateImageFunction<TImageType,TCoordRep,TCoefficientType> {
34     
35   public: 
36     /** Class typedefs */
37     typedef BSplineInterpolateImageFunctionWithLUT<TImageType,TCoordRep, TCoefficientType> Self;
38     typedef BSplineInterpolateImageFunction<TImageType,TCoordRep, TCoefficientType>  Superclass;
39     typedef SmartPointer<Self> Pointer;
40     typedef SmartPointer<const Self> ConstPointer;
41     typedef typename Superclass::OutputType OutputType;
42     typedef typename Superclass::ContinuousIndexType ContinuousIndexType;
43     typedef typename TImageType::IndexType           IndexType;
44     typedef typename TImageType::IndexValueType      IndexValueType;
45     typedef typename TImageType::SizeType            SizeType;
46     typedef typename TImageType::SpacingType         SpacingType;
47
48     /** New macro for creation of through a Smart Pointer */
49     itkNewMacro(Self);
50     
51     /** Setting LUT sampling (one parameters by dimension or a single
52         one for all dim); Default is 20 (for each dim) **/
53     void SetLUTSamplingFactor(const int& s);
54     void SetLUTSamplingFactors(const SizeType& s);
55
56     /** Get/Sets the Spline Order, supports 0th - 5th order
57      *  splines. The default is a 3rd order spline. */
58     void SetSplineOrder(const unsigned int & SplineOrder);
59
60     //JV this is added to support different degrees over each dimension
61     void SetSplineOrders(const  SizeType & SplineOrders);
62
63     /** Set the input image.  This must be set by the user. */
64     virtual void SetInputImage(const TImageType * inputData) ITK_OVERRIDE;
65     
66     /** Evaluate the function at a ContinuousIndex position.
67   Overwritten for taking LUT into account (RP: multi-threading-compatible version, 
68   the threadID is actually ignored) */  
69     virtual OutputType EvaluateAtContinuousIndex(const ContinuousIndexType & index, unsigned int /* threadID */ ) const ITK_OVERRIDE
70     {
71       return this->EvaluateAtContinuousIndex( index );
72     }
73
74     /** Evaluate the function at a ContinuousIndex position.
75         Overwritten for taking LUT into account */  
76     virtual OutputType EvaluateAtContinuousIndex(const ContinuousIndexType & index ) const ITK_OVERRIDE;
77     
78     /** Static convenient functions to compute BSpline weights for
79         various order, dimension, sampling ... **/
80     static void ComputeBlendingWeights(int dim, int order, int sampling, TCoefficientType * weights);
81
82   protected:
83     BSplineInterpolateImageFunctionWithLUT();
84     ~BSplineInterpolateImageFunctionWithLUT(){;}
85
86     SizeType               mSupport;            // nb of coef values used for interpolation (order+1) in 1 dimension
87     SizeType               mHalfSupport;        // half size of the previous
88     unsigned int           mSupportSize;        // Total support size for all dimension
89     std::vector<int>       mSupportOffset;      // Memory pointer offset for going from one coef position to the other (inside the whole support)
90     std::vector<IndexType> mSupportIndex;       // nD Index of all support values
91     IndexType              mInputMemoryOffset;  // Memory dimension offsets for input image
92
93     /** Sampling factors for LUT weights **/
94     SizeType               mSamplingFactors;
95     bool                   mWeightsAreUpToDate;
96     SizeType mSplineOrders;
97
98     // Filter to compute weights
99     itk::BSplineWeightsCalculator<TCoefficientType,TImageType::ImageDimension> mWeightsCalculator;
100
101     // Convenient functions
102     void UpdatePrecomputedWeights();
103     void UpdateWeightsProperties();
104     IndexType GetSampleIndexOfPixelPosition(const ContinuousIndexType & x, IndexType & EvaluateIndex) const;
105
106
107   }; // end class itkBSplineInterpolateImageFunctionWithLUT
108 } // end namespace
109
110 #ifndef ITK_MANUAL_INSTANTIATION
111 #include "itkBSplineInterpolateImageFunctionWithLUT.txx"
112 #endif
113
114 #endif /* end #define ITKBSPLINEINTERPOLATEIMAGEFUNCTIONWITHLUT_H */