DGtal 1.3.0
No Matches
testSTBWriter.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/io/writers/STBWriter.h"
#include "DGtal/images/ImageSelector.h"
#include "DGtal/io/colormaps/GradientColorMap.h"
#include "DGtal/io/writers/PPMWriter.h"

Go to the source code of this file.


 TEST_CASE ("Testing STBWriter")

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

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

Functions for testing class STBReader.

This file is part of the DGtal library.

Definition in file testSTBWriter.cpp.

Function Documentation


TEST_CASE ( "Testing STBWriter"  )

Definition at line 51 of file testSTBWriter.cpp.

53 SECTION("Testing feature io/readers of STBWriter (Grayscale PNG)")
54 {
55 std::string filename = testPath + "samples/contourS.png";
57 Image image = STBReader<Image>::import( filename );
58 CAPTURE(image);
59 PPMWriter<Image>::exportPPM("contourS-export.ppm", image);
61 STBWriter<Image>::exportPNG("contourS-export.png", image);
62 CHECK( image.isValid());
63 }
65 SECTION("Testing feature io/readers of STBWriter (PNG)")
66 {
67 std::string filename = testPath + "samples/color64.png";
69 Image image = STBReader<Image>::import( filename );
70 CHECK( image.isValid());
71 PPMWriter<Image>::exportPPM("color64-export.ppm", image);
72 STBWriter<Image>::exportTGA("color64-export.tga", image);
73 STBWriter<Image>::exportJPG("color64-export.jpg", image);
74 STBWriter<Image>::exportBMP("color64-export.bmp", image);
75 }
77 SECTION("Testing scalar functor (PNG)")
78 {
80 Image image(Z2i::Domain(Z2i::Point(0,0), Z2i::Point(8,8)));
82 image.setValue(Z2i::Point(3,3), 10);
83 image.setValue(Z2i::Point(1,1), 1);
84 image.setValue(Z2i::Point(7,7), 20);
86 // Creating colormap.
87 GradientColorMap<int> cmap_grad( 0, 30 );
88 cmap_grad.addColor( Color( 50, 50, 255 ) );
89 cmap_grad.addColor( Color( 255, 0, 0 ) );
90 cmap_grad.addColor( Color( 255, 255, 10 ) );
92 CHECK( image.isValid());
93 STBWriter<Image,GradientColorMap<int>>::exportPNG("scalar-export.jpg", image, cmap_grad );
94 }
Structure representing an RGB triple with alpha component.
Definition: Color.h:68
Aim: This class template may be used to (linearly) convert scalar values in a given range into a colo...
Aim: implements association bewteen points lying in a digital domain and values.
Definition: Image.h:70
static ImageContainer import(const std::string &filename, const Functor &aFunctor=Functor())
Aim: Image Writer using the stb_image.h header only code.
Definition: STBWriter.h:65
static bool exportTGA(const std::string &filename, const ImageContainer &anImage, const Functor &aFunctor=Functor())
static bool exportPNG(const std::string &filename, const ImageContainer &anImage, const Functor &aFunctor=Functor())
static bool exportBMP(const std::string &filename, const ImageContainer &anImage, const Functor &aFunctor=Functor())
static bool exportJPG(const std::string &filename, const ImageContainer &anImage, const Functor &aFunctor=Functor(), int quality=70)
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)
SECTION("Testing constant forward iterators")

References DGtal::GradientColorMap< PValue, PDefaultPreset, PDefaultFirstColor, PDefaultLastColor >::addColor(), CAPTURE(), DGtal::STBWriter< TImageContainer, TFunctor >::exportBMP(), DGtal::STBWriter< TImageContainer, TFunctor >::exportJPG(), DGtal::STBWriter< TImageContainer, TFunctor >::exportPNG(), DGtal::PPMWriter< TImage, TFunctor >::exportPPM(), DGtal::STBWriter< TImageContainer, TFunctor >::exportTGA(), DGtal::STBReader< TImageContainer, TFunctor >::import(), and SECTION().