00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
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 }
00111
00112 }
00113
00114
00115 #endif // ! MLN_MAKE_IMAGE3D_HH