DGtal  1.4.beta
testCompressedVolWriter.cpp
Go to the documentation of this file.
1 
31 #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 using namespace std;
43 using namespace DGtal;
44 using namespace Z3i;
45 
47 // Functions for testing class CompressedVolWriter.
49 
50 template <typename Image>
51 bool checkImage(const Image &a, const Image &b)
52 {
53  for(auto p: a.domain())
54  {
55  if (a(p) != b(p))
56  {
57  trace.info()<< p <<" "<< a(p) <<" "<<b(p)<<std::endl;
58  return false;
59  }
60  }
61  return true;
62 }
63 
64 TEST_CASE( "Testing CompressedVolWriter" )
65 {
66  Domain domain(Point(0,0,0), Point(10,10,10));
69  image.setValue(Point(5,5,5), 42);
70 
71  SECTION("Testing API of CompressedVol")
72  {
73  VolWriter< ImageContainerBySTLVector<Domain, unsigned char> >::exportVol("test.vol", image, false);
74  VolWriter< ImageContainerBySTLVector<Domain, unsigned char> >::exportVol("testz.vol", image);
75  REQUIRE( image.isValid() );
76  }
77 
78  SECTION("Testing write/read of CompressedVolWriter")
79  {
80  Image read = VolReader<Image>::importVol("test.vol");
81  trace.info()<<read<<std::endl;
82  REQUIRE( (checkImage(image,read) == true)) ;
83 
84  Image readz = VolReader<Image>::importVol("testz.vol");
85  trace.info()<<readz<<std::endl;
86  REQUIRE( (checkImage(image,readz) == true)) ;
87  }
88 }
89 
90 TEST_CASE( "Testing CompressedLongvol" )
91 {
92  Domain domain(Point(0,0,0), Point(2,2,2));
95  image.setValue(Point(1,1,1), 0X8899AABBCCDDEEFFull);
96 
97  SECTION("Testing API of CompressedVolWriter")
98  {
99  LongvolWriter< ImageContainerBySTLVector<Domain, DGtal::uint64_t> >::exportLongvol("test.lvol", image, false);
100  trace.info()<<std::endl;
101  LongvolWriter< ImageContainerBySTLVector<Domain, DGtal::uint64_t> >::exportLongvol("testz.lvol", image);
102  REQUIRE( image.isValid() );
103  }
104 
105  SECTION("Testing write/read of CompressedVolWriter")
106  {
107  Image read = LongvolReader<Image>::importLongvol("test.lvol");
108  REQUIRE( (checkImage(image,read) == true)) ;
109 
110  Image readz = LongvolReader<Image>::importLongvol("testz.lvol");
111  REQUIRE( (checkImage(image,readz) == true)) ;
112  }
113 }
114 
Aim: implements association bewteen points lying in a digital domain and values.
Definition: Image.h:70
std::ostream & info()
DGtal is the top-level namespace which contains all DGtal functions and types.
Trace trace
Definition: Common.h:153
Aim: implements methods to read a "Longvol" file format (with DGtal::uint64_t value type).
Definition: LongvolReader.h:92
Aim: Export a 3D Image using the Longvol formats (volumetric image with DGtal::uint64_t value type).
Definition: LongvolWriter.h:70
Aim: implements methods to read a "Vol" file format.
Definition: VolReader.h:90
Aim: Export a 3D Image using the Vol formats.
Definition: VolWriter.h:69
MyPointD Point
Definition: testClone2.cpp:383
TEST_CASE("Testing CompressedVolWriter")
bool checkImage(const Image &a, const Image &b)
Domain domain
Image image(domain)
ImageContainerBySTLVector< Domain, Value > Image
SECTION("Testing constant forward iterators")
REQUIRE(domain.isInside(aPoint))