]> Creatis software - clitk.git/blob - itk/itkBSplineInterpolateImageFunctionWithLUT.h
There were some f***** differences between clitk2 and clitk3 in the BLUT. Tried to...
[clitk.git] / itk / itkBSplineInterpolateImageFunctionWithLUT.h
1 #ifndef ITKBSPLINEINTERPOLATEIMAGEFUNCTIONWITHLUT_H
2 #define ITKBSPLINEINTERPOLATEIMAGEFUNCTIONWITHLUT_H
3
4 /* =========================================================================
5                                                                                 
6   @file   itkBSplineInterpolateImageFunctionWithLUT.h
7   @author David Sarrut <david.sarrut@creatis.insa-lyon.fr>
8
9   Copyright (c) 
10   * CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). 
11     All rights reserved. See Doc/License.txt or
12     http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
13   * Léon Bérard cancer center, 28 rue Laënnec, 69373 Lyon cedex 08, France
14   * http://www.creatis.insa-lyon.fr/rio
15                                                                                 
16   This software is distributed WITHOUT ANY WARRANTY; without even the
17   implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
18   PURPOSE.  See the above copyright notices for more information.
19                                                                              
20 ========================================================================= */
21
22 #include "itkBSplineWeightsCalculator.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 20 (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     
65     /** Evaluate the function at a ContinuousIndex position.
66         Overwritten for taking LUT into account */  
67     virtual OutputType EvaluateAtContinuousIndex(const ContinuousIndexType & index ) const;
68     
69     /** Static convenient functions to compute BSpline weights for
70         various order, dimension, sampling ... **/
71     static void ComputeBlendingWeights(int dim, int order, int sampling, TCoefficientType * weights);
72
73   protected:
74     BSplineInterpolateImageFunctionWithLUT();
75     ~BSplineInterpolateImageFunctionWithLUT(){;}
76
77     SizeType               mSupport;            // nb of coef values used for interpolation (order+1) in 1 dimension
78     SizeType               mHalfSupport;        // half size of the previous
79     unsigned int           mSupportSize;        // Total support size for all dimension
80     std::vector<int>       mSupportOffset;      // Memory pointer offset for going from one coef position to the other (inside the whole support)
81     std::vector<IndexType> mSupportIndex;       // nD Index of all support values
82     IndexType              mInputMemoryOffset;  // Memory dimension offsets for input image
83
84     /** Sampling factors for LUT weights **/
85     SizeType               mSamplingFactors;
86     bool                   mWeightsAreUpToDate;
87     SizeType mSplineOrders;
88
89     // Filter to compute weights
90     itk::BSplineWeightsCalculator<TCoefficientType,TImageType::ImageDimension> mWeightsCalculator;
91
92     // Convenient functions
93     void UpdatePrecomputedWeights();
94     void UpdateWeightsProperties();
95     IndexType GetSampleIndexOfPixelPosition(const ContinuousIndexType & x, IndexType & EvaluateIndex) const;
96
97
98   }; // end class itkBSplineInterpolateImageFunctionWithLUT
99 } // end namespace
100
101 #ifndef ITK_MANUAL_INSTANTIATION
102 #include "itkBSplineInterpolateImageFunctionWithLUT.txx"
103 #endif
104
105 #endif /* end #define ITKBSPLINEINTERPOLATEIMAGEFUNCTIONWITHLUT_H */