00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkNearestNeighborInterpolateImageFunction.h,v $ 00005 Language: C++ 00006 Date: $Date: 2006-02-06 22:01:57 $ 00007 Version: $Revision: 1.12 $ 00008 00009 Copyright (c) Insight Software Consortium. All rights reserved. 00010 See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 00015 00016 =========================================================================*/ 00017 #ifndef __itkNearestNeighborInterpolateImageFunction_h 00018 #define __itkNearestNeighborInterpolateImageFunction_h 00019 00020 #include "itkInterpolateImageFunction.h" 00021 00022 namespace itk 00023 { 00024 00036 template <class TInputImage, class TCoordRep = float> 00037 class ITK_EXPORT NearestNeighborInterpolateImageFunction : 00038 public InterpolateImageFunction<TInputImage,TCoordRep> 00039 { 00040 public: 00042 typedef NearestNeighborInterpolateImageFunction Self; 00043 typedef InterpolateImageFunction<TInputImage,TCoordRep> Superclass; 00044 typedef SmartPointer<Self> Pointer; 00045 typedef SmartPointer<const Self> ConstPointer; 00046 00048 itkTypeMacro(NearestNeighborInterpolateImageFunction, 00049 InterpolateImageFunction); 00050 00052 itkNewMacro(Self); 00053 00055 typedef typename Superclass::OutputType OutputType; 00056 00058 typedef typename Superclass::InputImageType InputImageType; 00059 00061 itkStaticConstMacro(ImageDimension, unsigned int,Superclass::ImageDimension); 00062 00064 typedef typename Superclass::IndexType IndexType; 00065 00067 typedef typename Superclass::ContinuousIndexType ContinuousIndexType; 00068 00077 virtual OutputType EvaluateAtContinuousIndex( 00078 const ContinuousIndexType & index ) const 00079 { 00080 IndexType nindex; 00081 this->ConvertContinuousIndexToNearestIndex(index, nindex); 00082 return static_cast<OutputType>( this->GetInputImage()->GetPixel( nindex ) ); 00083 } 00085 00086 protected: 00087 NearestNeighborInterpolateImageFunction(){}; 00088 ~NearestNeighborInterpolateImageFunction(){}; 00089 void PrintSelf(std::ostream& os, Indent indent) const 00090 { Superclass::PrintSelf( os, indent ); } 00091 00092 private: 00093 NearestNeighborInterpolateImageFunction(const Self&); //purposely not implemented 00094 void operator=(const Self&); //purposely not implemented 00095 00096 }; 00097 00098 } // end namespace itk 00099 00100 #endif 00101