go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
itkNDImageBase.h
Go to the documentation of this file.
1 /*======================================================================
2 
3  This file is part of the elastix software.
4 
5  Copyright (c) University Medical Center Utrecht. All rights reserved.
6  See src/CopyrightElastix.txt or http://elastix.isi.uu.nl/legal.php for
7  details.
8 
9  This software is distributed WITHOUT ANY WARRANTY; without even
10  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11  PURPOSE. See the above copyright notices for more information.
12 
13 ======================================================================*/
14 
15 #ifndef __itkNDImageBase_h
16 #define __itkNDImageBase_h
17 
18 #include "itkImage.h"
19 #include "itkArray.h"
20 #include <string>
21 #include "itkImageFileWriter.h"
22 
23 
24 namespace itk
25 {
26 
54  template < class TPixel >
55  class NDImageBase : public Object
56  {
57  public:
58 
60  typedef NDImageBase Self;
61  typedef Object Superclass;
62  typedef SmartPointer<Self> Pointer;
63  typedef SmartPointer<const Self> ConstPointer;
64 
66  // itkNewMacro( Self );
67  // not declared, because instantiating an object of this
68  // (abstract) type makes no sense.
69 
71  itkTypeMacro( NDImageBase, Object );
72 
73  typedef DataObject DataObjectType;
74  typedef DataObjectType::Pointer DataObjectPointer;
75 
77  typedef typename Image<TPixel,2>::PixelType PixelType;
78  typedef typename Image<TPixel,2>::ValueType ValueType;
79  typedef typename Image<TPixel,2>::InternalPixelType InternalPixelType;
80  typedef typename Image<TPixel,2>::AccessorType AccessorType;
81  typedef typename Image<TPixel,2>::PixelContainer PixelContainer;
82  typedef typename Image<TPixel,2>::PixelContainerPointer PixelContainerPointer;
83  typedef typename Image<TPixel,2>::PixelContainerConstPointer PixelContainerConstPointer;
84 
85  typedef typename ImageBase<2>::SpacingType Spacing2DType;
86  typedef typename ImageBase<2>::PointType Point2DType;
87 
88  typedef typename Spacing2DType::ValueType SpacingValueType;
89  typedef typename Point2DType::ValueType PointValueType;
90  typedef typename ImageBase<2>::IndexValueType IndexValueType;
91  typedef typename ImageBase<2>::SizeValueType SizeValueType;
92  typedef typename ImageBase<2>::OffsetValueType OffsetValueType;
93 
99  typedef Array<IndexValueType> IndexType;
100  typedef Array<SizeValueType> SizeType;
101  typedef Array<SpacingValueType> SpacingType;
102  typedef Array<PointValueType> PointType;
103  typedef Array<OffsetValueType> OffsetType;
108  //typedef typename Superclass::RegionType RegionType;
109 
118  //void SetRegions(RegionType region) = 0;
119  virtual void SetRegions(SizeType size) = 0;
120  virtual void SetRequestedRegion(DataObject *data) = 0;
121 
122  virtual void Allocate(void) = 0;
123  virtual void Initialize(void) = 0;
124 
125  virtual void FillBuffer (const TPixel& value) = 0;
126 
127  virtual void SetPixel(const IndexType &index, const TPixel& value) = 0;
128  virtual const TPixel& GetPixel(const IndexType &index) const = 0;
129  virtual TPixel& GetPixel(const IndexType &index) = 0;
130 
131  TPixel & operator[](const IndexType &index)
132  { return this->GetPixel(index); }
133  const TPixel& operator[](const IndexType &index) const
134  { return this->GetPixel(index); }
135 
136  virtual TPixel *GetBufferPointer() = 0;
137  virtual const TPixel *GetBufferPointer() const = 0;
138  virtual PixelContainer* GetPixelContainer() = 0;
139  virtual const PixelContainer* GetPixelContainer() const = 0;
140  virtual void SetPixelContainer( PixelContainer *container ) = 0;
141 
142  virtual AccessorType GetPixelAccessor( void ) = 0;
143  virtual const AccessorType GetPixelAccessor( void ) const = 0;
144 
145 
146  virtual void SetSpacing( const SpacingType & spacing ) = 0;
147  virtual void SetOrigin( const PointType & origin ) = 0;
148 
149  /* Get Spacing/Origin return copies; not a const &, like
150  * itkImage; necessary because of the conversion to arrays */
151  virtual SpacingType GetSpacing(void) = 0;
152  virtual PointType GetOrigin(void) = 0;
153 
156  virtual void CopyInformation(const DataObject *data) = 0;
157  virtual const OffsetValueType *GetOffsetTable() const = 0;
158  virtual OffsetValueType ComputeOffset(const IndexType &ind) const = 0;
159  virtual IndexType ComputeIndex(OffsetValueType offset) const = 0;
160 
164  virtual unsigned int ImageDimension(void) = 0;
165  virtual unsigned int GetImageDimension(void) = 0;
166 
168  virtual DataObject * GetImage(void) = 0;
169  virtual ProcessObject * GetWriter(void) = 0;
170  virtual ProcessObject * GetReader(void) = 0;
171 
172  virtual void SetImageIOWriter (ImageIOBase *_arg) = 0;
173  virtual ImageIOBase * GetImageIOWriter(void) = 0;
174  virtual void SetImageIOReader (ImageIOBase *_arg) = 0;
175  virtual ImageIOBase * GetImageIOReader(void) = 0;
176 
178  virtual void Write(void) = 0;
179 
181  virtual void Read(void) = 0;
182 
184  virtual void CreateNewImage(void) = 0;
185 
187  virtual void SetOutputFileName(const char *) = 0;
188  virtual void SetInputFileName(const char *) = 0;
189  virtual const char * GetOutputFileName(void) = 0;
190  virtual const char * GetInputFileName(void) = 0;
191 
192 
193  static Pointer NewNDImage(unsigned int dim);
194 
195  protected:
196 
198  virtual ~NDImageBase(){};
199 
200  //virtual void PrintSelf(std::ostream& os, Indent indent) const = 0;
201 
202  private:
203 
204  NDImageBase( const Self& ); // purposely not implemented
205  void operator=( const Self& ); // purposely not implemented
206 
207  }; // end class NDImageBase
208 
209 } // end namespace itk
210 
211 #include "itkNDImageTemplate.h"
212 
213 
214 namespace itk
215 {
216 
217  template < class TPixel>
218  typename NDImageBase<TPixel>::Pointer
220  {
221  switch (dim)
222  {
223  case 1:
224  return dynamic_cast< NDImageBase<TPixel> * >( NDImageTemplate<TPixel, 1>::New().GetPointer() );
225  case 2:
226  return dynamic_cast< NDImageBase<TPixel> * >( NDImageTemplate<TPixel, 2>::New().GetPointer() );
227  case 3:
228  return dynamic_cast< NDImageBase<TPixel> * >( NDImageTemplate<TPixel, 3>::New().GetPointer() );
229  case 4:
230  return dynamic_cast< NDImageBase<TPixel> * >( NDImageTemplate<TPixel, 4>::New().GetPointer() );
231  case 5:
232  return dynamic_cast< NDImageBase<TPixel> * >( NDImageTemplate<TPixel, 5>::New().GetPointer() );
233  //add here more dimensions if needed...
234  // we could do this also with a recursive
235  //template and a #define MAXDIM,
236  // or something like that....
237  default:
238  return 0;
239  }
240 
241  }
242 
243 } // end namespace itk
244 
245 
246 #endif // end #ifndef __itkNDImageBase_h
247 
virtual const OffsetValueType * GetOffsetTable() const =0
virtual AccessorType GetPixelAccessor(void)=0
virtual ImageIOBase * GetImageIOReader(void)=0
ImageBase< 2 >::OffsetValueType OffsetValueType
virtual void Write(void)=0
virtual PixelContainer * GetPixelContainer()=0
Image< TPixel, 2 >::InternalPixelType InternalPixelType
virtual unsigned int GetImageDimension(void)=0
Image< TPixel, 2 >::ValueType ValueType
virtual ProcessObject * GetWriter(void)=0
Array< SpacingValueType > SpacingType
void operator=(const Self &)
Array< PointValueType > PointType
SmartPointer< Self > Pointer
virtual const TPixel & GetPixel(const IndexType &index) const =0
TPixel & operator[](const IndexType &index)
virtual void SetOrigin(const PointType &origin)=0
Array< OffsetValueType > OffsetType
virtual SpacingType GetSpacing(void)=0
virtual void SetPixel(const IndexType &index, const TPixel &value)=0
virtual void SetImageIOReader(ImageIOBase *_arg)=0
Image< TPixel, 2 >::PixelContainer PixelContainer
virtual void FillBuffer(const TPixel &value)=0
DataObjectType::Pointer DataObjectPointer
NDImageBase Self
DataObject DataObjectType
virtual void SetRequestedRegion(DataObject *data)=0
virtual void SetPixelContainer(PixelContainer *container)=0
virtual TPixel * GetBufferPointer()=0
Image< TPixel, 2 >::PixelContainerConstPointer PixelContainerConstPointer
virtual void Read(void)=0
virtual PointType GetOrigin(void)=0
virtual ~NDImageBase()
virtual void Initialize(void)=0
const TPixel & operator[](const IndexType &index) const
static Pointer NewNDImage(unsigned int dim)
An image whose dimension can be specified at runtime.
Array< SizeValueType > SizeType
virtual void SetSpacing(const SpacingType &spacing)=0
ImageBase< 2 >::SpacingType Spacing2DType
virtual void SetImageIOWriter(ImageIOBase *_arg)=0
virtual IndexType ComputeIndex(OffsetValueType offset) const =0
ImageBase< 2 >::PointType Point2DType
ImageBase< 2 >::IndexValueType IndexValueType
Point2DType::ValueType PointValueType
virtual ProcessObject * GetReader(void)=0
Image< TPixel, 2 >::AccessorType AccessorType
Spacing2DType::ValueType SpacingValueType
virtual ImageIOBase * GetImageIOWriter(void)=0
Image< TPixel, 2 >::PixelType PixelType
virtual DataObject * GetImage(void)=0
ImageBase< 2 >::SizeValueType SizeValueType
virtual void SetRegions(SizeType size)=0
virtual void SetOutputFileName(const char *)=0
virtual const char * GetInputFileName(void)=0
virtual unsigned int ImageDimension(void)=0
virtual void SetInputFileName(const char *)=0
SmartPointer< const Self > ConstPointer
virtual void CopyInformation(const DataObject *data)=0
Image< TPixel, 2 >::PixelContainerPointer PixelContainerPointer
Array< IndexValueType > IndexType
virtual OffsetValueType ComputeOffset(const IndexType &ind) const =0
virtual const char * GetOutputFileName(void)=0
static Pointer New()
virtual void Allocate(void)=0
virtual void CreateNewImage(void)=0


Generated on 05-01-2014 for elastix by doxygen 1.8.5 elastix logo