ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkNearestNeighborInterpolateImageFunction.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 __itkNearestNeighborInterpolateImageFunction_h
00019 #define __itkNearestNeighborInterpolateImageFunction_h
00020 
00021 #include "itkInterpolateImageFunction.h"
00022 
00023 namespace itk
00024 {
00037 template< class TInputImage, class TCoordRep = double >
00038 class ITK_EXPORT NearestNeighborInterpolateImageFunction:
00039   public InterpolateImageFunction< TInputImage, TCoordRep >
00040 {
00041 public:
00043   typedef NearestNeighborInterpolateImageFunction            Self;
00044   typedef InterpolateImageFunction< TInputImage, TCoordRep > Superclass;
00045   typedef SmartPointer< Self >                               Pointer;
00046   typedef SmartPointer< const Self >                         ConstPointer;
00047 
00049   itkTypeMacro(NearestNeighborInterpolateImageFunction,
00050                InterpolateImageFunction);
00051 
00053   itkNewMacro(Self);
00054 
00056   typedef typename Superclass::OutputType OutputType;
00057 
00059   typedef typename Superclass::InputImageType InputImageType;
00060 
00062   itkStaticConstMacro(ImageDimension, unsigned int, Superclass::ImageDimension);
00063 
00065   typedef typename Superclass::IndexType IndexType;
00066 
00068   typedef typename Superclass::ContinuousIndexType ContinuousIndexType;
00069 
00078   virtual OutputType EvaluateAtContinuousIndex(
00079     const ContinuousIndexType & index) const
00080   {
00081     IndexType nindex;
00082 
00083     this->ConvertContinuousIndexToNearestIndex(index, nindex);
00084     return static_cast< OutputType >( this->GetInputImage()->GetPixel(nindex) );
00085   }
00086 
00087 protected:
00088   NearestNeighborInterpolateImageFunction(){}
00089   ~NearestNeighborInterpolateImageFunction(){}
00090   void PrintSelf(std::ostream & os, Indent indent) const
00091   { Superclass::PrintSelf(os, indent); }
00092 private:
00093   NearestNeighborInterpolateImageFunction(const Self &); //purposely not
00094                                                          // implemented
00095   void operator=(const Self &);                          //purposely not
00096 
00097   // implemented
00098 };
00099 } // end namespace itk
00100 
00101 #endif
00102