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

itkImageAdaptor.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkImageAdaptor.h,v $
00005   Language:  C++
00006   Date:      $Date: 2002/09/11 19:57:12 $
00007   Version:   $Revision: 1.40 $
00008 
00009   Copyright (c) 2002 Insight 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 __itkImageAdaptor_h
00018 #define __itkImageAdaptor_h
00019 
00020 #include "itkImage.h"
00021 
00022 namespace itk
00023 {
00024 
00046 template <class TImage, class TAccessor >
00047 class ITK_EXPORT ImageAdaptor : public ImageBase< ::itk::GetImageDimension<TImage>::ImageDimension>
00048 {
00049 public:
00054   itkStaticConstMacro(ImageDimension, unsigned int, TImage::ImageDimension);
00055 
00057   typedef ImageAdaptor  Self;
00058   typedef ImageBase<itkGetStaticConstMacro(ImageDimension)> Superclass;
00059   typedef SmartPointer<Self>  Pointer;
00060   typedef SmartPointer<const Self>  ConstPointer;
00061   
00063   itkTypeMacro(ImageAdaptor, ImageBase);
00064 
00066   typedef TImage InternalImageType;
00067   
00069   itkNewMacro(Self);  
00070 
00073   typedef typename TAccessor::ExternalType PixelType;
00074 
00077   typedef typename TAccessor::InternalType InternalPixelType;
00078 
00081   typedef   TAccessor   AccessorType;
00082 
00084   typedef Index<itkGetStaticConstMacro(ImageDimension)>  IndexType;
00085   typedef typename IndexType::IndexValueType    IndexValueType;
00086   
00088   typedef Size<itkGetStaticConstMacro(ImageDimension)>   SizeType;
00089   typedef typename SizeType::SizeValueType      SizeValueType;
00090     
00092   typedef Offset<itkGetStaticConstMacro(ImageDimension)> OffsetType;
00093   typedef typename OffsetType::OffsetValueType  OffsetValueType;
00094     
00097   typedef ImageRegion<itkGetStaticConstMacro(ImageDimension)> RegionType;
00098 
00105   typedef AffineTransform<double, itkGetStaticConstMacro(ImageDimension)> AffineTransformType;
00106 
00108   typedef typename AffineTransformType::OffsetType OriginOffsetType;
00109 
00116   virtual void SetLargestPossibleRegion(const RegionType &region);
00117 
00121   virtual void SetBufferedRegion(const RegionType &region);
00122 
00126   virtual void SetRequestedRegion(const RegionType &region);
00127 
00132   virtual void SetRequestedRegion(DataObject *data);
00133 
00140   virtual const RegionType & GetRequestedRegion() const;
00141 
00150   virtual const RegionType& GetLargestPossibleRegion() const;
00151 
00157   virtual const RegionType& GetBufferedRegion() const;
00158 
00160   inline void Allocate();
00161 
00162 
00165   virtual void Initialize();
00166 
00168   void SetPixel(const IndexType &index, const PixelType & value)
00169     { m_PixelAccessor.Set( m_Image->GetPixel(index), value ); }
00170   
00172   PixelType GetPixel(const IndexType &index) const
00173     { return m_PixelAccessor.Get( m_Image->GetPixel(index) ); }
00174 
00176   PixelType operator[](const IndexType &index) const
00177     { return m_PixelAccessor.Get( m_Image->GetPixel(index) ); }
00178 
00180   const OffsetValueType *GetOffsetTable() const;
00181 
00183   IndexType ComputeIndex(OffsetValueType offset) const;
00184 
00187   typedef typename TImage::PixelContainer        PixelContainer;
00188   typedef typename TImage::PixelContainerPointer PixelContainerPointer;
00189   
00191   PixelContainerPointer GetPixelContainer()
00192     { return m_Image->GetPixelContainer(); };
00193 
00196   void SetPixelContainer( PixelContainer *container );
00197   
00199   typedef InternalPixelType * InternalPixelPointerType;
00200 
00203   InternalPixelType *GetBufferPointer();
00204   const InternalPixelType *GetBufferPointer() const;
00205   void GetBufferPointer2( InternalPixelPointerType  & );
00206   
00208   virtual void SetSpacing( const double values[TImage::ImageDimension] );
00209   virtual void SetSpacing( const float values[TImage::ImageDimension] );
00210   
00215   virtual const double* GetSpacing() const;
00216  
00221   virtual const double * GetOrigin() const;
00222 
00224   virtual void SetOrigin( const double values[TImage::ImageDimension] );
00225   virtual void SetOrigin( const float values[TImage::ImageDimension] );
00226   
00228   virtual void SetImage( TImage * );
00229 
00231   virtual void Modified() const;
00232 
00234   virtual unsigned long GetMTime() const;
00235 
00237   AccessorType & GetPixelAccessor( void ) 
00238     { return m_PixelAccessor; }
00239     
00241   const AccessorType & GetPixelAccessor( void ) const
00242     { return m_PixelAccessor; }
00243 
00245   virtual void Update();
00246   virtual void UpdateOutputInformation();
00247   virtual void SetRequestedRegionToLargestPossibleRegion();
00248   virtual void CopyInformation(const DataObject *data);
00249    
00250 protected:
00251   ImageAdaptor();
00252   virtual ~ImageAdaptor();
00253   void PrintSelf(std::ostream& os, Indent indent) const;
00254   
00255 private:
00256   ImageAdaptor(const Self&); //purposely not implemented
00257   void operator=(const Self&); //purposely not implemented
00258   
00259   // Adapted image, most of the calls to ImageAdaptor
00260   // will be delegated to this image
00261   typename TImage::Pointer   m_Image;
00262 
00263   // Data accessor object, 
00264   // it converts the presentation of a pixel
00265   AccessorType               m_PixelAccessor;
00266   
00267 
00268 };
00269   
00270 } // end namespace itk
00271 
00272 #ifndef ITK_MANUAL_INSTANTIATION
00273 #include "itkImageAdaptor.txx"
00274 #endif
00275   
00276   
00277 
00278 #endif
00279 

Generated at Wed Mar 12 01:12:59 2003 for ITK by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2000