$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
make/image3d.hh
1 // Copyright (C) 2008, 2009, 2011 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_MAKE_IMAGE3D_HH
28 # define MLN_MAKE_IMAGE3D_HH
29 
37 
38 # include <mln/core/image/image3d.hh>
39 # include <mln/core/image/image2d.hh>
40 # include <mln/core/image/dmorph/slice_image.hh>
41 # include <mln/data/paste.hh>
42 # include <mln/util/array.hh>
43 
44 
45 
46 namespace mln
47 {
48 
49  namespace make
50  {
51 
54  template <typename I>
56  image3d(const util::array<I>& ima);
57 
60  template <typename I>
62  image3d(const Image<I>& ima);
63 
64 
65 # ifndef MLN_INCLUDE_ONLY
66 
67  template <typename I>
68  inline
70  image3d(const util::array<I>& ima)
71  {
72  mlc_equal(mln_domain(I), mln::box2d)::check();
73  mln_precondition(! ima.is_empty());
74 
75  def::coord n_slis = ima.nelements();
76  mln::box2d b = ima[0].domain();
77  mln::box3d b_ = make::box3d(0, b.pmin().row(), b.pmin().col(),
78  n_slis - 1, b.pmax().row(), b.pmax().col());
79  mln::image3d<mln_value(I)> output(b_);
80  for (def::coord sli = 0; sli < n_slis; ++sli)
81  {
82  mln_assertion(ima[sli].domain() == b);
83  data::paste(ima[sli], slice(output, sli).rw());
84  }
85  return output;
86  }
87 
88 
89  template <typename I>
90  inline
92  image3d(const Image<I>& ima_)
93  {
94  const I& ima = exact(ima_);
95 
96  mlc_equal(mln_domain(I), mln::box2d)::check();
97  mln_precondition(ima.is_valid());
98 
99  mln::box2d b = ima.domain();
100  mln::box3d b_ = make::box3d(0, b.pmin().row(), b.pmin().col(),
101  0, b.pmax().row(), b.pmax().col());
102  mln::image3d<mln_value(I)> output(b_);
103  data::paste(ima, slice(output, 0).rw());
104 
105  return output;
106  }
107 
108 # endif // ! MLN_INCLUDE_ONLY
109 
110  } // end of namespace mln::make
111 
112 } // end of namespace mln
113 
114 
115 #endif // ! MLN_MAKE_IMAGE3D_HH