DGtal  0.9.3
testCompressedVolWriter.cpp
Go to the documentation of this file.
1 
30 #include <iostream>
32 #include "DGtal/base/Common.h"
33 #include "ConfigTest.h"
34 #include "DGtalCatch.h"
35 #include "DGtal/helpers/StdDefs.h"
36 #include "DGtal/io/writers/LongvolWriter.h"
37 #include "DGtal/io/readers/LongvolReader.h"
38 #include "DGtal/io/writers/VolWriter.h"
39 #include "DGtal/io/readers/VolReader.h"
40 #include "DGtal/images/ImageContainerBySTLVector.h"
42 
43 using namespace std;
44 using namespace DGtal;
45 using namespace Z3i;
46 
48 // Functions for testing class CompressedVolWriter.
50 
51 template <typename Image>
52 bool checkImage(const Image &a, const Image &b)
53 {
54  for(auto p: a.domain())
55  {
56  if (a(p) != b(p))
57  {
58  trace.info()<< p <<" "<< a(p) <<" "<<b(p)<<std::endl;
59  return false;
60  }
61  }
62  return true;
63 }
64 
65 TEST_CASE( "Testing CompressedVolWriter" )
66 {
67  Domain domain(Point(0,0,0), Point(10,10,10));
69  Image image(domain);
70  image.setValue(Point(5,5,5), 42);
71 
72  SECTION("Testing API of CompressedVol")
73  {
74  VolWriter< ImageContainerBySTLVector<Domain, unsigned char> >::exportVol("test.vol", image, false);
75  VolWriter< ImageContainerBySTLVector<Domain, unsigned char> >::exportVol("testz.vol", image);
76  REQUIRE( image.isValid() );
77  }
78 
79  SECTION("Testing write/read of CompressedVolWriter")
80  {
81  Image read = VolReader<Image>::importVol("test.vol");
82  REQUIRE( (checkImage(image,read) == true)) ;
83 
84  Image readz = VolReader<Image>::importVol("testz.vol");
85  REQUIRE( (checkImage(image,readz) == true)) ;
86  }
87 }
88 
89 TEST_CASE( "Testing CompressedLongvol" )
90 {
91  Domain domain(Point(0,0,0), Point(2,2,2));
93  Image image(domain);
94  image.setValue(Point(1,1,1), 4222222);
95 
96  SECTION("Testing API of CompressedVolWriter")
97  {
98  LongvolWriter< ImageContainerBySTLVector<Domain, DGtal::uint64_t> >::exportLongvol("test.lvol", image, false);
99  trace.info()<<std::endl;
100  LongvolWriter< ImageContainerBySTLVector<Domain, DGtal::uint64_t> >::exportLongvol("testz.lvol", image);
101  REQUIRE( image.isValid() );
102  }
103 
104  SECTION("Testing write/read of CompressedVolWriter")
105  {
106  Image read = LongvolReader<Image>::importLongvol("test.lvol");
107  REQUIRE( (checkImage(image,read) == true)) ;
108 
109  Image readz = LongvolReader<Image>::importLongvol("testz.lvol");
110  REQUIRE( (checkImage(image,readz) == true)) ;
111  }
112 }
113 
Aim: implements association bewteen points lying in a digital domain and values.
Definition: Image.h:69
const Domain domain(Point(1, 2), Point(6, 5))
Trace trace
Definition: Common.h:137
bool isValid() const
Definition: Image.h:266
Aim: Export a 3D Image using the Vol formats.
Definition: VolWriter.h:68
STL namespace.
bool checkImage(const Image &a, const Image &b)
void setValue(const Point &aPoint, const Value &aValue)
Definition: Image.h:247
REQUIRE(domain.isInside(aPoint))
TEST_CASE("Testing CompressedVolWriter")
Aim: Export a 3D Image using the Longvol formats (volumetric image with DGtal::uint64_t value type)...
Definition: LongvolWriter.h:69
Aim: implements methods to read a "Vol" file format.
Definition: VolReader.h:89
DGtal is the top-level namespace which contains all DGtal functions and types.
MyPointD Point
Definition: testClone2.cpp:383
std::ostream & info()
ImageContainerBySTLVector< Domain, Value > Image
const Domain & domain() const
Definition: Image.h:192
SECTION("Testing constant forward iterators")
Aim: implements methods to read a "Longvol" file format (with DGtal::uint64_t value type)...
Definition: LongvolReader.h:91
Image image(domain)