31 #if defined(GenericReader_RECURSES)
32 #error Recursive header files inclusion detected in GenericReader.h
35 #define GenericReader_RECURSES
37 #if !defined GenericReader_h
39 #define GenericReader_h
45 #include "DGtal/images/CImage.h"
46 #include "DGtal/base/Common.h"
47 #include "DGtal/io/readers/VolReader.h"
48 #include "DGtal/io/readers/LongvolReader.h"
49 #include "DGtal/io/readers/PPMReader.h"
50 #include "DGtal/io/readers/PGMReader.h"
51 #include "DGtal/io/readers/RawReader.h"
52 #include "DGtal/io/readers/STBReader.h"
54 #include "DGtal/io/readers/HDF5Reader.h"
57 #include "DGtal/io/readers/DicomReader.h"
58 #include "DGtal/io/readers/ITKReader.h"
60 #include "DGtal/io/colormaps/BasicColorToScalarFunctors.h"
98 template <
typename TContainer,
int Tdim=TContainer::Po
int::dimension,
typename TValue =
typename TContainer::Value>
113 static TContainer
import(
const std::string &filename,
114 std::vector<unsigned int> dimSpace= std::vector<unsigned int > () );
128 template <
typename TFunctor>
130 const std::string & filename,
const TFunctor & aFunctor,
131 std::vector<unsigned int> dimSpace =
132 std::vector<unsigned int>() )
137 const std::string extension =
138 filename.substr( filename.find_last_of(
"." ) + 1 );
140 if ( extension ==
"raw" )
142 for (
unsigned int i = 0; i < dimSpace.size(); i++ )
143 ASSERT( dimSpace[ i ] != 0 );
145 for (
unsigned int i = 0; i < dimSpace.size(); i++ )
146 pt[ i ] = dimSpace[ i ];
149 filename, pt, aFunctor );
153 <<
" not yet implemented in DGtal GenericReader."
173 template <
typename TFunctor>
175 const std::string & filename,
const TFunctor & aFunctor,
176 std::vector<unsigned int> dimSpace =
177 std::vector<unsigned int>() )
185 const std::string extension =
186 filename.substr( filename.find_last_of(
"." ) + 1 );
188 if ( extension ==
"raw" )
190 for (
unsigned int i = 0; i < dimSpace.size(); i++ )
191 ASSERT( dimSpace[ i ] != 0 );
193 for (
unsigned int i = 0; i < dimSpace.size(); i++ )
194 pt[ i ] = dimSpace[ i ];
200 <<
" not yet implemented in DGtal GenericReader."
211 template <
typename TContainer,
typename TValue>
227 static TContainer
import(
const std::string &filename,
unsigned int x=0,
228 unsigned int y=0,
unsigned int z=0);
244 template<
typename TFunctor>
246 const TFunctor &aFunctor,
248 unsigned int y=0,
unsigned int z=0)
252 const std::string extension = filename.substr(filename.find_last_of(
".") + 1);
254 if ( extension ==
"vol" )
258 else if ( extension ==
"longvol" )
262 else if ( extension ==
"pgm3d" || extension ==
"pgm3D" || extension ==
"p3d" || extension ==
"pgm" )
266 else if ( extension ==
"raw" )
268 ASSERT( x != 0 && y != 0 && z != 0 );
274 if ( extension ==
"h5" )
279 if ( extension ==
"dcm" )
289 trace.
error() <<
"Extension " << extension<<
" in 3D, not yet implemented in DGtal GenericReader." << std::endl;
300 template <
typename TContainer>
316 static TContainer
import(
const std::string &filename,
unsigned int x=0,
317 unsigned int y=0,
unsigned int z=0);
333 template<
typename TFunctor>
335 const TFunctor &aFunctor,
337 unsigned int y=0,
unsigned int z=0)
341 const std::string extension = filename.substr( filename.find_last_of(
".") + 1 );
343 if ( extension ==
"longvol" )
347 else if ( extension ==
"raw" )
349 ASSERT( x != 0 && y != 0 && z != 0 );
355 if ( extension ==
"dcm" )
359 else if ( extension ==
"mha" || extension ==
"mhd" )
365 trace.
error() <<
"Extension " << extension<<
" not yet implemented in DGtal GenericReader." << std::endl;
377 template <
typename TContainer>
388 static TContainer
import(
const std::string &filename);
397 template <
typename TContainer,
typename TValue>
413 static TContainer
import(
const std::string &filename,
unsigned int x=0,
428 template<
typename TFunctor>
430 const TFunctor &aFunctor,
437 const std::string extension = filename.substr( filename.find_last_of(
".") + 1 );
439 if ( extension ==
"ppm" )
443 else if ( extension ==
"raw" )
445 ASSERT( x != 0 && y != 0 );
449 else if ( extension ==
"gif" || extension ==
"jpg" || extension ==
"png" || extension ==
"jpeg" || extension ==
"bmp" || extension ==
"tga" )
452 return reader.
import( filename, aFunctor );
455 trace.
error() <<
"Extension " << extension<<
" in 2D, not yet implemented in DGtal GenericReader." << std::endl;
471 template<
typename TFunctor>
473 const TFunctor &aFunctor,
unsigned int x=0,
480 const std::string extension = filename.substr( filename.find_last_of(
".") + 1 );
482 if ( extension ==
"raw" )
484 ASSERT( x!= 0 && y != 0);
488 else if ( extension ==
"pgm" )
498 trace.
error() <<
"Extension " << extension<<
" not yet implemented in DGtal GenericReader." << std::endl;
509 template <
typename TContainer>
525 static TContainer
import(
const std::string &filename,
unsigned int x=0,
540 template<
typename TFunctor>
542 const TFunctor &aFunctor,
unsigned int x=0,
549 const std::string extension = filename.substr(filename.find_last_of(
".") + 1);
551 if ( extension ==
"ppm" )
555 else if ( extension ==
"raw" )
557 ASSERT( x != 0 && y != 0 );
561 else if ( extension ==
"tga" || extension ==
"jpg" || extension ==
"png" || extension ==
"jpeg" || extension ==
"bmp" )
564 return reader.
import( filename, aFunctor );
567 trace.
error() <<
"Extension " << extension<<
" not yet implemented in DGtal GenericReader." << std::endl;
582 template<
typename TFunctor>
584 const TFunctor &aFunctor,
unsigned int x=0,
591 const std::string extension = filename.substr(filename.find_last_of(
".") + 1);
593 if ( extension ==
"raw" )
595 ASSERT( x != 0 && y != 0);
599 else if ( extension ==
"pgm ")
609 trace.
error() <<
"Extension " << extension<<
" not yet implemented in DGtal GenericReader." << std::endl;
622 #include "DGtal/io/readers/GenericReader.ih"
629 #undef GenericReader_RECURSES
Structure representing an RGB triple with alpha component.
Aim: Image reader using the stb_image.h header only code.
static ImageContainer import(const std::string &filename, const Functor &aFunctor=Functor())
DGtal is the top-level namespace which contains all DGtal functions and types.
boost::uint32_t uint32_t
unsigned 32-bit integer.
const auto ITK_IO_IMAGE_EXT
boost::uint64_t uint64_t
unsigned 64-bit integer.
static ImageContainer importDicom(const std::string &aFilename, const Functor &aFunctor=Functor())
static TContainer importWithValueFunctor(const std::string &filename, const TFunctor &aFunctor, unsigned int x=0, unsigned int y=0)
BOOST_CONCEPT_ASSERT((concepts::CImage< TContainer >))
static TContainer importWithColorFunctor(const std::string &filename, const TFunctor &aFunctor, unsigned int x=0, unsigned int y=0)
static TContainer importWithValueFunctor(const std::string &filename, const TFunctor &aFunctor, unsigned int x=0, unsigned int y=0)
BOOST_CONCEPT_ASSERT((concepts::CImage< TContainer >))
static TContainer importWithColorFunctor(const std::string &filename, const TFunctor &aFunctor, unsigned int x=0, unsigned int y=0)
static TContainer importWithValueFunctor(const std::string &filename, const TFunctor &aFunctor, unsigned int x=0, unsigned int y=0, unsigned int z=0)
BOOST_CONCEPT_ASSERT((concepts::CImage< TContainer >))
BOOST_CONCEPT_ASSERT((concepts::CImage< TContainer >))
static TContainer importWithValueFunctor(const std::string &filename, const TFunctor &aFunctor, unsigned int x=0, unsigned int y=0, unsigned int z=0)
BOOST_CONCEPT_ASSERT((concepts::CImage< TContainer >))
Aim: Provide a mechanism to load with the bestloader according to an image (2D or 3D) filename (by pa...
static TContainer importWithColorFunctor(const std::string &filename, const TFunctor &aFunctor, std::vector< unsigned int > dimSpace=std::vector< unsigned int >())
static TContainer importWithValueFunctor(const std::string &filename, const TFunctor &aFunctor, std::vector< unsigned int > dimSpace=std::vector< unsigned int >())
BOOST_CONCEPT_ASSERT((concepts::CImage< TContainer >))
static ImageContainer importHDF5_3D(const std::string &aFilename, const std::string &aDataset, const Functor &aFunctor=Functor())
static ImageContainer importHDF5(const std::string &aFilename, const std::string &aDataset, const Functor &aFunctor=Functor(), bool topbotomOrder=true)
static Image importITK(const std::string &filename, const TFunctor &aFunctor=TFunctor(), bool shiftDomainUsingOrigin=true)
static ImageContainer importLongvol(const std::string &filename, const Functor &aFunctor=Functor())
static ImageContainer importPGM3D(const std::string &aFilename, const Functor &aFunctor=Functor())
static ImageContainer importPGM(const std::string &aFilename, const Functor &aFunctor=Functor(), bool topbotomOrder=true)
static ImageContainer importPPM(const std::string &aFilename, const Functor &aFunctor=functors::ColorRGBEncoder< Value >(), bool topbotomOrder=true)
Aim: Raw binary import of an Image.
static ImageContainer importRaw8(const std::string &filename, const Vector &extent, const Functor &aFunctor=Functor())
static ImageContainer importRaw32(const std::string &filename, const Vector &extent, const Functor &aFunctor=Functor())
static ImageContainer importVol(const std::string &filename, const Functor &aFunctor=Functor())
Aim: Defines the concept describing a read/write image, having an output iterator.
Aim: Defines a unary functor, which associates arguments to results.