]> Creatis software - clitk.git/blob - itk/itkBSplineDecompositionImageFilterWithOBD.h
First Modification for Qt5 & VTK6
[clitk.git] / itk / itkBSplineDecompositionImageFilterWithOBD.h
1 /*=========================================================================
2   Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
3
4   Authors belong to: 
5   - University of LYON              http://www.universite-lyon.fr/
6   - Léon Bérard cancer center       http://www.centreleonberard.fr
7   - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
8
9   This software is distributed WITHOUT ANY WARRANTY; without even
10   the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11   PURPOSE.  See the copyright notices for more information.
12
13   It is distributed under dual licence
14
15   - BSD        See included LICENSE.txt file
16   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ===========================================================================**/
18 #ifndef __itkBSplineDecompositionImageFilterWithOBD_h
19 #define __itkBSplineDecompositionImageFilterWithOBD_h
20 #include <vector>
21
22 #include "itkImageLinearIteratorWithIndex.h"
23 #include "vnl/vnl_matrix.h"
24
25 #include "itkImageToImageFilter.h"
26
27 namespace itk
28 {
29
30 template <class TInputImage, class TOutputImage>
31 class ITK_EXPORT BSplineDecompositionImageFilterWithOBD : 
32     public ImageToImageFilter<TInputImage,TOutputImage>
33 {
34 public:
35   /** Standard class typedefs. */
36   typedef BSplineDecompositionImageFilterWithOBD       Self;
37   typedef ImageToImageFilter<TInputImage,TOutputImage>  Superclass;
38   typedef SmartPointer<Self>                    Pointer;
39   typedef SmartPointer<const Self>              ConstPointer;
40
41  /** Run-time type information (and related methods). */
42   itkTypeMacro(BSplineDecompositionImageFilterWithOBD, itk::ImageToImageFilter);
43
44   /** New macro for creation of through a Smart Pointer */
45   itkNewMacro( Self );
46
47   /** Inherit input and output image types from Superclass. */
48   typedef typename Superclass::InputImageType InputImageType;
49   typedef typename Superclass::InputImagePointer InputImagePointer;
50   typedef typename Superclass::InputImageConstPointer InputImageConstPointer;
51   typedef typename Superclass::OutputImagePointer OutputImagePointer;
52
53   //JV add the size 
54   typedef typename InputImageType::SizeType SizeType;
55
56   /** Dimension underlying input image. */
57   itkStaticConstMacro(ImageDimension, unsigned int,TInputImage::ImageDimension);
58   itkStaticConstMacro(OutputImageDimension, unsigned int, TOutputImage::ImageDimension);
59
60   /** Iterator typedef support */
61   typedef ImageLinearIteratorWithIndex<TOutputImage> OutputLinearIterator;
62
63   /** Get/Sets the Spline Order, supports 0th - 5th order splines. The default
64    *  is a 3rd order spline. */
65   //JV only used to set the current order  
66   void SetSplineOrder(unsigned int SplineOrder);
67   //JV  Set the order by Dimension
68   void SetSplineOrders(SizeType);
69
70   itkGetMacro(SplineOrder, int);
71
72 #ifdef ITK_USE_CONCEPT_CHECKING
73   /** Begin concept checking */
74   itkConceptMacro(DimensionCheck,
75     (Concept::SameDimension<ImageDimension, OutputImageDimension>));
76   itkConceptMacro(InputConvertibleToDoubleCheck,
77     (Concept::Convertible<typename TInputImage::PixelType, double>));
78   itkConceptMacro(OutputConvertibleToDoubleCheck,
79     (Concept::Convertible<typename TOutputImage::PixelType, double>));
80   itkConceptMacro(InputConvertibleToOutputCheck,
81      (Concept::Convertible<typename TInputImage::PixelType,
82                            typename TOutputImage::PixelType>));
83   itkConceptMacro(DoubleConvertibleToOutputCheck,
84     (Concept::Convertible<double, typename TOutputImage::PixelType>));
85   /** End concept checking */
86 #endif
87
88 protected:
89   BSplineDecompositionImageFilterWithOBD();
90   virtual ~BSplineDecompositionImageFilterWithOBD() {};
91   void PrintSelf(std::ostream& os, Indent indent) const;
92
93   void GenerateData( );
94
95   /** This filter requires all of the input image. */
96   void GenerateInputRequestedRegion();
97
98   /** This filter must produce all of its output at once. */
99   void EnlargeOutputRequestedRegion( DataObject *output ); 
100
101   /** These are needed by the smoothing spline routine. */
102   std::vector<double>       m_Scratch;       // temp storage for processing of Coefficients
103   typename TInputImage::SizeType   m_DataLength;  // Image size
104   unsigned int              m_SplineOrder;   // User specified spline order (3rd or cubic is the default)
105
106   //JV multiple splineOrders
107   SizeType                  m_SplineOrders; //SplineOrder by dimension 
108
109   double                    m_SplinePoles[3];// Poles calculated for a given spline order
110   int                       m_NumberOfPoles; // number of poles
111   double                    m_Tolerance;     // Tolerance used for determining initial causal coefficient
112   unsigned int              m_IteratorDirection; // Direction for iterator incrementing
113
114
115 private:
116   BSplineDecompositionImageFilterWithOBD( const Self& ); //purposely not implemented
117   void operator=( const Self& ); //purposely not implemented
118
119   /** Determines the poles given the Spline Order. */
120   virtual void SetPoles();
121
122   /** Converts a vector of data to a vector of Spline coefficients. */
123   virtual bool DataToCoefficients1D();
124
125   /** Converts an N-dimension image of data to an equivalent sized image
126    *    of spline coefficients. */
127   void DataToCoefficientsND();
128
129   /** Determines the first coefficient for the causal filtering of the data. */
130   virtual void SetInitialCausalCoefficient(double z);
131
132   /** Determines the first coefficient for the anti-causal filtering of the data. */
133   virtual void SetInitialAntiCausalCoefficient(double z);
134
135   /** Used to initialize the Coefficients image before calculation. */
136   void CopyImageToImage();
137
138   /** Copies a vector of data from the Coefficients image to the m_Scratch vector. */
139   void CopyCoefficientsToScratch( OutputLinearIterator & );
140
141   /** Copies a vector of data from m_Scratch to the Coefficients image. */
142   void CopyScratchToCoefficients( OutputLinearIterator & );
143   
144 };
145
146
147 } // namespace itk
148 #ifndef ITK_MANUAL_INSTANTIATION
149 #include "itkBSplineDecompositionImageFilterWithOBD.txx"
150 #endif
151
152 #endif
153