DGtal  1.0.0
Functions
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.

Functions

 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/.

Author
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
Date
2018/01/30

Functions for testing class MagickReader.

This file is part of the DGtal library.

Definition in file testMagickReader.cpp.

Function Documentation

◆ TEST_CASE()

TEST_CASE ( "Magick Reader"  )

Definition at line 59 of file testMagickReader.cpp.

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

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