Milena (Olena)  User documentation 2.0a Id
 All Classes Namespaces Functions Variables Typedefs Enumerator Groups Pages
at.cc
1 // Copyright (C) 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/core/image/image1d.hh>
27 #include <mln/core/image/dmorph/sub_image.hh>
28 #include <mln/core/image/vmorph/cast_image.hh>
29 
30 /*#include <mln/core/image/image2d.hh>
31 #include <mln/core/image/image3d.hh>
32 #include <mln/pw/image.hh>
33 #include <mln/core/image/flat_image.hh>
34 #include <mln/core/image/dmorph/image_if.hh>
35 #include <mln/core/image/dmorph/extension_val.hh>*/
36 
37 #include <mln/data/fill.hh>
38 #include <mln/data/paste.hh>
39 #include <mln/data/compare.hh>
40 
41 #include <mln/opt/at.hh>
42 
43 #include <mln/debug/iota.hh>
44 #include <mln/debug/println.hh>
45 #include <mln/trace/all.hh>
46 
47 
48 int main()
49 {
50  using namespace mln;
51  const unsigned size = 50;
52 
54  {
55  image1d<short> ima(size);
56  debug::iota(ima);
57  const image1d<short> cima = ima;
58 
59  point1d p(5);
60  mln_assertion(cima(p) == opt::at(cima, 5));
61 
62  opt::at(ima, 5) = 12;
63  mln_assertion(cima(p) == 12);
64  }
65  {
66  typedef image1d<short> I;
67  typedef sub_image< image1d<short>, box1d > II;
68 
69  I ima(size);
70  II sub_ima(ima, make::box1d(4, 10));
71  const II csub_ima(ima, make::box1d(4, 10));
72  point1d p(5);
73 
74  data::fill(ima, short(51));
75  mln_assertion(csub_ima(p) == opt::at(csub_ima, 5));
76  opt::at(sub_ima, 5) = 12;
77  mln_assertion(sub_ima(p) == 12);
78  }
79  {
80  typedef image1d<unsigned short> I;
81  typedef cast_image_<int, I> II;
82 
83  I in(size, size);
84  II cast(in);
85  const II ccast(in);
86  point1d p(5);
87 
88  data::fill(in, (unsigned short)51);
89  mln_assertion(ccast(p) == opt::at(ccast, 5));
90  // FIXME
91  //opt::at(cast, 5) = 12;
92  //mln_assertion(cast(p) == 12);
93  }
94 
96  {
97  image2d<short> ima(size, size);
98  debug::iota(ima);
99  const image2d<short> cima = ima;
100 
101  point2d p(5, 5);
102  mln_assertion(cima(p) == opt::at(cima, 5, 5));
103 
104  opt::at(ima, 5, 5) = 12;
105  mln_assertion(cima(p) == 12);
106  }
107  {
108  typedef image2d<short> I;
109  typedef sub_image< image2d<short>, box2d > II;
110 
111  I ima(size, size);
112  II sub_ima(ima, make::box2d(4,4, 10, 10));
113  const II csub_ima(ima, make::box2d(4, 4, 10, 10));
114  point2d p(5, 5);
115 
116  data::fill(ima, short(51));
117  mln_assertion(csub_ima(p) == opt::at(csub_ima, 5, 5));
118  opt::at(sub_ima, 5, 5) = 12;
119  mln_assertion(sub_ima(p) == 12);
120  }
121  {
122  typedef image2d<unsigned short> I;
123  typedef cast_image_<int, I> II;
124 
125  I in(size, size);
126  II cast(in);
127  const II ccast(in);
128  point2d p(5,5);
129 
130  data::fill(in, (unsigned short)51);
131  mln_assertion(ccast(p) == opt::at(ccast, 5, 5));
132  // FIXME
133  //opt::at(cast, 5) = 12;
134  //mln_assertion(cast(p) == 12);
135  }
136 
137 
139  {
140  image3d<short> ima(size, size, size);
141  debug::iota(ima);
142  const image3d<short> cima = ima;
143 
144  point3d p(5, 5, 5);
145  mln_assertion(cima(p) == opt::at(cima, 5, 5, 5));
146 
147  opt::at(ima, 5, 5, 5) = 12;
148  mln_assertion(cima(p) == 12);
149  }
150 }