ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkInterpolateImageFunction.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 __itkInterpolateImageFunction_h
00019 #define __itkInterpolateImageFunction_h
00020 
00021 #include "itkImageFunction.h"
00022 
00023 namespace itk
00024 {
00043 template< class TInputImage, class TCoordRep = double >
00044 class ITK_EXPORT InterpolateImageFunction:
00045   public ImageFunction< TInputImage,
00046                         typename NumericTraits< typename TInputImage::PixelType >::RealType, TCoordRep >
00047 {
00048 public:
00050   typedef InterpolateImageFunction Self;
00051   typedef ImageFunction< TInputImage,
00052                          typename NumericTraits< typename TInputImage::PixelType >::RealType,
00053                          TCoordRep >                         Superclass;
00054 
00055   typedef SmartPointer< Self >       Pointer;
00056   typedef SmartPointer< const Self > ConstPointer;
00057 
00059   itkTypeMacro(InterpolateImageFunction, ImageFunction);
00060 
00062   typedef typename Superclass::OutputType OutputType;
00063 
00065   typedef typename Superclass::InputImageType InputImageType;
00066 
00068   itkStaticConstMacro(ImageDimension, unsigned int,
00069                       Superclass::ImageDimension);
00070 
00072   typedef typename Superclass::PointType PointType;
00073 
00075   typedef typename Superclass::IndexType      IndexType;
00076   typedef typename Superclass::IndexValueType IndexValueType;
00077 
00079   typedef typename Superclass::ContinuousIndexType ContinuousIndexType;
00080 
00082   typedef typename NumericTraits< typename TInputImage::PixelType >::RealType RealType;
00083 
00092   virtual OutputType Evaluate(const PointType & point) const
00093   {
00094     ContinuousIndexType index;
00095 
00096     this->GetInputImage()->TransformPhysicalPointToContinuousIndex(point, index);
00097     return ( this->EvaluateAtContinuousIndex(index) );
00098   }
00099 
00110   virtual OutputType EvaluateAtContinuousIndex(
00111     const ContinuousIndexType & index) const = 0;
00112 
00121   virtual OutputType EvaluateAtIndex(const IndexType & index) const
00122   {
00123     return ( static_cast< RealType >( this->GetInputImage()->GetPixel(index) ) );
00124   }
00125 
00126 protected:
00127   InterpolateImageFunction(){}
00128   ~InterpolateImageFunction(){}
00129   void PrintSelf(std::ostream & os, Indent indent) const
00130   { Superclass::PrintSelf(os, indent); }
00131 private:
00132   InterpolateImageFunction(const Self &); //purposely not implemented
00133   void operator=(const Self &);           //purposely not implemented
00134 };
00135 } // end namespace itk
00136 
00137 #endif
00138