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 __clitkVectorBSplineDecompositionImageFilter_h
19 #define __clitkVectorBSplineDecompositionImageFilter_h
22 #include "itkImageLinearIteratorWithIndex.h"
23 #include "vnl/vnl_matrix.h"
25 #include "itkImageToImageFilter.h"
30 template <class TInputImage, class TOutputImage>
31 class ITK_EXPORT VectorBSplineDecompositionImageFilter :
32 public itk::ImageToImageFilter<TInputImage,TOutputImage>
35 /** Standard class typedefs. */
36 typedef VectorBSplineDecompositionImageFilter Self;
37 typedef itk::ImageToImageFilter<TInputImage,TOutputImage> Superclass;
38 typedef itk::SmartPointer<Self> Pointer;
39 typedef itk::SmartPointer<const Self> ConstPointer;
41 /** Run-time type information (and related methods). */
42 itkTypeMacro(VectorBSplineDecompositionImageFilter, ImageToImageFilter);
44 /** New macro for creation of through a Smart Pointer */
47 /** Inherit input and output image types from Superclass. */
48 typedef typename Superclass::InputImageType InputImageType;
49 typedef typename Superclass::InputImagePointer InputImagePointer;
50 typedef typename Superclass::InputImageConstPointer InputImageConstPointer;
51 typedef typename Superclass::OutputImagePointer OutputImagePointer;
53 /** Dimension underlying input image. */
54 itkStaticConstMacro(ImageDimension, unsigned int,TInputImage::ImageDimension);
55 itkStaticConstMacro(OutputImageDimension, unsigned int,TOutputImage::ImageDimension);
58 itkStaticConstMacro(VectorDimension, unsigned int,TInputImage::PixelType::Dimension);
60 /** Iterator typedef support */
61 typedef itk::ImageLinearIteratorWithIndex<TOutputImage> OutputLinearIterator;
63 /** Get/Sets the Spline Order, supports 0th - 5th order splines. The default
64 * is a 3rd order spline. */
65 void SetSplineOrder(unsigned int SplineOrder);
66 itkGetMacro(SplineOrder, int);
69 //JV modified from the original "double" version
70 #ifdef ITK_USE_CONCEPT_CHECKING
71 /** Begin concept checking */
72 itkConceptMacro(DimensionCheck,
73 (itk::Concept::SameDimension<ImageDimension, OutputImageDimension>));
74 itkConceptMacro(InputConvertibleToDoubleCheck,
75 (itk::Concept::Convertible<typename TInputImage::PixelType, itk::Vector<double, VectorDimension> >));
76 itkConceptMacro(OutputConvertibleToDoubleCheck,
77 (itk::Concept::Convertible<typename TOutputImage::PixelType, itk::Vector<double, VectorDimension> >));
78 itkConceptMacro(InputConvertibleToOutputCheck,
79 (itk::Concept::Convertible<typename TInputImage::PixelType,
80 typename TOutputImage::PixelType>));
81 itkConceptMacro(DoubleConvertibleToOutputCheck,
82 (itk::Concept::Convertible<itk::Vector<double, VectorDimension>, typename TOutputImage::PixelType>));
83 /** End concept checking */
87 VectorBSplineDecompositionImageFilter();
88 virtual ~VectorBSplineDecompositionImageFilter() {};
89 void PrintSelf(std::ostream& os, itk::Indent indent) const;
93 /** This filter requires all of the input image. */
94 void GenerateInputRequestedRegion();
96 /** This filter must produce all of its output at once. */
97 void EnlargeOutputRequestedRegion( itk::DataObject *output );
99 /** These are needed by the smoothing spline routine. */
101 std::vector< itk::Vector<double, VectorDimension> > m_Scratch; // temp storage for processing of Coefficients
102 typename TInputImage::SizeType m_DataLength; // Image size
103 unsigned int m_SplineOrder; // User specified spline order (3rd or cubic is the default)
104 double m_SplinePoles[3];// Poles calculated for a given spline order
105 int m_NumberOfPoles; // number of poles
106 double m_Tolerance; // Tolerance used for determining initial causal coefficient
107 unsigned int m_IteratorDirection; // Direction for iterator incrementing
111 VectorBSplineDecompositionImageFilter( const Self& ); //purposely not implemented
112 void operator=( const Self& ); //purposely not implemented
114 /** Determines the poles given the Spline Order. */
115 virtual void SetPoles();
117 /** Converts a vector of data to a vector of Spline coefficients. */
118 virtual bool DataToCoefficients1D();
120 /** Converts an N-dimension image of data to an equivalent sized image
121 * of spline coefficients. */
122 void DataToCoefficientsND();
124 /** Determines the first coefficient for the causal filtering of the data. */
125 virtual void SetInitialCausalCoefficient(double z);
127 /** Determines the first coefficient for the anti-causal filtering of the data. */
128 virtual void SetInitialAntiCausalCoefficient(double z);
130 /** Used to initialize the Coefficients image before calculation. */
131 void CopyImageToImage();
133 /** Copies a vector of data from the Coefficients image to the m_Scratch vector. */
134 void CopyCoefficientsToScratch( OutputLinearIterator & );
136 /** Copies a vector of data from m_Scratch to the Coefficients image. */
137 void CopyScratchToCoefficients( OutputLinearIterator & );
144 #ifndef ITK_MANUAL_INSTANTIATION
145 #include "clitkVectorBSplineDecompositionImageFilter.txx"