DGtal  1.0.0
Public Types | Public Member Functions | Static Public Member Functions
DGtal::MagickWriter< TImage, TFunctor > Struct Template Reference

Aim: Export image using Imagemagick backend. More...

#include <DGtal/io/writers/MagickWriter.h>

Public Types

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

Public Member Functions

 BOOST_CONCEPT_ASSERT ((concepts::CUnaryFunctor< TFunctor, Value, Color >))
 
 BOOST_STATIC_ASSERT ((TImage::Domain::dimension==2))
 

Static Public Member Functions

static bool exportMagick (const std::string &filename, const Image &anImage, const Functor &aFunctor=Functor())
 

Detailed Description

template<typename TImage, typename TFunctor = functors::Identity>
struct DGtal::MagickWriter< TImage, TFunctor >

Aim: Export image using Imagemagick backend.

Description of template struct 'MagickWriter'

If imagemagick is enabled (with WITH_MAGICK set to true), this writer export any image to a generic color Magick++ image (png, jpg, gif, bmp...) using a given colormap functor.

The file format is given by the filename extension during the export.

Template Parameters
TImagethe Image type.
TFunctorthe type of functor used in the export. The return type of the functor must be a DGtal::Color (e.g. any colormap)
See also
testMagickWriter.cpp

Definition at line 93 of file MagickWriter.h.

Member Typedef Documentation

◆ Functor

template<typename TImage , typename TFunctor = functors::Identity>
typedef TFunctor DGtal::MagickWriter< TImage, TFunctor >::Functor

Definition at line 98 of file MagickWriter.h.

◆ Image

template<typename TImage , typename TFunctor = functors::Identity>
typedef TImage DGtal::MagickWriter< TImage, TFunctor >::Image

Definition at line 96 of file MagickWriter.h.

◆ Value

template<typename TImage , typename TFunctor = functors::Identity>
typedef TImage::Value DGtal::MagickWriter< TImage, TFunctor >::Value

Definition at line 97 of file MagickWriter.h.

Member Function Documentation

◆ BOOST_CONCEPT_ASSERT()

template<typename TImage , typename TFunctor = functors::Identity>
DGtal::MagickWriter< TImage, TFunctor >::BOOST_CONCEPT_ASSERT ( (concepts::CUnaryFunctor< TFunctor, Value, Color >)  )

◆ BOOST_STATIC_ASSERT()

template<typename TImage , typename TFunctor = functors::Identity>
DGtal::MagickWriter< TImage, TFunctor >::BOOST_STATIC_ASSERT ( (TImage::Domain::dimension==2)  )

◆ exportMagick()

template<typename TImage , typename TFunctor = functors::Identity>
static bool DGtal::MagickWriter< TImage, TFunctor >::exportMagick ( const std::string &  filename,
const Image anImage,
const Functor aFunctor = Functor() 
)
inlinestatic

Export an Image with ImageMagick.

Parameters
filenamename of the output file the suffix is used to select the file format (png, bmp, jpg,...).
anImagethe image to export
aFunctorfunctor used to cast image values to DGtal::Color
Returns
true if no errors occur.

Definition at line 113 of file MagickWriter.h.

115  {
116  Magick::InitializeMagick(NULL);
117  int w = (anImage.domain().upperBound()[0] - anImage.domain().lowerBound()[0])+1;
118  int h = (anImage.domain().upperBound()[1] - anImage.domain().lowerBound()[1])+1;
119  Magick::Geometry geom(w,h);
120  Magick::Image image(geom,"white");
121  for(auto point: anImage.domain())
122  {
123  Color c = aFunctor( anImage(point) );
124  Magick::ColorRGB magickc( c.red()/255., c.green()/255., c.blue()/255.) ;
125  image.pixelColor( point[0] + anImage.domain().lowerBound()[0],
126  (h-1) - (point[1] + anImage.domain().lowerBound()[1]),
127  magickc );
128  }
129  image.write(filename);
130  return true;
131  }
ImageContainerBySTLVector< Domain, Value > Image
Image image(domain)

References image().


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