Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkWindowedSincInterpolateImageFunction.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkWindowedSincInterpolateImageFunction.h,v $
00005   Language:  C++
00006   Date:      $Date: 2009-04-06 00:05:54 $
00007   Version:   $Revision: 1.9 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012      This software is distributed WITHOUT ANY WARRANTY; without even 
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00014      PURPOSE.  See the above copyright notices for more information.
00015 
00016 =========================================================================*/
00017 #ifndef __itkWindowedSincInterpolateImageFunction_h
00018 #define __itkWindowedSincInterpolateImageFunction_h
00019 
00020 #include "itkConstNeighborhoodIterator.h"
00021 #include "itkConstantBoundaryCondition.h"
00022 #include "itkInterpolateImageFunction.h"
00023 
00024 namespace itk
00025 {
00026 
00027 namespace Function {
00028 
00035 template< unsigned int VRadius, 
00036   class TInput=double, class TOutput=double>
00037 class CosineWindowFunction
00038 {
00039 public:
00040   inline TOutput operator()( const TInput & A ) const
00041     { return (TOutput) vcl_cos(A * m_Factor ); }
00042 private:
00043 
00045   static const double m_Factor;
00046 }; 
00047 
00054 template< unsigned int VRadius, 
00055   class TInput=double, class TOutput=double>
00056 class HammingWindowFunction
00057 {
00058 public:
00059   inline TOutput operator()( const TInput & A ) const
00060    { return (TOutput) 0.54 + 0.46 * vcl_cos(A * m_Factor ); }
00061 private:
00062 
00064   static const double m_Factor;
00065 }; 
00066 
00073 template< unsigned int VRadius, 
00074   class TInput=double, class TOutput=double>
00075 class WelchWindowFunction
00076 {
00077 public:
00078   inline TOutput operator()( const TInput & A ) const
00079    { return (TOutput) (1.0 - A * m_Factor * A); }
00080 private:
00081 
00083   static const double m_Factor;
00084 }; 
00085 
00094 template< unsigned int VRadius, 
00095   class TInput=double, class TOutput=double>
00096 class LanczosWindowFunction
00097 {
00098 public:
00099   inline TOutput operator()( const TInput & A ) const
00100     {
00101     if(A == 0.0) return (TOutput) 1.0;
00102     double z = m_Factor * A;
00103     return (TOutput) ( vcl_sin(z) / z ); 
00104     }
00105 private:
00106 
00108   static const double m_Factor;
00109 }; 
00110 
00117 template< unsigned int VRadius, 
00118   class TInput=double, class TOutput=double>
00119 class BlackmanWindowFunction
00120 {
00121 public:
00122   inline TOutput operator()( const TInput & A ) const
00123     {
00124     return (TOutput)
00125       (0.42 + 0.5 * vcl_cos(A * m_Factor1) + 0.08 * vcl_cos(A * m_Factor2));
00126     }
00127 private:
00128 
00130   static const double m_Factor1;
00131 
00133   static const double m_Factor2;
00134 }; 
00135 
00136 } // namespace Function
00137 
00247 template <
00248   class TInputImage, 
00249   unsigned int VRadius, 
00250   class TWindowFunction = Function::HammingWindowFunction<VRadius>,
00251   class TBoundaryCondition = ConstantBoundaryCondition<TInputImage>,
00252   class TCoordRep=double >
00253 class ITK_EXPORT WindowedSincInterpolateImageFunction : 
00254   public InterpolateImageFunction<TInputImage, TCoordRep>
00255 {
00256 public:
00257 
00259   typedef WindowedSincInterpolateImageFunction            Self;
00260   typedef InterpolateImageFunction<TInputImage,TCoordRep> Superclass;
00261 
00262   typedef SmartPointer<Self>        Pointer;
00263   typedef SmartPointer<const Self>  ConstPointer;
00264   
00266   itkTypeMacro(WindowedSincInterpolateImageFunction, 
00267     InterpolateImageFunction);
00268 
00270   itkNewMacro(Self);  
00271 
00273   typedef typename Superclass::OutputType OutputType;
00274 
00276   typedef typename Superclass::InputImageType InputImageType;
00277 
00279   typedef typename Superclass::RealType RealType;
00280 
00282   itkStaticConstMacro(ImageDimension, unsigned int,Superclass::ImageDimension);
00283 
00285   typedef typename Superclass::IndexType IndexType;
00286 
00288   typedef TInputImage ImageType;
00289 
00291   typedef typename Superclass::ContinuousIndexType ContinuousIndexType;
00292 
00293   virtual void SetInputImage(const ImageType *image);
00294 
00301   virtual OutputType EvaluateAtContinuousIndex( 
00302     const ContinuousIndexType & index ) const;
00303 
00304 protected:
00305   WindowedSincInterpolateImageFunction();
00306   virtual ~WindowedSincInterpolateImageFunction();
00307   void PrintSelf(std::ostream& os, Indent indent) const;
00308 
00309 private:
00310   WindowedSincInterpolateImageFunction( const Self& ); //not implemented
00311   void operator=( const Self& ); //purposely not implemented
00312 
00313   // Internal typedefs
00314   typedef ConstNeighborhoodIterator<
00315     ImageType, TBoundaryCondition> IteratorType;
00316 
00317   // Constant to store twice the radius
00318   static const unsigned int m_WindowSize;
00319 
00321   TWindowFunction m_WindowFunction;
00322 
00325   unsigned int *m_OffsetTable;
00326 
00328   unsigned int m_OffsetTableSize;
00329 
00331   unsigned int **m_WeightOffsetTable;
00332 
00334   inline double Sinc(double x) const
00335     { 
00336     double px = vnl_math::pi * x;
00337     return (x == 0.0) ? 1.0 : vcl_sin(px) / px;
00338     }
00339 };
00341 
00342 } // namespace itk
00343 
00344 #ifndef ITK_MANUAL_INSTANTIATION
00345 #include "itkWindowedSincInterpolateImageFunction.txx"
00346 #endif
00347 
00348 #endif // _itkWindowedSincInterpolateImageFunction_h
00349 

Generated at Tue Sep 15 05:30:42 2009 for ITK by doxygen 1.5.8 written by Dimitri van Heesch, © 1997-2000