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

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 }

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 }

References DGtal::Trace::beginBlock(), DGtal::Trace::endBlock(), 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::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");
70  trace.endBlock();
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 }

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

Referenced by main().

DGtal::SetFromImage
Aim: Define utilities to convert a digital set into an image.
Definition: SetFromImage.h:63
DGtal::Trace::endBlock
double endBlock()
DGtal::Image::domain
const Domain & domain() const
Definition: Image.h:192
DGtal::ImageContainerBySTLVector
Definition: ImageContainerBySTLVector.h:126
DGtal::Trace::emphase
std::ostream & emphase()
DGtal::trace
Trace trace
Definition: Common.h:154
DGtal::Trace::beginBlock
void beginBlock(const std::string &keyword="")
testPNMReader
bool testPNMReader()
Definition: testPNMReader.cpp:53
DGtal::Trace::info
std::ostream & info()
testPNM3DASCIIReader
bool testPNM3DASCIIReader()
Definition: testPNMReader.cpp:111
Image
ImageContainerBySTLVector< Domain, Value > Image
Definition: testSimpleRandomAccessRangeFromPoint.cpp:45
DGtal::PGMReader
Aim: Import a 2D or 3D using the Netpbm formats (ASCII mode).
Definition: PGMReader.h:97
testPNM3DReader
bool testPNM3DReader()
Definition: testPNMReader.cpp:95
DGtal::Board2D
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Definition: Board2D.h:70
DGtal::Image
Aim: implements association bewteen points lying in a digital domain and values.
Definition: Image.h:69
LibBoard::Board::saveEPS
void saveEPS(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition: Board.cpp:805
DGtal::PPMReader
Aim: Import a 2D or 3D using the Netpbm formats (ASCII mode).
Definition: PPMReader.h:98
DGtal::DigitalSetByAssociativeContainer
Aim: A wrapper class around a STL associative container for storing sets of digital points within som...
Definition: DigitalSetByAssociativeContainer.h:89