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: 2006/02/06 22:01:57 $
00007   Version:   $Revision: 1.4 $
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         nindex[j] = static_cast<ValueType>( vnl_math_rnd( index[j] ) );
00096         }
00097       }
00098     return static_cast<OutputType>( this->GetInputImage()->GetPixel( nindex ) );
00099   }
00101 
00102 
00110   virtual OutputType EvaluateAtIndex( 
00111     const IndexType & index ) const
00112   {
00113     IndexType nindex;
00114     for ( unsigned int j = 0; j < ImageDimension; j++ )
00115       {
00116       if ( index[j] < this->GetStartIndex()[j] ) 
00117         { 
00118         nindex[j] = this->GetStartIndex()[j]; 
00119         }
00120       else if ( index[j] > this->GetEndIndex()[j] ) 
00121         { 
00122         nindex[j] = this->GetEndIndex()[j];
00123         }
00124       else
00125         {
00126         nindex[j] = index[j];
00127         }
00128       }
00129     return static_cast<OutputType>( this->GetInputImage()->GetPixel( nindex ) );
00130   }
00132 
00133 
00134 protected:
00135   NearestNeighborExtrapolateImageFunction(){};
00136   ~NearestNeighborExtrapolateImageFunction(){};
00137   void PrintSelf(std::ostream& os, Indent indent) const
00138    { Superclass::PrintSelf( os, indent ); }
00139 
00140 private:
00141   NearestNeighborExtrapolateImageFunction(const Self&); //purposely not implemented
00142   void operator=(const Self&); //purposely not implemented
00143 
00144 };
00145 
00146 } // end namespace itk
00147 
00148 #endif
00149 

Generated at Sun Sep 23 13:41:09 2007 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000