$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
graylevel_f_full.cc
1 // Copyright (C) 2006, 2007, 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/value/graylevel.hh>
27 #include <mln/value/glf.hh>
28 #include <mln/value/gl8.hh>
29 #include <mln/value/gl16.hh>
30 #include <mln/literal/all.hh>
31 
32 
33 int main()
34 {
35  using namespace mln;
36  using value::glf;
37  using value::gl8;
38  using value::gl16;
39  using value::graylevel;
40 
41  using literal::black;
43  using literal::white;
44 
45  // Constructions
46  {
47  glf a;
48 
49  glf b = 0.42;
50  mln_assertion(b.value() == 0.42f);
51 
52  glf c = 0.42;
53  mln_assertion(c.value() == 0.42f);
54 
55  glf d = c;
56  mln_assertion(d.value() == 0.42f);
57 
58  glf e = 0;
59  mln_assertion(e.value() == 0.f);
60 
61  graylevel<24> f = mlc_pow_int(2, 24) - 1;
62  glf g = f;
63  mln_assertion(g.value() == 1.f);
64 
65  graylevel<24> h = 0;
66  glf i = h;
67  mln_assertion(i.value() == 0.f);
68  }
69 
70  // Literals
71  {
72  glf a(white);
73  mln_assertion(a == glf(white));
74  mln_assertion(a.value() == 1.f);
75  glf d = white;
76  mln_assertion(d == glf(white));
77  mln_assertion(d.value() == 1.f);
78 
79  glf b(black);
80  mln_assertion(b == glf(black));
81  mln_assertion(b.value() == 0.f);
82  glf e = black;
83  mln_assertion(e == glf(black));
84  mln_assertion(e.value() == 0.f);
85 
86  glf c(medium_gray);
87  mln_assertion(c == glf(medium_gray));
88  mln_assertion(c.value() == 0.5f);
89  glf f = medium_gray;
90  mln_assertion(f == glf(medium_gray));
91  mln_assertion(f.value() == 0.5f);
92  }
93 
94  // FIXME : addition, multiplication, division.
95 }