DGtal 1.4.0
Loading...
Searching...
No Matches
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"
42using namespace std;
43using namespace DGtal;
44using namespace Z3i;
45
47// Functions for testing class CompressedVolWriter.
49
50template <typename Image>
51bool 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
64TEST_CASE( "Testing CompressedVolWriter" )
65{
66 Domain domain(Point(0,0,0), Point(10,10,10));
68 Image image(domain);
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);
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
90TEST_CASE( "Testing CompressedLongvol" )
91{
92 Domain domain(Point(0,0,0), Point(2,2,2));
94 Image image(domain);
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()
Space::Point Point
Definition StdDefs.h:168
DGtal is the top-level namespace which contains all DGtal functions and types.
Trace trace
Definition Common.h:153
STL namespace.
static ImageContainer importLongvol(const std::string &filename, const Functor &aFunctor=Functor())
Aim: Export a 3D Image using the Longvol formats (volumetric image with DGtal::uint64_t value type).
static ImageContainer importVol(const std::string &filename, const Functor &aFunctor=Functor())
Aim: Export a 3D Image using the Vol formats.
Definition VolWriter.h:69
TEST_CASE("Testing CompressedVolWriter")
bool checkImage(const Image &a, const Image &b)
Domain domain
ImageContainerBySTLVector< Domain, Value > Image
SECTION("Testing constant forward iterators")
REQUIRE(domain.isInside(aPoint))