$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
tiff/load.cc
1 // Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
2 //
3 // This file is part of Olena.
4 //
5 // Olena is free software: you can redistribute it and/or modify it under
6 // the terms of the GNU General Public License as published by the Free
7 // Software Foundation, version 2 of the License.
8 //
9 // Olena is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with Olena. If not, see <http://www.gnu.org/licenses/>.
16 //
17 // As a special exception, you may use this file as part of a free
18 // software project without restriction. Specifically, if other files
19 // instantiate templates or use macros or inline functions from this
20 // file, or you compile this file and link it with other files to produce
21 // an executable, this file does not by itself cause the resulting
22 // executable to be covered by the GNU General Public License. This
23 // exception does not however invalidate any other reasons why the
24 // executable file might be covered by the GNU General Public License.
25 
26 #include <mln/core/image/image2d.hh>
27 #include <mln/io/tiff/load.hh>
28 
29 #include <mln/data/compare.hh>
30 
31 #include <mln/value/int_u8.hh>
32 #include <mln/value/rgb8.hh>
33 
34 #include "tests/data.hh"
35 
36 #include <mln/debug/println.hh>
37 
38 using mln::value::rgb8;
39 using mln::value::int_u8;
40 
41 rgb8 ref_rgb[6][6] = { { rgb8(0,0,0), rgb8(255,255,255), rgb8(255,255,255), rgb8(255,255,255), rgb8(255,246,0), rgb8(0,0,0) },
42  { rgb8(255,255,255), rgb8(0,0,0), rgb8(255,255,255), rgb8(255,255,255), rgb8(255,255,255), rgb8(0,0,0) },
43  { rgb8(0,255,48), rgb8(255,255,255), rgb8(255,0,0), rgb8(255,255,255), rgb8(0,255,246), rgb8(0,0,0) },
44  { rgb8(255,255,255), rgb8(255,255,255), rgb8(255,255,255), rgb8(0,0,0), rgb8(255,255,255), rgb8(0,0,0) },
45  { rgb8(42,0,255), rgb8(255,255,255), rgb8(255,255,255), rgb8(255,255,255), rgb8(0,0,0), rgb8(0,0,0) },
46  { rgb8(0,0,0), rgb8(0,0,0), rgb8(0,0,0), rgb8(0,0,0), rgb8(0,0,0), rgb8(0,0,0) } };
47 
48 int_u8 ref_gl[6][6] = { { 0, 255, 255, 255, 230, 0 },
49  { 255, 0, 255, 255, 255, 0 },
50  { 186, 255, 54, 255, 200, 0 },
51  { 255, 255, 255, 0, 255, 0 },
52  { 27, 255, 255, 255, 0, 0 },
53  { 0, 0, 0, 0, 0, 0 } };
54 
55 bool ref_bw[6][6] = { { 0, 1, 1, 1, 1, 0 },
56  { 1, 0, 1, 1, 1, 0 },
57  { 1, 1, 0, 1, 1, 0 },
58  { 1, 1, 1, 0, 1, 0 },
59  { 0, 1, 1, 1, 0, 0 },
60  { 0, 0, 0, 0, 0, 0 } };
61 
62 
63 int main()
64 {
65  using namespace mln;
66  using namespace mln::value;
67 
69  {
70  image2d<rgb8> ref = make::image(ref_rgb);
71  image2d<rgb8> pic;
72  io::tiff::load(pic, MLN_TESTS_IMG_DIR "/test_rgb8.tif");
73  mln_assertion(pic == ref);
74  }
75 
76  {
77  image2d<int_u8> ref = make::image(ref_gl);
78  image2d<int_u8> pic;
79  io::tiff::load(pic, MLN_TESTS_IMG_DIR "/test_gl.tif");
80  mln_assertion(pic == ref);
81  }
82 
83  {
84  image2d<bool> ref = make::image(ref_bw);
85  image2d<bool> pic;
86  io::tiff::load(pic, MLN_TESTS_IMG_DIR "/test_bw.tif");
87  mln_assertion(pic == ref);
88  }
89 
90 }