Milena (Olena)
User documentation 2.0a Id
|
00001 // Copyright (C) 2008, 2009, 2011 EPITA Research and Development 00002 // Laboratory (LRDE) 00003 // 00004 // This file is part of Olena. 00005 // 00006 // Olena is free software: you can redistribute it and/or modify it under 00007 // the terms of the GNU General Public License as published by the Free 00008 // Software Foundation, version 2 of the License. 00009 // 00010 // Olena is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 // General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with Olena. If not, see <http://www.gnu.org/licenses/>. 00017 // 00018 // As a special exception, you may use this file as part of a free 00019 // software project without restriction. Specifically, if other files 00020 // instantiate templates or use macros or inline functions from this 00021 // file, or you compile this file and link it with other files to produce 00022 // an executable, this file does not by itself cause the resulting 00023 // executable to be covered by the GNU General Public License. This 00024 // exception does not however invalidate any other reasons why the 00025 // executable file might be covered by the GNU General Public License. 00026 00027 #ifndef MLN_MAKE_IMAGE3D_HH 00028 # define MLN_MAKE_IMAGE3D_HH 00029 00037 00038 # include <mln/core/image/image3d.hh> 00039 # include <mln/core/image/image2d.hh> 00040 # include <mln/core/image/dmorph/slice_image.hh> 00041 # include <mln/data/paste.hh> 00042 # include <mln/util/array.hh> 00043 00044 00045 00046 namespace mln 00047 { 00048 00049 namespace make 00050 { 00051 00054 template <typename I> 00055 mln::image3d<mln_value(I)> 00056 image3d(const util::array<I>& ima); 00057 00060 template <typename I> 00061 mln::image3d<mln_value(I)> 00062 image3d(const Image<I>& ima); 00063 00064 00065 # ifndef MLN_INCLUDE_ONLY 00066 00067 template <typename I> 00068 inline 00069 mln::image3d<mln_value(I)> 00070 image3d(const util::array<I>& ima) 00071 { 00072 mlc_equal(mln_domain(I), mln::box2d)::check(); 00073 mln_precondition(! ima.is_empty()); 00074 00075 def::coord n_slis = ima.nelements(); 00076 mln::box2d b = ima[0].domain(); 00077 mln::box3d b_ = make::box3d(0, b.pmin().row(), b.pmin().col(), 00078 n_slis - 1, b.pmax().row(), b.pmax().col()); 00079 mln::image3d<mln_value(I)> output(b_); 00080 for (def::coord sli = 0; sli < n_slis; ++sli) 00081 { 00082 mln_assertion(ima[sli].domain() == b); 00083 data::paste(ima[sli], slice(output, sli).rw()); 00084 } 00085 return output; 00086 } 00087 00088 00089 template <typename I> 00090 inline 00091 mln::image3d<mln_value(I)> 00092 image3d(const Image<I>& ima_) 00093 { 00094 const I& ima = exact(ima_); 00095 00096 mlc_equal(mln_domain(I), mln::box2d)::check(); 00097 mln_precondition(ima.is_valid()); 00098 00099 mln::box2d b = ima.domain(); 00100 mln::box3d b_ = make::box3d(0, b.pmin().row(), b.pmin().col(), 00101 0, b.pmax().row(), b.pmax().col()); 00102 mln::image3d<mln_value(I)> output(b_); 00103 data::paste(ima, slice(output, 0).rw()); 00104 00105 return output; 00106 } 00107 00108 # endif // ! MLN_INCLUDE_ONLY 00109 00110 } // end of namespace mln::make 00111 00112 } // end of namespace mln 00113 00114 00115 #endif // ! MLN_MAKE_IMAGE3D_HH