1 #ifndef __clitkVectorBSplineDecompositionImageFilterWithOBD_h
2 #define __clitkVectorBSplineDecompositionImageFilterWithOBD_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 VectorBSplineDecompositionImageFilterWithOBD :
15 public itk::ImageToImageFilter<TInputImage,TOutputImage>
18 /** Standard class typedefs. */
19 typedef VectorBSplineDecompositionImageFilterWithOBD 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(VectorBSplineDecompositionImageFilterWithOBD, 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 typedef typename InputImageType::SizeType SizeType;
44 itkStaticConstMacro(VectorDimension, unsigned int,TInputImage::PixelType::Dimension);
46 /** Iterator typedef support */
47 typedef itk::ImageLinearIteratorWithIndex<TOutputImage> OutputLinearIterator;
49 /** Get/Sets the Spline Order, supports 0th - 5th order splines. The default
50 * is a 3rd order spline. */
51 void SetSplineOrder(unsigned int SplineOrder);
52 itkGetMacro(SplineOrder, int);
53 //JV Set the order by Dimension
54 void SetSplineOrders(SizeType);
56 //JV modified from the original "double" version
57 #ifdef ITK_USE_CONCEPT_CHECKING
58 /** Begin concept checking */
59 itkConceptMacro(DimensionCheck,
60 (itk::Concept::SameDimension<ImageDimension, OutputImageDimension>));
61 itkConceptMacro(InputConvertibleToDoubleCheck,
62 (itk::Concept::Convertible<typename TInputImage::PixelType, itk::Vector<double, VectorDimension> >));
63 itkConceptMacro(OutputConvertibleToDoubleCheck,
64 (itk::Concept::Convertible<typename TOutputImage::PixelType, itk::Vector<double, VectorDimension> >));
65 itkConceptMacro(InputConvertibleToOutputCheck,
66 (itk::Concept::Convertible<typename TInputImage::PixelType,
67 typename TOutputImage::PixelType>));
68 itkConceptMacro(DoubleConvertibleToOutputCheck,
69 (itk::Concept::Convertible<itk::Vector<double, VectorDimension>, typename TOutputImage::PixelType>));
70 /** End concept checking */
74 VectorBSplineDecompositionImageFilterWithOBD();
75 virtual ~VectorBSplineDecompositionImageFilterWithOBD() {};
76 void PrintSelf(std::ostream& os, itk::Indent indent) const;
80 /** This filter requires all of the input image. */
81 void GenerateInputRequestedRegion();
83 /** This filter must produce all of its output at once. */
84 void EnlargeOutputRequestedRegion( itk::DataObject *output );
86 /** These are needed by the smoothing spline routine. */
87 //JV multiple splineOrders
88 SizeType m_SplineOrders; //SplineOrder by dimension
91 std::vector< itk::Vector<double, VectorDimension> > m_Scratch; // temp storage for processing of Coefficients
92 typename TInputImage::SizeType m_DataLength; // Image size
93 unsigned int m_SplineOrder; // User specified spline order (3rd or cubic is the default)
94 double m_SplinePoles[3];// Poles calculated for a given spline order
95 int m_NumberOfPoles; // number of poles
96 double m_Tolerance; // Tolerance used for determining initial causal coefficient
97 unsigned int m_IteratorDirection; // Direction for iterator incrementing
101 VectorBSplineDecompositionImageFilterWithOBD( const Self& ); //purposely not implemented
102 void operator=( const Self& ); //purposely not implemented
104 /** Determines the poles given the Spline Order. */
105 virtual void SetPoles();
107 /** Converts a vector of data to a vector of Spline coefficients. */
108 virtual bool DataToCoefficients1D();
110 /** Converts an N-dimension image of data to an equivalent sized image
111 * of spline coefficients. */
112 void DataToCoefficientsND();
114 /** Determines the first coefficient for the causal filtering of the data. */
115 virtual void SetInitialCausalCoefficient(double z);
117 /** Determines the first coefficient for the anti-causal filtering of the data. */
118 virtual void SetInitialAntiCausalCoefficient(double z);
120 /** Used to initialize the Coefficients image before calculation. */
121 void CopyImageToImage();
123 /** Copies a vector of data from the Coefficients image to the m_Scratch vector. */
124 void CopyCoefficientsToScratch( OutputLinearIterator & );
126 /** Copies a vector of data from m_Scratch to the Coefficients image. */
127 void CopyScratchToCoefficients( OutputLinearIterator & );
134 #ifndef ITK_MANUAL_INSTANTIATION
135 #include "clitkVectorBSplineDecompositionImageFilterWithOBD.txx"