]> Creatis software - clitk.git/blob - itk/clitkVectorBSplineDecompositionImageFilterWithOBD.h
Initial revision
[clitk.git] / itk / clitkVectorBSplineDecompositionImageFilterWithOBD.h
1 #ifndef __clitkVectorBSplineDecompositionImageFilterWithOBD_h
2 #define __clitkVectorBSplineDecompositionImageFilterWithOBD_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 VectorBSplineDecompositionImageFilterWithOBD : 
16     public itk::ImageToImageFilter<TInputImage,TOutputImage>
17 {
18 public:
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;
24
25   /** Run-time type information (and related methods). */
26   itkTypeMacro(VectorBSplineDecompositionImageFilterWithOBD, 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 add the size 
42   typedef typename InputImageType::SizeType SizeType;
43
44   //JV vector dimension
45   itkStaticConstMacro(VectorDimension, unsigned int,TInputImage::PixelType::Dimension);
46
47   /** Iterator typedef support */
48   typedef itk::ImageLinearIteratorWithIndex<TOutputImage> OutputLinearIterator;
49
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);
56
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 */
72 #endif
73
74 protected:
75   VectorBSplineDecompositionImageFilterWithOBD();
76   virtual ~VectorBSplineDecompositionImageFilterWithOBD() {};
77   void PrintSelf(std::ostream& os, itk::Indent indent) const;
78
79   void GenerateData( );
80
81   /** This filter requires all of the input image. */
82   void GenerateInputRequestedRegion();
83
84   /** This filter must produce all of its output at once. */
85   void EnlargeOutputRequestedRegion( itk::DataObject *output ); 
86
87   /** These are needed by the smoothing spline routine. */
88   //JV multiple splineOrders
89   SizeType                  m_SplineOrders; //SplineOrder by dimension 
90
91   //JV
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
99
100
101 private:
102   VectorBSplineDecompositionImageFilterWithOBD( const Self& ); //purposely not implemented
103   void operator=( const Self& ); //purposely not implemented
104
105   /** Determines the poles given the Spline Order. */
106   virtual void SetPoles();
107
108   /** Converts a vector of data to a vector of Spline coefficients. */
109   virtual bool DataToCoefficients1D();
110
111   /** Converts an N-dimension image of data to an equivalent sized image
112    *    of spline coefficients. */
113   void DataToCoefficientsND();
114
115   /** Determines the first coefficient for the causal filtering of the data. */
116   virtual void SetInitialCausalCoefficient(double z);
117
118   /** Determines the first coefficient for the anti-causal filtering of the data. */
119   virtual void SetInitialAntiCausalCoefficient(double z);
120
121   /** Used to initialize the Coefficients image before calculation. */
122   void CopyImageToImage();
123
124   /** Copies a vector of data from the Coefficients image to the m_Scratch vector. */
125   void CopyCoefficientsToScratch( OutputLinearIterator & );
126
127   /** Copies a vector of data from m_Scratch to the Coefficients image. */
128   void CopyScratchToCoefficients( OutputLinearIterator & );
129   
130 };
131
132
133 } // namespace clitk
134
135 #ifndef ITK_MANUAL_INSTANTIATION
136 #include "clitkVectorBSplineDecompositionImageFilterWithOBD.txx"
137 #endif
138
139 #endif
140