DGtal  1.2.0
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 
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));
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));
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:70
std::ostream & info()
DGtal is the top-level namespace which contains all DGtal functions and types.
Trace trace
Definition: Common.h:154
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))