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