DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ImageContainerByITKImage.h
1 
17 #pragma once
18 
31 #if defined(ImageContainerByITKImage_RECURSES)
32 #error Recursive header files inclusion detected in ImageContainerByITKImage.h
33 #else // defined(ImageContainerByITKImage_RECURSES)
34 
35 #define ImageContainerByITKImage_RECURSES
36 
37 #if !defined ImageContainerByITKImage_h
38 
39 #define ImageContainerByITKImage_h
40 
42 // Inclusions
43 #include "DGtal/base/Common.h"
44 #include "DGtal/base/CLabel.h"
45 #include "DGtal/kernel/domains/CDomain.h"
46 
47 #include <itkImage.h>
48 #include <itkImageRegionConstIterator.h>
49 #include <itkImageRegionIterator.h>
50 #include <iostream>
51 
53 
54 namespace DGtal
55 {
56  namespace experimental
57  {
58 
60  // template class ImageContainerByITKImage
70  template <typename TDomain, typename TValue>
72  {
73  // ----------------------- Standard services ------------------------------
74  public:
75 
78 
79  typedef TValue Value;
80  typedef TDomain Domain;
81 
82  // static constants
83  static const typename Domain::Dimension dimension = Domain::dimension;
84 
85  typedef typename Domain::Point Point;
86  typedef typename Domain::Vector Vector;
87  typedef typename Domain::Dimension Dimension;
88  typedef typename Domain::Integer Integer;
89  typedef typename Domain::Size Size;
90  typedef Point Vertex;
91 
92  typedef typename itk::Image< TValue, dimension> ITKImage;
93  typedef typename ITKImage::Pointer ITKImagePointer;
94  typedef typename itk::ImageRegionConstIterator< ITKImage > ConstIterator;
95  typedef typename itk::ImageRegionIterator< ITKImage > Iterator;
96 
98 
104  ImageContainerByITKImage(const Point &aPointA,
105  const Point &aPointB );
106 
113  ImageContainerByITKImage(const Point &aPointA,
114  const Point &aPointB,
115  ITKImagePointer &aRef);
116 
121 
122  // ----------------------- Interface --------------------------------------
123  public:
124 
125 
132  Value operator()(const Point &aPoint) const;
133 
140  Value operator()(const ConstIterator &it) const;
141 
148  Value operator()(const Iterator &it) const;
149 
150 
157  void setValue(const Point &aPoint, const Value &aValue);
158 
165  void setValue(Iterator &it, const Value &V);
166 
167  // ------------------------- methods ------------------------------
168 
169 
173  Domain domain() const
174  {
176  }
177 
182  Point extent() const
183  {
184  return myUpperBound - myLowerBound;
185  }
186 
187 
192  {
193  return myITKImagePointer;
194  }
195 
196  // ------------------------- stream ------------------------------
197 
202  void selfDisplay ( std::ostream & out ) const;
203 
208  bool isValid() const;
209 
210  // ------------------------- Iterators ------------------------------
216  {
217  return myConstItBegin;
218  }
219 
225  {
226  return myItBegin;
227  }
228 
233  ConstIterator begin ( const Point &aPoint ) const;
234 
239  const ConstIterator end() const
240  {
241  return myConstItEnd;
242  }
243 
249  {
250  return myItEnd;
251  }
252 
258  ConstIterator end(const Point &aPoint) const;
259 
260  // ------------------------- Private Datas --------------------------------
261  private:
262 
263  // ------------------------- Hidden services ------------------------------
264  protected:
265 
271 
272  private:
273 
280 
288 
289  // ------------------------- Internals ------------------------------------
290  private:
291 
295  typename ITKImage::RegionType myRegion;
300 
301  }; // end of class ImageContainerByITKImage
302 
303  }
304 
311  template <typename T, typename TV>
312  std::ostream&
313  operator<< ( std::ostream & out, const experimental::ImageContainerByITKImage<T, TV> & object );
314 
315 }
317 // Includes inline functions.
318 #include "DGtal/images/ImageContainerByITKImage.ih"
319 
320 //
322 
323 #endif // !defined ImageContainerByITKImage_h
324 
325 #undef ImageContainerByITKImage_RECURSES
326 #endif // else defined(ImageContainerByITKImage_RECURSES)