$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
dump.cc
1 // Copyright (C) 2009, 2010, 2011 EPITA Research and Development
2 // Laboratory (LRDE)
3 //
4 // This file is part of Olena.
5 //
6 // Olena is free software: you can redistribute it and/or modify it under
7 // the terms of the GNU General Public License as published by the Free
8 // Software Foundation, version 2 of the License.
9 //
10 // Olena is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with Olena. If not, see <http://www.gnu.org/licenses/>.
17 //
18 // As a special exception, you may use this file as part of a free
19 // software project without restriction. Specifically, if other files
20 // instantiate templates or use macros or inline functions from this
21 // file, or you compile this file and link it with other files to produce
22 // an executable, this file does not by itself cause the resulting
23 // executable to be covered by the GNU General Public License. This
24 // exception does not however invalidate any other reasons why the
25 // executable file might be covered by the GNU General Public License.
26 
29 
30 #include <mln/core/image/image2d.hh>
31 #include <mln/core/image/image3d.hh>
32 #include <mln/make/image3d.hh>
33 
34 #include <mln/debug/println.hh>
35 
36 #include <mln/io/dump/load.hh>
37 #include <mln/io/dump/save.hh>
38 
39 #include <mln/data/compare.hh>
40 
41 #include <mln/value/int_u8.hh>
42 #include <mln/value/rgb8.hh>
43 
44 #include "tests/data.hh"
45 
46 #include <mln/debug/println.hh>
47 
48 
49 int main()
50 {
51  using namespace mln;
52 
53  // FIXME: Factor.
54 
56  {
57  bool data[4] = { 0, 1,
58  1, 0 };
59  image2d<bool> pic = make::image2d(data);
60 
61  io::dump::save(pic, "dump-bool.dump");
62 
63  image2d<bool> pic2;
64  io::dump::load(pic2, "dump-bool.dump");
65 
66  mln_assertion(pic.domain() == pic2.domain());
67  mln_assertion(pic == pic2);
68  }
69 
71  {
72  bool data[4] = { 0, 1,
73  1, 0 };
75 
76  // Create a 3D image where each slice is a copy of SLICE.
78  for (unsigned i = 0; i < 3; ++i)
79  slices.append(slice);
80  image3d<bool> pic = make::image3d(slices);
81 
82  debug::println(pic);
83 
84  io::dump::save(pic, "dump-bool-3d.dump");
85 
86  image3d<bool> pic2;
87  io::dump::load(pic2, "dump-bool-3d.dump");
88 
89  mln_assertion(pic.domain() == pic2.domain());
90  mln_assertion(pic == pic2);
91  }
92 
94  {
95  value::int_u8 data[4] = { 5, 1,
96  1, 9 };
98  io::dump::save(pic, "dump-int_u8.dump");
100  io::dump::load(pic2, "dump-int_u8.dump");
101 
102  mln_assertion(pic.domain() == pic2.domain());
103  mln_assertion(pic == pic2);
104  }
105 
107  {
108  unsigned data[4] = { 5, 1,
109  1, 9 };
110  image2d<unsigned> pic = make::image2d(data);
111  io::dump::save(pic, "dump-unsigned.dump");
112  image2d<unsigned> pic2;
113  io::dump::load(pic2, "dump-unsigned.dump");
114 
115  mln_assertion(pic.domain() == pic2.domain());
116  mln_assertion(pic == pic2);
117  }
118 
120  {
121  float data[4] = { 5.2, 1.4,
122  mln_min(float), mln_max(float) };
123  image2d<float> pic = make::image2d(data);
124  io::dump::save(pic, "dump-float.dump");
125  image2d<float> pic2;
126  io::dump::load(pic2, "dump-float.dump");
127 
128  mln_assertion(pic.domain() == pic2.domain());
129  mln_assertion(pic == pic2);
130  }
131 
133  {
134  double data[4] = { 5.2, 1.4,
135  mln_min(double), mln_max(double) };
136  image2d<double> pic = make::image2d(data);
137  io::dump::save(pic, "dump-double.dump");
138  image2d<double> pic2;
139  io::dump::load(pic2, "dump-double.dump");
140 
141  mln_assertion(pic.domain() == pic2.domain());
142  mln_assertion(pic == pic2);
143  }
144 
145 
147  {
148  using value::rgb8;
149  value::rgb8 data[4] = { rgb8(2,4,5), rgb8(1,23,255),
150  rgb8(64,41,150), rgb8(23,53,49) };
152  io::dump::save(pic, "dump-rgb8.dump");
153 
155  io::dump::load(pic2, "dump-rgb8.dump");
156 
157  mln_assertion(pic.domain() == pic2.domain());
158  mln_assertion(pic == pic2);
159  }
160 
161 }