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

itkVectorImageNeighborhoodAccessorFunctor.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkVectorImageNeighborhoodAccessorFunctor.h,v $
00005   Language:  C++
00006   Date:      $Date: 2009-03-03 15:11:40 $
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 __itkVectorImageNeighborhoodAccessorFunctor_h
00018 #define __itkVectorImageNeighborhoodAccessorFunctor_h
00019 
00020 #include "itkVariableLengthVector.h"
00021 #include "itkImageBoundaryCondition.h"
00022 #include "itkNeighborhood.h"
00023 #include "itkImageBase.h"
00024 
00025 namespace itk
00026 {
00027  
00040 template< class TImage >
00041 class VectorImageNeighborhoodAccessorFunctor
00042 {
00043 public:
00044   typedef TImage                                ImageType;
00045   typedef typename ImageType::PixelType         PixelType;
00046   typedef typename ImageType::InternalPixelType InternalPixelType;
00047   typedef unsigned int                          VectorLengthType;
00048   typedef typename ImageType::OffsetType        OffsetType;
00049 
00050   typedef Neighborhood< InternalPixelType *,
00051           ::itk::GetImageDimension< TImage >::ImageDimension> NeighborhoodType;
00052 
00053   typedef ImageBoundaryCondition< ImageType > const 
00054                           *ImageBoundaryConditionConstPointerType;
00055   
00056   VectorImageNeighborhoodAccessorFunctor( VectorLengthType length ) 
00057       : m_VectorLength( length ), m_OffsetMultiplier( length -1 ) { };
00058   VectorImageNeighborhoodAccessorFunctor() 
00059       : m_VectorLength( 0 ), m_OffsetMultiplier( 0 ) {};
00060   
00074   inline void SetBegin( const InternalPixelType * begin ) 
00075     { this->m_Begin = const_cast< InternalPixelType * >( begin ); }
00077 
00085   inline PixelType Get( const InternalPixelType *pixelPointer ) const 
00086     { 
00087     return PixelType(pixelPointer+(pixelPointer-m_Begin)*m_OffsetMultiplier, m_VectorLength);
00088     }
00089 
00091   inline void Set( InternalPixelType* &pixelPointer, const PixelType &p ) const
00092     {
00093     InternalPixelType *truePixelPointer = 
00094       pixelPointer + (pixelPointer-m_Begin)*m_OffsetMultiplier;
00095     for( VectorLengthType i=0; i< m_VectorLength; i++ ) 
00096       { 
00097       truePixelPointer[i] = p[i];
00098       }
00099     }
00101 
00102   inline PixelType BoundaryCondition( 
00103       const OffsetType& point_index,
00104       const OffsetType &boundary_offset, 
00105       const NeighborhoodType *data,
00106       const ImageBoundaryConditionConstPointerType boundaryCondition) const
00107     {
00108     return boundaryCondition->operator()(point_index, boundary_offset, data, *this);
00109     }
00110 
00111 
00114   void SetVectorLength( VectorLengthType length )
00115     { 
00116     m_VectorLength = length;
00117     m_OffsetMultiplier = length - 1;
00118     }
00119 
00122   VectorLengthType GetVectorLength()
00123     {
00124     return m_VectorLength;
00125     }
00126 
00127 private:
00128   VectorLengthType m_VectorLength; 
00129   VectorLengthType m_OffsetMultiplier; // m_OffsetMultiplier = m_VectorLength-1
00130                                         // (precomputed for speedup).
00131   InternalPixelType *m_Begin; // Begin of the buffer. 
00132 };
00133 
00134 
00135 } // end namespace itk
00136 #endif
00137 

Generated at Tue Sep 15 05:19:03 2009 for ITK by doxygen 1.5.8 written by Dimitri van Heesch, © 1997-2000