$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
at.hh
1 // Copyright (C) 2008, 2009, 2013 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 
27 #ifndef MLN_OPT_AT_HH
28 # define MLN_OPT_AT_HH
29 
33 
34 # include <mln/core/concept/image.hh>
35 # include <mln/trait/images.hh>
36 # include <mln/debug/trace.hh>
37 
38 # include <mln/core/alias/point1d.hh>
39 # include <mln/core/alias/point2d.hh>
40 # include <mln/core/alias/point3d.hh>
41 
42 namespace mln
43 {
44 
45  namespace opt
46  {
47 
50  template <typename I>
51  mln_rvalue(I) at(const Image<I>& ima, def::coord ind);
52 
54  template <typename I>
55  mln_lvalue(I) at(Image<I>& ima, def::coord ind);
56 
57 
60  template <typename I>
61  mln_rvalue(I) at(const Image<I>& ima, def::coord row, def::coord col);
62 
64  template <typename I>
65  mln_lvalue(I) at(Image<I>& ima, def::coord row, def::coord col);
66 
70  template <typename I>
71  mln_rvalue(I) at(const Image<I>& ima,
72  def::coord sli, def::coord row, def::coord col);
73 
74 
75 
78  template <typename I>
79  mln_lvalue(I) at(Image<I>& ima,
80  def::coord sli, def::coord row, def::coord col);
81 
82 
83 # ifndef MLN_INCLUDE_ONLY
84 
85 
87  namespace impl
88  {
89 
90  template <typename I>
91  inline
92  mln_rvalue(I) at_1d_impl(trait::image::category::domain_morpher,
93  const Image<I>& ima, def::coord ind)
94  {
95  point1d p(ind);
96  return exact(ima)(p);
97  }
98 
99  template <typename I>
100  inline
101  mln_rvalue(I) at_1d_impl(trait::image::category::morpher,
102  const Image<I>& ima, def::coord ind)
103  {
104  // FIXME: what about morpher that modify the image value?
105  // (through a function for instance)
106  return at(*exact(ima).delegatee_(), ind);
107  }
108 
109  template <typename I>
110  inline
111  mln_rvalue(I) at_1d_impl(trait::image::category::primary,
112  const Image<I>& ima, def::coord ind)
113  {
114  return exact(ima).at_(ind);
115  }
116 
117 
118  template <typename I>
119  inline
120  mln_lvalue(I) at_1d_impl(trait::image::category::domain_morpher,
121  Image<I>& ima, def::coord ind)
122  {
123  mlc_is(mln_trait_image_pw_io(I),
124  trait::image::pw_io::read_write)::check();
125 
126  point1d p(ind);
127  return exact(ima)(p);
128  }
129 
130  template <typename I>
131  inline
132  mln_lvalue(I) at_1d_impl(trait::image::category::morpher,
133  Image<I>& ima, def::coord ind)
134  {
135  // FIXME: what about morpher that modify the image value?
136  // (through a function for instance)
137  return at(*exact(ima).delegatee_(), ind);
138  }
139 
140  template <typename I>
141  inline
142  mln_lvalue(I) at_1d_impl(trait::image::category::primary,
143  Image<I>& ima, def::coord ind)
144  {
145  return exact(ima).at_(ind);
146  }
147 
148  } // end of namespace mln::opt::impl
149 
150  template <typename I>
151  inline
152  mln_rvalue(I) at(const Image<I>& ima, def::coord ind)
153  {
154  mlc_is(mln_trait_image_dimension(I),
155  trait::image::dimension::one_d)::check();
156 
157  return impl::at_1d_impl(mln_trait_image_category(I)(), ima, ind);
158  }
159 
160  template <typename I>
161  mln_lvalue(I) at(Image<I>& ima, def::coord ind)
162  {
163  mlc_is(mln_trait_image_dimension(I),
164  trait::image::dimension::one_d)::check();
165 
166  return impl::at_1d_impl(mln_trait_image_category(I)(), ima, ind);
167  }
168 
169 
170 
172  namespace impl
173  {
174 
175  template <typename I>
176  inline
177  mln_rvalue(I) at_2d_impl(trait::image::category::domain_morpher,
178  const Image<I>& ima, def::coord row, def::coord col)
179  {
180  point2d p(row, col);
181  return exact(ima)(p);
182  }
183 
184  template <typename I>
185  inline
186  mln_rvalue(I) at_2d_impl(trait::image::category::morpher,
187  const Image<I>& ima, def::coord row, def::coord col)
188  {
189  // FIXME: what about morpher that modify the image value?
190  // (through a function for instance)
191  return at(*exact(ima).delegatee_(), row, col);
192  }
193 
194  template <typename I>
195  inline
196  mln_rvalue(I) at_2d_impl(trait::image::category::primary,
197  const Image<I>& ima, def::coord row, def::coord col)
198  {
199  return exact(ima).at_(row, col);
200  }
201 
202 
203  template <typename I>
204  inline
205  mln_lvalue(I) at_2d_impl(trait::image::category::domain_morpher,
206  Image<I>& ima, def::coord row, def::coord col)
207  {
208  mlc_is(mln_trait_image_pw_io(I),
209  trait::image::pw_io::read_write)::check();
210 
211  point2d p(row, col);
212  return exact(ima)(p);
213  }
214 
215  template <typename I>
216  inline
217  mln_lvalue(I) at_2d_impl(trait::image::category::morpher,
218  Image<I>& ima, def::coord row, def::coord col)
219  {
220  // FIXME: what about morpher that modify the image value?
221  // (through a function for instance)
222  return at(*exact(ima).delegatee_(), row, col);
223  }
224 
225  template <typename I>
226  inline
227  mln_lvalue(I) at_2d_impl(trait::image::category::primary,
228  Image<I>& ima, def::coord row, def::coord col)
229  {
230  return exact(ima).at_(row, col);
231  }
232 
233  } // end of namespace mln::opt::impl
234 
235  template <typename I>
236  inline
237  mln_rvalue(I) at(const Image<I>& ima, def::coord row, def::coord col)
238  {
239  mlc_is(mln_trait_image_dimension(I),
240  trait::image::dimension::two_d)::check();
241 
242  return impl::at_2d_impl(mln_trait_image_category(I)(), ima, row, col);
243  }
244 
245  template <typename I>
246  mln_lvalue(I) at(Image<I>& ima, def::coord row, def::coord col)
247  {
248  mlc_is(mln_trait_image_dimension(I),
249  trait::image::dimension::two_d)::check();
250 
251  return impl::at_2d_impl(mln_trait_image_category(I)(), ima, row, col);
252  }
253 
254 
256  namespace impl
257  {
258 
259  template <typename I>
260  inline
261  mln_rvalue(I) at_3d_impl(trait::image::category::domain_morpher,
262  const Image<I>& ima, def::coord sli, def::coord row, def::coord col)
263  {
264  point3d p(sli, row, col);
265  return exact(ima)(p);
266  }
267 
268  template <typename I>
269  inline
270  mln_rvalue(I) at_3d_impl(trait::image::category::morpher,
271  const Image<I>& ima, def::coord sli, def::coord row, def::coord col)
272  {
273  // FIXME: what about morpher that modify the image value?
274  // (through a function for instance)
275  return at(*exact(ima).delegatee_(), sli, row, col);
276  }
277 
278  template <typename I>
279  inline
280  mln_rvalue(I) at_3d_impl(trait::image::category::primary,
281  const Image<I>& ima, def::coord sli, def::coord row, def::coord col)
282  {
283  return exact(ima).at_(sli, row, col);
284  }
285 
286 
287  template <typename I>
288  inline
289  mln_lvalue(I) at_3d_impl(trait::image::category::domain_morpher,
290  Image<I>& ima, def::coord sli, def::coord row, def::coord col)
291  {
292  mlc_is(mln_trait_image_pw_io(I),
293  trait::image::pw_io::read_write)::check();
294 
295  point3d p(sli, row, col);
296  return exact(ima)(p);
297  }
298 
299  template <typename I>
300  inline
301  mln_lvalue(I) at_3d_impl(trait::image::category::morpher,
302  Image<I>& ima, def::coord sli, def::coord row, def::coord col)
303  {
304  // FIXME: what about morpher that modify the image value?
305  // (through a function for instance)
306  return at(*exact(ima).delegatee_(), sli, row, col);
307  }
308 
309  template <typename I>
310  inline
311  mln_lvalue(I) at_3d_impl(trait::image::category::primary,
312  Image<I>& ima, def::coord sli, def::coord row, def::coord col)
313  {
314  return exact(ima).at_(sli, row, col);
315  }
316 
317  } // end of namespace mln::opt::impl
318 
319  template <typename I>
320  inline
321  mln_rvalue(I) at(const Image<I>& ima, def::coord sli, def::coord row, def::coord col)
322  {
323  mlc_is(mln_trait_image_dimension(I),
324  trait::image::dimension::three_d)::check();
325 
326  return impl::at_3d_impl(mln_trait_image_category(I)(),
327  ima, sli, row, col);
328  }
329 
330  template <typename I>
331  mln_lvalue(I) at(Image<I>& ima, def::coord sli, def::coord row, def::coord col)
332  {
333  mlc_is(mln_trait_image_dimension(I),
334  trait::image::dimension::three_d)::check();
335 
336  return impl::at_3d_impl(mln_trait_image_category(I)(),
337  ima, sli, row, col);
338  }
339 
340 # endif // ! MLN_INCLUDE_ONLY
341 
342  } // end of namespace mln::opt
343 
344 } // end of namespace mln
345 
346 
347 #endif // ! MLN_OPT_AT_HH