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://www.centreleonberard.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 __clitkVectorBSplineInterpolateImageFunctionWithLUT_h
19 #define __clitkVectorBSplineInterpolateImageFunctionWithLUT_h
20 /* =========================================================================
22 @file clitVectorkBSplineInterpolateImageFunctionWithLUT.h
23 @author jefvdmb@gmail.com
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 "clitkVectorBSplineInterpolateImageFunction.h"
45 class TCoordRep = double,
46 class TCoefficientType = double >
47 class ITK_EXPORT VectorBSplineInterpolateImageFunctionWithLUT :
48 public VectorBSplineInterpolateImageFunction<TImageType,TCoordRep,TCoefficientType> {
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;
63 typedef TCoefficientType CoefficientDataType;
64 typedef typename Superclass::CoefficientImagePixelType CoefficientImagePixelType;
65 typedef typename Superclass::CoefficientImageType CoefficientImageType;
67 /** New macro for creation of through a Smart Pointer */
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);
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);
79 //JV this is added to support different degrees over each dimension
80 void SetSplineOrders(const SizeType & SplineOrders);
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; }
87 /** Evaluate the function at a ContinuousIndex position.
88 Overwritten for taking LUT into account (RP: multi-threading-compatible version,
89 the threadID is actually ignored) */
90 virtual OutputType EvaluateAtContinuousIndex(const ContinuousIndexType & index, unsigned int /* threadID */ ) const
92 std::cout << "EvaluateAtContinuousIndex" << std::endl;
93 return this->EvaluateAtContinuousIndex( index );
96 /** Evaluate the function at a ContinuousIndex position.
97 Overwritten for taking LUT into account */
98 virtual OutputType EvaluateAtContinuousIndex(const ContinuousIndexType & index ) const;
99 void EvaluateWeightsAtContinuousIndex(const ContinuousIndexType & x, const TCoefficientType ** pweights, IndexType & evaluateIndex) const;
101 /** Static convenient functions to compute BSpline weights for
102 various order, dimension, sampling ... **/
103 static void ComputeBlendingWeights(int dim, int order, int sampling, TCoefficientType * weights);
106 VectorBSplineInterpolateImageFunctionWithLUT();
107 ~VectorBSplineInterpolateImageFunctionWithLUT(){;}
109 SizeType mSupport; // nb of coef values used for interpolation (order+1) in 1 dimension
110 SizeType mHalfSupport; // half size of the previous
111 unsigned int mSupportSize; // Total support size for all dimension
112 std::vector<int> mSupportOffset; // Memory pointer offset for going from one coef position to the other (inside the whole support)
113 std::vector<IndexType> mSupportIndex; // nD Index of all support values
114 IndexType mInputMemoryOffset; // Memory dimension offsets for input image
116 /** Sampling factors for LUT weights **/
117 SizeType mSamplingFactors;
118 bool mWeightsAreUpToDate;
119 SizeType mSplineOrders;
121 // Filter to compute weights
122 itk::BSplineWeightsCalculator<TCoefficientType,TImageType::ImageDimension> mWeightsCalculator;
124 // Convenient functions
125 void UpdatePrecomputedWeights();
126 void UpdateWeightsProperties();
127 IndexType GetSampleIndexOfPixelPosition(const ContinuousIndexType & x, IndexType & EvaluateIndex) const;
130 }; // end class clitkVectorBSplineInterpolateImageFunctionWithLUT
133 #ifndef ITK_MANUAL_INSTANTIATION
134 #include "clitkVectorBSplineInterpolateImageFunctionWithLUT.txx"
137 #endif /* end #define CLITKBSPLINEINTERPOLATEIMAGEFUNCTIONWITHLUT_H */