DGtal 1.3.0
Loading...
Searching...
No Matches
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
43using namespace std;
44using namespace DGtal;
45
47// Functions for testing class STBReader.
49
50TEST_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
static ImageContainer import(const std::string &filename, const Functor &aFunctor=Functor())
DGtal is the top-level namespace which contains all DGtal functions and types.
STL namespace.
ImageContainerBySTLVector< Domain, Value > Type
Definition: ImageSelector.h:78
static bool exportPPM(const std::string &filename, const Image &aImage, const Functor &aFunctor=Functor(), bool topbottomOrder=true)
CAPTURE(thicknessHV)
TEST_CASE("Testing STBReader")
SECTION("Testing constant forward iterators")