Orfeo Toolbox  3.16
itkImageAdaptor.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Insight Segmentation & Registration Toolkit
4  Module: $RCSfile: itkImageAdaptor.h,v $
5  Language: C++
6  Date: $Date: 2008-10-19 12:33:32 $
7  Version: $Revision: 1.70 $
8 
9  Copyright (c) Insight Software Consortium. All rights reserved.
10  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
11 
12  This software is distributed WITHOUT ANY WARRANTY; without even
13  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14  PURPOSE. See the above copyright notices for more information.
15 
16 =========================================================================*/
17 #ifndef __itkImageAdaptor_h
18 #define __itkImageAdaptor_h
19 
20 #include "itkImage.h"
22 
23 namespace itk
24 {
25 
47 template <class TImage, class TAccessor >
48 class ITK_EXPORT ImageAdaptor : public ImageBase< ::itk::GetImageDimension<TImage>::ImageDimension>
49 {
50 public:
55  itkStaticConstMacro(ImageDimension, unsigned int, TImage::ImageDimension);
56 
58  typedef ImageAdaptor Self;
63 
65  itkTypeMacro(ImageAdaptor, ImageBase);
66 
68  typedef TImage InternalImageType;
69 
71  itkNewMacro(Self);
72 
75  typedef typename TAccessor::ExternalType PixelType;
76 
79  typedef typename TAccessor::InternalType InternalPixelType;
80 
82 
85  typedef TAccessor AccessorType;
86 
90 
92  typedef typename Superclass::IndexType IndexType;
93  typedef typename IndexType::IndexValueType IndexValueType;
94 
96  typedef typename Superclass::SizeType SizeType;
97  typedef typename SizeType::SizeValueType SizeValueType;
98 
100  typedef typename Superclass::OffsetType OffsetType;
101  typedef typename OffsetType::OffsetValueType OffsetValueType;
102 
105  typedef typename Superclass::RegionType RegionType;
106 
109  typedef typename Superclass::SpacingType SpacingType;
110 
113  typedef typename Superclass::PointType PointType;
114 
118  typedef typename Superclass::DirectionType DirectionType;
119 
126  virtual void SetLargestPossibleRegion(const RegionType &region);
127 
131  virtual void SetBufferedRegion(const RegionType &region);
132 
136  virtual void SetRequestedRegion(const RegionType &region);
137 
142  virtual void SetRequestedRegion(DataObject *data);
143 
150  virtual const RegionType & GetRequestedRegion() const;
151 
160  virtual const RegionType& GetLargestPossibleRegion() const;
161 
167  virtual const RegionType& GetBufferedRegion() const;
168 
170  inline void Allocate()
171  {
172  m_Image->Allocate();
173  }
174 
175 
178  virtual void Initialize();
179 
181  void SetPixel(const IndexType &index, const PixelType & value)
182  { m_PixelAccessor.Set( m_Image->GetPixel(index), value ); }
183 
185  PixelType GetPixel(const IndexType &index) const
186  { return m_PixelAccessor.Get( m_Image->GetPixel(index) ); }
187 
189  PixelType operator[](const IndexType &index) const
190  { return m_PixelAccessor.Get( m_Image->GetPixel(index) ); }
191 
193  const OffsetValueType *GetOffsetTable() const;
194 
196  IndexType ComputeIndex(OffsetValueType offset) const;
197 
200  typedef typename TImage::PixelContainer PixelContainer;
201  typedef typename TImage::PixelContainerPointer PixelContainerPointer;
202  typedef typename TImage::PixelContainerConstPointer PixelContainerConstPointer;
203 
205  PixelContainerPointer GetPixelContainer()
206  { return m_Image->GetPixelContainer(); }
207 
208  const PixelContainer* GetPixelContainer() const
209  { return m_Image->GetPixelContainer(); }
210 
213  void SetPixelContainer( PixelContainer *container );
214 
225  virtual void Graft(const DataObject *data);
226 
229 
232  InternalPixelType *GetBufferPointer();
233  const InternalPixelType *GetBufferPointer() const;
234 
236  virtual void SetSpacing( const SpacingType &values );
237  virtual void SetSpacing( const double* values /*[ImageDimension]*/ );
238  virtual void SetSpacing( const float* values /*[ImageDimension]*/ );
239 
243  virtual const SpacingType& GetSpacing() const;
244 
248  virtual const PointType& GetOrigin() const;
249 
251  virtual void SetOrigin( const PointType values);
252  virtual void SetOrigin( const double* values /*[ImageDimension]*/ );
253  virtual void SetOrigin( const float* values /*[ImageDimension]*/ );
254 
256  virtual void SetDirection( const DirectionType direction );
257 
261  virtual const DirectionType& GetDirection() const;
262 
264  virtual void SetImage( TImage * );
265 
267  virtual void Modified() const;
268 
270  virtual unsigned long GetMTime() const;
271 
273  AccessorType & GetPixelAccessor( void )
274  { return m_PixelAccessor; }
275 
277  const AccessorType & GetPixelAccessor( void ) const
278  { return m_PixelAccessor; }
279 
281  void SetPixelAccessor( const AccessorType & accessor )
282  { m_PixelAccessor = accessor; }
283 
285  virtual void Update();
286  virtual void CopyInformation(const DataObject *data);
287 
290  virtual void UpdateOutputInformation();
291  virtual void SetRequestedRegionToLargestPossibleRegion();
292  virtual void PropagateRequestedRegion() throw (InvalidRequestedRegionError);
293  virtual void UpdateOutputData();
294  virtual bool VerifyRequestedRegion();
295 
300  template<class TCoordRep>
301  bool TransformPhysicalPointToContinuousIndex(
302  const Point<TCoordRep,
303  itkGetStaticConstMacro(ImageDimension)>& point,
304  ContinuousIndex<TCoordRep,
305  itkGetStaticConstMacro(ImageDimension)>& index ) const
306  {
307  return m_Image->TransformPhysicalPointToContinuousIndex( point, index );
308  }
309 
314  template<class TCoordRep>
315  bool TransformPhysicalPointToIndex(
316  const Point<TCoordRep,
317  itkGetStaticConstMacro(ImageDimension)>& point,
318  IndexType & index ) const
319  {
320  return m_Image->TransformPhysicalPointToIndex( point, index );
321  }
322 
327  template<class TCoordRep>
328  void TransformContinuousIndexToPhysicalPoint(
329  const ContinuousIndex<TCoordRep,
330  itkGetStaticConstMacro(ImageDimension)>& index,
331  Point<TCoordRep,
332  itkGetStaticConstMacro(ImageDimension)>& point ) const
333  {
334  m_Image->TransformContinuousIndexToPhysicalPoint( index, point );
335  }
336 
342  template<class TCoordRep>
343  void TransformIndexToPhysicalPoint(
344  const IndexType & index,
345  Point<TCoordRep,
346  itkGetStaticConstMacro(ImageDimension)>& point ) const
347  {
348  m_Image->TransformIndexToPhysicalPoint( index, point );
349  }
350 
351  template<class TCoordRep>
352  void TransformLocalVectorToPhysicalVector(
353  const FixedArray< TCoordRep, itkGetStaticConstMacro(ImageDimension) > & inputGradient,
354  FixedArray< TCoordRep, itkGetStaticConstMacro(ImageDimension) > & outputGradient ) const
355  {
356  m_Image->TransformLocalVectorToPhysicalVector( inputGradient, outputGradient );
357  }
358 
359 protected:
360 
361  ImageAdaptor();
362  virtual ~ImageAdaptor();
363  void PrintSelf(std::ostream& os, Indent indent) const;
364 
365 private:
366 
367  ImageAdaptor(const Self&); //purposely not implemented
368  void operator=(const Self&); //purposely not implemented
369 
370  // Adapted image, most of the calls to ImageAdaptor
371  // will be delegated to this image
372  typename TImage::Pointer m_Image;
373 
374  // Data accessor object,
375  // it converts the presentation of a pixel
377 
378 
379 };
380 
381 } // end namespace itk
382 
383 #ifndef ITK_MANUAL_INSTANTIATION
384 #include "itkImageAdaptor.txx"
385 #endif
386 
387 #endif

Generated at Sat Feb 2 2013 23:42:34 for Orfeo Toolbox with doxygen 1.8.1.1