00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
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 ); }
00076
00084 inline PixelType Get( const InternalPixelType *pixelPointer ) const
00085 {
00086 return PixelType(pixelPointer+(pixelPointer-m_Begin)*m_OffsetMultiplier, m_VectorLength);
00087 }
00088
00090 inline void Set( InternalPixelType* &pixelPointer, const PixelType &p ) const
00091 {
00092 InternalPixelType *truePixelPointer =
00093 pixelPointer + (pixelPointer-m_Begin)*m_OffsetMultiplier;
00094 for( VectorLengthType i=0; i< m_VectorLength; i++ )
00095 {
00096 truePixelPointer[i] = p[i];
00097 }
00098 }
00099
00100 inline PixelType BoundaryCondition(
00101 const OffsetType& point_index,
00102 const OffsetType &boundary_offset,
00103 const NeighborhoodType *data,
00104 const ImageBoundaryConditionConstPointerType boundaryCondition) const
00105 {
00106 return boundaryCondition->operator()(point_index, boundary_offset, data, *this);
00107 }
00108
00109
00112 void SetVectorLength( VectorLengthType length )
00113 {
00114 m_VectorLength = length;
00115 m_OffsetMultiplier = length - 1;
00116 }
00117
00120 VectorLengthType GetVectorLength()
00121 {
00122 return m_VectorLength;
00123 }
00124
00125 private:
00126 VectorLengthType m_VectorLength;
00127 VectorLengthType m_OffsetMultiplier;
00128
00129 InternalPixelType *m_Begin;
00130 };
00131
00132
00133 }
00134 #endif