Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkNearestNeighborExtrapolateImageFunction.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkNearestNeighborExtrapolateImageFunction.h,v $
00005   Language:  C++
00006   Date:      $Date: 2009-05-16 16:05:13 $
00007   Version:   $Revision: 1.7 $
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 __itkNearestNeighborExtrapolateImageFunction_h
00018 #define __itkNearestNeighborExtrapolateImageFunction_h
00019 
00020 #include "itkExtrapolateImageFunction.h"
00021 
00022 namespace itk
00023 {
00024 
00038 template <class TInputImage, class TCoordRep = float>
00039 class ITK_EXPORT NearestNeighborExtrapolateImageFunction : 
00040   public ExtrapolateImageFunction<TInputImage,TCoordRep> 
00041 {
00042 public:
00044   typedef NearestNeighborExtrapolateImageFunction         Self;
00045   typedef ExtrapolateImageFunction<TInputImage,TCoordRep> Superclass;
00046   typedef SmartPointer<Self>                              Pointer;
00047   typedef SmartPointer<const Self>                        ConstPointer;
00048 
00050   itkTypeMacro(NearestNeighborExtrapolateImageFunction, 
00051     InterpolateImageFunction);
00052 
00054   itkNewMacro(Self);  
00055 
00057   typedef typename Superclass::OutputType OutputType;
00058 
00060   typedef typename Superclass::InputImageType InputImageType;
00061 
00063   itkStaticConstMacro(ImageDimension, unsigned int,Superclass::ImageDimension);
00064 
00066   typedef typename Superclass::IndexType IndexType;
00067 
00069   typedef typename Superclass::ContinuousIndexType ContinuousIndexType;
00070 
00078   virtual OutputType EvaluateAtContinuousIndex( 
00079     const ContinuousIndexType & index ) const
00080     {
00081     typedef typename IndexType::IndexValueType ValueType;
00082     IndexType nindex;
00083     for ( unsigned int j = 0; j < ImageDimension; j++ )
00084       {
00085       if ( index[j] < this->GetStartContinuousIndex()[j] ) 
00086         { 
00087         nindex[j] = this->GetStartIndex()[j]; 
00088         }
00089       else if ( index[j] > this->GetEndContinuousIndex()[j] ) 
00090         { 
00091         nindex[j] = this->GetEndIndex()[j];
00092         }
00093       else
00094         {
00095 #ifdef ITK_USE_CENTERED_PIXEL_COORDINATES_CONSISTENTLY
00096         nindex[j] = static_cast<ValueType>( itk::Math::RoundHalfIntegerUp( index[j] ) );
00097 #else
00098         nindex[j] = static_cast<ValueType>( vnl_math_rnd_halfintup( index[j] ) );
00099 #endif
00100         }
00101       }
00102     return static_cast<OutputType>( this->GetInputImage()->GetPixel( nindex ) );
00103     }
00105 
00106 
00114   virtual OutputType EvaluateAtIndex( 
00115     const IndexType & index ) const
00116     {
00117     IndexType nindex;
00118     for ( unsigned int j = 0; j < ImageDimension; j++ )
00119       {
00120       if ( index[j] < this->GetStartIndex()[j] ) 
00121         { 
00122         nindex[j] = this->GetStartIndex()[j]; 
00123         }
00124       else if ( index[j] > this->GetEndIndex()[j] ) 
00125         { 
00126         nindex[j] = this->GetEndIndex()[j];
00127         }
00128       else
00129         {
00130         nindex[j] = index[j];
00131         }
00132       }
00133     return static_cast<OutputType>( this->GetInputImage()->GetPixel( nindex ) );
00134     }
00136 
00137 
00138 protected:
00139   NearestNeighborExtrapolateImageFunction(){};
00140   ~NearestNeighborExtrapolateImageFunction(){};
00141   void PrintSelf(std::ostream& os, Indent indent) const
00142    { Superclass::PrintSelf( os, indent ); }
00143 
00144 private:
00145   NearestNeighborExtrapolateImageFunction(const Self&); //purposely not implemented
00146   void operator=(const Self&); //purposely not implemented
00147 
00148 };
00149 
00150 } // end namespace itk
00151 
00152 #endif
00153 

Generated at Thu May 28 10:57:02 2009 for ITK by doxygen 1.5.5 written by Dimitri van Heesch, © 1997-2000