DGtal 2.2.0
Loading...
Searching...
No Matches
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>

Inheritance diagram for DGtal::GenericReader< TContainer, Tdim, TValue >:
[legend]

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

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>
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.
Examples
geometry/surfaces/dvcm-3d.cpp, images/imageBasicSubsampling.cpp, io/viewers/viewer3D-9-3Dimages.cpp, and tutorial-examples/2DSliceImageFromVol.cpp.

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

◆ importWithColorFunctor()

template<typename TContainer, int Tdim = TContainer::Point::dimension, typename TValue = typename TContainer::Value>
template<typename TFunctor>
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.

178 {
181 typename TContainer::Value>));
182
184 const std::string extension =
185 filename.substr( filename.find_last_of( "." ) + 1 );
186
187 if ( extension == "raw" )
188 {
189 for ( unsigned int i = 0; i < dimSpace.size(); i++ )
190 ASSERT( dimSpace[ i ] != 0 );
191 typename TContainer::Point const pt;
192 for ( unsigned int i = 0; i < dimSpace.size(); i++ )
193 pt[ i ] = dimSpace[ i ];
196 }
197
198 trace.error() << "Extension " << extension
199 << " not yet implemented in DGtal GenericReader."
200 << std::endl;
201 throw dgtalio;
202 }
Aim: Provide a mechanism to load with the bestloader according to an image (2D or 3D) filename (by pa...
BOOST_CONCEPT_ASSERT((concepts::CImage< TContainer >))

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

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

References BOOST_CONCEPT_ASSERT(), DGtal::Trace::error(), and DGtal::trace.

Referenced by testGenericReader().


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