DGtal  1.2.0
testMagickReader.cpp File Reference
#include <iostream>
#include "DGtal/base/Common.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/images/ImageSelector.h"
#include "DGtal/io/colormaps/HueShadeColorMap.h"
#include "DGtal/io/readers/MagickReader.h"
#include "DGtal/io/boards/Board2D.h"
#include "ConfigTest.h"
#include "DGtalCatch.h"
Include dependency graph for testMagickReader.cpp:

Go to the source code of this file.


 TEST_CASE ("Magick Reader")

Detailed Description

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

David Coeurjolly (david.nosp@m..coe.nosp@m.urjol.nosp@m.ly@l.nosp@m.iris..nosp@m.cnrs.nosp@m..fr ) Laboratoire d'InfoRmatique en Image et Systèmes d'information - LIRIS (CNRS, UMR 5205), CNRS, France

Functions for testing class MagickReader.

This file is part of the DGtal library.

Definition in file testMagickReader.cpp.

Function Documentation


TEST_CASE ( "Magick Reader"  )

Definition at line 59 of file testMagickReader.cpp.

60 {
61  SECTION("Color->grayscale")
62  {
63  //Default image selector = STLVector
66  std::string filename = testPath + "samples/color64.png";
68  trace.info()<<"Importing: "<<filename<<endl;
71  Image img = reader.importImage( filename , Color2Gray());
73  Board2D board;
74  typedef HueShadeColorMap<unsigned char,2> HueTwice;
77  Display2DFactory::drawImage<HueTwice>(board, img, (unsigned char)0, (unsigned char)255);
78  board.saveSVG("testMagick-export.svg");
80  REQUIRE(img.isValid());
81  REQUIRE(img.extent() == Z2i::Vector(64,64));
82  }
84  SECTION("Color->Color")
85  {
86  typedef ImageSelector<Z2i::Domain, Color>::Type ImageColor;
88  std::string filename = testPath + "samples/color64.png";
90  trace.info()<<"Importing: "<<filename<<endl;
93  ImageColor img = reader.importImage( filename );
95  Color a = img( Z2i::Point(1,1));
96  CAPTURE( a );
97  img.setValue( Z2i::Point(1,1), Color(13,13,13));
98  a = img( Z2i::Point(1,1));
99  CAPTURE( a );
101  REQUIRE(img.isValid());
102  REQUIRE(img.extent() == Z2i::Vector(64,64));
103  }
104 }
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Definition: Board2D.h:71
Structure representing an RGB triple with alpha component.
Definition: Color.h:67
Aim: This class template may be used to (linearly) convert scalar values in a given range into a colo...
Aim: implements association bewteen points lying in a digital domain and values.
Definition: Image.h:70
std::ostream & info()
void saveSVG(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition: Board.cpp:1012
void setUnit(Unit unit)
Definition: Board.cpp:240
Trace trace
Definition: Common.h:154
Aim: implements methods to read a 2D image using the ImageMagick library.
Definition: MagickReader.h:112
static ImageContainer importImage(const std::string &filename, const Functor &aFunctor=Functor(), bool topbotomOrder=true)
ImageContainerBySTLVector< Domain, Value > Image
SECTION("Testing constant forward iterators")

References CAPTURE(), DGtal::MagickReader< TImageContainer, TFunctor >::importImage(), DGtal::Trace::info(), REQUIRE(), LibBoard::Board::saveSVG(), SECTION(), LibBoard::Board::setUnit(), DGtal::trace, and LibBoard::Board::UCentimeter.