DGtal  1.4.beta
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"
Include dependency graph for testSTBWriter.cpp:

Go to the source code of this file.

Functions

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

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 testSTBWriter.cpp.

Function Documentation

◆ TEST_CASE()

TEST_CASE ( "Testing STBWriter )

Definition at line 51 of file testSTBWriter.cpp.

52 {
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);
60 
61  STBWriter<Image>::exportPNG("contourS-export.png", image);
62  CHECK( image.isValid());
63  }
64 
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  }
76 
77  SECTION("Testing scalar functor (PNG)")
78  {
81 
82  image.setValue(Z2i::Point(3,3), 10);
83  image.setValue(Z2i::Point(1,1), 1);
84  image.setValue(Z2i::Point(7,7), 20);
85 
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 ) );
91 
92  CHECK( image.isValid());
93  STBWriter<Image,GradientColorMap<int>>::exportPNG("scalar-export.jpg", image, cmap_grad );
94  }
95 
96 }
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
Aim: Image reader using the stb_image.h header only code.
Definition: STBReader.h:62
Aim: Image Writer using the stb_image.h header only code.
Definition: STBWriter.h:65
Aim: Export a 2D and a 3D Image using the Netpbm PPM formats (ASCII mode).
Definition: PPMWriter.h:73
CAPTURE(thicknessHV)
Image image(domain)
ImageContainerBySTLVector< Domain, Value > Image
SECTION("Testing constant forward iterators")

References DGtal::GradientColorMap< PValue, PDefaultPreset, PDefaultFirstColor, PDefaultLastColor >::addColor(), CAPTURE(), image(), and SECTION().