31 #if defined(GenericReader_RECURSES)
32 #error Recursive header files inclusion detected in GenericReader.h
33 #else // defined(GenericReader_RECURSES)
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"
53 #include "DGtal/io/readers/HDF5Reader.h"
56 #include "DGtal/io/readers/MagickReader.h"
59 #include "DGtal/io/readers/DicomReader.h"
60 #include "DGtal/io/readers/ITKReader.h"
62 #include "DGtal/io/colormaps/BasicColorToScalarFunctors.h"
100 template <
typename TContainer,
int Tdim=TContainer::Po
int::dimension,
typename TValue =
typename TContainer::Value>
115 static TContainer
import(
const std::string &filename,
116 std::vector<unsigned int> dimSpace= std::vector<unsigned int > () );
130 template <
typename TFunctor>
132 const std::string & filename,
const TFunctor & aFunctor,
133 std::vector<unsigned int> dimSpace =
134 std::vector<unsigned int>() )
139 const std::string extension =
140 filename.substr( filename.find_last_of(
"." ) + 1 );
142 if ( extension ==
"raw" )
144 for (
unsigned int i = 0; i < dimSpace.size(); i++ )
145 ASSERT( dimSpace[ i ] != 0 );
147 for (
unsigned int i = 0; i < dimSpace.size(); i++ )
148 pt[ i ] = dimSpace[ i ];
151 filename, pt, aFunctor );
155 <<
" not yet implemented in DGtal GenericReader."
175 template <
typename TFunctor>
177 const std::string & filename,
const TFunctor & aFunctor,
178 std::vector<unsigned int> dimSpace =
179 std::vector<unsigned int>() )
187 const std::string extension =
188 filename.substr( filename.find_last_of(
"." ) + 1 );
190 if ( extension ==
"raw" )
192 for (
unsigned int i = 0; i < dimSpace.size(); i++ )
193 ASSERT( dimSpace[ i ] != 0 );
195 for (
unsigned int i = 0; i < dimSpace.size(); i++ )
196 pt[ i ] = dimSpace[ i ];
202 <<
" not yet implemented in DGtal GenericReader."
213 template <
typename TContainer,
typename TValue>
229 static TContainer
import(
const std::string &filename,
unsigned int x=0,
230 unsigned int y=0,
unsigned int z=0);
246 template<
typename TFunctor>
248 const TFunctor &aFunctor,
250 unsigned int y=0,
unsigned int z=0)
254 const std::string extension = filename.substr(filename.find_last_of(
".") + 1);
256 if ( extension ==
"vol" )
260 else if ( extension ==
"longvol" )
264 else if ( extension ==
"pgm3d" || extension ==
"pgm3D" || extension ==
"p3d" || extension ==
"pgm" )
268 else if ( extension ==
"raw" )
270 ASSERT( x != 0 && y != 0 && z != 0 );
276 if ( extension ==
"h5" )
281 if ( extension ==
"dcm" )
291 trace.
error() <<
"Extension " << extension<<
" in 3D, not yet implemented in DGtal GenericReader." << std::endl;
302 template <
typename TContainer>
318 static TContainer
import(
const std::string &filename,
unsigned int x=0,
319 unsigned int y=0,
unsigned int z=0);
335 template<
typename TFunctor>
337 const TFunctor &aFunctor,
339 unsigned int y=0,
unsigned int z=0)
343 const std::string extension = filename.substr( filename.find_last_of(
".") + 1 );
345 if ( extension ==
"longvol" )
349 else if ( extension ==
"raw" )
351 ASSERT( x != 0 && y != 0 && z != 0 );
357 if ( extension ==
"dcm" )
361 else if ( extension ==
"mha" || extension ==
"mhd" )
367 trace.
error() <<
"Extension " << extension<<
" not yet implemented in DGtal GenericReader." << std::endl;
379 template <
typename TContainer>
390 static TContainer
import(
const std::string &filename);
399 template <
typename TContainer,
typename TValue>
415 static TContainer
import(
const std::string &filename,
unsigned int x=0,
431 template<
typename TFunctor>
433 const TFunctor &aFunctor,
440 const std::string extension = filename.substr( filename.find_last_of(
".") + 1 );
442 if ( extension ==
"ppm" )
446 else if ( extension ==
"raw" )
448 ASSERT( x != 0 && y != 0 );
452 else if ( extension ==
"gif" || extension ==
"jpg" || extension ==
"png" || extension ==
"jpeg" || extension ==
"bmp" )
458 trace.
error() <<
"Extension " << extension<<
" not yet implemented in DGtal but you can add Magick option to deal with this image type." << std::endl;
463 trace.
error() <<
"Extension " << extension<<
" in 2D, not yet implemented in DGtal GenericReader." << std::endl;
479 template<
typename TFunctor>
481 const TFunctor &aFunctor,
unsigned int x=0,
488 const std::string extension = filename.substr( filename.find_last_of(
".") + 1 );
490 if ( extension ==
"raw" )
492 ASSERT( x!= 0 && y != 0);
496 else if ( extension ==
"pgm" )
506 trace.
error() <<
"Extension " << extension<<
" not yet implemented in DGtal GenericReader." << std::endl;
517 template <
typename TContainer>
533 static TContainer
import(
const std::string &filename,
unsigned int x=0,
549 template<
typename TFunctor>
551 const TFunctor &aFunctor,
unsigned int x=0,
558 const std::string extension = filename.substr(filename.find_last_of(
".") + 1);
560 if ( extension ==
"ppm" )
564 else if ( extension ==
"raw" )
566 ASSERT( x != 0 && y != 0 );
570 else if ( extension ==
"gif" || extension ==
"jpg" || extension ==
"png" || extension ==
"jpeg" || extension ==
"bmp" )
576 trace.
error() <<
"Extension " << extension<<
" not yet implemented in DGtal but you can add Magick option to deal with this image type." << std::endl;
581 trace.
error() <<
"Extension " << extension<<
" not yet implemented in DGtal GenericReader." << std::endl;
596 template<
typename TFunctor>
598 const TFunctor &aFunctor,
unsigned int x=0,
605 const std::string extension = filename.substr(filename.find_last_of(
".") + 1);
607 if ( extension ==
"raw" )
609 ASSERT( x != 0 && y != 0);
613 else if ( extension ==
"pgm ")
623 trace.
error() <<
"Extension " << extension<<
" not yet implemented in DGtal GenericReader." << std::endl;
636 #include "DGtal/io/readers/GenericReader.ih"
641 #endif // !defined GenericReader_h
643 #undef GenericReader_RECURSES
644 #endif // else defined(GenericReader_RECURSES)
static ImageContainer importHDF5(const std::string &aFilename, const std::string &aDataset, const Functor &aFunctor=Functor(), bool topbotomOrder=true)
const auto ITK_IO_IMAGE_EXT
static ImageContainer importVol(const std::string &filename, const Functor &aFunctor=Functor())
static TContainer importWithValueFunctor(const std::string &filename, const TFunctor &aFunctor, unsigned int x=0, unsigned int y=0, unsigned int z=0)
boost::uint32_t uint32_t
unsigned 32-bit integer.
Structure representing an RGB triple with alpha component.
static TContainer importWithValueFunctor(const std::string &filename, const TFunctor &aFunctor, std::vector< unsigned int > dimSpace=std::vector< unsigned int >())
Aim: Raw binary import of an Image.
static TContainer importWithValueFunctor(const std::string &filename, const TFunctor &aFunctor, unsigned int x=0, unsigned int y=0)
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, 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)
Aim: implements methods to read a 2D image using the ImageMagick library.
static ImageContainer importPPM(const std::string &aFilename, const Functor &aFunctor=functors::ColorRGBEncoder< Value >(), bool topbotomOrder=true)
static ImageContainer importRaw8(const std::string &filename, const Vector &extent, const Functor &aFunctor=Functor())
DGtal is the top-level namespace which contains all DGtal functions and types.
static ImageContainer importPGM(const std::string &aFilename, const Functor &aFunctor=Functor(), bool topbotomOrder=true)
static TContainer importWithColorFunctor(const std::string &filename, const TFunctor &aFunctor, std::vector< unsigned int > dimSpace=std::vector< unsigned int >())
static ImageContainer importDicom(const std::string &aFilename, const Functor &aFunctor=Functor())
boost::uint64_t uint64_t
unsigned 64-bit integer.
static ImageContainer importImage(const std::string &filename, const Functor &aFunctor=Functor(), bool topbotomOrder=true)
static ImageContainer importRaw32(const std::string &filename, const Vector &extent, const Functor &aFunctor=Functor())
BOOST_CONCEPT_ASSERT((concepts::CImage< TContainer >))
static ImageContainer importPGM3D(const std::string &aFilename, const Functor &aFunctor=Functor())
static ImageContainer importLongvol(const std::string &filename, const Functor &aFunctor=Functor())
static TContainer importWithValueFunctor(const std::string &filename, const TFunctor &aFunctor, unsigned int x=0, unsigned int y=0)
static TContainer importWithColorFunctor(const std::string &filename, const TFunctor &aFunctor, unsigned int x=0, unsigned int y=0)
Aim: Defines a unary functor, which associates arguments to results.
static ImageContainer importHDF5_3D(const std::string &aFilename, const std::string &aDataset, const Functor &aFunctor=Functor())
static Image importITK(const std::string &filename, const TFunctor &aFunctor=TFunctor(), bool shiftDomainUsingOrigin=true)
Aim: Defines the concept describing a read/write image, having an output iterator.