DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
testRawReader.cpp
1 
30 
31 #include <iostream>
32 #include "DGtal/base/Common.h"
33 
34 #include "DGtal/kernel/SpaceND.h"
35 #include "DGtal/kernel/domains/HyperRectDomain.h"
36 #include "DGtal/images/ImageSelector.h"
37 #include "DGtal/io/writers/PGMWriter.h"
38 #include "DGtal/io/readers/RawReader.h"
39 
40 #include "ConfigTest.h"
41 
42 
44 
45 using namespace std;
46 using namespace DGtal;
47 
49 // Functions for testing class RawReader.
51 
55 bool testRawReader2D()
56 {
57  unsigned int nbok = 0;
58  unsigned int nb = 0;
59 
60  trace.beginBlock ( "Testing Raw reader ..." );
61 
62  typedef SpaceND<2> Space2;
63  typedef HyperRectDomain<Space2> TDomain;
64  typedef TDomain::Vector Vector;
65 
66  //Default image selector = STLVector
68 
69  std::string filename = testPath + "samples/raw2D-64x64.raw";
70 
71  Vector ext(16,16);
72 
73  Image image = RawReader<Image>::importRaw8( filename , ext);
74 
76  trace.info() << image <<endl;
77 
78  //export
79  PGMWriter<Image>::exportPGM("export-raw-reader.pgm",image);
80 
82 
83  nbok += true ? 1 : 0;
84  nb++;
85  trace.info() << "(" << nbok << "/" << nb << ") "
86  << "true == true" << std::endl;
87  trace.endBlock();
88 
89  return nbok == nb;
90 }
91 
93 // Standard services - public :
94 
95 int main( int argc, char** argv )
96 {
97  trace.beginBlock ( "Testing class RawReader" );
98  trace.info() << "Args:";
99  for ( int i = 0; i < argc; ++i )
100  trace.info() << " " << argv[ i ];
101  trace.info() << endl;
102 
103  bool res = testRawReader2D(); // && ... other tests
104  trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
105  trace.endBlock();
106  return res ? 0 : 1;
107 }
108 // //