DGtal  1.1.0
ITKReader.h
1 
17 #pragma once
18 
35 #if defined(ITKReader_RECURSES)
36 #error Recursive header files inclusion detected in ITKReader.h
37 #else // defined(ITKReader_RECURSES)
38 
39 #define ITKReader_RECURSES
40 
41 #if !defined ITKReader_h
42 
43 #define ITKReader_h
44 
45 #include "DGtal/base/Common.h"
46 #include "DGtal/base/CUnaryFunctor.h"
47 #include "DGtal/images/CImage.h"
48 #include "DGtal/base/BasicFunctors.h"
49 #include "DGtal/io/ITKIOTrait.h"
50 #include "DGtal/images/ImageContainerByITKImage.h"
51 #if defined(__GNUG__)
52 #pragma GCC diagnostic push
53 #pragma GCC diagnostic ignored "-Wpedantic"
54 #endif
55 #if defined(__clang__)
56 #pragma clang diagnostic push
57 #pragma clang diagnostic ignored "-Wdocumentation"
58 #endif
59 #include <itkImageFileReader.h>
60 #if defined(__clang__)
61 #pragma clang diagnostic pop
62 #endif
63 #if defined(__GNUG__)
64 #pragma GCC diagnostic pop
65 #endif
66 
67 namespace DGtal
68 {
69 
78  template <typename TImage>
79  struct ITKReader
80  {
81  typedef TImage Image;
82  typedef typename TImage::Value Value;
84 
86  BOOST_STATIC_ASSERT(( (TImage::Domain::dimension == 3)
87  || (TImage::Domain::dimension == 2) ));
88 
104  template <typename TFunctor =
106  static Image importITK(
107  const std::string & filename,
108  const TFunctor & aFunctor = TFunctor(), bool shiftDomainUsingOrigin=true);
109 
122  static Image importITK(const std::string & filename, bool shiftDomainUsingOrigin);
123 
124 
132  static itk::ImageIOBase::IOComponentType
133  getITKComponentType( const std::string & filename );
134 
135  private:
136 
137  template <typename Domain, typename PixelType>
139  readDGtalITKImage(const std::string & filename, bool shiftDomainUsingOrigin=true);
140 
141 
142  template <typename Image, typename Domain, typename OrigValue,
143  typename TFunctor, typename Value>
144  struct Aux
145  {
146  static inline Image
147  readDGtalImageFromITKtypes( const std::string & filename,
148  const TFunctor & aFunctor, bool shiftDomainUsingOrigin=true);
149  };
150 
151  //specialization
152  template <typename Domain, typename OrigValue, typename TFunctor,
153  typename Value>
155  TFunctor, Value>
156  {
158  readDGtalImageFromITKtypes( const std::string & filename,
159  const TFunctor & aFunctor, bool shiftDomainUsingOrigin=true);
160  };
161 
162 
174  template <typename TypeDGtalImage, typename TFunctor>
176  const std::string & filename,
177  const TFunctor & aFunctor, bool shiftDomainUsingOrigin=true);
178  };
179 }//namespace
180 
182 // Includes inline functions.
183 #include "DGtal/io/readers/ITKReader.ih"
184 
185 // //
187 
188 #endif // !defined ITKReader_h
189 
190 #undef ITKReader_RECURSES
191 #endif // else defined(ITKReader_RECURSES)
DGtal::HyperRectDomain< Space >
DGtal::ImageContainerByITKImage
Aim: implements a model of CImageContainer using a ITK Image.
Definition: ImageContainerByITKImage.h:94
DGtal::ITKReader::readDGtalImageFromITKtypes
static Image readDGtalImageFromITKtypes(const std::string &filename, const TFunctor &aFunctor, bool shiftDomainUsingOrigin=true)
DGtal::ITKReader::Value
TImage::Value Value
Definition: ITKReader.h:82
DGtal::functors::Cast
Aim: Define a simple functor using the static cast operator.
Definition: BasicFunctors.h:394
DGtal::ITKReader::readDGtalITKImage
static ImageContainerByITKImage< Domain, PixelType > readDGtalITKImage(const std::string &filename, bool shiftDomainUsingOrigin=true)
DGtal::ITKReader::Aux::readDGtalImageFromITKtypes
static Image readDGtalImageFromITKtypes(const std::string &filename, const TFunctor &aFunctor, bool shiftDomainUsingOrigin=true)
DGtal::ITKReader::ValueOut
ITKIOTrait< Value >::ValueOut ValueOut
Definition: ITKReader.h:83
DGtal::ITKIOTrait::ValueOut
Value ValueOut
Definition: ITKIOTrait.h:56
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition: ClosedIntegerHalfPlane.h:49
Domain
HyperRectDomain< Space > Domain
Definition: testSimpleRandomAccessRangeFromPoint.cpp:44
DGtal::ITKReader::getITKComponentType
static itk::ImageIOBase::IOComponentType getITKComponentType(const std::string &filename)
DGtal::ITKReader::Aux
Definition: ITKReader.h:145
DGtal::ITKReader::Aux< ImageContainerByITKImage< Domain, Value >, Domain, OrigValue, TFunctor, Value >::readDGtalImageFromITKtypes
static ImageContainerByITKImage< Domain, Value > readDGtalImageFromITKtypes(const std::string &filename, const TFunctor &aFunctor, bool shiftDomainUsingOrigin=true)
DGtal::ITKReader
Aim: Import a 2D/3D Image using the ITK formats.
Definition: ITKReader.h:80
DGtal::ITKReader::importITK
static Image importITK(const std::string &filename, bool shiftDomainUsingOrigin)
DGtal::ITKReader::Image
TImage Image
Definition: ITKReader.h:81
DGtal::ITKReader::BOOST_CONCEPT_ASSERT
BOOST_CONCEPT_ASSERT((concepts::CImage< TImage >))
Value
double Value
Definition: testSimpleRandomAccessRangeFromPoint.cpp:38
DGtal::ITKReader::importITK
static Image importITK(const std::string &filename, const TFunctor &aFunctor=TFunctor(), bool shiftDomainUsingOrigin=true)
DGtal::concepts::CImage
Aim: Defines the concept describing a read/write image, having an output iterator.
Definition: CImage.h:103