ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkBSplineResampleImageFilterBase.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 /*=========================================================================
00019  *
00020  *  Portions of this file are subject to the VTK Toolkit Version 3 copyright.
00021  *
00022  *  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00023  *
00024  *  For complete copyright, license and disclaimer of warranty information
00025  *  please refer to the NOTICE file at the top of the ITK source tree.
00026  *
00027  *=========================================================================*/
00028 #ifndef __itkBSplineResampleImageFilterBase_h
00029 #define __itkBSplineResampleImageFilterBase_h
00030 
00031 #include <vector>
00032 
00033 #include "itkImageLinearIteratorWithIndex.h"
00034 #include "itkImageRegionIterator.h"   // Used for the output iterator needs to
00035                                       // match filter program
00036 #include "itkProgressReporter.h"
00037 #include "itkImageToImageFilter.h"
00038 
00039 namespace itk
00040 {
00081 template< class TInputImage, class TOutputImage >
00082 class ITK_EXPORT BSplineResampleImageFilterBase:
00083   public ImageToImageFilter< TInputImage, TOutputImage >
00084 {
00085 public:
00087   typedef BSplineResampleImageFilterBase                  Self;
00088   typedef ImageToImageFilter< TInputImage, TOutputImage > Superclass;
00089   typedef SmartPointer< Self >                            Pointer;
00090   typedef SmartPointer< const Self >                      ConstPointer;
00091 
00093   itkTypeMacro(BSplineResampleImageFilterBase, ImageToImageFilter);
00094 
00096   //  Must be sustantiated through another class. itkNewMacro( Self );
00097 
00099   typedef typename Superclass::InputImageType InputImageType;
00100 
00102   itkStaticConstMacro(ImageDimension, unsigned int,
00103                       TInputImage::ImageDimension);
00104 
00106   typedef typename TInputImage::IndexType IndexType;
00107 
00109   typedef typename TInputImage::SizeType SizeType;
00110 
00112   typedef typename TInputImage::RegionType RegionType;
00113 
00115   typedef typename Superclass::OutputImagePixelType OutputImagePixelType;
00116 
00118   typedef itk::ImageLinearConstIteratorWithIndex< TInputImage > ConstInputImageIterator;
00119 
00121   typedef itk::ImageLinearConstIteratorWithIndex< TOutputImage > ConstOutputImageIterator;
00122 
00124   typedef itk::ImageLinearIteratorWithIndex< TOutputImage > OutputImageIterator;
00125 
00128   void SetSplineOrder(int SplineOrder);
00129 
00131   itkGetConstMacro(SplineOrder, int);
00132 protected:
00133 
00135   void ReduceNDImage(OutputImageIterator & OutItr);
00136 
00138   void ExpandNDImage(OutputImageIterator & OutItr);
00139 
00142   virtual void InitializePyramidSplineFilter(int SplineOrder);
00143 
00145   virtual void Reduce1DImage(
00146     const std::vector< double > & In,
00147     OutputImageIterator & Iter,
00148     unsigned int traverseSize,
00149     ProgressReporter & progress
00150     );
00151 
00153   virtual void Expand1DImage(
00154     const std::vector< double > & In,
00155     OutputImageIterator & Iter,
00156     unsigned int traverseSize,
00157     ProgressReporter & progress
00158     );
00159 
00160   BSplineResampleImageFilterBase();
00161   virtual ~BSplineResampleImageFilterBase() {}
00162   void PrintSelf(std::ostream & os, Indent indent) const;
00163 
00164   int m_SplineOrder;                      // User specified spline order
00165   int m_GSize;                            // downsampling filter size
00166   int m_HSize;                            // upsampling filter size
00167 
00168   std::vector< double >       m_G;        // downsampling filter coefficients
00169   std::vector< double >       m_H;        // upsampling filter coefficients
00170 private:
00171 
00172   // Resizes m_Scratch Variable based on image sizes
00173   void InitializeScratch(SizeType DataLength);
00174 
00175   // Copies a line of data from the input to the m_Scratch for subsequent
00176   // processing
00177   void CopyInputLineToScratch(ConstInputImageIterator & Iter);
00178 
00179   void CopyOutputLineToScratch(ConstOutputImageIterator & Iter);
00180 
00181   void CopyLineToScratch(ConstInputImageIterator & Iter);
00182 
00183   std::vector< double >       m_Scratch;        // temp storage for processing
00184                                                 // of Coefficients
00185 
00186   BSplineResampleImageFilterBase(const Self &); //purposely not implemented
00187   void operator=(const Self &);                 //purposely not implemented
00188 };
00189 } // namespace itk
00190 
00191 #ifndef ITK_MANUAL_INSTANTIATION
00192 #include "itkBSplineResampleImageFilterBase.hxx"
00193 #endif
00194 
00195 #endif
00196