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