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