DGtal  1.1.0
MagickReader.h
1 
17 #pragma once
18 
31 #if defined(MagickReader_RECURSES)
32 #error Recursive header files inclusion detected in MagickReader.h
33 #else // defined(MagickReader_RECURSES)
34 
35 #define MagickReader_RECURSES
36 
37 #if !defined MagickReader_h
38 
39 #define MagickReader_h
40 
42 // Inclusions
43 #include <iostream>
44 #include <string>
45 #include <cstdio>
46 
47 #if defined(WITH_MAGICK)
48 // Specific inclusion method to fix warning with GraphicsMagic 1.3.31 and Clang.
49 // The warning comes from two "diagnostic pop" with missing corresponding push.
50 // "MagickLibAddendum" is defined in ImageMagick since 9 years but not in GraphicsMagic.
51 # if !defined(MagickLibAddendum) && defined(__clang__)
52 # pragma clang diagnostic push
53 # pragma clang diagnostic push
54 # include <Magick++.h>
55 # if MagickLibVersion != 0x221900
56 # pragma clang diagnostic pop
57 # pragma clang diagnostic pop
58 # endif
59 # else
60 # include <Magick++.h>
61 # endif
62 #else // defined WITH_MAGICK
63 # error "DGtal has not been built with imagemagick support. Consider adding -DWITH_MAGICK=true when building the project with cmake."
64 #endif // defined WITH_MAGICK
65 
66 
67 #include "DGtal/base/CUnaryFunctor.h"
68 #include "DGtal/base/Common.h"
70 
71 namespace DGtal
72 {
73  namespace functors
74  {
75  template<typename TValue>
76  struct MagickCast
77  {
79  TValue operator()(const Color &col) const
80  {
81  return myCast( col.red() + col.green() + col.blue() );
82  }
83  };
84 
85  template<>
86  struct MagickCast<Color>
87  {
88  Color operator()(const Color &col) const
89  {
90  return col;
91  }
92  };
93  }
94 
96  // template class MagickReader
110  template <typename TImageContainer, typename TFunctor= functors::MagickCast< typename TImageContainer::Value > >
112  {
113  // ----------------------- Standard services ------------------------------
114  public:
115 
116  typedef TImageContainer ImageContainer;
118  typedef typename TImageContainer::Value Value;
119  typedef TFunctor Functor ;
120 
121  BOOST_STATIC_ASSERT( (ImageContainer::Domain::dimension == 2));
122 
134  static ImageContainer importImage(const std::string & filename,
135  const Functor & aFunctor = Functor(),
136  bool topbotomOrder = true);
137 
138  }; // end of class MagickReader
139 
140 
141 } // namespace DGtal
142 
143 
145 // Includes inline functions.
146 #include "DGtal/io/readers/MagickReader.ih"
147 
148 // //
150 
151 #endif // !defined MagickReader_h
152 
153 #undef MagickReader_RECURSES
154 #endif // else defined(MagickReader_RECURSES)
DGtal::MagickReader::BOOST_STATIC_ASSERT
BOOST_STATIC_ASSERT((ImageContainer::Domain::dimension==2))
DGtal::functors::MagickCast::operator()
TValue operator()(const Color &col) const
Definition: MagickReader.h:79
DGtal::Color
Structure representing an RGB triple with alpha component.
Definition: Color.h:67
DGtal::functors::Cast< TValue >
DGtal::MagickReader::Value
TImageContainer::Value Value
Definition: MagickReader.h:118
DGtal::functors::MagickCast< Color >::operator()
Color operator()(const Color &col) const
Definition: MagickReader.h:88
DGtal::functors::MagickCast
Definition: MagickReader.h:77
DGtal::Color::red
void red(const unsigned char aRedValue)
DGtal::MagickReader
Aim: implements methods to read a 2D image using the ImageMagick library.
Definition: MagickReader.h:112
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition: ClosedIntegerHalfPlane.h:49
DGtal::MagickReader::ImageContainer
TImageContainer ImageContainer
Definition: MagickReader.h:116
DGtal::functors::MagickCast::myCast
Cast< TValue > myCast
Definition: MagickReader.h:78
DGtal::MagickReader::importImage
static ImageContainer importImage(const std::string &filename, const Functor &aFunctor=Functor(), bool topbotomOrder=true)
Vector
FreemanChain< int >::Vector Vector
Definition: testCombinDSS.cpp:60
DGtal::Color::green
void green(const unsigned char aGreenValue)
DGtal::Color::blue
void blue(const unsigned char aBlueValue)
DGtal::MagickReader::Functor
TFunctor Functor
Definition: MagickReader.h:119
DGtal::MagickReader::Vector
TImageContainer::Domain::Vector Vector
Definition: MagickReader.h:117
Value
double Value
Definition: testSimpleRandomAccessRangeFromPoint.cpp:38