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