DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Types | Public Member Functions | Static Public Member Functions
DGtal::RawWriter< TImage, TFunctor > Struct Template Reference

#include <RawWriter.h>

Public Types

typedef TImage Image
typedef TImage::Value Value
typedef TFunctor Functor

Public Member Functions

 BOOST_CONCEPT_ASSERT ((CUnaryFunctor< TFunctor, Value, unsigned char >))

Static Public Member Functions

static bool exportRaw8 (const std::string &filename, const Image &aImage, const Functor &aFunctor=Functor())

Detailed Description

template<typename TImage, typename TFunctor = DefaultFunctor>
struct DGtal::RawWriter< TImage, TFunctor >

Aim: Raw binary export of an Image.

Description of template struct 'RawWriter'

A functor can be specified to convert image values to raw values (unsigned char for exportRaw8).

Template Parameters:
TImagethe Image type.
TFunctorthe type of functor used in the export.

Definition at line 68 of file RawWriter.h.


Member Typedef Documentation

template<typename TImage , typename TFunctor = DefaultFunctor>
typedef TFunctor DGtal::RawWriter< TImage, TFunctor >::Functor

Definition at line 74 of file RawWriter.h.

template<typename TImage , typename TFunctor = DefaultFunctor>
typedef TImage DGtal::RawWriter< TImage, TFunctor >::Image

Definition at line 72 of file RawWriter.h.

template<typename TImage , typename TFunctor = DefaultFunctor>
typedef TImage::Value DGtal::RawWriter< TImage, TFunctor >::Value

Definition at line 73 of file RawWriter.h.


Member Function Documentation

template<typename TImage , typename TFunctor = DefaultFunctor>
DGtal::RawWriter< TImage, TFunctor >::BOOST_CONCEPT_ASSERT ( (CUnaryFunctor< TFunctor, Value, unsigned char >)  )
template<typename TImage , typename TFunctor = DefaultFunctor>
bool DGtal::RawWriter< I, C >::exportRaw8 ( const std::string &  filename,
const Image aImage,
const Functor aFunctor = Functor() 
)
static

Export an Image to Raw format (8bits, unsigned char).

Parameters:
filenamename of the output file
aImagethe image to export
aFunctorfunctor used to cast image values
Returns:
true if no errors occur.
Todo:
catch IOerror excpetion

Definition at line 44 of file RawWriter.ih.

{
ofstream out;
typename I::Domain::Vector ext = aImage.extent();
typename I::Domain domain = aImage.domain();
typename I::Value val;
out.open(filename.c_str(), ios_base::binary);
//We scan the domain
for(typename I::Domain::ConstIterator it = domain.begin(), itend=domain.end();
it!=itend;
++it)
{
val = aImage( (*it) );
out.put( static_cast<unsigned char>(aFunctor (val) ) );
}
out.close();
return true;
}

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