DGtal  0.9.3beta
Public Member Functions | Static Public Member Functions
DGtal::GenericReader< TContainer, 2, DGtal::uint32_t > Struct Template Reference

#include <DGtal/io/readers/GenericReader.h>

Public Member Functions

 BOOST_CONCEPT_ASSERT ((concepts::CImage< TContainer >))
 

Static Public Member Functions

static TContainer import (const std::string &filename, unsigned int x=0, unsigned int y=0) throw (DGtal::IOException)
 
template<typename TFunctor >
static TContainer importWithColorFunctor (const std::string &filename, const TFunctor &aFunctor, unsigned int x=0, unsigned int y=0) throw (DGtal::IOException)
 
template<typename TFunctor >
static TContainer importWithValueFunctor (const std::string &filename, const TFunctor &aFunctor, unsigned int x=0, unsigned int y=0) throw (DGtal::IOException)
 

Detailed Description

template<typename TContainer>
struct DGtal::GenericReader< TContainer, 2, DGtal::uint32_t >

GenericReader Template partial specialisation for volume images of dimension 2 with DGtal::uint32_t values

Definition at line 427 of file GenericReader.h.

Member Function Documentation

template<typename TContainer >
DGtal::GenericReader< TContainer, 2, DGtal::uint32_t >::BOOST_CONCEPT_ASSERT ( (concepts::CImage< TContainer >)  )
template<typename TContainer >
static TContainer DGtal::GenericReader< TContainer, 2, DGtal::uint32_t >::import ( const std::string &  filename,
unsigned int  x = 0,
unsigned int  y = 0 
)
throw (DGtal::IOException
)
static

Import a volume image file. For the special format h5 (you need to set WITH_HDF5 of cmake build), the default parameter datasetName needs to be updated according to the dimension if the image.

Parameters
filenamethe image filename to be imported.
xspecify the x image size to be used with raw format.
yspecify the y image size to be used with raw format.
template<typename TContainer >
template<typename TFunctor >
static TContainer DGtal::GenericReader< TContainer, 2, DGtal::uint32_t >::importWithColorFunctor ( const std::string &  filename,
const TFunctor &  aFunctor,
unsigned int  x = 0,
unsigned int  y = 0 
)
throw (DGtal::IOException
)
inlinestatic

