00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkBSplineDecompositionImageFilter.h,v $ 00005 Language: C++ 00006 Date: $Date: 2002/09/11 23:28:23 $ 00007 Version: $Revision: 1.2 $ 00008 00009 Copyright (c) 2002 Insight Consortium. All rights reserved. 00010 See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. 00011 00012 Portions of this code are covered under the VTK copyright. 00013 See VTKCopyright.txt or http://www.kitware.com/VTKCopyright.htm for details. 00014 00015 This software is distributed WITHOUT ANY WARRANTY; without even 00016 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00017 PURPOSE. See the above copyright notices for more information. 00018 00019 =========================================================================*/ 00020 00021 #ifndef __itkBSplineDecompositionImageFilter_h 00022 #define __itkBSplineDecompositionImageFilter_h 00023 00024 #include <vector> 00025 00026 #include "itkImageLinearIteratorWithIndex.h" 00027 #include "vnl/vnl_matrix.h" 00028 00029 #include "itkImageToImageFilter.h" 00030 00031 namespace itk 00032 { 00065 template <class TInputImage, class TOutputImage> 00066 class ITK_EXPORT BSplineDecompositionImageFilter : 00067 public ImageToImageFilter<TInputImage,TOutputImage> 00068 { 00069 public: 00071 typedef BSplineDecompositionImageFilter Self; 00072 typedef ImageToImageFilter<TInputImage,TOutputImage> Superclass; 00073 typedef SmartPointer<Self> Pointer; 00074 typedef SmartPointer<const Self> ConstPointer; 00075 00077 itkTypeMacro(BSplineDecompositionImageFilter, ImageToImageFilter); 00078 00079 00081 itkNewMacro( Self ); 00082 00084 typedef typename TOutputImage::Pointer OutputImagePointer; 00085 typedef typename TInputImage::Pointer InputImagePointer; 00086 00088 typedef typename Superclass::InputImageType InputImageType; 00089 00091 enum { ImageDimension = TInputImage::ImageDimension }; 00092 00094 typedef itk::ImageLinearIteratorWithIndex<TInputImage> Iterator; 00095 00096 00099 void SetSplineOrder(unsigned int SplineOrder); 00100 00101 itkGetMacro(SplineOrder, int); 00102 00104 virtual void SetInput(const TInputImage * inputData); 00105 virtual void SetInput( unsigned int, const TInputImage * image); 00106 00108 void GenerateInputRequestedRegion(); 00109 00110 protected: 00111 BSplineDecompositionImageFilter(); 00112 virtual ~BSplineDecompositionImageFilter() {}; 00113 void PrintSelf(std::ostream& os, Indent indent) const; 00114 00115 void GenerateData( ); 00116 void EnlargeOutputRequestedRegion( DataObject *output ); 00117 void GenerateOutputInformation(); 00118 00119 private: 00121 virtual void SetPoles(); 00122 00124 virtual bool DataToCoefficients1D(); 00125 00128 void DataToCoefficientsND(InputImagePointer inPtr, OutputImagePointer outPtr); 00129 00131 virtual void SetInitialCausalCoefficient(double z); 00132 00134 virtual void SetInitialAntiCausalCoefficient(double z); 00135 00137 void CopyImageToImage(const TInputImage * input, TOutputImage * output ); 00138 00140 void CopyCoefficientsToScratch( Iterator & ); 00141 00143 void CopyScratchToCoefficients( Iterator & ); 00144 00145 // These are needed by the smoothing spline routine. 00146 protected: 00147 std::vector<double> m_Scratch; // temp storage for processing of Coefficients 00148 typename TInputImage::SizeType m_DataLength; // Image size 00149 unsigned int m_SplineOrder; // User specified spline order (3rd or cubic is the default) 00150 double m_SplinePoles[3];// Poles calculated for a given spline order 00151 int m_NumberOfPoles; // number of poles 00152 double m_Tolerance; // Tolerance used for determining initial causal coefficient 00153 unsigned int m_IteratorDirection; // Direction for iterator incrementing 00154 00155 private: 00156 BSplineDecompositionImageFilter( const Self& ); //purposely not implemented 00157 void operator=( const Self& ); //purposely not implemented 00158 00159 }; 00160 00161 } // namespace itk 00162 00163 #ifndef ITK_MANUAL_INSTANTIATION 00164 #include "itkBSplineDecompositionImageFilter.txx" 00165 #endif 00166 00167 #endif 00168