DGtal 1.3.0
Loading...
Searching...
No Matches
Functions
testPNMReader.cpp File Reference
#include <iostream>
#include "DGtal/base/Common.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/io/boards/Board2D.h"
#include "DGtal/io/readers/PPMReader.h"
#include "DGtal/io/readers/PGMReader.h"
#include "DGtal/images/ImageSelector.h"
#include "DGtal/images/imagesSetsUtils/SetFromImage.h"
#include "ConfigTest.h"

Go to the source code of this file.

Functions

bool testPNMReader ()
 
bool testPNM3DReader ()
 
bool testPNM3DASCIIReader ()
 
int main (int argc, char **argv)
 

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
Bertrand Kerautret (kerau.nosp@m.tre@.nosp@m.loria.nosp@m..fr ) LORIA (CNRS, UMR 7503), University of Nancy, France
Date
2011/04/29

Functions for testing class PNMReader.

This file is part of the DGtal library.

Definition in file testPNMReader.cpp.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 130 of file testPNMReader.cpp.

131{
132 trace.beginBlock ( "Testing class PNMReader" );
133 trace.info() << "Args:";
134 for ( int i = 0; i < argc; ++i )
135 trace.info() << " " << argv[ i ];
136 trace.info() << endl;
137
138 bool res = testPNMReader() && testPNM3DReader() && testPNM3DASCIIReader(); // && ... other tests
139 trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
140 trace.endBlock();
141 return res ? 0 : 1;
142}
void beginBlock(const std::string &keyword="")
std::ostream & emphase()
std::ostream & info()
double endBlock()
Trace trace
Definition: Common.h:154
bool testPNMReader()
bool testPNM3DASCIIReader()
bool testPNM3DReader()

References DGtal::Trace::beginBlock(), DGtal::Trace::emphase(), DGtal::Trace::endBlock(), DGtal::Trace::info(), testPNM3DASCIIReader(), testPNM3DReader(), testPNMReader(), and DGtal::trace.

◆ testPNM3DASCIIReader()

bool testPNM3DASCIIReader ( )

Definition at line 111 of file testPNMReader.cpp.

112{
113 trace.beginBlock ( "Testing P2 pgm3D reader ..." );
114 std::string filename = testPath + "samples/ascii_ball.pgm3d";
115
116 trace.info() << "Loading filename: "<< filename<<std::endl;
117
119 Image image = PGMReader<Image>::importPGM3D( filename );
120
121 trace.info() << "Image 3D = "<<image<<std::endl;
122
123 trace.endBlock();
124 return true;
125}
Aim: implements association bewteen points lying in a digital domain and values.
Definition: Image.h:70
ImageContainerBySTLVector< Domain, Value > Type
Definition: ImageSelector.h:78
static ImageContainer importPGM3D(const std::string &aFilename, const Functor &aFunctor=Functor())

References DGtal::Trace::beginBlock(), DGtal::Trace::endBlock(), DGtal::PGMReader< TImageContainer, TFunctor >::importPGM3D(), DGtal::Trace::info(), and DGtal::trace.

Referenced by main().

◆ testPNM3DReader()

bool testPNM3DReader ( )

Example of a test. To be completed.

Definition at line 95 of file testPNMReader.cpp.

96{
97 trace.beginBlock ( "Testing pgm3D reader ..." );
98 std::string filename = testPath + "samples/simple.pgm3d";
99
100 trace.info() << "Loading filename: "<< filename<<std::endl;
101
103 Image image = PGMReader<Image>::importPGM3D( filename );
104
105 trace.info() << "Image 3D = "<<image<<std::endl;
106
107 trace.endBlock();
108 return true;
109}

References DGtal::Trace::beginBlock(), DGtal::Trace::endBlock(), DGtal::PGMReader< TImageContainer, TFunctor >::importPGM3D(), DGtal::Trace::info(), and DGtal::trace.

Referenced by main().

◆ testPNMReader()

bool testPNMReader ( )

Example of a test. To be completed.

Definition at line 53 of file testPNMReader.cpp.

54{
55 trace.beginBlock ( "Testing pgm reader ..." );
56 std::string filename = testPath + "samples/circleR10.pgm";
57
58 trace.info() << "Loading filename: "<< filename<<std::endl;
59
61 Image image = PGMReader<Image>::importPGM( filename );
62
63 Z2i::DigitalSet set2d (image.domain());
65
66 Board2D board;
67 board << image.domain() << set2d; // display domain and set
68
69 board.saveEPS( "testPNMReaderPGM.eps");
71
72 trace.beginBlock ( "Testing ppm reader ..." );
73 std::string filenamePPM = testPath + "samples/color64.ppm";
74
75 trace.info() << "Loading filename: "<< filenamePPM <<std::endl;
76
78 Image imagePPM = PPMReader<Image>::importPPM( filenamePPM );
79
80 Z2i::DigitalSet set2dPPM (imagePPM.domain());
81 SetFromImage<Z2i::DigitalSet>::append<Image>(set2dPPM, imagePPM, 0, 0xFFFFFEu);
82
83 Board2D boardPPM;
84 boardPPM << imagePPM.domain() << set2dPPM; // display domain and set
85
86 boardPPM.saveEPS( "testPNMReaderPPM.eps");
87 trace.endBlock();
88
89 return true;
90}
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Definition: Board2D.h:71
Aim: A wrapper class around a STL associative container for storing sets of digital points within som...
const Domain & domain() const
Definition: Image.h:192
void saveEPS(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition: Board.cpp:805
static ImageContainer importPGM(const std::string &aFilename, const Functor &aFunctor=Functor(), bool topbotomOrder=true)
static ImageContainer importPPM(const std::string &aFilename, const Functor &aFunctor=functors::ColorRGBEncoder< Value >(), bool topbotomOrder=true)
Aim: Define utilities to convert a digital set into an image.
Definition: SetFromImage.h:64

References DGtal::Trace::beginBlock(), DGtal::Image< TImageContainer >::domain(), DGtal::Trace::endBlock(), DGtal::PGMReader< TImageContainer, TFunctor >::importPGM(), DGtal::PPMReader< TImageContainer, TFunctor >::importPPM(), DGtal::Trace::info(), LibBoard::Board::saveEPS(), and DGtal::trace.

Referenced by main().