DGtal  1.4.beta
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)
 
template<typename TFunctor >
static TContainer importWithColorFunctor (const std::string &filename, const TFunctor &aFunctor, unsigned int x=0, unsigned int y=0)
 
template<typename TFunctor >
static TContainer importWithValueFunctor (const std::string &filename, const TFunctor &aFunctor, unsigned int x=0, unsigned int y=0)
 

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 510 of file GenericReader.h.

Member Function Documentation

◆ BOOST_CONCEPT_ASSERT()

template<typename TContainer >
DGtal::GenericReader< TContainer, 2, DGtal::uint32_t >::BOOST_CONCEPT_ASSERT ( (concepts::CImage< TContainer >)  )

◆ import()

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 
)
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.

◆ importWithColorFunctor()

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 
)
inlinestatic

Import an image file by specifying a color encoder functor (used only for color image format ppm, png, tga, bmp,jpeg) .

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 541 of file GenericReader.h.

544  {
545 
546  BOOST_CONCEPT_ASSERT(( concepts::CUnaryFunctor<TFunctor, DGtal::Color, typename TContainer::Value> )) ;
547  DGtal::IOException dgtalio;
548  //Getting image extension
549  const std::string extension = filename.substr(filename.find_last_of(".") + 1);
550 
551  if ( extension == "ppm" )
552  {
553  return PPMReader<TContainer, TFunctor>::importPPM(filename, aFunctor);
554  }
555  else if ( extension == "raw" )
556  {
557  ASSERT( x != 0 && y != 0 );
558  typename TContainer::Point const pt (x,y);
559  return RawReader< TContainer, TFunctor >::template importRaw<DGtal::Color>( filename, pt, aFunctor);
560  }
561  else if ( extension == "tga" || extension == "jpg" || extension == "png" || extension == "jpeg" || extension == "bmp" )
562  {
563  STBReader<TContainer, TFunctor> reader;
564  return reader.import( filename, aFunctor );
565  }
566 
567  trace.error() << "Extension " << extension<< " not yet implemented in DGtal GenericReader." << std::endl;
568  throw dgtalio;
569  }
std::ostream & error()
Trace trace
Definition: Common.h:153
BOOST_CONCEPT_ASSERT((concepts::CImage< TContainer >))
static ImageContainer importPPM(const std::string &aFilename, const Functor &aFunctor=functors::ColorRGBEncoder< Value >(), bool topbotomOrder=true)
MyPointD Point
Definition: testClone2.cpp:383

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

◆ importWithValueFunctor()

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 
)
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 583 of file GenericReader.h.

586  {
587  BOOST_CONCEPT_ASSERT(( concepts::CUnaryFunctor<TFunctor, unsigned char, typename TContainer::Value > )) ;
588 
589  DGtal::IOException dgtalio;
590  //Getting image extension
591  const std::string extension = filename.substr(filename.find_last_of(".") + 1);
592 
593  if ( extension == "raw" )
594  {
595  ASSERT( x != 0 && y != 0);
596  typename TContainer::Point const pt (x,y);
597  return RawReader< TContainer, TFunctor >::importRaw8 ( filename, pt, aFunctor );
598  }
599  else if ( extension == "pgm ")
600  {
601  return PGMReader<TContainer, TFunctor>::importPGM(filename, aFunctor);
602  }
603 
604 #ifdef WITH_HDF5
605  if (extension=="h5")
606  return HDF5Reader<TContainer, TFunctor>::importHDF5(filename, "image8bit", aFunctor);
607 #endif
608 
609  trace.error() << "Extension " << extension<< " not yet implemented in DGtal GenericReader." << std::endl;
610  throw dgtalio;
611 
612  }
static ImageContainer importHDF5(const std::string &aFilename, const std::string &aDataset, const Functor &aFunctor=Functor(), bool topbotomOrder=true)
static ImageContainer importPGM(const std::string &aFilename, const Functor &aFunctor=Functor(), bool topbotomOrder=true)
static ImageContainer importRaw8(const std::string &filename, const Vector &extent, const Functor &aFunctor=Functor())

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.


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