DGtal  1.0.0
ImageContainerByITKImage.h
1 
17 #pragma once
18 
32 #if defined(ImageContainerByITKImage_RECURSES)
33 #error Recursive header files inclusion detected in ImageContainerByITKImage.h
34 #else // defined(ImageContainerByITKImage_RECURSES)
35 
36 #define ImageContainerByITKImage_RECURSES
37 
38 #if !defined ImageContainerByITKImage_h
39 
40 #define ImageContainerByITKImage_h
41 
43 // Inclusions
44 #include "DGtal/base/Common.h"
45 #include "DGtal/base/CLabel.h"
46 #include "DGtal/kernel/domains/CDomain.h"
47 #include "DGtal/kernel/domains/CDomain.h"
48 #include "DGtal/images/DefaultConstImageRange.h"
49 #include "DGtal/images/DefaultImageRange.h"
50 
51 #if defined(__GNUG__)
52 #pragma GCC diagnostic push
53 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
54 #pragma GCC diagnostic ignored "-Wpedantic"
55 #endif
56 #if defined(__clang__)
57 #pragma clang diagnostic push
58 #pragma clang diagnostic ignored "-Wdocumentation"
59 #endif
60 #include <itkImage.h>
61 #include <itkImageRegionConstIterator.h>
62 #include <itkImageRegionIterator.h>
63 #include <iostream>
64 #if defined(__clang__)
65 #pragma clang diagnostic pop
66 #endif
67 #if defined(__GNUG__)
68 #pragma GCC diagnostic pop
69 #endif
70 
72 namespace DGtal
73 {
74 
76  // template class ImageContainerByITKImage
90  template <typename TDomain, typename TValue>
92  {
93  // ----------------------- Standard services ------------------------------
94  public:
95 
98 
99  typedef TValue Value;
100  typedef TDomain Domain;
102 
103  // static constants
104  static const typename Domain::Dimension dimension = Domain::dimension;
105 
106  typedef typename Domain::Point Point;
107  typedef typename Domain::Vector Vector;
108  typedef typename Domain::Dimension Dimension;
109  typedef typename Domain::Integer Integer;
110  typedef typename Domain::Size Size;
111  typedef Point Vertex;
112 
113  typedef typename itk::Image< TValue, dimension> ITKImage;
114  typedef typename ITKImage::Pointer ITKImagePointer;
115  typedef typename itk::ImageRegionConstIterator< ITKImage > ConstIterator;
116  typedef typename itk::ImageRegionIterator< ITKImage > Iterator;
117 
120 
126  ImageContainerByITKImage(const Domain& aDomain);
127 
134 
142 
150 
155 
156  // ----------------------- Interface --------------------------------------
157  public:
158 
165  void updateDomain();
166 
172  {
173  return ConstRange(*this);
174  }
175 
181  {
182  return Range(*this);
183  }
184 
191  Value operator()(const Point &aPoint) const;
192 
199  Value operator()(const ConstIterator &it) const;
200 
207  Value operator()(const Iterator &it) const;
208 
215  void setValue(const Point &aPoint, const Value &aValue);
216 
223  void setValue(Iterator &it, const Value &V);
224 
225  // ------------------------- methods ------------------------------
226 
227 
231  const Domain& domain() const
232  {
233  return myDomain;
234  }
235 
239  inline
241  {
242  return myITKImagePointer;
243  }
244 
245  // ------------------------- stream ------------------------------
246 
251  void selfDisplay ( std::ostream & out ) const;
252 
257  bool isValid() const;
258 
259  // ------------------------- Iterators ------------------------------
264  inline
266  {
267  ConstIterator iter = ConstIterator(myITKImagePointer, myITKImagePointer->GetLargestPossibleRegion());
268  iter.GoToBegin();
269  return iter;
270  }
271 
276  inline
278  {
279  Iterator iter = Iterator(myITKImagePointer, myITKImagePointer->GetLargestPossibleRegion());
280  iter.GoToBegin();
281  return iter;
282  }
283 
288  inline
289  const ConstIterator end() const
290  {
291  ConstIterator iter = ConstIterator(myITKImagePointer, myITKImagePointer->GetLargestPossibleRegion());
292  iter.GoToEnd();
293  return iter;
294  }
295 
300  inline
302  {
303  Iterator iter = Iterator(myITKImagePointer, myITKImagePointer->GetLargestPossibleRegion());
304  iter.GoToEnd();
305  return iter;
306  }
307 
308  // ------------------------- Private Datas --------------------------------
309  private:
310 
311  // ------------------------- Hidden services ------------------------------
312  protected:
313 
319 
320  // ------------------------- Internals ------------------------------------
321  private:
322 
324  Domain myDomain; // cached from myITKImagePointer region. updated when calling update().
325  }; // end of class ImageContainerByITKImage
326 
333  template <typename T, typename TV>
334  std::ostream&
335  operator<< ( std::ostream & out, const ImageContainerByITKImage<T, TV> & object );
336 
337 }
339 // Includes inline functions.
340 #include "DGtal/images/ImageContainerByITKImage.ih"
341 
342 //
344 
345 #endif // !defined ImageContainerByITKImage_h
346 
347 #undef ImageContainerByITKImage_RECURSES
348 #endif // else defined(ImageContainerByITKImage_RECURSES)
const Point aPoint(3, 4)
Aim: model of CConstBidirectionalRangeFromPoint that adapts the domain of an image in order to iterat...
Aim: Define the concept of DGtal labels. Models of CLabel can be default-constructible,...
Definition: CLabel.h:91
ImageContainerByITKImage< TDomain, TValue > Self
MyDigitalSurface::ConstIterator ConstIterator
Aim: model of CConstBidirectionalRangeFromPoint and CBidirectionalRangeWithWritableIteratorFromPoint ...
ITKImagePointer getITKImagePointer() const
itk::ImageRegionIterator< ITKImage > Iterator
static const Domain::Dimension dimension
DefaultConstImageRange< Self > ConstRange
void selfDisplay(std::ostream &out) const
ImageContainerByITKImage & operator=(const ImageContainerByITKImage &other)
Space::Dimension Dimension
Aim: This concept represents a digital domain, i.e. a non mutable subset of points of the given digit...
Definition: CDomain.h:129
void setValue(const Point &aPoint, const Value &aValue)
itk::ImageRegionConstIterator< ITKImage > ConstIterator
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
BOOST_CONCEPT_ASSERT((concepts::CLabel< TValue >))
Value operator()(const Point &aPoint) const
itk::Image< TValue, dimension > ITKImage
DGtal is the top-level namespace which contains all DGtal functions and types.
MyPointD Point
Definition: testClone2.cpp:383
Aim: implements a model of CImageContainer using a ITK Image.