Go to the documentation of this file.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 ); }
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;
00130
00131 InternalPixelType *m_Begin;
00132 };
00133
00134
00135 }
00136 #endif
00137