DGtal  1.2.0
Public Member Functions | Static Public Member Functions
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 101 of file GenericReader.h.

Member Function Documentation

◆ BOOST_CONCEPT_ASSERT()

template<typename TContainer , int Tdim = TContainer::Point::dimension, typename TValue = typename TContainer::Value>
DGtal::GenericReader< TContainer, Tdim, TValue >::BOOST_CONCEPT_ASSERT ( (concepts::CImage< TContainer >)  )

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

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

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

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: