DGtal  1.4.2
testSTBReader.cpp
Go to the documentation of this file.
1 
31 #include <iostream>
32 #include "DGtal/base/Common.h"
33 #include "ConfigTest.h"
34 #include "DGtalCatch.h"
35 #include "DGtal/helpers/StdDefs.h"
36 #include "DGtal/io/readers/STBReader.h"
37 #include "DGtal/images/ImageSelector.h"
38 
39 #include "DGtal/io/writers/PPMWriter.h"
40 
42 
43 using namespace std;
44 using namespace DGtal;
45 
47 // Functions for testing class STBReader.
49 
50 TEST_CASE( "Testing STBReader" )
51 {
52  SECTION("Testing feature io/readers of STBReader (Grayscale PNG)")
53  {
54  std::string filename = testPath + "samples/contourS.png";
56  Image image = STBReader<Image>::import( filename );
57  CAPTURE(image);
58 
59  PPMWriter<Image>::exportPPM("testwriter.ppm", image);
60  CHECK( image.isValid());
61  }
62 
63  SECTION("Testing feature io/readers of STBReader (PPM color)")
64  {
65  std::string filename = testPath + "samples/color64.";
67 
68  Image image = STBReader<Image>::import( filename+"ppm" );
69  PPMWriter<Image>::exportPPM("testwriterColor.ppm", image);
70  CHECK( image.isValid());
71  }
72 
73  SECTION("Testing all file formats")
74  {
75  std::string filename = testPath + "samples/color64.";
77 
78  Image imagePPM = STBReader<Image>::import( filename+"ppm" );
79  CHECK( imagePPM.isValid());
80  Image imageJPG = STBReader<Image>::import( filename+"jpg" );
81  CHECK( imageJPG.isValid());
82  Image imageTGA = STBReader<Image>::import( filename+"tga" );
83  CHECK( imageTGA.isValid());
84  Image imageBMP = STBReader<Image>::import( filename+"bmp" );
85  CHECK( imageBMP.isValid());
86  Image imagePNG = STBReader<Image>::import( filename+"png" );
87  CHECK( imagePNG.isValid());
88  Image imageGIF = STBReader<Image>::import( filename+"gif" );
89  CHECK( imageGIF.isValid());
90 
91  //For lossless compression formats
92  CHECK( imageBMP == imagePPM );
93  CHECK( imageTGA == imagePPM );
94  CHECK( imagePNG == imagePPM );
95  }
96 }
97 
Aim: implements association bewteen points lying in a digital domain and values.
Definition: Image.h:70
bool isValid() const
Definition: Image.h:266
Aim: Image reader using the stb_image.h header only code.
Definition: STBReader.h:62
DGtal is the top-level namespace which contains all DGtal functions and types.
Aim: Export a 2D and a 3D Image using the Netpbm PPM formats (ASCII mode).
Definition: PPMWriter.h:73
CAPTURE(thicknessHV)
TEST_CASE("Testing STBReader")
ImageContainerBySTLVector< Domain, Value > Image
SECTION("Testing constant forward iterators")