00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkImageAdaptor_h
00018 #define __itkImageAdaptor_h
00019
00020 #include "itkImage.h"
00021 #include "itkDefaultPixelAccessorFunctor.h"
00022
00023 namespace itk
00024 {
00025
00047 template <class TImage, class TAccessor >
00048 class ITK_EXPORT ImageAdaptor : public ImageBase< ::itk::GetImageDimension<TImage>::ImageDimension>
00049 {
00050 public:
00051
00056 itkStaticConstMacro(ImageDimension, unsigned int, TImage::ImageDimension);
00057
00059 typedef ImageAdaptor Self;
00060 typedef ImageBase<itkGetStaticConstMacro(ImageDimension)> Superclass;
00061 typedef SmartPointer<Self> Pointer;
00062 typedef SmartPointer<const Self> ConstPointer;
00063 typedef WeakPointer<const Self> ConstWeakPointer;
00064
00066 itkTypeMacro(ImageAdaptor, ImageBase);
00067
00069 typedef TImage InternalImageType;
00070
00072 itkNewMacro(Self);
00073
00076 typedef typename TAccessor::ExternalType PixelType;
00077
00080 typedef typename TAccessor::InternalType InternalPixelType;
00081
00082 typedef PixelType IOPixelType;
00083
00086 typedef TAccessor AccessorType;
00087
00090 typedef DefaultPixelAccessorFunctor< Self > AccessorFunctorType;
00091
00093 typedef typename Superclass::IndexType IndexType;
00094 typedef typename IndexType::IndexValueType IndexValueType;
00095
00097 typedef typename Superclass::SizeType SizeType;
00098 typedef typename SizeType::SizeValueType SizeValueType;
00099
00101 typedef typename Superclass::OffsetType OffsetType;
00102 typedef typename OffsetType::OffsetValueType OffsetValueType;
00103
00106 typedef typename Superclass::RegionType RegionType;
00107
00110 typedef typename Superclass::SpacingType SpacingType;
00111
00114 typedef typename Superclass::PointType PointType;
00115
00122 virtual void SetLargestPossibleRegion(const RegionType ®ion);
00123
00127 virtual void SetBufferedRegion(const RegionType ®ion);
00128
00132 virtual void SetRequestedRegion(const RegionType ®ion);
00133
00138 virtual void SetRequestedRegion(DataObject *data);
00139
00146 virtual const RegionType & GetRequestedRegion() const;
00147
00156 virtual const RegionType& GetLargestPossibleRegion() const;
00157
00163 virtual const RegionType& GetBufferedRegion() const;
00164
00166 inline void Allocate()
00167 {
00168 m_Image->Allocate();
00169 }
00170
00171
00174 virtual void Initialize();
00175
00177 void SetPixel(const IndexType &index, const PixelType & value)
00178 { m_PixelAccessor.Set( m_Image->GetPixel(index), value ); }
00179
00181 PixelType GetPixel(const IndexType &index) const
00182 { return m_PixelAccessor.Get( m_Image->GetPixel(index) ); }
00183
00185 PixelType operator[](const IndexType &index) const
00186 { return m_PixelAccessor.Get( m_Image->GetPixel(index) ); }
00187
00189 const OffsetValueType *GetOffsetTable() const;
00190
00192 IndexType ComputeIndex(OffsetValueType offset) const;
00193
00196 typedef typename TImage::PixelContainer PixelContainer;
00197 typedef typename TImage::PixelContainerPointer PixelContainerPointer;
00198 typedef typename TImage::PixelContainerConstPointer PixelContainerConstPointer;
00199
00201 PixelContainerPointer GetPixelContainer()
00202 { return m_Image->GetPixelContainer(); };
00203
00206 void SetPixelContainer( PixelContainer *container );
00207
00218 virtual void Graft(const DataObject *data);
00219
00221 typedef InternalPixelType * InternalPixelPointerType;
00222
00225 InternalPixelType *GetBufferPointer();
00226 const InternalPixelType *GetBufferPointer() const;
00228
00230 virtual void SetSpacing( const SpacingType values );
00231 virtual void SetSpacing( const double* values );
00232 virtual void SetSpacing( const float* values );
00234
00238 virtual const SpacingType& GetSpacing() const;
00239
00243 virtual const PointType& GetOrigin() const;
00244
00246 virtual void SetOrigin( const PointType values);
00247 virtual void SetOrigin( const double* values );
00248 virtual void SetOrigin( const float* values );
00250
00252 virtual void SetImage( TImage * );
00253
00255 virtual void Modified() const;
00256
00258 virtual unsigned long GetMTime() const;
00259
00261 AccessorType & GetPixelAccessor( void )
00262 { return m_PixelAccessor; }
00263
00265 const AccessorType & GetPixelAccessor( void ) const
00266 { return m_PixelAccessor; }
00267
00269 void SetPixelAccessor( const AccessorType & accessor )
00270 { m_PixelAccessor = accessor; }
00271
00273 virtual void Update();
00274 virtual void CopyInformation(const DataObject *data);
00276
00279 virtual void UpdateOutputInformation();
00280 virtual void SetRequestedRegionToLargestPossibleRegion();
00281 virtual void PropagateRequestedRegion() throw (InvalidRequestedRegionError);
00282 virtual void UpdateOutputData();
00283 virtual bool VerifyRequestedRegion();
00285
00290 template<class TCoordRep>
00291 bool TransformPhysicalPointToContinuousIndex(
00292 const Point<TCoordRep,
00293 itkGetStaticConstMacro(ImageDimension)>& point,
00294 ContinuousIndex<TCoordRep,
00295 itkGetStaticConstMacro(ImageDimension)>& index ) const
00296 {
00297 return m_Image->TransformPhysicalPointToContinuousIndex( point, index );
00298 }
00299
00304 template<class TCoordRep>
00305 bool TransformPhysicalPointToIndex(
00306 const Point<TCoordRep,
00307 itkGetStaticConstMacro(ImageDimension)>& point,
00308 IndexType & index ) const
00309 {
00310 return m_Image->TransformPhysicalPointToIndex( point, index );
00311 }
00312
00317 template<class TCoordRep>
00318 void TransformContinuousIndexToPhysicalPoint(
00319 const ContinuousIndex<TCoordRep,
00320 itkGetStaticConstMacro(ImageDimension)>& index,
00321 Point<TCoordRep,
00322 itkGetStaticConstMacro(ImageDimension)>& point ) const
00323 {
00324 m_Image->TransformContinuousIndexToPhysicalPoint( index, point );
00325 }
00326
00332 template<class TCoordRep>
00333 void TransformIndexToPhysicalPoint(
00334 const IndexType & index,
00335 Point<TCoordRep,
00336 itkGetStaticConstMacro(ImageDimension)>& point ) const
00337 {
00338 m_Image->TransformIndexToPhysicalPoint( index, point );
00339 }
00340
00341
00342 protected:
00343 ImageAdaptor();
00344 virtual ~ImageAdaptor();
00345 void PrintSelf(std::ostream& os, Indent indent) const;
00346
00347 private:
00348 ImageAdaptor(const Self&);
00349 void operator=(const Self&);
00350
00351
00352
00353 typename TImage::Pointer m_Image;
00354
00355
00356
00357 AccessorType m_PixelAccessor;
00358
00359
00360 };
00361
00362 }
00363
00364 #ifndef ITK_MANUAL_INSTANTIATION
00365 #include "itkImageAdaptor.txx"
00366 #endif
00367
00368
00369
00370 #endif
00371
00372