DGtal  1.1.0
ImageContainerByITKImage.h
1 
17 #pragma once
18 
33 #if defined(ImageContainerByITKImage_RECURSES)
34 #error Recursive header files inclusion detected in ImageContainerByITKImage.h
35 #else // defined(ImageContainerByITKImage_RECURSES)
36 
37 #define ImageContainerByITKImage_RECURSES
38 
39 #if !defined ImageContainerByITKImage_h
40 
41 #define ImageContainerByITKImage_h
42 
44 // Inclusions
45 #include "DGtal/base/Common.h"
46 #include "DGtal/base/CLabel.h"
47 #include "DGtal/kernel/domains/CDomain.h"
48 #include "DGtal/kernel/domains/CDomain.h"
49 #include "DGtal/kernel/PointVector.h"
50 #include "DGtal/images/DefaultConstImageRange.h"
51 #include "DGtal/images/DefaultImageRange.h"
52 
53 #if defined(__GNUG__)
54 #pragma GCC diagnostic push
55 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
56 #pragma GCC diagnostic ignored "-Wpedantic"
57 #endif
58 #if defined(__clang__)
59 #pragma clang diagnostic push
60 #pragma clang diagnostic ignored "-Wdocumentation"
61 #endif
62 #include <itkImage.h>
63 #include <itkImageRegionConstIterator.h>
64 #include <itkImageRegionIterator.h>
65 #include <iostream>
66 #if defined(__clang__)
67 #pragma clang diagnostic pop
68 #endif
69 #if defined(__GNUG__)
70 #pragma GCC diagnostic pop
71 #endif
72 
74 namespace DGtal
75 {
76 
78  // template class ImageContainerByITKImage
92  template <typename TDomain, typename TValue>
94  {
95  // ----------------------- Standard services ------------------------------
96  public:
97 
100 
101  typedef TValue Value;
102  typedef TDomain Domain;
104 
105  // static constants
106  static const typename Domain::Dimension dimension = Domain::dimension;
107 
108  typedef typename Domain::Point Point;
109  typedef typename Domain::Vector Vector;
110  typedef typename Domain::Dimension Dimension;
111  typedef typename Domain::Integer Integer;
112  typedef typename Domain::Size Size;
113  typedef Point Vertex;
116 
117  typedef typename itk::Image< TValue, dimension> ITKImage;
118  typedef typename ITKImage::Pointer ITKImagePointer;
119  typedef typename itk::ImageRegionConstIterator< ITKImage > ConstIterator;
120  typedef typename itk::ImageRegionIterator< ITKImage > Iterator;
121 
124 
131 
138 
146 
154 
159 
160  // ----------------------- Interface --------------------------------------
161  public:
162 
173  void updateDomain(const Point & inputDomainShift = Point());
174 
180  {
181  return ConstRange(*this);
182  }
183 
189  {
190  return Range(*this);
191  }
192 
199  Value operator()(const Point &domainPoint) const;
200 
207  Value operator()(const ConstIterator &it) const;
208 
215  Value operator()(const Iterator &it) const;
216 
223  void setValue(const Point &domainPoint, const Value &aValue);
224 
231  void setValue(Iterator &it, const Value &V);
232 
233  // ------------------------- methods ------------------------------
234 
235 
239  const Domain& domain() const
240  {
241  return myDomain;
242  }
243 
247  inline
249  {
250  return myITKImagePointer;
251  }
252 
253  inline
254  const Point & getDomainShift() const
255  {
256  return myDomainShift;
257  }
258 
259  // ------------------------- stream ------------------------------
260 
265  void selfDisplay ( std::ostream & out ) const;
266 
271  bool isValid() const;
272 
273  // ------------------------- Iterators ------------------------------
278  inline
280  {
281  ConstIterator iter = ConstIterator(myITKImagePointer, myITKImagePointer->GetLargestPossibleRegion());
282  iter.GoToBegin();
283  return iter;
284  }
285 
290  inline
292  {
293  Iterator iter = Iterator(myITKImagePointer, myITKImagePointer->GetLargestPossibleRegion());
294  iter.GoToBegin();
295  return iter;
296  }
297 
302  inline
303  const ConstIterator end() const
304  {
305  ConstIterator iter = ConstIterator(myITKImagePointer, myITKImagePointer->GetLargestPossibleRegion());
306  iter.GoToEnd();
307  return iter;
308  }
309 
314  inline
316  {
317  Iterator iter = Iterator(myITKImagePointer, myITKImagePointer->GetLargestPossibleRegion());
318  iter.GoToEnd();
319  return iter;
320  }
321 
322  // ----------------- DomainPoint to/from IndexPoint interface -------------
323 
332  inline Point getDomainPointFromIndex(const Point &indexPoint) const;
333 
334  inline Point getIndexFromDomainPoint(const Point &domainPoint) const;
335 
343  inline Point getDomainPointFromItkIndex(const typename ITKImage::IndexType &itkIndexPoint) const;
344 
345  inline typename ITKImage::IndexType getItkIndexFromDomainPoint(const Point &domainPoint) const;
346 
347 
348  // ------------------------- PhysicalPoint interface ----------------------
349 
361  inline PhysicalPoint getPhysicalPointFromDomainPoint(const Point &domainPoint) const;
362 
363  inline Point getDomainPointFromPhysicalPoint(const PhysicalPoint &physicalPoint) const;
364 
377 
378  // ------------------------- Private Datas --------------------------------
379  private:
380 
381  // ------------------------- Hidden services ------------------------------
382  protected:
383 
389 
390  // ------------------------- Internals ------------------------------------
391  private:
392 
394  Domain myDomain; // cached from myITKImagePointer region. updated when calling update().
395 
413  }; // end of class ImageContainerByITKImage
414 
421  template <typename T, typename TV>
422  std::ostream&
423  operator<< ( std::ostream & out, const ImageContainerByITKImage<T, TV> & object );
424 
425 }
427 // Includes inline functions.
428 #include "DGtal/images/ImageContainerByITKImage.ih"
429 
430 //
432 
433 #endif // !defined ImageContainerByITKImage_h
434 
435 #undef ImageContainerByITKImage_RECURSES
436 #endif // else defined(ImageContainerByITKImage_RECURSES)
DGtal::ImageContainerByITKImage::Self
ImageContainerByITKImage< TDomain, TValue > Self
Definition: ImageContainerByITKImage.h:103
DGtal::ImageContainerByITKImage::selfDisplay
void selfDisplay(std::ostream &out) const
DGtal::HyperRectDomain::Dimension
Space::Dimension Dimension
Definition: HyperRectDomain.h:116
DGtal::ImageContainerByITKImage::getUpperBoundAsPhysicalPoint
PhysicalPoint getUpperBoundAsPhysicalPoint() const
DGtal::ImageContainerByITKImage::getDomainShift
const Point & getDomainShift() const
Definition: ImageContainerByITKImage.h:254
DGtal::ImageContainerByITKImage::getDomainPointFromIndex
Point getDomainPointFromIndex(const Point &indexPoint) const
DGtal::ImageContainerByITKImage::updateDomain
void updateDomain(const Point &inputDomainShift=Point())
DGtal::ImageContainerByITKImage::end
Iterator end()
Definition: ImageContainerByITKImage.h:315
DGtal::ImageContainerByITKImage::getDomainPointFromItkIndex
Point getDomainPointFromItkIndex(const typename ITKImage::IndexType &itkIndexPoint) const
DGtal::ImageContainerByITKImage
Aim: implements a model of CImageContainer using a ITK Image.
Definition: ImageContainerByITKImage.h:94
DGtal::ImageContainerByITKImage::myITKImagePointer
ITKImagePointer myITKImagePointer
Definition: ImageContainerByITKImage.h:393
DGtal::ImageContainerByITKImage::Vector
Domain::Vector Vector
Definition: ImageContainerByITKImage.h:109
DGtal::ImageContainerByITKImage::getITKImagePointer
ITKImagePointer getITKImagePointer() const
Definition: ImageContainerByITKImage.h:248
DGtal::ImageContainerByITKImage::myDomain
Domain myDomain
Definition: ImageContainerByITKImage.h:394
DGtal::ImageContainerByITKImage::operator=
ImageContainerByITKImage & operator=(const ImageContainerByITKImage &other)
DGtal::ImageContainerByITKImage::ITKImagePointer
ITKImage::Pointer ITKImagePointer
Definition: ImageContainerByITKImage.h:118
DGtal::ImageContainerByITKImage::Size
Domain::Size Size
Definition: ImageContainerByITKImage.h:112
DGtal::ImageContainerByITKImage::constRange
ConstRange constRange() const
Definition: ImageContainerByITKImage.h:179
DGtal::ImageContainerByITKImage::range
Range range()
Definition: ImageContainerByITKImage.h:188
DGtal::HyperRectDomain< Space >::Size
Space::Size Size
Definition: HyperRectDomain.h:117
DGtal::ImageContainerByITKImage::ImageContainerByITKImage
ImageContainerByITKImage(const ITKImagePointer &aRef)
DGtal::DefaultConstImageRange
Aim: model of CConstBidirectionalRangeFromPoint that adapts the domain of an image in order to iterat...
Definition: DefaultConstImageRange.h:77
DGtal::ImageContainerByITKImage::myDomainShift
Point myDomainShift
Definition: ImageContainerByITKImage.h:412
DGtal::DefaultImageRange
Aim: model of CConstBidirectionalRangeFromPoint and CBidirectionalRangeWithWritableIteratorFromPoint ...
Definition: DefaultImageRange.h:77
DGtal::ImageContainerByITKImage::begin
Iterator begin()
Definition: ImageContainerByITKImage.h:291
DGtal::ImageContainerByITKImage::setValue
void setValue(const Point &domainPoint, const Value &aValue)
DGtal::ImageContainerByITKImage::ImageContainerByITKImage
ImageContainerByITKImage(const Domain &aDomain)
DGtal::concepts::CDomain
Aim: This concept represents a digital domain, i.e. a non mutable subset of points of the given digit...
Definition: CDomain.h:130
DGtal::ImageContainerByITKImage::begin
ConstIterator begin() const
Definition: ImageContainerByITKImage.h:279
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition: ClosedIntegerHalfPlane.h:49
DGtal::ImageContainerByITKImage::RealPoint
PointVector< dimension, double > RealPoint
Definition: ImageContainerByITKImage.h:114
DGtal::ImageContainerByITKImage::Range
DefaultImageRange< Self > Range
Definition: ImageContainerByITKImage.h:123
DGtal::ImageContainerByITKImage::setValue
void setValue(Iterator &it, const Value &V)
DGtal::ImageContainerByITKImage::ImageContainerByITKImage
ImageContainerByITKImage(const ImageContainerByITKImage &other)
DGtal::ImageContainerByITKImage::ImageContainerByITKImage
ImageContainerByITKImage()
DGtal::ImageContainerByITKImage::~ImageContainerByITKImage
~ImageContainerByITKImage()
DGtal::ImageContainerByITKImage::BOOST_CONCEPT_ASSERT
BOOST_CONCEPT_ASSERT((concepts::CLabel< TValue >))
DGtal::ImageContainerByITKImage::dimension
static const Domain::Dimension dimension
Definition: ImageContainerByITKImage.h:106
DGtal::ImageContainerByITKImage::ConstIterator
itk::ImageRegionConstIterator< ITKImage > ConstIterator
Definition: ImageContainerByITKImage.h:119
DGtal::operator<<
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
DGtal::ImageContainerByITKImage::getDomainPointFromPhysicalPoint
Point getDomainPointFromPhysicalPoint(const PhysicalPoint &physicalPoint) const
DGtal::concepts::CLabel
Aim: Define the concept of DGtal labels. Models of CLabel can be default-constructible,...
Definition: CLabel.h:93
DGtal::ImageContainerByITKImage::ConstRange
DefaultConstImageRange< Self > ConstRange
Definition: ImageContainerByITKImage.h:122
DGtal::ImageContainerByITKImage::operator()
Value operator()(const Iterator &it) const
DGtal::ImageContainerByITKImage::ITKImage
itk::Image< TValue, dimension > ITKImage
Definition: ImageContainerByITKImage.h:117
DGtal::ImageContainerByITKImage::operator()
Value operator()(const Point &domainPoint) const
DGtal::ImageContainerByITKImage::getItkIndexFromDomainPoint
ITKImage::IndexType getItkIndexFromDomainPoint(const Point &domainPoint) const
DGtal::ImageContainerByITKImage::end
const ConstIterator end() const
Definition: ImageContainerByITKImage.h:303
DGtal::HyperRectDomain< Space >::Integer
Space::Integer Integer
Definition: HyperRectDomain.h:114
DGtal::PointVector< dim, Integer >
DGtal::ImageContainerByITKImage::Domain
TDomain Domain
Definition: ImageContainerByITKImage.h:102
DGtal::ImageContainerByITKImage::Iterator
itk::ImageRegionIterator< ITKImage > Iterator
Definition: ImageContainerByITKImage.h:120
DGtal::ImageContainerByITKImage::Value
TValue Value
Definition: ImageContainerByITKImage.h:101
DGtal::ImageContainerByITKImage::Dimension
Domain::Dimension Dimension
Definition: ImageContainerByITKImage.h:110
DGtal::ImageContainerByITKImage::getLowerBoundAsPhysicalPoint
PhysicalPoint getLowerBoundAsPhysicalPoint() const
DGtal::ImageContainerByITKImage::Integer
Domain::Integer Integer
Definition: ImageContainerByITKImage.h:111
DGtal::ImageContainerByITKImage::Vertex
Point Vertex
Definition: ImageContainerByITKImage.h:113
DGtal::ImageContainerByITKImage::BOOST_CONCEPT_ASSERT
BOOST_CONCEPT_ASSERT((concepts::CDomain< TDomain >))
DGtal::ImageContainerByITKImage::isValid
bool isValid() const
DGtal::ImageContainerByITKImage::operator()
Value operator()(const ConstIterator &it) const
DGtal::ImageContainerByITKImage::Point
Domain::Point Point
Definition: ImageContainerByITKImage.h:108
DGtal::ImageContainerByITKImage::domain
const Domain & domain() const
Definition: ImageContainerByITKImage.h:239
DGtal::ImageContainerByITKImage::PhysicalPoint
RealPoint PhysicalPoint
Definition: ImageContainerByITKImage.h:115
DGtal::ImageContainerByITKImage::getIndexFromDomainPoint
Point getIndexFromDomainPoint(const Point &domainPoint) const
DGtal::ImageContainerByITKImage::getPhysicalPointFromDomainPoint
PhysicalPoint getPhysicalPointFromDomainPoint(const Point &domainPoint) const