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