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

itkImage.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkImage.h,v $
00005   Language:  C++
00006   Date:      $Date: 2008-10-18 17:19:48 $
00007   Version:   $Revision: 1.149 $
00008 
00009   Copyright (c) Insight Software 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 __itkImage_h
00018 #define __itkImage_h
00019 
00020 #include "itkImageBase.h"
00021 #include "itkImageRegion.h"
00022 #include "itkImportImageContainer.h"
00023 #include "itkDefaultPixelAccessor.h"
00024 #include "itkDefaultPixelAccessorFunctor.h"
00025 #include "itkPoint.h"
00026 #include "itkFixedArray.h"
00027 #include "itkWeakPointer.h"
00028 #include "itkNeighborhoodAccessorFunctor.h"
00029 
00030 namespace itk
00031 {
00080 template <class TPixel, unsigned int VImageDimension=2>
00081 class ITK_EXPORT Image : public ImageBase<VImageDimension>
00082 {
00083 public:
00085   typedef Image                        Self;
00086   typedef ImageBase<VImageDimension>   Superclass;
00087   typedef SmartPointer<Self>           Pointer;
00088   typedef SmartPointer<const Self>     ConstPointer;
00089   typedef WeakPointer<const Self>      ConstWeakPointer;
00090 
00092   itkNewMacro(Self);
00093 
00095   itkTypeMacro(Image, ImageBase);
00096 
00099   typedef TPixel PixelType;
00100 
00102   typedef TPixel ValueType;
00103 
00108   typedef TPixel InternalPixelType;
00109 
00110   typedef PixelType IOPixelType;
00111 
00114   typedef DefaultPixelAccessor< PixelType >    AccessorType;
00115   typedef DefaultPixelAccessorFunctor< Self >  AccessorFunctorType;
00116 
00119   typedef NeighborhoodAccessorFunctor< Self >  NeighborhoodAccessorFunctorType;
00120 
00125   itkStaticConstMacro(ImageDimension, unsigned int, VImageDimension);
00126 
00128   typedef ImportImageContainer<unsigned long, PixelType> PixelContainer;
00129 
00131   typedef typename Superclass::IndexType       IndexType;
00132   typedef typename Superclass::IndexValueType  IndexValueType;
00133 
00135   typedef typename Superclass::OffsetType OffsetType;
00136 
00138   typedef typename Superclass::SizeType  SizeType;
00139 
00141   typedef typename Superclass::DirectionType  DirectionType;
00142 
00144   typedef typename Superclass::RegionType  RegionType;
00145 
00148   typedef typename Superclass::SpacingType SpacingType;
00149 
00152   typedef typename Superclass::PointType PointType;
00153 
00155   typedef typename PixelContainer::Pointer        PixelContainerPointer;
00156   typedef typename PixelContainer::ConstPointer   PixelContainerConstPointer;
00157 
00159   typedef typename Superclass::OffsetValueType OffsetValueType;
00160 
00163   void Allocate();
00164 
00168   void SetRegions(RegionType region)
00169     {
00170     this->SetLargestPossibleRegion(region);
00171     this->SetBufferedRegion(region);
00172     this->SetRequestedRegion(region);
00173     };
00175 
00176   void SetRegions(SizeType size)
00177     {
00178     RegionType region; region.SetSize(size);
00179     this->SetLargestPossibleRegion(region);
00180     this->SetBufferedRegion(region);
00181     this->SetRequestedRegion(region);
00182     };
00183 
00186   virtual void Initialize();
00187 
00190   void FillBuffer (const TPixel& value);
00191 
00197   void SetPixel(const IndexType &index, const TPixel& value)
00198     {
00199     typename Superclass::OffsetValueType offset = this->ComputeOffset(index);
00200     (*m_Buffer)[offset] = value;
00201     }
00202 
00207   const TPixel& GetPixel(const IndexType &index) const
00208     {
00209     typename Superclass::OffsetValueType offset = this->ComputeOffset(index);
00210     return ( (*m_Buffer)[offset] );
00211     }
00212 
00217   TPixel& GetPixel(const IndexType &index)
00218     {
00219     typename Superclass::OffsetValueType offset = this->ComputeOffset(index);
00220     return ( (*m_Buffer)[offset] );
00221     }
00222 
00227   TPixel & operator[](const IndexType &index)
00228     { return this->GetPixel(index); }
00229 
00234   const TPixel& operator[](const IndexType &index) const
00235      { return this->GetPixel(index); }
00236 
00239   TPixel *GetBufferPointer()
00240     { return m_Buffer ? m_Buffer->GetBufferPointer() : 0; }
00241   const TPixel *GetBufferPointer() const
00242     { return m_Buffer ? m_Buffer->GetBufferPointer() : 0; }
00244 
00246   PixelContainer* GetPixelContainer()
00247     { return m_Buffer.GetPointer(); }
00248 
00249   const PixelContainer* GetPixelContainer() const
00250     { return m_Buffer.GetPointer(); }
00251 
00254   void SetPixelContainer( PixelContainer *container );
00255 
00266   virtual void Graft(const DataObject *data);
00267 
00268 
00270   AccessorType GetPixelAccessor( void )
00271     { return AccessorType(); }
00272 
00274   const AccessorType GetPixelAccessor( void ) const
00275     { return AccessorType(); }
00276 
00278   NeighborhoodAccessorFunctorType GetNeighborhoodAccessor()
00279     { return NeighborhoodAccessorFunctorType(); }
00280 
00282   const NeighborhoodAccessorFunctorType GetNeighborhoodAccessor() const
00283     { return NeighborhoodAccessorFunctorType(); }
00284 
00285 protected:
00286   Image();
00287   void PrintSelf(std::ostream& os, Indent indent) const;
00288   virtual ~Image() {};
00289 
00295   virtual void ComputeIndexToPhysicalPointMatrices();
00296 
00297 private:
00298   Image(const Self&); //purposely not implemented
00299   void operator=(const Self&); //purposely not implemented
00300 
00302   PixelContainerPointer m_Buffer;
00303 
00304 };
00305 
00306 } // end namespace itk
00307 
00308 // Define instantiation macro for this template.
00309 #define ITK_TEMPLATE_Image(_, EXPORT, x, y) namespace itk { \
00310   _(2(class EXPORT Image< ITK_TEMPLATE_2 x >)) \
00311   namespace Templates { typedef Image< ITK_TEMPLATE_2 x > Image##y; } \
00312   }
00313 
00314 #if ITK_TEMPLATE_EXPLICIT
00315 # include "Templates/itkImage+-.h"
00316 #endif
00317 
00318 #if ITK_TEMPLATE_TXX
00319 # include "itkImage.txx"
00320 #endif
00321 
00322 #endif
00323 

Generated at Wed Nov 5 21:56:38 2008 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000