00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkVectorImage_h
00018 #define __itkVectorImage_h
00019
00020 #include "itkImage.h"
00021 #include "itkImageRegion.h"
00022 #include "itkImportImageContainer.h"
00023 #include "itkDefaultVectorPixelAccessor.h"
00024 #include "itkDefaultVectorPixelAccessorFunctor.h"
00025 #include "itkVectorImageNeighborhoodAccessorFunctor.h"
00026 #include "itkPoint.h"
00027 #include "itkContinuousIndex.h"
00028 #include "itkVariableLengthVector.h"
00029 #include "itkWeakPointer.h"
00030
00031 namespace itk
00032 {
00033
00085 template <class TPixel, unsigned int VImageDimension=3 >
00086 class ITK_EXPORT VectorImage :
00087 public Image< VariableLengthVector< TPixel >, VImageDimension >
00088 {
00089 public:
00091 typedef VectorImage Self;
00092 typedef ImageBase<VImageDimension> Superclass;
00093 typedef SmartPointer<Self> Pointer;
00094 typedef SmartPointer<const Self> ConstPointer;
00095 typedef WeakPointer<const Self> ConstWeakPointer;
00096
00098 itkNewMacro(Self);
00099
00101 itkTypeMacro(VectorImage, Image);
00102
00107 typedef VariableLengthVector< TPixel > PixelType;
00108
00112 typedef TPixel InternalPixelType;
00113
00115 typedef TPixel ValueType ;
00116
00119 typedef DefaultVectorPixelAccessor< InternalPixelType > AccessorType;
00120
00123 typedef DefaultVectorPixelAccessorFunctor< Self > AccessorFunctorType;
00124
00126 typedef VectorImageNeighborhoodAccessorFunctor<
00127 Self > NeighborhoodAccessorFunctorType;
00128
00130 typedef ImportImageContainer<unsigned long, InternalPixelType> PixelContainer;
00131
00133 typedef typename Superclass::IndexType IndexType;
00134
00136 typedef typename Superclass::OffsetType OffsetType;
00137
00139 typedef typename Superclass::SizeType SizeType;
00140
00142 typedef typename Superclass::DirectionType DirectionType;
00143
00145 typedef typename Superclass::RegionType RegionType;
00146
00149 typedef typename Superclass::SpacingType SpacingType;
00150
00153 typedef typename Superclass::PointType PointType;
00154
00156 typedef typename PixelContainer::Pointer PixelContainerPointer;
00157 typedef typename PixelContainer::ConstPointer PixelContainerConstPointer;
00158
00160 typedef typename Superclass::OffsetValueType OffsetValueType;
00161
00162 typedef unsigned int VectorLengthType;
00163
00166 void Allocate();
00167
00170 virtual void Initialize();
00171
00174 void FillBuffer(const PixelType& value);
00175
00176 void SetPixel( const IndexType &index, const PixelType& value )
00177 {
00178 OffsetValueType offset = m_VectorLength * this->ComputeOffset(index);
00179 for( VectorLengthType i = 0; i < m_VectorLength; i++ )
00180 {
00181 (*m_Buffer)[offset + i] = value[i];
00182 }
00183 }
00184
00189 const PixelType GetPixel(const IndexType &index) const
00190 {
00191 OffsetValueType offset = m_VectorLength * this->ComputeOffset(index);
00192 PixelType p( &((*m_Buffer)[offset]), m_VectorLength );
00193 return p;
00194 }
00195
00200 PixelType GetPixel(const IndexType &index )
00201 {
00202 OffsetValueType offset = m_VectorLength * this->ComputeOffset(index);
00203 PixelType p( &((*m_Buffer)[offset]), m_VectorLength );
00204 return p;
00205 }
00206
00209 InternalPixelType *GetBufferPointer()
00210 { return m_Buffer ? m_Buffer->GetBufferPointer() : 0; }
00211 const InternalPixelType *GetBufferPointer() const
00212 { return m_Buffer ? m_Buffer->GetBufferPointer() : 0; }
00213
00215 PixelContainer* GetPixelContainer()
00216 { return m_Buffer.GetPointer(); }
00217
00219 const PixelContainer* GetPixelContainer() const
00220 { return m_Buffer.GetPointer(); }
00221
00224 void SetPixelContainer( PixelContainer *container );
00225
00236 virtual void Graft(const DataObject *data);
00237
00239 AccessorType GetPixelAccessor( void )
00240 { return AccessorType( m_VectorLength ); }
00241
00243 const AccessorType GetPixelAccessor( void ) const
00244 { return AccessorType( m_VectorLength ); }
00245
00247 NeighborhoodAccessorFunctorType GetNeighborhoodAccessor()
00248 { return NeighborhoodAccessorFunctorType( m_VectorLength ); }
00249
00251 const NeighborhoodAccessorFunctorType GetNeighborhoodAccessor() const
00252 { return NeighborhoodAccessorFunctorType(m_VectorLength); }
00253
00254
00256 itkSetMacro( VectorLength, VectorLengthType );
00257 itkGetConstReferenceMacro( VectorLength, VectorLengthType );
00258
00259 protected:
00260 VectorImage();
00261 void PrintSelf( std::ostream& os, Indent indent ) const;
00262 virtual ~VectorImage() {};
00263
00264 private:
00265 VectorImage( const Self & );
00266 void operator=(const Self&);
00267
00268
00269 private:
00271 VectorLengthType m_VectorLength;
00272
00274 PixelContainerPointer m_Buffer;
00275 };
00276
00277
00278 }
00279 #ifndef ITK_MANUAL_INSTANTIATION
00280 #include "itkVectorImage.txx"
00281 #endif
00282
00283 #endif