DGtal  0.9.3
Functions
testMagickReader.cpp File Reference
#include <iostream>
#include "DGtal/base/Common.h"
#include "DGtal/kernel/SpaceND.h"
#include "DGtal/kernel/domains/HyperRectDomain.h"
#include "DGtal/images/ImageSelector.h"
#include "DGtal/io/colormaps/HueShadeColorMap.h"
#include "DGtal/io/colormaps/GrayscaleColorMap.h"
#include "DGtal/io/colormaps/GradientColorMap.h"
#include "DGtal/io/colormaps/ColorBrightnessColorMap.h"
#include "DGtal/io/readers/MagickReader.h"
#include "DGtal/io/boards/Board2D.h"
#include "ConfigTest.h"
Include dependency graph for testMagickReader.cpp:

Go to the source code of this file.

Functions

bool testMagickReader ()
 
int main (int argc, char **argv)
 

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
2010/07/30

Functions for testing class MagickReader.

This file is part of the DGtal library.

Definition in file testMagickReader.cpp.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 110 of file testMagickReader.cpp.

References DGtal::Trace::beginBlock(), DGtal::Trace::emphase(), DGtal::Trace::endBlock(), DGtal::Trace::info(), testMagickReader(), and DGtal::trace.

111 {
112  trace.beginBlock ( "Testing class MagickReader" );
113  trace.info() << "Args:";
114  for ( int i = 0; i < argc; ++i )
115  trace.info() << " " << argv[ i ];
116  trace.info() << endl;
117 
118  bool res = testMagickReader(); // && ... other tests
119  trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
120  trace.endBlock();
121  return res ? 0 : 1;
122 }
void beginBlock(const std::string &keyword="")
bool testMagickReader()
Trace trace
Definition: Common.h:137
double endBlock()
std::ostream & emphase()
std::ostream & info()

◆ testMagickReader()

bool testMagickReader ( )

Example of a test. To be completed.

Definition at line 60 of file testMagickReader.cpp.

References DGtal::Trace::beginBlock(), DGtal::Trace::endBlock(), DGtal::MagickReader< TImageContainer, TFunctor >::importImage(), DGtal::Trace::info(), DGtal::Image< TImageContainer >::isValid(), LibBoard::Board::setUnit(), DGtal::trace, and LibBoard::Board::UCentimeter.

Referenced by main().

61 {
62  unsigned int nbok = 0;
63  unsigned int nb = 0;
64 
65  trace.beginBlock ( "Testing MagickReader ..." );
66 
67  typedef SpaceND<2> Space2;
68  typedef HyperRectDomain<Space2> TDomain;
69 
70  //Default image selector = STLVector
72 
73  std::string filename = testPath + "samples/color64.png";
74 
75  trace.info()<<"Importing: "<<filename<<endl;
76 
77  MagickReader<Image> reader;
78  Image img = reader.importImage( filename );
79 
80  nbok += img.isValid() ? 1 : 0;
81  nb++;
82  trace.info() << "(" << nbok << "/" << nb << ") "
83  << "img.isValid() == true"
84  << std::endl;
85 
86  nbok += img.extent() == Image::Vector( 64, 64 ) ? 1 : 0;
87  nb++;
88  trace.info() << "(" << nbok << "/" << nb << ") "
89  << "img.extent() = " << img.extent()
90  << "( == {64,64} )"
91  << std::endl;
92 
93  Board2D board;
94  typedef HueShadeColorMap<unsigned char,2> HueTwice;
95 
96 
98 
99  Display2DFactory::drawImage<HueTwice>(board, img, (unsigned char)0, (unsigned char)255);
100  board.saveSVG("testMagick-export.svg");
101 
102  trace.endBlock();
103 
104  return nbok == nb;
105 }
void beginBlock(const std::string &keyword="")
Trace trace
Definition: Common.h:137
Aim: SpaceND is a utility class that defines the fundamental structure of a Digital Space in ND...
Definition: SpaceND.h:95
bool isValid() const
Definition: Image.h:266
Aim: Parallelepidec region of a digital space, model of a &#39;CDomain&#39;.
double endBlock()
Aim: This class template may be used to (linearly) convert scalar values in a given range into a colo...
Aim: implements methods to read a 2D image using the ImageMagick library.
Definition: MagickReader.h:65
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
void setUnit(Unit unit)
Definition: Board.cpp:240
Aim: This class specializes a &#39;Board&#39; class so as to display DGtal objects more naturally (with <<)...
Definition: Board2D.h:70