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"
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" )
285 else if ( extension ==
"nii" || extension ==
"mha" ||
286 extension ==
"mhd" || extension ==
"tiff" ||
293 trace.
error() <<
"Extension " << extension<<
" in 3D, not yet implemented in DGtal GenericReader." << std::endl;
304 template <
typename TContainer>
320 static TContainer
import(
const std::string &filename,
unsigned int x=0,
321 unsigned int y=0,
unsigned int z=0);
337 template<
typename TFunctor>
339 const TFunctor &aFunctor,
341 unsigned int y=0,
unsigned int z=0)
345 const std::string extension = filename.substr( filename.find_last_of(
".") + 1 );
347 if ( extension ==
"longvol" )
351 else if ( extension ==
"raw" )
353 ASSERT( x != 0 && y != 0 && z != 0 );
359 if ( extension ==
"dcm" )
363 else if ( extension ==
"mha" || extension ==
"mhd" )
369 trace.
error() <<
"Extension " << extension<<
" not yet implemented in DGtal GenericReader." << std::endl;
381 template <
typename TContainer>
392 static TContainer
import(
const std::string &filename);
401 template <
typename TContainer,
typename TValue>
417 static TContainer
import(
const std::string &filename,
unsigned int x=0,
433 template<
typename TFunctor>
435 const TFunctor &aFunctor,
442 const std::string extension = filename.substr( filename.find_last_of(
".") + 1 );
444 if ( extension ==
"ppm" )
448 else if ( extension ==
"raw" )
450 ASSERT( x != 0 && y != 0 );
454 else if ( extension ==
"gif" || extension ==
"jpg" || extension ==
"png" || extension ==
"jpeg" || extension ==
"bmp" )
460 trace.
error() <<
"Extension " << extension<<
" not yet implemented in DGtal but you can add Magick option to deal with this image type." << std::endl;
465 trace.
error() <<
"Extension " << extension<<
" in 2D, not yet implemented in DGtal GenericReader." << std::endl;
481 template<
typename TFunctor>
483 const TFunctor &aFunctor,
unsigned int x=0,
490 const std::string extension = filename.substr( filename.find_last_of(
".") + 1 );
492 if ( extension ==
"raw" )
494 ASSERT( x!= 0 && y != 0);
498 else if ( extension ==
"pgm" )
508 trace.
error() <<
"Extension " << extension<<
" not yet implemented in DGtal GenericReader." << std::endl;
519 template <
typename TContainer>
535 static TContainer
import(
const std::string &filename,
unsigned int x=0,
551 template<
typename TFunctor>
553 const TFunctor &aFunctor,
unsigned int x=0,
560 const std::string extension = filename.substr(filename.find_last_of(
".") + 1);
562 if ( extension ==
"ppm" )
566 else if ( extension ==
"raw" )
568 ASSERT( x != 0 && y != 0 );
572 else if ( extension ==
"gif" || extension ==
"jpg" || extension ==
"png" || extension ==
"jpeg" || extension ==
"bmp" )
578 trace.
error() <<
"Extension " << extension<<
" not yet implemented in DGtal but you can add Magick option to deal with this image type." << std::endl;
583 trace.
error() <<
"Extension " << extension<<
" not yet implemented in DGtal GenericReader." << std::endl;
598 template<
typename TFunctor>
600 const TFunctor &aFunctor,
unsigned int x=0,
607 const std::string extension = filename.substr(filename.find_last_of(
".") + 1);
609 if ( extension ==
"raw" )
611 ASSERT( x != 0 && y != 0);
615 else if ( extension ==
"pgm ")
625 trace.
error() <<
"Extension " << extension<<
" not yet implemented in DGtal GenericReader." << std::endl;
638 #include "DGtal/io/readers/GenericReader.ih"
645 #undef GenericReader_RECURSES
Structure representing an RGB triple with alpha component.
DGtal is the top-level namespace which contains all DGtal functions and types.
boost::uint32_t uint32_t
unsigned 32-bit integer.
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())
Aim: implements methods to read a 2D image using the ImageMagick library.
static ImageContainer importImage(const std::string &filename, const Functor &aFunctor=Functor(), bool topbotomOrder=true)
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.