DGtal 1.4.0
Loading...
Searching...
No Matches
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)
39#define ITKReader_RECURSES
40
41#if !defined ITKReader_h
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
67namespace 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 =
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)
Aim: implements a model of CImageContainer using a ITK Image.
DGtal is the top-level namespace which contains all DGtal functions and types.
static ImageContainerByITKImage< Domain, Value > readDGtalImageFromITKtypes(const std::string &filename, const TFunctor &aFunctor, bool shiftDomainUsingOrigin=true)
static Image readDGtalImageFromITKtypes(const std::string &filename, const TFunctor &aFunctor, bool shiftDomainUsingOrigin=true)
Aim: Import a 2D/3D Image using the ITK formats.
Definition ITKReader.h:80
static Image importITK(const std::string &filename, const TFunctor &aFunctor=TFunctor(), bool shiftDomainUsingOrigin=true)
ITKIOTrait< Value >::ValueOut ValueOut
Definition ITKReader.h:83
static Image readDGtalImageFromITKtypes(const std::string &filename, const TFunctor &aFunctor, bool shiftDomainUsingOrigin=true)
static itk::ImageIOBase::IOComponentType getITKComponentType(const std::string &filename)
static Image importITK(const std::string &filename, bool shiftDomainUsingOrigin)
BOOST_CONCEPT_ASSERT((concepts::CImage< TImage >))
static ImageContainerByITKImage< Domain, PixelType > readDGtalITKImage(const std::string &filename, bool shiftDomainUsingOrigin=true)
TImage::Value Value
Definition ITKReader.h:82
Aim: Defines the concept describing a read/write image, having an output iterator.
Definition CImage.h:103
Aim: Define a simple functor using the static cast operator.
HyperRectDomain< Space > Domain