DGtal  0.9.4beta
Public Member Functions | Static Public Member Functions
DGtal::GenericReader< TContainer, 2, TValue > 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, typename TValue>
struct DGtal::GenericReader< TContainer, 2, TValue >

GenericReader Template partial specialisation for volume images of dimension 2

Definition at line 402 of file GenericReader.h.

Member Function Documentation

template<typename TContainer , typename TValue >
DGtal::GenericReader< TContainer, 2, TValue >::BOOST_CONCEPT_ASSERT ( (concepts::CImage< TContainer >)  )
template<typename TContainer , typename TValue >
static TContainer DGtal::GenericReader< TContainer, 2, TValue >::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 , typename TValue >
template<typename TFunctor >
static TContainer DGtal::GenericReader< TContainer, 2, TValue >::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 434 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.

438  {
439  BOOST_CONCEPT_ASSERT(( concepts::CUnaryFunctor<TFunctor, DGtal::Color, typename TContainer::Value> )) ;
440  DGtal::IOException dgtalio;
441  //Getting image extension
442  const std::string extension = filename.substr( filename.find_last_of(".") + 1 );
443 
444  if ( extension == "ppm" )
445  {
446  return PPMReader<TContainer, TFunctor>::importPPM(filename, aFunctor);
447  }
448  else if ( extension == "raw" )
449  {
450  ASSERT( x != 0 && y != 0 );
451  typename TContainer::Point const pt (x,y);
452  return RawReader< TContainer, TFunctor >::template importRaw<DGtal::Color>( filename, pt, aFunctor);
453  }
454  else if ( extension == "gif" || extension == "jpg" || extension == "png" || extension == "jpeg" || extension == "bmp" )
455  {
456 #ifdef WITH_MAGICK
457  MagickReader<TContainer, TFunctor> reader;
458  return reader.importImage( filename, aFunctor );
459 #else
460  trace.error() << "Extension " << extension<< " not yet implemented in DGtal but you can add Magick option to deal with this image type." << std::endl;
461  throw dgtalio;
462 #endif
463  }
464 
465  trace.error() << "Extension " << extension<< " in 2D, not yet implemented in DGtal GenericReader." << std::endl;
466  throw dgtalio;
467  }
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 , typename TValue >
template<typename TFunctor >
static TContainer DGtal::GenericReader< TContainer, 2, TValue >::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. image.
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 482 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.

485  {
486  BOOST_CONCEPT_ASSERT(( concepts::CUnaryFunctor<TFunctor, unsigned char, typename TContainer::Value > )) ;
487 
488  DGtal::IOException dgtalio;
489  //Getting image extension
490  const std::string extension = filename.substr( filename.find_last_of(".") + 1 );
491 
492  if ( extension == "raw" )
493  {
494  ASSERT( x!= 0 && y != 0);
495  typename TContainer::Point const pt (x,y);
496  return RawReader< TContainer, TFunctor >::importRaw8( filename, pt, aFunctor );
497  }
498  else if ( extension == "pgm" )
499  {
500  return PGMReader<TContainer, TFunctor>::importPGM(filename, aFunctor);
501  }
502 
503 #ifdef WITH_HDF5
504  if (extension=="h5")
505  return HDF5Reader<TContainer, TFunctor>::importHDF5(filename, "image8bit", aFunctor);
506 #endif
507 
508  trace.error() << "Extension " << extension<< " not yet implemented in DGtal GenericReader." << std::endl;
509  throw dgtalio;
510 
511  }
Trace trace
Definition: Common.h:137
BOOST_CONCEPT_ASSERT((concepts::CImage< TContainer >))
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)
std::ostream & error()

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