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