Orfeo Toolbox  4.0
itkImageAdaptor.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef __itkImageAdaptor_h
19 #define __itkImageAdaptor_h
20 
21 #include "itkImage.h"
22 
23 namespace itk
24 {
25 
26 template <typename TPixelType, unsigned int VImageDimension > class VectorImage;
27 
54 template< typename TImage, typename TAccessor >
55 class ImageAdaptor:public ImageBase< TImage::ImageDimension >
56 {
57 public:
62  itkStaticConstMacro(ImageDimension, unsigned int, TImage::ImageDimension);
63 
65  typedef ImageAdaptor Self;
70 
72  itkTypeMacro(ImageAdaptor, ImageBase);
73 
75  typedef TImage InternalImageType;
76 
78  itkNewMacro(Self);
79 
82  typedef typename TAccessor::ExternalType PixelType;
83 
86  typedef typename TAccessor::InternalType InternalPixelType;
87 
89 
92  typedef TAccessor AccessorType;
93 
96  typedef typename InternalImageType::AccessorFunctorType::template Rebind< Self >::Type AccessorFunctorType;
97 
99  typedef typename Superclass::IndexType IndexType;
101 
103  typedef typename Superclass::SizeType SizeType;
105 
109 
113 
117 
121 
126 
127 
133  template <typename UPixelType, unsigned int UImageDimension = TImage::ImageDimension>
134  struct Rebind
135  {
137  };
138 
139 
146  virtual void SetLargestPossibleRegion(const RegionType & region);
147 
151  virtual void SetBufferedRegion(const RegionType & region);
152 
156  virtual void SetRequestedRegion(const RegionType & region);
157 
162  virtual void SetRequestedRegion(const DataObject *data);
163 
170  virtual const RegionType & GetRequestedRegion() const;
171 
180  virtual const RegionType & GetLargestPossibleRegion() const;
181 
187  virtual const RegionType & GetBufferedRegion() const;
188 
190  inline void Allocate()
191  {
192  m_Image->Allocate();
193  }
194 
197  virtual void Initialize();
198 
200  void SetPixel(const IndexType & index, const PixelType & value)
201  { m_PixelAccessor.Set(m_Image->GetPixel(index), value); }
202 
204  PixelType GetPixel(const IndexType & index) const
205  { return m_PixelAccessor.Get( m_Image->GetPixel(index) ); }
206 
208  PixelType operator[](const IndexType & index) const
209  { return m_PixelAccessor.Get( m_Image->GetPixel(index) ); }
210 
212  const OffsetValueType * GetOffsetTable() const;
213 
215  IndexType ComputeIndex(OffsetValueType offset) const;
216 
219  typedef typename TImage::PixelContainer PixelContainer;
220  typedef typename TImage::PixelContainerPointer PixelContainerPointer;
221  typedef typename TImage::PixelContainerConstPointer PixelContainerConstPointer;
222 
225  { return m_Image->GetPixelContainer(); }
226 
228  { return m_Image->GetPixelContainer(); }
229 
232  void SetPixelContainer(PixelContainer *container);
233 
244  virtual void Graft(const DataObject *data);
245 
248 
252 
253  const InternalPixelType * GetBufferPointer() const;
254 
256  virtual void SetSpacing(const SpacingType & values);
257 
258  virtual void SetSpacing(const double *values /*[ImageDimension]*/);
259 
260  virtual void SetSpacing(const float *values /*[ImageDimension]*/);
261 
265  virtual const SpacingType & GetSpacing() const;
266 
270  virtual const PointType & GetOrigin() const;
271 
273  virtual void SetOrigin(const PointType values);
274 
275  virtual void SetOrigin(const double *values /*[ImageDimension]*/);
276 
277  virtual void SetOrigin(const float *values /*[ImageDimension]*/);
278 
280  virtual void SetDirection(const DirectionType & direction);
281 
285  virtual const DirectionType & GetDirection() const;
286 
288  virtual void SetImage(TImage *);
289 
291  virtual void Modified() const;
292 
294  virtual ModifiedTimeType GetMTime() const;
295 
298  { return m_PixelAccessor; }
299 
301  const AccessorType & GetPixelAccessor(void) const
302  { return m_PixelAccessor; }
303 
305  void SetPixelAccessor(const AccessorType & accessor)
306  { m_PixelAccessor = accessor; }
307 
309  virtual void Update();
310 
311  virtual void CopyInformation(const DataObject *data);
312 
315  virtual void UpdateOutputInformation();
316 
318 
319  virtual void PropagateRequestedRegion()
320  throw ( InvalidRequestedRegionError );
321 
322  virtual void UpdateOutputData();
323 
324  virtual bool VerifyRequestedRegion();
325 
330  template< typename TCoordRep >
332  const Point< TCoordRep,
333  itkGetStaticConstMacro(ImageDimension) > & point,
334  ContinuousIndex< TCoordRep,
335  itkGetStaticConstMacro(ImageDimension) > & index) const
336  {
337  return m_Image->TransformPhysicalPointToContinuousIndex(point, index);
338  }
339 
344  template< typename TCoordRep >
346  const Point< TCoordRep,
347  itkGetStaticConstMacro(ImageDimension) > & point,
348  IndexType & index) const
349  {
350  return m_Image->TransformPhysicalPointToIndex(point, index);
351  }
352 
357  template< typename TCoordRep >
359  const ContinuousIndex< TCoordRep,
360  itkGetStaticConstMacro(ImageDimension) > & index,
361  Point< TCoordRep,
362  itkGetStaticConstMacro(ImageDimension) > & point) const
363  {
364  m_Image->TransformContinuousIndexToPhysicalPoint(index, point);
365  }
366 
372  template< typename TCoordRep >
374  const IndexType & index,
375  Point< TCoordRep,
376  itkGetStaticConstMacro(ImageDimension) > & point) const
377  {
378  m_Image->TransformIndexToPhysicalPoint(index, point);
379  }
380 
381  template< typename TCoordRep >
383  const FixedArray< TCoordRep, itkGetStaticConstMacro(ImageDimension) > & inputGradient,
384  FixedArray< TCoordRep, itkGetStaticConstMacro(ImageDimension) > & outputGradient) const
385  {
386  m_Image->TransformLocalVectorToPhysicalVector(inputGradient, outputGradient);
387  }
388 
389  template< typename TCoordRep >
391  const FixedArray< TCoordRep, itkGetStaticConstMacro(ImageDimension) > & inputGradient,
392  FixedArray< TCoordRep, itkGetStaticConstMacro(ImageDimension) > & outputGradient) const
393  {
394  m_Image->TransformPhysicalVectorToLocalVector(inputGradient, outputGradient);
395  }
396 
397 protected:
398 
399  ImageAdaptor();
400  virtual ~ImageAdaptor();
401  void PrintSelf(std::ostream & os, Indent indent) const;
402 
403 private:
404 
405  ImageAdaptor(const Self &); //purposely not implemented
406  void operator=(const Self &); //purposely not implemented
407 
408  // a specialized method to update PixelAccessors for VectorImages,
409  // to have the correct vector length of the image.
410  template< typename TPixelType >
411  void UpdateAccessor( typename ::itk::VectorImage< TPixelType, ImageDimension > * itkNotUsed( dummy ) )
412  {
413  this->m_PixelAccessor.SetVectorLength( this->m_Image->GetNumberOfComponentsPerPixel() );
414  }
415 
416  // The other image types don't expect an accessor which needs any updates
417  template< typename T > void UpdateAccessor( T *itkNotUsed( dummy ) ) { }
418 
419  // Adapted image, most of the calls to ImageAdaptor
420  // will be delegated to this image
421  typename TImage::Pointer m_Image;
422 
423  // Data accessor object,
424  // it converts the presentation of a pixel
426 };
427 } // end namespace itk
428 
429 #ifndef ITK_MANUAL_INSTANTIATION
430 #include "itkImageAdaptor.hxx"
431 #endif
432 
433 #endif

Generated at Sat Mar 8 2014 14:49:49 for Orfeo Toolbox with doxygen 1.8.3.1