1 /* =========================================================================
3 @file itkBSplineInterpolateImageFunctionWithLUT.h
4 @author David Sarrut <david.sarrut@creatis.insa-lyon.fr>
7 * CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image).
8 All rights reserved. See Doc/License.txt or
9 http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
10 * Léon Bérard cancer center, 28 rue Laënnec, 69373 Lyon cedex 08, France
11 * http://www.creatis.insa-lyon.fr/rio
13 This software is distributed WITHOUT ANY WARRANTY; without even the
14 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 PURPOSE. See the above copyright notices for more information.
17 ========================================================================= */
19 #ifndef ITKBSPLINEINTERPOLATEIMAGEFUNCTIONWITHLUT_H
20 #define ITKBSPLINEINTERPOLATEIMAGEFUNCTIONWITHLUT_H
21 #include "itkCastImageFilter.h"
22 #include "itkBSplineWeightsCalculator.h"
23 //#include "clitkTimer.h"
25 #include <itkBSplineInterpolateImageFunction.h>
31 class TCoordRep = double,
32 class TCoefficientType = double >
33 class ITK_EXPORT BSplineInterpolateImageFunctionWithLUT :
34 public itk::BSplineInterpolateImageFunction<TImageType,TCoordRep,TCoefficientType> {
38 typedef BSplineInterpolateImageFunctionWithLUT<TImageType,TCoordRep, TCoefficientType> Self;
39 typedef BSplineInterpolateImageFunction<TImageType,TCoordRep, TCoefficientType> Superclass;
40 typedef SmartPointer<Self> Pointer;
41 typedef SmartPointer<const Self> ConstPointer;
42 typedef typename Superclass::OutputType OutputType;
43 typedef typename Superclass::ContinuousIndexType ContinuousIndexType;
44 typedef typename TImageType::IndexType IndexType;
45 typedef typename TImageType::IndexValueType IndexValueType;
46 typedef typename TImageType::SizeType SizeType;
47 typedef typename TImageType::SpacingType SpacingType;
49 /** New macro for creation of through a Smart Pointer */
51 BSplineInterpolateImageFunctionWithLUT();
53 /** Setting LUT sampling (one parameters by dimension or a single
54 one for all dim); Default is 10 (for each dim) **/
55 void SetLUTSamplingFactor(int s);
56 void SetLUTSamplingFactors(int * s);
58 /** Get/Sets the Spline Order, supports 0th - 5th order
59 * splines. The default is a 3rd order spline. */
60 void SetSplineOrder(unsigned int SplineOrder);
62 //JV this is added to support different degrees over each dimension
63 void SetSplineOrders( SizeType SplineOrders);
65 /** Set the input image. This must be set by the user. */
66 virtual void SetInputImage(const TImageType * inputData);
67 void SetOutputSpacing(const SpacingType & s);
68 void SetInputImageIsCoefficient(bool inputIsCoef) { mInputIsCoef = inputIsCoef; }
70 /** Evaluate the function at a ContinuousIndex position.
71 Overwritten for taking LUT into account */
72 virtual OutputType EvaluateAtContinuousIndex(const ContinuousIndexType & index ) const;
74 /** Static convenient functions to compute BSpline weights for
75 various order, dimension, sampling ... **/
76 static void ComputeBlendingWeights(int dim, int order, int sampling, TCoefficientType * weights);
78 /** Timer giving computation time for coefficients computation **/
79 // const clitk::Timer & GetCoefTimer() const { return mCoefficientTimer; }
81 /** Get estimated error **/
83 double GetIntrinsicError() const { return *mIntrinsecError; }
84 long GetNumberOfError() const { return *mNumberOfError; }
85 double GetIntrinsicErrorMax() const { return *mIntrinsecErrorMax; }
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
95 /** Sampling factors for LUT weights **/
96 SizeType mSamplingFactors;
97 bool mWeightsAreUpToDate;
98 SpacingType mOutputSpacing;
100 double * mIntrinsecError;
101 double * mIntrinsecErrorMax;
102 long * mNumberOfError;
104 //JV add iscoeff, and splineorders
106 SizeType mSplineOrders;
108 // Filter to compute weights
109 itk::BSplineWeightsCalculator<TCoefficientType,TImageType::ImageDimension> mWeightsCalculator;
111 // Convenient functions
112 void UpdatePrecomputedWeights();
113 IndexType GetSampleIndexOfPixelPosition(const ContinuousIndexType & x, IndexType & EvaluateIndex) const;
116 // clitk::Timer mCoefficientTimer;
117 // clitk::Timer mLUTTimer;
120 std::vector<int> mCorrectedSupportOffset;
121 TCoefficientType * coef;
123 std::vector<IndexType> mCorrectedSupportIndex;
125 }; // end class itkBSplineInterpolateImageFunctionWithLUT
127 #include "itkBSplineInterpolateImageFunctionWithLUT.txx"
131 #endif /* end #define ITKBSPLINEINTERPOLATEIMAGEFUNCTIONWITHLUT_H */