1 /*=========================================================================
2 Program: vv http://www.creatis.insa-lyon.fr/rio/vv
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
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.
13 It is distributed under dual licence
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
22 #include "itkImageLinearIteratorWithIndex.h"
23 #include "vnl/vnl_matrix.h"
25 #include "itkImageToImageFilter.h"
30 template <class TInputImage, class TOutputImage>
31 class ITK_EXPORT VectorBSplineDecompositionImageFilterWithOBD :
32 public itk::ImageToImageFilter<TInputImage,TOutputImage>
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;
41 /** Run-time type information (and related methods). */
42 itkTypeMacro(VectorBSplineDecompositionImageFilterWithOBD, ImageToImageFilter);
44 /** New macro for creation of through a Smart Pointer */
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;
53 /** Dimension underlying input image. */
54 itkStaticConstMacro(ImageDimension, unsigned int,TInputImage::ImageDimension);
55 itkStaticConstMacro(OutputImageDimension, unsigned int,TOutputImage::ImageDimension);
58 typedef typename InputImageType::SizeType SizeType;
61 itkStaticConstMacro(VectorDimension, unsigned int,TInputImage::PixelType::Dimension);
63 /** Iterator typedef support */
64 typedef itk::ImageLinearIteratorWithIndex<TOutputImage> OutputLinearIterator;
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);
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 */
91 VectorBSplineDecompositionImageFilterWithOBD();
92 virtual ~VectorBSplineDecompositionImageFilterWithOBD() {};
93 void PrintSelf(std::ostream& os, itk::Indent indent) const;
97 /** This filter requires all of the input image. */
98 void GenerateInputRequestedRegion();
100 /** This filter must produce all of its output at once. */
101 void EnlargeOutputRequestedRegion( itk::DataObject *output );
103 /** These are needed by the smoothing spline routine. */
104 //JV multiple splineOrders
105 SizeType m_SplineOrders; //SplineOrder by dimension
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
118 VectorBSplineDecompositionImageFilterWithOBD( const Self& ); //purposely not implemented
119 void operator=( const Self& ); //purposely not implemented
121 /** Determines the poles given the Spline Order. */
122 virtual void SetPoles();
124 /** Converts a vector of data to a vector of Spline coefficients. */
125 virtual bool DataToCoefficients1D();
127 /** Converts an N-dimension image of data to an equivalent sized image
128 * of spline coefficients. */
129 void DataToCoefficientsND();
131 /** Determines the first coefficient for the causal filtering of the data. */
132 virtual void SetInitialCausalCoefficient(double z);
134 /** Determines the first coefficient for the anti-causal filtering of the data. */
135 virtual void SetInitialAntiCausalCoefficient(double z);
137 /** Used to initialize the Coefficients image before calculation. */
138 void CopyImageToImage();
140 /** Copies a vector of data from the Coefficients image to the m_Scratch vector. */
141 void CopyCoefficientsToScratch( OutputLinearIterator & );
143 /** Copies a vector of data from m_Scratch to the Coefficients image. */
144 void CopyScratchToCoefficients( OutputLinearIterator & );
151 #ifndef ITK_MANUAL_INSTANTIATION
152 #include "clitkVectorBSplineDecompositionImageFilterWithOBD.txx"