milena r1733: Add a constructor to plain image type

URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena ChangeLog: 2008-02-16 Matthieu Garrigues <garrigues@lrde.epita.fr> Add a constructor to plain image type. * mln/core/plain.hh: (plain<I>::plain()) New. * tests/decorated_image.cc: Add a todo, this test doesn't work * tests/plain.cc: Explain the use of plain image. --- mln/core/plain.hh | 8 ++++++++ tests/decorated_image.cc | 1 + tests/plain.cc | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+) Index: trunk/milena/tests/plain.cc =================================================================== --- trunk/milena/tests/plain.cc (revision 1732) +++ trunk/milena/tests/plain.cc (revision 1733) @@ -35,6 +35,10 @@ #include <mln/value/int_u8.hh> #include <mln/level/compare.hh> +#include <mln/level/fill.hh> + + +#include <mln/debug/println.hh> #include <mln/io/pgm/load.hh> #include <mln/io/pgm/save.hh> @@ -74,4 +78,33 @@ mln_assertion(ima == ima2); } + + { + image2d<int_u8> lena(12,12); + level::fill(lena, 42); + + point2d p1(0,0); + point2d p2(5,4); + + image2d< image2d<int_u8> > ima(2,2); + level::fill(ima, lena); + // The 4 pixels of ima share the same data (holded by lena). + // Then this update will affect the 4 pixels of ima. + ima(p1)(p2) = 0; + // ima(0,0)(p2) == ima(0,1)(p2) == ima(1,0)(p2) == ima(1,1)(p2) == 0 + + image2d< plain< image2d<int_u8> > > ima_plain(2,2); + level::fill(ima_plain, plain< image2d<int_u8> >(lena)); + // The 4 pixels of ima_plain are instances of plain< + // image2d<int_u8> >. So each of them hold their own data. Then + // this update will affect just one pixel at the coordinate 0,0 of + // ima_plain. + ima_plain(p1)(p2) = 0; + // ima_plain(0,0)(p2) == 0 + // ima_plain(0,1)(p2) == 0 + // ima_plain(1,0)(p2) == 0 + // ima_plain(1,1)(p2) == 0 + + } + } Index: trunk/milena/tests/decorated_image.cc =================================================================== --- trunk/milena/tests/decorated_image.cc (revision 1732) +++ trunk/milena/tests/decorated_image.cc (revision 1733) @@ -28,6 +28,7 @@ /*! \file tests/decorated_image.cc * * \brief Tests on mln::decorated_image. + * \todo Make this test work. */ #include <mln/core/image2d.hh> Index: trunk/milena/mln/core/plain.hh =================================================================== --- trunk/milena/mln/core/plain.hh (revision 1732) +++ trunk/milena/mln/core/plain.hh (revision 1733) @@ -89,6 +89,7 @@ /// Constructors. plain(const I& ima); + plain(); /// Read-only access of pixel value at point site \p p. /// Mutable access is only OK for reading (not writing). @@ -128,6 +129,13 @@ this->data_ = new internal::data_< plain<I> >(ima); } + + template <typename I> + inline + plain<I>::plain() + { + } + template <typename I> inline plain<I>&
participants (1)
-
Matthieu Garrigues