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