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-10-29 17:37:04 $
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 __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   typedef typename Superclass::IndexValueType IndexValueType;
00068 
00070   typedef typename Superclass::ContinuousIndexType ContinuousIndexType;
00071 
00079   virtual OutputType EvaluateAtContinuousIndex( 
00080     const ContinuousIndexType & index ) const
00081     {
00082     IndexType nindex;
00083     for ( unsigned int j = 0; j < ImageDimension; j++ )
00084       {
00085       nindex[j] = Math::RoundHalfIntegerUp<IndexValueType>( index[j] );
00086       if ( nindex[j] < this->GetStartIndex()[j] ) 
00087         { 
00088         nindex[j] = this->GetStartIndex()[j]; 
00089         }
00090       else if ( nindex[j] > this->GetEndIndex()[j] ) 
00091         { 
00092         nindex[j] = this->GetEndIndex()[j];
00093         }
00094       }
00095     return static_cast<OutputType>( this->GetInputImage()->GetPixel( nindex ) );
00096     }
00098 
00099 
00107   virtual OutputType EvaluateAtIndex( 
00108     const IndexType & index ) const
00109     {
00110     IndexType nindex;
00111     for ( unsigned int j = 0; j < ImageDimension; j++ )
00112       {
00113       if ( index[j] < this->GetStartIndex()[j] ) 
00114         { 
00115         nindex[j] = this->GetStartIndex()[j]; 
00116         }
00117       else if ( index[j] > this->GetEndIndex()[j] ) 
00118         { 
00119         nindex[j] = this->GetEndIndex()[j];
00120         }
00121       else
00122         {
00123         nindex[j] = index[j];
00124         }
00125       }
00126     return static_cast<OutputType>( this->GetInputImage()->GetPixel( nindex ) );
00127     }
00129 
00130 
00131 protected:
00132   NearestNeighborExtrapolateImageFunction(){};
00133   ~NearestNeighborExtrapolateImageFunction(){};
00134   void PrintSelf(std::ostream& os, Indent indent) const
00135    { Superclass::PrintSelf( os, indent ); }
00136 
00137 private:
00138   NearestNeighborExtrapolateImageFunction(const Self&); //purposely not implemented
00139   void operator=(const Self&); //purposely not implemented
00140 
00141 };
00142 
00143 } // end namespace itk
00144 
00145 #endif
00146 

Generated at Fri Apr 16 19:09:21 2010 for ITK by doxygen 1.6.1 written by Dimitri van Heesch, © 1997-2000