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: 2010-04-09 23:22:45 $
00007   Version:   $Revision: 1.152 $
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   typedef typename Superclass::SizeValueType  SizeValueType;
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 
00164   void Allocate();
00165 
00169   void SetRegions(RegionType region)
00170     {
00171     this->SetLargestPossibleRegion(region);
00172     this->SetBufferedRegion(region);
00173     this->SetRequestedRegion(region);
00174     };
00176 
00177   void SetRegions(SizeType size)
00178     {
00179     RegionType region; region.SetSize(size);
00180     this->SetLargestPossibleRegion(region);
00181     this->SetBufferedRegion(region);
00182     this->SetRequestedRegion(region);
00183     }
00184 
00187   virtual void Initialize();
00188 
00191   void FillBuffer (const TPixel& value);
00192 
00198   void SetPixel(const IndexType &index, const TPixel& value)
00199     {
00200     typename Superclass::OffsetValueType offset = this->ComputeOffset(index);
00201     (*m_Buffer)[offset] = value;
00202     }
00203 
00208   const TPixel& GetPixel(const IndexType &index) const
00209     {
00210     typename Superclass::OffsetValueType offset = this->ComputeOffset(index);
00211     return ( (*m_Buffer)[offset] );
00212     }
00213 
00218   TPixel& GetPixel(const IndexType &index)
00219     {
00220     typename Superclass::OffsetValueType offset = this->ComputeOffset(index);
00221     return ( (*m_Buffer)[offset] );
00222     }
00223 
00228   TPixel & operator[](const IndexType &index)
00229     { return this->GetPixel(index); }
00230 
00235   const TPixel& operator[](const IndexType &index) const
00236      { return this->GetPixel(index); }
00237 
00240   TPixel *GetBufferPointer()
00241     { return m_Buffer ? m_Buffer->GetBufferPointer() : 0; }
00242   const TPixel *GetBufferPointer() const
00243     { return m_Buffer ? m_Buffer->GetBufferPointer() : 0; }
00245 
00247   PixelContainer* GetPixelContainer()
00248     { return m_Buffer.GetPointer(); }
00249 
00250   const PixelContainer* GetPixelContainer() const
00251     { return m_Buffer.GetPointer(); }
00252 
00255   void SetPixelContainer( PixelContainer *container );
00256 
00267   virtual void Graft(const DataObject *data);
00268 
00269 
00271   AccessorType GetPixelAccessor( void )
00272     { return AccessorType(); }
00273 
00275   const AccessorType GetPixelAccessor( void ) const
00276     { return AccessorType(); }
00277 
00279   NeighborhoodAccessorFunctorType GetNeighborhoodAccessor()
00280     { return NeighborhoodAccessorFunctorType(); }
00281 
00283   const NeighborhoodAccessorFunctorType GetNeighborhoodAccessor() const
00284     { return NeighborhoodAccessorFunctorType(); }
00285 
00286 protected:
00287   Image();
00288   void PrintSelf(std::ostream& os, Indent indent) const;
00289   virtual ~Image() {}
00290 
00296   virtual void ComputeIndexToPhysicalPointMatrices();
00297 
00298 private:
00299   Image(const Self&); //purposely not implemented
00300   void operator=(const Self&); //purposely not implemented
00301 
00303   PixelContainerPointer m_Buffer;
00304 
00305 };
00306 
00307 } // end namespace itk
00308 
00309 // Define instantiation macro for this template.
00310 #define ITK_TEMPLATE_Image(_, EXPORT, x, y) namespace itk { \
00311   _(2(class EXPORT Image< ITK_TEMPLATE_2 x >)) \
00312   namespace Templates { typedef Image< ITK_TEMPLATE_2 x > Image##y; } \
00313   }
00314 
00315 #if ITK_TEMPLATE_EXPLICIT
00316 # include "Templates/itkImage+-.h"
00317 #endif
00318 
00319 #if ITK_TEMPLATE_TXX
00320 # include "itkImage.txx"
00321 #endif
00322 
00323 #endif
00324 

Generated at Mon Jul 12 2010 18:35:36 for ITK by doxygen 1.7.1 written by Dimitri van Heesch, © 1997-2000