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-10-29 11:18:58 $
00007   Version:   $Revision: 1.10 $
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   typedef typename Superclass::IndexValueType IndexValueType;
00287 
00289   typedef TInputImage ImageType;
00290 
00292   typedef typename Superclass::ContinuousIndexType ContinuousIndexType;
00293 
00294   virtual void SetInputImage(const ImageType *image);
00295 
00302   virtual OutputType EvaluateAtContinuousIndex( 
00303     const ContinuousIndexType & index ) const;
00304 
00305 protected:
00306   WindowedSincInterpolateImageFunction();
00307   virtual ~WindowedSincInterpolateImageFunction();
00308   void PrintSelf(std::ostream& os, Indent indent) const;
00309 
00310 private:
00311   WindowedSincInterpolateImageFunction( const Self& ); //not implemented
00312   void operator=( const Self& ); //purposely not implemented
00313 
00314   // Internal typedefs
00315   typedef ConstNeighborhoodIterator<
00316     ImageType, TBoundaryCondition> IteratorType;
00317 
00318   // Constant to store twice the radius
00319   static const unsigned int m_WindowSize;
00320 
00322   TWindowFunction m_WindowFunction;
00323 
00326   unsigned int *m_OffsetTable;
00327 
00329   unsigned int m_OffsetTableSize;
00330 
00332   unsigned int **m_WeightOffsetTable;
00333 
00335   inline double Sinc(double x) const
00336     { 
00337     double px = vnl_math::pi * x;
00338     return (x == 0.0) ? 1.0 : vcl_sin(px) / px;
00339     }
00340 };
00342 
00343 } // namespace itk
00344 
00345 #ifndef ITK_MANUAL_INSTANTIATION
00346 #include "itkWindowedSincInterpolateImageFunction.txx"
00347 #endif
00348 
00349 #endif // _itkWindowedSincInterpolateImageFunction_h
00350 

Generated at Mon Jul 12 2010 20:19:33 for ITK by doxygen 1.7.1 written by Dimitri van Heesch, © 1997-2000