• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List

image3d.hh

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

Generated on Thu Sep 8 2011 18:31:58 for Milena (Olena) by  doxygen 1.7.1