31 #if defined(MagickWriter_RECURSES)
32 #error Recursive header files inclusion detected in MagickWriter.h
35 #define MagickWriter_RECURSES
37 #if !defined MagickWriter_h
39 #define MagickWriter_h
45 #include "DGtal/base/CUnaryFunctor.h"
46 #include "DGtal/base/BasicFunctors.h"
47 #include "DGtal/io/writers/MagickWriter.h"
48 #include "DGtal/io/Color.h"
51 #pragma error "You must activate imagemagick (-DWITH_MAGICK=true) to include this file"
57 #if !defined(MagickLibAddendum) && defined(__clang__)
58 # pragma clang diagnostic push
59 # pragma clang diagnostic push
60 # include <Magick++.h>
61 # if MagickLibVersion != 0x221900
62 # pragma clang diagnostic pop
63 # pragma clang diagnostic pop
66 # include <Magick++.h>
92 template <
typename TImage,
typename TFunctor = functors::Identity>
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);
121 for(
auto point: anImage.domain())
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]),
129 image.write(filename);
143 #undef MagickWriter_RECURSES
Structure representing an RGB triple with alpha component.
DGtal is the top-level namespace which contains all DGtal functions and types.
Aim: Export image using Imagemagick backend.
BOOST_CONCEPT_ASSERT((concepts::CUnaryFunctor< TFunctor, Value, Color >))
BOOST_STATIC_ASSERT((TImage::Domain::dimension==2))
static bool exportMagick(const std::string &filename, const Image &anImage, const Functor &aFunctor=Functor())
Aim: Defines a unary functor, which associates arguments to results.
ImageContainerBySTLVector< Domain, Value > Image