ITK  4.2.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 
00140   virtual OutputType EvaluateAtContinuousIndex(
00141     const ContinuousIndexType & cindex) const;
00142 
00157   itkSetMacro(UseImageDirection, bool);
00158   itkGetConstMacro(UseImageDirection, bool);
00159   itkBooleanMacro(UseImageDirection);
00160 protected:
00161   CentralDifferenceImageFunction();
00162   ~CentralDifferenceImageFunction(){}
00163   void PrintSelf(std::ostream & os, Indent indent) const;
00165 
00166 private:
00167   CentralDifferenceImageFunction(const Self &); //purposely not implemented
00168   void operator=(const Self &);                 //purposely not implemented
00169 
00170   // flag to take or not the image direction into account
00171   // when computing the derivatives.
00172   bool m_UseImageDirection;
00173 
00174   // interpolator
00175   InterpolatorPointer   m_Interpolator;
00176 };
00177 } // end namespace itk
00178 
00179 // Define instantiation macro for this template.
00180 #define ITK_TEMPLATE_CentralDifferenceImageFunction(_, EXPORT, TypeX, TypeY)     \
00181   namespace itk                                                                  \
00182   {                                                                              \
00183   _( 2 ( class EXPORT CentralDifferenceImageFunction< ITK_TEMPLATE_2 TypeX > ) ) \
00184   namespace Templates                                                            \
00185   {                                                                              \
00186   typedef CentralDifferenceImageFunction< ITK_TEMPLATE_2 TypeX >                 \
00187   CentralDifferenceImageFunction##TypeY;                                       \
00188   }                                                                              \
00189   }
00190 
00191 #if ITK_TEMPLATE_EXPLICIT
00192 // HACK:  template < class TInputImage, class TCoordRep >
00193 //    const unsigned int
00194 // CentralDifferenceImageFunction<TInputImage,TCoordRep>::ImageDimension;
00195 #include "Templates/itkCentralDifferenceImageFunction+-.h"
00196 #endif
00197 
00198 #if ITK_TEMPLATE_TXX
00199 #include "itkCentralDifferenceImageFunction.hxx"
00200 #endif
00201 
00202 #endif
00203