ITK  4.0.0
Insight Segmentation and Registration Toolkit
itkVectorCentralDifferenceImageFunction.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 __itkVectorCentralDifferenceImageFunction_h
00019 #define __itkVectorCentralDifferenceImageFunction_h
00020 
00021 #include "itkImageFunction.h"
00022 #include "itkMatrix.h"
00023 
00024 namespace itk
00025 {
00026 #ifndef __itkVectorInterpolateImageFunction_h
00027 
00033 template< typename T >
00034 struct GetDimension {
00035   itkStaticConstMacro(Dimension, int, T::Dimension);
00036 };
00037 #endif
00038 
00057 template<
00058   class TInputImage,
00059   class TCoordRep = float >
00060 class ITK_EXPORT VectorCentralDifferenceImageFunction:
00061   public ImageFunction< TInputImage,
00062                         Matrix< double,                                                            \
00063                                 ::itk::GetDimension< typename TInputImage::PixelType >::Dimension, \
00064                                 ::itk::GetImageDimension< TInputImage >::ImageDimension >,
00065                         TCoordRep >
00066 {
00067 public:
00068   typedef typename TInputImage::PixelType InputPixelType;
00069 
00071   itkStaticConstMacro(Dimension, unsigned int,
00072                       InputPixelType::Dimension);
00073 
00075   itkStaticConstMacro(ImageDimension, unsigned int,
00076                       TInputImage::ImageDimension);
00077 
00079   typedef VectorCentralDifferenceImageFunction Self;
00080   typedef ImageFunction< TInputImage,
00081                          Matrix< double, itkGetStaticConstMacro(Dimension),
00082                                  itkGetStaticConstMacro(ImageDimension) >,
00083                          TCoordRep >       Superclass;
00084   typedef SmartPointer< Self >       Pointer;
00085   typedef SmartPointer< const Self > ConstPointer;
00087 
00089   itkTypeMacro(VectorCentralDifferenceImageFunction, ImageFunction);
00090 
00092   itkNewMacro(Self);
00093 
00095   typedef TInputImage InputImageType;
00096 
00098   typedef typename Superclass::OutputType OutputType;
00099 
00101   typedef typename Superclass::IndexType IndexType;
00102 
00104   typedef typename Superclass::ContinuousIndexType ContinuousIndexType;
00105 
00107   typedef typename Superclass::PointType PointType;
00108 
00116   virtual OutputType EvaluateAtIndex(const IndexType & index) const;
00117 
00126   virtual OutputType Evaluate(const PointType & point) const
00127   {
00128     IndexType index;
00129 
00130     this->ConvertPointToNearestIndex(point, index);
00131     return this->EvaluateAtIndex(index);
00132   }
00133 
00134   virtual OutputType EvaluateAtContinuousIndex(
00135     const ContinuousIndexType & cindex) const
00136   {
00137     IndexType index;
00138 
00139     this->ConvertContinuousIndexToNearestIndex(cindex, index);
00140     return this->EvaluateAtIndex(index);
00141   }
00142 
00153   itkSetMacro(UseImageDirection, bool);
00154   itkGetConstMacro(UseImageDirection, bool);
00155   itkBooleanMacro(UseImageDirection);
00156 protected:
00157   VectorCentralDifferenceImageFunction();
00158   ~VectorCentralDifferenceImageFunction(){}
00159   void PrintSelf(std::ostream & os, Indent indent) const;
00161 
00162 private:
00163   VectorCentralDifferenceImageFunction(const Self &); //purposely not
00164                                                       // implemented
00165   void operator=(const Self &);                       //purposely not
00166                                                       // implemented
00167 
00168   // flag to take or not the image direction into account
00169   // when computing the derivatives.
00170   bool m_UseImageDirection;
00171 };
00172 } // end namespace itk
00173 
00174 #ifndef ITK_MANUAL_INSTANTIATION
00175 #include "itkVectorCentralDifferenceImageFunction.hxx"
00176 #endif
00177 
00178 #endif
00179