ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkGaussianInterpolateImageFunction.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkGaussianInterpolateImageFunction.h,v $
00005   Language:  C++
00006   Date:      $Date: $
00007   Version:   $Revision: $
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 __itkGaussianInterpolateImageFunction_h
00018 #define __itkGaussianInterpolateImageFunction_h
00019 
00020 #include "itkInterpolateImageFunction.h"
00021 
00022 #include "itkConceptChecking.h"
00023 #include "itkFixedArray.h"
00024 #include "vnl/vnl_erf.h"
00025 
00026 namespace itk
00027 {
00028 
00050 template <class TInputImage, class TCoordRep = double>
00051 class ITK_EXPORT GaussianInterpolateImageFunction :
00052   public InterpolateImageFunction<TInputImage, TCoordRep>
00053 {
00054 public:
00056   typedef GaussianInterpolateImageFunction                 Self;
00057   typedef InterpolateImageFunction<TInputImage, TCoordRep> Superclass;
00058   typedef SmartPointer<Self>                               Pointer;
00059   typedef SmartPointer<const Self>                         ConstPointer;
00060 
00062   itkTypeMacro( GaussianInterpolateImageFunction, InterpolateImageFunction );
00063 
00065   itkNewMacro( Self );
00066 
00068   itkStaticConstMacro( ImageDimension, unsigned int,
00069     TInputImage::ImageDimension );
00070 
00071 
00073   typedef typename Superclass::OutputType OutputType;
00074 
00076   typedef typename Superclass::InputImageType InputImageType;
00077 
00079   typedef typename Superclass::RealType RealType;
00080 
00082   typedef typename Superclass::IndexType IndexType;
00083 
00085   typedef typename Superclass::ContinuousIndexType ContinuousIndexType;
00086 
00088   typedef FixedArray<RealType, ImageDimension> ArrayType;
00089 
00093   virtual void SetInputImage( const TInputImage *image )
00094     {
00095     Superclass::SetInputImage( image );
00096     this->ComputeBoundingBox();
00097     }
00099 
00103   virtual void SetSigma( const ArrayType s )
00104     {
00105     itkDebugMacro( "setting Sigma to " << s );
00106     if( this->m_Sigma != s )
00107       {
00108       this->m_Sigma = s;
00109       this->ComputeBoundingBox();
00110       this->Modified();
00111       }
00112     }
00113   virtual void SetSigma( RealType *s )
00114     {
00115     ArrayType sigma;
00116     for( unsigned int d = 0; d < ImageDimension; d++ )
00117       {
00118       sigma[d] = s[d];
00119       }
00120     this->SetSigma( sigma );
00121     }
00122   itkGetConstMacro( Sigma, ArrayType );
00124 
00128   virtual void SetAlpha( const RealType a )
00129     {
00130     itkDebugMacro( "setting Alpha to " << a );
00131     if( this->m_Alpha != a )
00132       {
00133       this->m_Alpha = a;
00134       this->ComputeBoundingBox();
00135       this->Modified();
00136       }
00137     }
00138   itkGetConstMacro( Alpha, RealType );
00140 
00144   virtual void SetParameters( RealType *sigma, RealType alpha )
00145     {
00146     this->SetSigma( sigma );
00147     this->SetAlpha( alpha );
00148     }
00150 
00154   virtual OutputType EvaluateAtContinuousIndex(
00155     const ContinuousIndexType & cindex ) const
00156     {
00157     return this->EvaluateAtContinuousIndex( cindex, NULL );
00158     }
00159 
00160 protected:
00161   GaussianInterpolateImageFunction();
00162   ~GaussianInterpolateImageFunction(){};
00163   void PrintSelf( std::ostream& os, Indent indent ) const;
00164 
00165   virtual void ComputeBoundingBox();
00166 
00167   virtual void ComputeErrorFunctionArray( unsigned int dimension, RealType cindex,
00168     vnl_vector<RealType> &erfArray, vnl_vector<RealType> &gerfArray,
00169     bool evaluateGradient = false ) const;
00170 
00171   ArrayType                                 m_Sigma;
00172   RealType                                  m_Alpha;
00173 
00174   ArrayType                                 m_BoundingBoxStart;
00175   ArrayType                                 m_BoundingBoxEnd;
00176   ArrayType                                 m_ScalingFactor;
00177   ArrayType                                 m_CutoffDistance;
00178 
00179 private:
00180   GaussianInterpolateImageFunction( const Self& ); //purposely not implemented
00181   void operator=( const Self& ); //purposely not implemented
00182 
00186   virtual OutputType EvaluateAtContinuousIndex(
00187     const ContinuousIndexType &, OutputType * ) const;
00188 };
00189 
00190 } // end namespace itk
00191 
00192 #ifndef ITK_MANUAL_INSTANTIATION
00193 #include "itkGaussianInterpolateImageFunction.hxx"
00194 #endif
00195 
00196 #endif
00197