1 /*=========================================================================
2 Program: vv http://www.creatis.insa-lyon.fr/rio/vv
5 - University of LYON http://www.universite-lyon.fr/
6 - Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
7 - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
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.
13 It is distributed under dual licence
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 /* =========================================================================
22 @file itkBSplineInterpolateImageFunctionWithLUT.h
23 @author David Sarrut <david.sarrut@creatis.insa-lyon.fr>
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
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.
36 ========================================================================= */
38 #include "itkBSplineWeightsCalculator.h"
39 //#include "clitkTimer.h"
40 #include <itkBSplineInterpolateImageFunction.h>
46 class TCoordRep = double,
47 class TCoefficientType = double >
48 class ITK_EXPORT BSplineInterpolateImageFunctionWithLUT :
49 public itk::BSplineInterpolateImageFunction<TImageType,TCoordRep,TCoefficientType> {
53 typedef BSplineInterpolateImageFunctionWithLUT<TImageType,TCoordRep, TCoefficientType> Self;
54 typedef BSplineInterpolateImageFunction<TImageType,TCoordRep, TCoefficientType> Superclass;
55 typedef SmartPointer<Self> Pointer;
56 typedef SmartPointer<const Self> ConstPointer;
57 typedef typename Superclass::OutputType OutputType;
58 typedef typename Superclass::ContinuousIndexType ContinuousIndexType;
59 typedef typename TImageType::IndexType IndexType;
60 typedef typename TImageType::IndexValueType IndexValueType;
61 typedef typename TImageType::SizeType SizeType;
62 typedef typename TImageType::SpacingType SpacingType;
64 /** New macro for creation of through a Smart Pointer */
67 /** Setting LUT sampling (one parameters by dimension or a single
68 one for all dim); Default is 10 (for each dim) **/
69 void SetLUTSamplingFactor(const int& s);
70 void SetLUTSamplingFactors(const SizeType& s);
72 /** Get/Sets the Spline Order, supports 0th - 5th order
73 * splines. The default is a 3rd order spline. */
74 void SetSplineOrder(const unsigned int & SplineOrder);
76 //JV this is added to support different degrees over each dimension
77 void SetSplineOrders(const SizeType & SplineOrders);
79 /** Set the input image. This must be set by the user. */
80 virtual void SetInputImage(const TImageType * inputData);
81 //void SetOutputSpacing(const SpacingType & s);
82 //void SetInputImageIsCoefficient(bool inputIsCoef) { mInputIsCoef = inputIsCoef; }
84 /** Evaluate the function at a ContinuousIndex position.
85 Overwritten for taking LUT into account */
86 virtual OutputType EvaluateAtContinuousIndex(const ContinuousIndexType & index ) const;
88 /** Static convenient functions to compute BSpline weights for
89 various order, dimension, sampling ... **/
90 static void ComputeBlendingWeights(int dim, int order, int sampling, TCoefficientType * weights);
92 /** Timer giving computation time for coefficients computation **/
93 // const clitk::Timer & GetCoefTimer() const { return mCoefficientTimer; }
95 /** Get estimated error **/
97 double GetIntrinsicError() const { return *mIntrinsecError; }
98 long GetNumberOfError() const { return *mNumberOfError; }
99 double GetIntrinsicErrorMax() const { return *mIntrinsecErrorMax; }
102 BSplineInterpolateImageFunctionWithLUT();
103 ~BSplineInterpolateImageFunctionWithLUT(){;}
105 SizeType mSupport; // nb of coef values used for interpolation (order+1) in 1 dimension
106 SizeType mHalfSupport; // half size of the previous
107 unsigned int mSupportSize; // Total support size for all dimension
108 std::vector<int> mSupportOffset; // Memory pointer offset for going from one coef position to the other (inside the whole support)
109 std::vector<IndexType> mSupportIndex; // nD Index of all support values
110 IndexType mInputMemoryOffset; // Memory dimension offsets for input image
112 /** Sampling factors for LUT weights **/
113 SizeType mSamplingFactors;
114 bool mWeightsAreUpToDate;
115 //SpacingType mOutputSpacing;
117 double * mIntrinsecError;
118 double * mIntrinsecErrorMax;
119 long * mNumberOfError;
121 //JV add iscoeff, and splineorders
122 // bool mInputIsCoef;
123 SizeType mSplineOrders;
125 // Filter to compute weights
126 itk::BSplineWeightsCalculator<TCoefficientType,TImageType::ImageDimension> mWeightsCalculator;
128 // Convenient functions
129 void UpdatePrecomputedWeights();
130 void UpdateWeightsProperties();
131 IndexType GetSampleIndexOfPixelPosition(const ContinuousIndexType & x, IndexType & EvaluateIndex) const;
134 // clitk::Timer mCoefficientTimer;
135 // clitk::Timer mLUTTimer;
138 //JV threadsafety: everything on the stack
139 //std::vector<int> mCorrectedSupportOffset;
140 //std::vector<IndexType> mCorrectedSupportIndex;
141 TCoefficientType * coef;
143 }; // end class itkBSplineInterpolateImageFunctionWithLUT
146 #ifndef ITK_MANUAL_INSTANTIATION
147 #include "itkBSplineInterpolateImageFunctionWithLUT.txx"
150 #endif /* end #define ITKBSPLINEINTERPOLATEIMAGEFUNCTIONWITHLUT_H */