ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkCentralDifferenceImageFunction.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 #ifndef __itkCentralDifferenceImageFunction_h
00019 #define __itkCentralDifferenceImageFunction_h
00020 
00021 #include "itkImageFunction.h"
00022 #include "itkCovariantVector.h"
00023 #include "itkInterpolateImageFunction.h"
00024 
00025 namespace itk
00026 {
00040 template<
00041   class TInputImage,
00042   class TCoordRep = float >
00043 class ITK_EXPORT CentralDifferenceImageFunction:
00044   public ImageFunction< TInputImage,
00045                         CovariantVector< double, \
00046                                          TInputImage::ImageDimension >,
00047                         TCoordRep >
00048 {
00049 public:
00050 
00052   itkStaticConstMacro(ImageDimension, unsigned int,
00053                       TInputImage::ImageDimension);
00054 
00056   typedef CentralDifferenceImageFunction Self;
00057   typedef ImageFunction< TInputImage,
00058                          CovariantVector< double,
00059                                           itkGetStaticConstMacro(ImageDimension) >,
00060                          TCoordRep >       Superclass;
00061   typedef SmartPointer< Self >       Pointer;
00062   typedef SmartPointer< const Self > ConstPointer;
00063 
00065   itkTypeMacro(CentralDifferenceImageFunction, ImageFunction);
00066 
00068   itkNewMacro(Self);
00069 
00071   typedef TInputImage InputImageType;
00072 
00074   typedef typename Superclass::OutputType OutputType;
00075 
00077   typedef typename Superclass::IndexType IndexType;
00078 
00080   typedef typename Superclass::ContinuousIndexType ContinuousIndexType;
00081 
00083   typedef typename Superclass::PointType PointType;
00084 
00086   typedef typename TInputImage::SpacingType SpacingType;
00087 
00089   typedef InterpolateImageFunction< TInputImage, TCoordRep > InterpolatorType;
00090   typedef typename InterpolatorType::Pointer                 InterpolatorPointer;
00091 
00093   virtual void SetInputImage(const TInputImage *inputData);
00094 
00097   virtual void SetInterpolator(InterpolatorType *interpolator);
00098 
00100   itkGetConstObjectMacro( Interpolator, InterpolatorType );
00101 
00113   virtual OutputType EvaluateAtIndex(const IndexType & index) const;
00114 
00127   virtual OutputType Evaluate(const PointType & point) const;
00128 
00141   virtual OutputType EvaluateAtContinuousIndex(
00142     const ContinuousIndexType & cindex) const;
00143 
00158   itkSetMacro(UseImageDirection, bool);
00159   itkGetConstMacro(UseImageDirection, bool);
00160   itkBooleanMacro(UseImageDirection);
00161 protected:
00162   CentralDifferenceImageFunction();
00163   ~CentralDifferenceImageFunction(){}
00164   void PrintSelf(std::ostream & os, Indent indent) const;
00166 
00167 private:
00168   CentralDifferenceImageFunction(const Self &); //purposely not implemented
00169   void operator=(const Self &);                 //purposely not implemented
00170 
00171   // flag to take or not the image direction into account
00172   // when computing the derivatives.
00173   bool m_UseImageDirection;
00174 
00175   // interpolator
00176   InterpolatorPointer   m_Interpolator;
00177 };
00178 } // end namespace itk
00179 
00180 // Define instantiation macro for this template.
00181 #define ITK_TEMPLATE_CentralDifferenceImageFunction(_, EXPORT, TypeX, TypeY)     \
00182   namespace itk                                                                  \
00183   {                                                                              \
00184   _( 2 ( class EXPORT CentralDifferenceImageFunction< ITK_TEMPLATE_2 TypeX > ) ) \
00185   namespace Templates                                                            \
00186   {                                                                              \
00187   typedef CentralDifferenceImageFunction< ITK_TEMPLATE_2 TypeX >                 \
00188   CentralDifferenceImageFunction##TypeY;                                       \
00189   }                                                                              \
00190   }
00191 
00192 #if ITK_TEMPLATE_EXPLICIT
00193 // HACK:  template < class TInputImage, class TCoordRep >
00194 //    const unsigned int
00195 // CentralDifferenceImageFunction<TInputImage,TCoordRep>::ImageDimension;
00196 #include "Templates/itkCentralDifferenceImageFunction+-.h"
00197 #endif
00198 
00199 #if ITK_TEMPLATE_TXX
00200 #include "itkCentralDifferenceImageFunction.hxx"
00201 #endif
00202 
00203 #endif
00204