]> Creatis software - clitk.git/blob - itk/clitkVectorBSplineDecompositionImageFilter.h
- ggo is now used by the filter
[clitk.git] / itk / clitkVectorBSplineDecompositionImageFilter.h
1 #ifndef __clitkVectorBSplineDecompositionImageFilter_h
2 #define __clitkVectorBSplineDecompositionImageFilter_h
3
4 #include <vector>
5
6 #include "itkImageLinearIteratorWithIndex.h"
7 #include "vnl/vnl_matrix.h"
8
9 #include "itkImageToImageFilter.h"
10
11 namespace clitk
12 {
13
14 template <class TInputImage, class TOutputImage>
15 class ITK_EXPORT VectorBSplineDecompositionImageFilter : 
16     public itk::ImageToImageFilter<TInputImage,TOutputImage>
17 {
18 public:
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;
24
25   /** Run-time type information (and related methods). */
26   itkTypeMacro(VectorBSplineDecompositionImageFilter, ImageToImageFilter);
27  
28   /** New macro for creation of through a Smart Pointer */
29   itkNewMacro( Self );
30
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;
36
37   /** Dimension underlying input image. */
38   itkStaticConstMacro(ImageDimension, unsigned int,TInputImage::ImageDimension);
39   itkStaticConstMacro(OutputImageDimension, unsigned int,TOutputImage::ImageDimension);
40
41   //JV vector dimension
42   itkStaticConstMacro(VectorDimension, unsigned int,TInputImage::PixelType::Dimension);
43
44   /** Iterator typedef support */
45   typedef itk::ImageLinearIteratorWithIndex<TOutputImage> OutputLinearIterator;
46
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);
51
52
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 */
68 #endif
69
70 protected:
71   VectorBSplineDecompositionImageFilter();
72   virtual ~VectorBSplineDecompositionImageFilter() {};
73   void PrintSelf(std::ostream& os, itk::Indent indent) const;
74
75   void GenerateData( );
76
77   /** This filter requires all of the input image. */
78   void GenerateInputRequestedRegion();
79
80   /** This filter must produce all of its output at once. */
81   void EnlargeOutputRequestedRegion( itk::DataObject *output ); 
82
83   /** These are needed by the smoothing spline routine. */
84   //JV
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
92
93
94 private:
95   VectorBSplineDecompositionImageFilter( const Self& ); //purposely not implemented
96   void operator=( const Self& ); //purposely not implemented
97
98   /** Determines the poles given the Spline Order. */
99   virtual void SetPoles();
100
101   /** Converts a vector of data to a vector of Spline coefficients. */
102   virtual bool DataToCoefficients1D();
103
104   /** Converts an N-dimension image of data to an equivalent sized image
105    *    of spline coefficients. */
106   void DataToCoefficientsND();
107
108   /** Determines the first coefficient for the causal filtering of the data. */
109   virtual void SetInitialCausalCoefficient(double z);
110
111   /** Determines the first coefficient for the anti-causal filtering of the data. */
112   virtual void SetInitialAntiCausalCoefficient(double z);
113
114   /** Used to initialize the Coefficients image before calculation. */
115   void CopyImageToImage();
116
117   /** Copies a vector of data from the Coefficients image to the m_Scratch vector. */
118   void CopyCoefficientsToScratch( OutputLinearIterator & );
119
120   /** Copies a vector of data from m_Scratch to the Coefficients image. */
121   void CopyScratchToCoefficients( OutputLinearIterator & );
122   
123 };
124
125
126 } // namespace itk
127
128 #ifndef ITK_MANUAL_INSTANTIATION
129 #include "clitkVectorBSplineDecompositionImageFilter.txx"
130 #endif
131
132 #endif
133