DGtal  1.4.beta
DGtal::GenericReader< TContainer, Tdim, TValue > Struct Template Reference

Aim: Provide a mechanism to load with the bestloader according to an image (2D or 3D) filename (by parsing the extension). More...

#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, std::vector< unsigned int > dimSpace=std::vector< unsigned int >())
 
template<typename TFunctor >
static TContainer importWithValueFunctor (const std::string &filename, const TFunctor &aFunctor, std::vector< unsigned int > dimSpace=std::vector< unsigned int >())
 
template<typename TFunctor >
static TContainer importWithColorFunctor (const std::string &filename, const TFunctor &aFunctor, std::vector< unsigned int > dimSpace=std::vector< unsigned int >())
 

Detailed Description

template<typename TContainer, int Tdim = TContainer::Point::dimension, typename TValue = typename TContainer::Value>
struct DGtal::GenericReader< TContainer, Tdim, TValue >

Aim: Provide a mechanism to load with the bestloader according to an image (2D or 3D) filename (by parsing the extension).

Description of template class 'GenericReader'

The typical use is very simple:

Advanced:
the file format value type will be cast to TContainer::Value. For instance, VOL file format deals with "unsigned char" and if the TContainer::Value type is different, you could have type conversion issues.
Template Parameters
TContainerthe container (mainly an ImageContainer like ImageContainerBySTLVector or ImageContainerBySTLMap).
Tdimthe dimension of the container (by default given by the container).

Definition at line 99 of file GenericReader.h.

Member Function Documentation

◆ BOOST_CONCEPT_ASSERT()

◆ import()

template<typename TContainer , int Tdim = TContainer::Point::dimension, typename TValue = typename TContainer::Value>
static TContainer DGtal::GenericReader< TContainer, Tdim, TValue >::import ( const std::string &  filename,
std::vector< unsigned int >  dimSpace = std::vector< unsigned int >() 
)
static

Import a volume nd image file. For the special format of raw image, the default parameter of the image size must be given in the optional function vector parameter (dimSpace).

Parameters
filenamethe image filename to imported.
dimSpacea vector containing the n dimensional image size.

Referenced by get_mean_binarizer_from_an_image(), main(), DGtal::Shortcuts< TKSpace >::makeBinaryImage(), DGtal::Shortcuts< TKSpace >::makeDoubleImage(), DGtal::Shortcuts< TKSpace >::makeFloatImage(), DGtal::Shortcuts< TKSpace >::makeGrayScaleImage(), testGenericReader(), and testGenericWriter().

◆ importWithColorFunctor()

template<typename TContainer , int Tdim = TContainer::Point::dimension, typename TValue = typename TContainer::Value>
template<typename TFunctor >
static TContainer DGtal::GenericReader< TContainer, Tdim, TValue >::importWithColorFunctor ( const std::string &  filename,
const TFunctor &  aFunctor,
std::vector< unsigned int >  dimSpace = std::vector<unsigned int>() 
)
inlinestatic

Import a volume nd image file by specifying a value functor.

Template Parameters
TFunctorThe type of the functor (should verify the concept CUnaryFunctor<TFunctor, TValue , TContainer::Value > )
Parameters
dimSpacea vector containing the n dimensional image size.
filenamethe image filename to be imported.
aFunctoran ColorRGBEncoder. The type of the functor (should verify the concept CUnaryFunctor<TFunctor, TContainer::Value, DGtal::Color >).

Definition at line 174 of file GenericReader.h.

179  {
181  (concepts::CUnaryFunctor<TFunctor, DGtal::Color,
182  typename TContainer::Value>));
183 
184  DGtal::IOException dgtalio;
185  const std::string extension =
186  filename.substr( filename.find_last_of( "." ) + 1 );
187 
188  if ( extension == "raw" )
189  {
190  for ( unsigned int i = 0; i < dimSpace.size(); i++ )
191  ASSERT( dimSpace[ i ] != 0 );
192  typename TContainer::Point const pt;
193  for ( unsigned int i = 0; i < dimSpace.size(); i++ )
194  pt[ i ] = dimSpace[ i ];
195  return RawReader<TContainer, TFunctor>::template importRaw<
196  DGtal::Color>( filename, pt, aFunctor );
197  }
198 
199  trace.error() << "Extension " << extension
200  << " not yet implemented in DGtal GenericReader."
201  << std::endl;
202  throw dgtalio;
203  }
Structure representing an RGB triple with alpha component.
Definition: Color.h:68
std::ostream & error()
Trace trace
Definition: Common.h:153
BOOST_CONCEPT_ASSERT((concepts::CImage< TContainer >))
MyPointD Point
Definition: testClone2.cpp:383

References DGtal::GenericReader< TContainer, Tdim, TValue >::BOOST_CONCEPT_ASSERT(), DGtal::Trace::error(), and DGtal::trace.

◆ importWithValueFunctor()

template<typename TContainer , int Tdim = TContainer::Point::dimension, typename TValue = typename TContainer::Value>
template<typename TFunctor >
static TContainer DGtal::GenericReader< TContainer, Tdim, TValue >::importWithValueFunctor ( const std::string &  filename,
const TFunctor &  aFunctor,
std::vector< unsigned int >  dimSpace = std::vector<unsigned int>() 
)
inlinestatic

Import a volume nd image file by specifying a value functor.

Template Parameters
TFunctorThe type of the functor (should verify the concept CUnaryFunctor<TFunctor, TValue , TContainer::Value > )
Parameters
dimSpacea vector containing the n dimensional image size..
filenamethe image filename to be imported.
aFunctorto transform the input type of image value (TValue) into the given image type (TContainer::Value).

Definition at line 129 of file GenericReader.h.

133  {
135  (concepts::CUnaryFunctor<TFunctor, TValue, typename TContainer::Value>));
136  DGtal::IOException dgtalio;
137  const std::string extension =
138  filename.substr( filename.find_last_of( "." ) + 1 );
139 
140  if ( extension == "raw" )
141  {
142  for ( unsigned int i = 0; i < dimSpace.size(); i++ )
143  ASSERT( dimSpace[ i ] != 0 );
144  typename TContainer::Point const pt;
145  for ( unsigned int i = 0; i < dimSpace.size(); i++ )
146  pt[ i ] = dimSpace[ i ];
147 
148  return RawReader<TContainer, TFunctor>::template importRaw<TValue>(
149  filename, pt, aFunctor );
150  }
151 
152  trace.error() << "Extension " << extension
153  << " not yet implemented in DGtal GenericReader."
154  << std::endl;
155  throw dgtalio;
156  }

References DGtal::GenericReader< TContainer, Tdim, TValue >::BOOST_CONCEPT_ASSERT(), DGtal::Trace::error(), and DGtal::trace.

Referenced by testGenericReader().


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