Import an image file by specifying a color encoder functor (used only for color image format ppm, ( gif, jpeg, ... if the magick image lib is installed) .

Template Parameters
TFunctorThe type of the functor (should verify the concept CUnaryFunctor<TFunctor, TContainer::Value, DGtal::Color > ).
Parameters
filenamethe image filename to be imported.
aFunctoran ColorRGBEncoder. The type of the functor (should verify the concept CUnaryFunctor<TFunctor, TContainer::Value, DGtal::Color > ).
xspecify the x image size to be used with raw format.
yspecify the y image size to be used with raw format.

Definition at line 459 of file GenericReader.h.

References DGtal::GenericReader< TContainer, Tdim, TValue >::BOOST_CONCEPT_ASSERT(), DGtal::Trace::error(), DGtal::MagickReader< TImageContainer, TFunctor >::importImage(), DGtal::PPMReader< TImageContainer, TFunctor >::importPPM(), and DGtal::trace.

462  {
463 
464  BOOST_CONCEPT_ASSERT(( concepts::CUnaryFunctor<TFunctor, DGtal::Color, typename TContainer::Value> )) ;
465  DGtal::IOException dgtalio;
466  //Getting image extension
467  const std::string extension = filename.substr(filename.find_last_of(".") + 1);
468 
469  if ( extension == "ppm" )
470  {
471  return PPMReader<TContainer, TFunctor>::importPPM(filename, aFunctor);
472  }
473  else if ( extension == "raw" )
474  {
475  ASSERT( x != 0 && y != 0 );
476  typename TContainer::Point const pt (x,y);
477  return RawReader< TContainer, TFunctor >::template importRaw<DGtal::Color>( filename, pt, aFunctor);
478  }
479  else if ( extension == "gif" || extension == "jpg" || extension == "png" || extension == "jpeg" || extension == "bmp" )
480  {
481 #ifdef WITH_MAGICK
482  MagickReader<TContainer, TFunctor> reader;
483  return reader.importImage( filename, aFunctor );
484 #else
485  trace.error() << "Extension " << extension<< " not yet implemented in DGtal but you can add Magick option to deal with this image type." << std::endl;
486  throw dgtalio;
487 #endif
488  }
489 
490  trace.error() << "Extension " << extension<< " not yet implemented in DGtal GenericReader." << std::endl;
491  throw dgtalio;
492  }
Trace trace
Definition: Common.h:137
BOOST_CONCEPT_ASSERT((concepts::CImage< TContainer >))
std::ostream & error()
static ImageContainer importPPM(const std::string &aFilename, const Functor &aFunctor=functors::ColorRGBEncoder< Value >(), bool topbotomOrder=true)
template<typename TContainer >
template<typename TFunctor >
static TContainer DGtal::GenericReader< TContainer, 2, DGtal::uint32_t >::importWithValueFunctor ( const std::string &  filename,
const TFunctor &  aFunctor,
unsigned int  x = 0,
unsigned int  y = 0 
)
throw (DGtal::IOException
)
inlinestatic

Import an image file by specifying a value functor used for grayscale image.

Template Parameters
TFunctorThe type of the functor (should verify the concept CUnaryFunctor<TFunctor, unsigned char, TContainer::Value > ).
Parameters
filenamethe image filename to be imported.
aFunctorto transform input unsigned char of image value into the given image type.
xspecify the x image size to be used with raw format.
yspecify the y image size to be used with raw format.

Definition at line 506 of file GenericReader.h.

References DGtal::GenericReader< TContainer, Tdim, TValue >::BOOST_CONCEPT_ASSERT(), DGtal::Trace::error(), DGtal::HDF5Reader< TImageContainer, TFunctor >::importHDF5(), DGtal::PGMReader< TImageContainer, TFunctor >::importPGM(), DGtal::RawReader< TImageContainer, TFunctor >::importRaw8(), and DGtal::trace.

509  {
510  BOOST_CONCEPT_ASSERT(( concepts::CUnaryFunctor<TFunctor, unsigned char, typename TContainer::Value > )) ;
511 
512  DGtal::IOException dgtalio;
513  //Getting image extension
514  const std::string extension = filename.substr(filename.find_last_of(".") + 1);
515 
516  if ( extension == "raw" )
517  {
518  ASSERT( x != 0 && y != 0);
519  typename TContainer::Point const pt (x,y);
520  return RawReader< TContainer, TFunctor >::importRaw8 ( filename, pt, aFunctor );
521  }
522  else if ( extension == "pgm ")
523  {
524  return PGMReader<TContainer, TFunctor>::importPGM(filename, aFunctor);
525  }
526 
527 #ifdef WITH_HDF5
528  if (extension=="h5")
529  return HDF5Reader<TContainer, TFunctor>::importHDF5(filename, "image8bit", aFunctor);
530 #endif
531 
532  trace.error() << "Extension " << extension<< " not yet implemented in DGtal GenericReader." << std::endl;
533  throw dgtalio;
534 
535  }
Trace trace
Definition: Common.h:137
static ImageContainer importRaw8(const std::string &filename, const Vector &extent, const Functor &aFunctor=Functor())
static ImageContainer importPGM(const std::string &aFilename, const Functor &aFunctor=Functor(), bool topbotomOrder=true)
static ImageContainer importHDF5(const std::string &aFilename, const std::string &aDataset, const Functor &aFunctor=Functor(), bool topbotomOrder=true)
BOOST_CONCEPT_ASSERT((concepts::CImage< TContainer >))
std::ostream & error()

The documentation for this struct was generated from the following file: