]> Creatis software - clitk.git/blob - itk/itkBSplineDecompositionImageFilterWithOBD.h
Initial revision
[clitk.git] / itk / itkBSplineDecompositionImageFilterWithOBD.h
1 #ifndef __itkBSplineDecompositionImageFilterWithOBD_h
2 #define __itkBSplineDecompositionImageFilterWithOBD_h
3
4 #include <vector>
5
6 #include "itkImageLinearIteratorWithIndex.h"
7 #include "vnl/vnl_matrix.h"
8
9 #include "itkImageToImageFilter.h"
10
11 namespace itk
12 {
13
14 template <class TInputImage, class TOutputImage>
15 class ITK_EXPORT BSplineDecompositionImageFilterWithOBD : 
16     public ImageToImageFilter<TInputImage,TOutputImage>
17 {
18 public:
19   /** Standard class typedefs. */
20   typedef BSplineDecompositionImageFilterWithOBD       Self;
21   typedef ImageToImageFilter<TInputImage,TOutputImage>  Superclass;
22   typedef SmartPointer<Self>                    Pointer;
23   typedef SmartPointer<const Self>              ConstPointer;
24
25  /** Run-time type information (and related methods). */
26   itkTypeMacro(BSplineDecompositionImageFilterWithOBD, itk::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   //JV add the size 
38   typedef typename InputImageType::SizeType SizeType;
39
40   /** Dimension underlying input image. */
41   itkStaticConstMacro(ImageDimension, unsigned int,TInputImage::ImageDimension);
42   itkStaticConstMacro(OutputImageDimension, unsigned int, TOutputImage::ImageDimension);
43
44   /** Iterator typedef support */
45   typedef ImageLinearIteratorWithIndex<TOutputImage> OutputLinearIterator;
46
47   /** Get/Sets the Spline Order, supports 0th - 5th order splines. The default
48    *  is a 3rd order spline. */
49   //JV only used to set the current order  
50   void SetSplineOrder(unsigned int SplineOrder);
51   //JV  Set the order by Dimension
52   void SetSplineOrders(SizeType);
53
54   itkGetMacro(SplineOrder, int);
55
56 #ifdef ITK_USE_CONCEPT_CHECKING
57   /** Begin concept checking */
58   itkConceptMacro(DimensionCheck,
59     (Concept::SameDimension<ImageDimension, OutputImageDimension>));
60   itkConceptMacro(InputConvertibleToDoubleCheck,
61     (Concept::Convertible<typename TInputImage::PixelType, double>));
62   itkConceptMacro(OutputConvertibleToDoubleCheck,
63     (Concept::Convertible<typename TOutputImage::PixelType, double>));
64   itkConceptMacro(InputConvertibleToOutputCheck,
65      (Concept::Convertible<typename TInputImage::PixelType,
66                            typename TOutputImage::PixelType>));
67   itkConceptMacro(DoubleConvertibleToOutputCheck,
68     (Concept::Convertible<double, typename TOutputImage::PixelType>));
69   /** End concept checking */
70 #endif
71
72 protected:
73   BSplineDecompositionImageFilterWithOBD();
74   virtual ~BSplineDecompositionImageFilterWithOBD() {};
75   void PrintSelf(std::ostream& os, Indent indent) const;
76
77   void GenerateData( );
78
79   /** This filter requires all of the input image. */
80   void GenerateInputRequestedRegion();
81
82   /** This filter must produce all of its output at once. */
83   void EnlargeOutputRequestedRegion( DataObject *output ); 
84
85   /** These are needed by the smoothing spline routine. */
86   std::vector<double>       m_Scratch;       // temp storage for processing of Coefficients
87   typename TInputImage::SizeType   m_DataLength;  // Image size
88   unsigned int              m_SplineOrder;   // User specified spline order (3rd or cubic is the default)
89
90   //JV multiple splineOrders
91   SizeType                  m_SplineOrders; //SplineOrder by dimension 
92
93   double                    m_SplinePoles[3];// Poles calculated for a given spline order
94   int                       m_NumberOfPoles; // number of poles
95   double                    m_Tolerance;     // Tolerance used for determining initial causal coefficient
96   unsigned int              m_IteratorDirection; // Direction for iterator incrementing
97
98
99 private:
100   BSplineDecompositionImageFilterWithOBD( const Self& ); //purposely not implemented
101   void operator=( const Self& ); //purposely not implemented
102
103   /** Determines the poles given the Spline Order. */
104   virtual void SetPoles();
105
106   /** Converts a vector of data to a vector of Spline coefficients. */
107   virtual bool DataToCoefficients1D();
108
109   /** Converts an N-dimension image of data to an equivalent sized image
110    *    of spline coefficients. */
111   void DataToCoefficientsND();
112
113   /** Determines the first coefficient for the causal filtering of the data. */
114   virtual void SetInitialCausalCoefficient(double z);
115
116   /** Determines the first coefficient for the anti-causal filtering of the data. */
117   virtual void SetInitialAntiCausalCoefficient(double z);
118
119   /** Used to initialize the Coefficients image before calculation. */
120   void CopyImageToImage();
121
122   /** Copies a vector of data from the Coefficients image to the m_Scratch vector. */
123   void CopyCoefficientsToScratch( OutputLinearIterator & );
124
125   /** Copies a vector of data from m_Scratch to the Coefficients image. */
126   void CopyScratchToCoefficients( OutputLinearIterator & );
127   
128 };
129
130
131 } // namespace itk
132 #ifndef ITK_MANUAL_INSTANTIATION
133 #include "itkBSplineDecompositionImageFilterWithOBD.txx"
134 #endif
135
136 #endif
137