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 __itkBSplineDecompositionImageFilterWithOBD_h
19 #define __itkBSplineDecompositionImageFilterWithOBD_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 BSplineDecompositionImageFilterWithOBD :
32 public ImageToImageFilter<TInputImage,TOutputImage>
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;
41 /** Run-time type information (and related methods). */
42 itkTypeMacro(BSplineDecompositionImageFilterWithOBD, itk::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;
54 typedef typename InputImageType::SizeType SizeType;
56 /** Dimension underlying input image. */
57 itkStaticConstMacro(ImageDimension, unsigned int,TInputImage::ImageDimension);
58 itkStaticConstMacro(OutputImageDimension, unsigned int, TOutputImage::ImageDimension);
60 /** Iterator typedef support */
61 typedef ImageLinearIteratorWithIndex<TOutputImage> OutputLinearIterator;
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);
70 itkGetMacro(SplineOrder, int);
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 */
89 BSplineDecompositionImageFilterWithOBD();
90 virtual ~BSplineDecompositionImageFilterWithOBD() {};
91 void PrintSelf(std::ostream& os, Indent indent) const;
95 /** This filter requires all of the input image. */
96 void GenerateInputRequestedRegion();
98 /** This filter must produce all of its output at once. */
99 void EnlargeOutputRequestedRegion( DataObject *output );
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)
106 //JV multiple splineOrders
107 SizeType m_SplineOrders; //SplineOrder by dimension
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
116 BSplineDecompositionImageFilterWithOBD( const Self& ); //purposely not implemented
117 void operator=( const Self& ); //purposely not implemented
119 /** Determines the poles given the Spline Order. */
120 virtual void SetPoles();
122 /** Converts a vector of data to a vector of Spline coefficients. */
123 virtual bool DataToCoefficients1D();
125 /** Converts an N-dimension image of data to an equivalent sized image
126 * of spline coefficients. */
127 void DataToCoefficientsND();
129 /** Determines the first coefficient for the causal filtering of the data. */
130 virtual void SetInitialCausalCoefficient(double z);
132 /** Determines the first coefficient for the anti-causal filtering of the data. */
133 virtual void SetInitialAntiCausalCoefficient(double z);
135 /** Used to initialize the Coefficients image before calculation. */
136 void CopyImageToImage();
138 /** Copies a vector of data from the Coefficients image to the m_Scratch vector. */
139 void CopyCoefficientsToScratch( OutputLinearIterator & );
141 /** Copies a vector of data from m_Scratch to the Coefficients image. */
142 void CopyScratchToCoefficients( OutputLinearIterator & );
148 #ifndef ITK_MANUAL_INSTANTIATION
149 #include "itkBSplineDecompositionImageFilterWithOBD.txx"