DGtal 1.3.0
Loading...
Searching...
No Matches
Functions
testSTBReader.cpp File Reference
#include <iostream>
#include "DGtal/base/Common.h"
#include "ConfigTest.h"
#include "DGtalCatch.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/io/readers/STBReader.h"
#include "DGtal/images/ImageSelector.h"
#include "DGtal/io/writers/PPMWriter.h"

Go to the source code of this file.

Functions

 TEST_CASE ("Testing STBReader")
 

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 Systemes d'information - LIRIS (CNRS, UMR 5205), CNRS, France
Date
2022/06/14

Functions for testing class STBReader.

This file is part of the DGtal library.

Definition in file testSTBReader.cpp.

Function Documentation

◆ TEST_CASE()

TEST_CASE ( "Testing STBReader"  )

Definition at line 50 of file testSTBReader.cpp.

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}
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())
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)
SECTION("Testing constant forward iterators")

References CAPTURE(), DGtal::PPMWriter< TImage, TFunctor >::exportPPM(), DGtal::STBReader< TImageContainer, TFunctor >::import(), DGtal::Image< TImageContainer >::isValid(), and SECTION().