1 #ifndef __clitkVectorBSplineDecompositionImageFilter_h
2 #define __clitkVectorBSplineDecompositionImageFilter_h
5 #include "itkImageLinearIteratorWithIndex.h"
6 #include "vnl/vnl_matrix.h"
8 #include "itkImageToImageFilter.h"
13 template <class TInputImage, class TOutputImage>
14 class ITK_EXPORT VectorBSplineDecompositionImageFilter :
15 public itk::ImageToImageFilter<TInputImage,TOutputImage>
18 /** Standard class typedefs. */
19 typedef VectorBSplineDecompositionImageFilter Self;
20 typedef itk::ImageToImageFilter<TInputImage,TOutputImage> Superclass;
21 typedef itk::SmartPointer<Self> Pointer;
22 typedef itk::SmartPointer<const Self> ConstPointer;
24 /** Run-time type information (and related methods). */
25 itkTypeMacro(VectorBSplineDecompositionImageFilter, ImageToImageFilter);
27 /** New macro for creation of through a Smart Pointer */
30 /** Inherit input and output image types from Superclass. */
31 typedef typename Superclass::InputImageType InputImageType;
32 typedef typename Superclass::InputImagePointer InputImagePointer;
33 typedef typename Superclass::InputImageConstPointer InputImageConstPointer;
34 typedef typename Superclass::OutputImagePointer OutputImagePointer;
36 /** Dimension underlying input image. */
37 itkStaticConstMacro(ImageDimension, unsigned int,TInputImage::ImageDimension);
38 itkStaticConstMacro(OutputImageDimension, unsigned int,TOutputImage::ImageDimension);
41 itkStaticConstMacro(VectorDimension, unsigned int,TInputImage::PixelType::Dimension);
43 /** Iterator typedef support */
44 typedef itk::ImageLinearIteratorWithIndex<TOutputImage> OutputLinearIterator;
46 /** Get/Sets the Spline Order, supports 0th - 5th order splines. The default
47 * is a 3rd order spline. */
48 void SetSplineOrder(unsigned int SplineOrder);
49 itkGetMacro(SplineOrder, int);
52 //JV modified from the original "double" version
53 #ifdef ITK_USE_CONCEPT_CHECKING
54 /** Begin concept checking */
55 itkConceptMacro(DimensionCheck,
56 (itk::Concept::SameDimension<ImageDimension, OutputImageDimension>));
57 itkConceptMacro(InputConvertibleToDoubleCheck,
58 (itk::Concept::Convertible<typename TInputImage::PixelType, itk::Vector<double, VectorDimension> >));
59 itkConceptMacro(OutputConvertibleToDoubleCheck,
60 (itk::Concept::Convertible<typename TOutputImage::PixelType, itk::Vector<double, VectorDimension> >));
61 itkConceptMacro(InputConvertibleToOutputCheck,
62 (itk::Concept::Convertible<typename TInputImage::PixelType,
63 typename TOutputImage::PixelType>));
64 itkConceptMacro(DoubleConvertibleToOutputCheck,
65 (itk::Concept::Convertible<itk::Vector<double, VectorDimension>, typename TOutputImage::PixelType>));
66 /** End concept checking */
70 VectorBSplineDecompositionImageFilter();
71 virtual ~VectorBSplineDecompositionImageFilter() {};
72 void PrintSelf(std::ostream& os, itk::Indent indent) const;
76 /** This filter requires all of the input image. */
77 void GenerateInputRequestedRegion();
79 /** This filter must produce all of its output at once. */
80 void EnlargeOutputRequestedRegion( itk::DataObject *output );
82 /** These are needed by the smoothing spline routine. */
84 std::vector< itk::Vector<double, VectorDimension> > m_Scratch; // temp storage for processing of Coefficients
85 typename TInputImage::SizeType m_DataLength; // Image size
86 unsigned int m_SplineOrder; // User specified spline order (3rd or cubic is the default)
87 double m_SplinePoles[3];// Poles calculated for a given spline order
88 int m_NumberOfPoles; // number of poles
89 double m_Tolerance; // Tolerance used for determining initial causal coefficient
90 unsigned int m_IteratorDirection; // Direction for iterator incrementing
94 VectorBSplineDecompositionImageFilter( const Self& ); //purposely not implemented
95 void operator=( const Self& ); //purposely not implemented
97 /** Determines the poles given the Spline Order. */
98 virtual void SetPoles();
100 /** Converts a vector of data to a vector of Spline coefficients. */
101 virtual bool DataToCoefficients1D();
103 /** Converts an N-dimension image of data to an equivalent sized image
104 * of spline coefficients. */
105 void DataToCoefficientsND();
107 /** Determines the first coefficient for the causal filtering of the data. */
108 virtual void SetInitialCausalCoefficient(double z);
110 /** Determines the first coefficient for the anti-causal filtering of the data. */
111 virtual void SetInitialAntiCausalCoefficient(double z);
113 /** Used to initialize the Coefficients image before calculation. */
114 void CopyImageToImage();
116 /** Copies a vector of data from the Coefficients image to the m_Scratch vector. */
117 void CopyCoefficientsToScratch( OutputLinearIterator & );
119 /** Copies a vector of data from m_Scratch to the Coefficients image. */
120 void CopyScratchToCoefficients( OutputLinearIterator & );
127 #ifndef ITK_MANUAL_INSTANTIATION
128 #include "clitkVectorBSplineDecompositionImageFilter.txx"