$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
fill_with_value.cc
1 // Copyright (C) 2007, 2008, 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/data/fill_with_value.hh>
27 
28 #include <mln/core/image/image1d.hh>
29 #include <mln/core/image/image2d.hh>
30 #include <mln/core/image/image3d.hh>
31 #include <mln/core/image/flat_image.hh>
32 #include <mln/core/image/dmorph/image_if.hh>
33 #include <mln/core/image/dmorph/sub_image.hh>
34 #include <mln/core/image/dmorph/extension_val.hh>
35 
36 #include <mln/value/rgb8.hh>
37 #include <mln/fun/p2b/chess.hh>
38 
39 #include <mln/make/box2d.hh>
40 
41 int main()
42 {
43  using namespace mln;
44  const unsigned size = 50;
45 
46  {
47  typedef image1d<unsigned char> I;
48  I ima(size);
49  data::fill_with_value(ima, 51);
50  mln_piter_(I) p(ima.domain());
51  for_all(p)
52  mln_assertion(ima(p) == 51);
53  }
54 
55 
56  {
57  typedef image2d<unsigned char> I;
58  I ima(size, size);
59  data::fill_with_value(ima, 51);
60  mln_piter_(I) p(ima.domain());
61  for_all(p)
62  mln_assertion(ima(p) == 51);
63  }
64 
65  {
66  typedef image3d<value::rgb8> I;
67  I ima(size, size, size);
68  data::fill_with_value(ima, value::rgb8(255, 0, 255));
69  mln_piter_(I) p(ima.domain());
70  for_all(p)
71  mln_assertion(ima(p) == value::rgb8(255, 0, 255));
72  }
73 
74 
75  {
77  data::fill_with_value(ima, 51);
78  box2d::piter p(ima.domain());
79  for_all(p)
80  mln_assertion(ima(p) == 51);
81  }
82 
83 
84  {
85  typedef image2d<unsigned char> I;
87 
88  I ima(size, size);
89  data::fill_with_value(ima, 51);
90 
91  II ima_if = ima | fun::p2b::chess();
92  data::fill_with_value(ima_if, 42);
93 
94  II::piter p(ima_if.domain());
95  for_all(p)
96  mln_assertion(ima_if(p) == 42);
97  }
98 
99  {
100  typedef image2d<int> I;
101  typedef sub_image< image2d<int>, box2d > II;
102  I ima(size, size);
103  II sub_ima(ima, make::box2d(4,4, 10,10));
104 
105  data::fill_with_value(sub_ima, 5);
106 
107  II::piter p(sub_ima.domain());
108  for_all(p)
109  mln_assertion(sub_ima(p) == 5);
110  }
111 
112  {
113  typedef image2d<int> I;
114  typedef extension_val< image2d<int> > II;
115  I ima(size, size);
116  II extend_ima(ima, 5);
117 
118  data::fill_with_value(extend_ima, 51);
119 
120  II::piter p(extend_ima.domain());
121  for_all(p)
122  mln_assertion(extend_ima(p) == 51);
123  }
124 
125 }