00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkNearestNeighborInterpolateImageFunction.h,v $ 00005 Language: C++ 00006 Date: $Date: 2002/09/11 19:57:13 $ 00007 Version: $Revision: 1.8 $ 00008 00009 Copyright (c) 2002 Insight 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>( m_Image->GetPixel( nindex ) ); 00083 } 00084 00085 protected: 00086 NearestNeighborInterpolateImageFunction(){}; 00087 ~NearestNeighborInterpolateImageFunction(){}; 00088 void PrintSelf(std::ostream& os, Indent indent) const 00089 { Superclass::PrintSelf( os, indent ); } 00090 00091 private: 00092 NearestNeighborInterpolateImageFunction(const Self&); //purposely not implemented 00093 void operator=(const Self&); //purposely not implemented 00094 00095 }; 00096 00097 } // namespace itk 00098 00099 #endif