
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena ChangeLog: 2007-10-23 Guillaume Duhamel <guillaume.duhamel@lrde.epita.fr> Fix display show and add color_pretty version for fllt. * mln/display/remove.hh: New function which removes all created file from display::save. * mln/display/show.hh: Update for previous function. * tests/show.cc: Update test for display::remove. * mln/display/color_pretty.hh: Add display::color_pretty_rgb for fllt, this function take three v_set and color a new image by these point_set. * tests/color_pretty.cc: Update test for display::color_pretty_rgb. * mln/util/abr.hh, * tests/abr.cc: Update typo. --- mln/display/color_pretty.hh | 57 +++++++++++++++++++++++++++- mln/display/remove.hh | 87 ++++++++++++++++++++++++++++++++++++++++++++ mln/display/show.hh | 2 + mln/util/abr.hh | 2 - tests/abr.cc | 2 - tests/color_pretty.cc | 44 +++++++++++++++++++++- tests/show.cc | 2 + 7 files changed, 190 insertions(+), 6 deletions(-) Index: trunk/milena/tests/abr.cc =================================================================== --- trunk/milena/tests/abr.cc (revision 1375) +++ trunk/milena/tests/abr.cc (revision 1376) @@ -21,7 +21,7 @@ // file, or you compile this file and link it with other files to // produce an executable, this file does not by itself cause the // resulting executable to be covered by the GNU General Public -// License. +// License. This exception does not however invalidate any other // reasons why the executable file might be covered by the GNU General // Public License. Index: trunk/milena/tests/show.cc =================================================================== --- trunk/milena/tests/show.cc (revision 1375) +++ trunk/milena/tests/show.cc (revision 1376) @@ -41,6 +41,7 @@ # include <mln/core/w_window2d_int.hh> # include <mln/display/show.hh> # include <mln/display/save.hh> +# include <mln/display/remove.hh> # include <mln/display/color_pretty.hh> # include <mln/io/ppm/save.hh> @@ -70,4 +71,5 @@ display::save (t); display::show (t, "xv"); } + display::remove (); } Index: trunk/milena/tests/color_pretty.cc =================================================================== --- trunk/milena/tests/color_pretty.cc (revision 1375) +++ trunk/milena/tests/color_pretty.cc (revision 1376) @@ -41,6 +41,7 @@ # include <mln/core/w_window2d_int.hh> # include <mln/display/color_pretty.hh> # include <mln/io/ppm/save.hh> +# include <mln/core/set_p.hh> int main() @@ -61,8 +62,49 @@ // Call chamfer for a distance image. image2d<unsigned> tmp = geom::chamfer(input, w_win, max); + set_p<point2d > s1; + set_p<point2d > s2; + set_p<point2d > s3; + + +// typedef image_if_value<image2d<unsigned> > I; +// { +// I t = inplace (tmp | 4); +// mln_piter(image_if_value<image2d<unsigned> >) p (t.domain ()); +// for_all (p) +// s1.insert (p); +// } + +// { +// I tmp = inplace (tmp | 6); +// mln_point(I) p (tmp.domain ()); +// for_all (p) +// s2.insert (p); +// } + +// { +// I tmp = inplace (tmp | 8); +// mln_point(I) p (tmp.domain ()); +// for_all (p) +// s3.insert (p); +// } + +// for (int i = 0; i < 100; ++i) +// for (int j = 0; j < 100; ++j) +// s1.insert(point2d(i, j)); + + for (int i = 200; i < 300; ++i) + for (int j = 0; j < 100; ++j) + s2.insert(point2d(i, j)); + + for (int i = 0; i < 100; ++i) + for (int j = 200; j < 300; ++j) + s3.insert(point2d(i, j)); + + + // Call color_pretty for sub_image. - image2d<value::rgb8> out = display::color_pretty(inplace (tmp | 4)); + image2d<value::rgb8> out = display::color_pretty_rgb(tmp, s1, s2, s3); // Save output image from color in out.ppm. io::ppm::save(out, "out.ppm"); Index: trunk/milena/mln/display/color_pretty.hh =================================================================== --- trunk/milena/mln/display/color_pretty.hh (revision 1375) +++ trunk/milena/mln/display/color_pretty.hh (revision 1376) @@ -40,7 +40,7 @@ # include <mln/value/rgb8.hh> # include <mln/level/fill.hh> # include <mln/level/paste.hh> - +# include <mln/core/set_p.hh> namespace mln { @@ -52,6 +52,13 @@ typename trait::image_from_mesh < mln_mesh(I), value::rgb8 >::ret color_pretty(const Image<I>& input_); + template <typename I> + typename trait::image_from_mesh < mln_mesh(I), value::rgb8 >::ret + color_pretty_rgb(const Image<I>& input_, + const set_p<mln_point(I) >& s1_, + const set_p<mln_point(I) >& s2_, + const set_p<mln_point(I) >& s3_); + # ifndef MLN_INCLUDE_ONLY namespace impl @@ -88,8 +95,6 @@ image2d<value::rgb8> output(input.domain().bbox()); level::fill(output, value::rgb8(255, 0, 0)); -// /// FIXME by : -// level::paste(input, output); { mln_piter(I) p(input.domain()); @@ -99,6 +104,42 @@ return output; } + template <typename I> + typename trait::image_from_mesh < mln_mesh(I), value::rgb8 >::ret + color_pretty_rgb(const Image<I>& input_, + const set_p<mln_point(I) >& s1_, + const set_p<mln_point(I) >& s2_, + const set_p<mln_point(I) >& s3_) + { + const I& input = exact (input_); + + image2d<value::rgb8> output(input.domain().bbox()); + level::fill(output, value::rgb8(0, 0, 0)); + + { + mln_piter(set_p<mln_point(I) >) p(s1_); + + for_all(p) + output(p).red() = 255; + } + + { + mln_piter(set_p<mln_point(I) >) p(s2_); + + for_all(p) + output(p).green() = 255; + } + + { + mln_piter(set_p<mln_point(I) >) p(s3_); + + for_all(p) + output(p).blue() = 255; + } + return output; + } + + } // end of namespace mln::display::impl /// Facade. @@ -109,6 +150,16 @@ return impl::color_pretty(input_); } + template <typename I> + typename trait::image_from_mesh < mln_mesh(I), value::rgb8 >::ret + color_pretty_rgb(const Image<I>& input_, + const set_p<mln_point(I) >& s1_, + const set_p<mln_point(I) >& s2_, + const set_p<mln_point(I) >& s3_) + { + return impl::color_pretty_rgb(input_, s1_, s2_, s3_); + } + # endif // !MLN_INCLUDE_ONLY } // end of namespace mln::display Index: trunk/milena/mln/display/remove.hh =================================================================== --- trunk/milena/mln/display/remove.hh (revision 0) +++ trunk/milena/mln/display/remove.hh (revision 1376) @@ -0,0 +1,87 @@ +// Copyright (C) 2007 EPITA Research and Development Laboratory +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// of the GNU General Public License version 2 as published by the +// Free Software Foundation. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. This exception does not however invalidate any other +// reasons why the executable file might be covered by the GNU General +// Public License. + +#ifndef MLN_DISPLAY_REMOVE_HH +# define MLN_DISPLAY_REMOVE_HH + +/*! \file mln/display/remove.hh + * + * \brief Remove all temporary files creat by display::save. + * + */ + +# include <mln/trait/image_from_mesh.hh> +# include <mln/core/image_if_value.hh> +# include <mln/core/image2d.hh> +# include <mln/display/save.hh> + +# include <map> + +namespace mln +{ + + namespace display + { + + void + remove(); + +# ifndef MLN_INCLUDE_ONLY + + namespace impl + { + + void + remove() + { + + for (std::map<void*, std::string>::const_iterator it = map_saved_image_tmp_.begin (); + it != map_saved_image_tmp_.end (); + ++it) + { + std::string s = "rm -f " + (*it).second; + system (s.c_str ()); + } + } + + } // end of namespace mln::display::impl + + /// Facade. + void + remove() + { + return impl::remove(); + } + +# endif // !MLN_INCLUDE_ONLY + + } // end of namespace mln::display + +} // end of namespace mln + + +#endif // ! MLN_DISPLAY_REMOVE_HH Index: trunk/milena/mln/display/show.hh =================================================================== --- trunk/milena/mln/display/show.hh (revision 1375) +++ trunk/milena/mln/display/show.hh (revision 1376) @@ -64,6 +64,8 @@ std::string s = cmd + " " + map_saved_image_tmp_[(void*)input.id_ ()] + " &"; system (s.c_str ()); + s = "sleep 3 && pkill " + cmd; + system (s.c_str ()); } } // end of namespace mln::display::impl Index: trunk/milena/mln/util/abr.hh =================================================================== --- trunk/milena/mln/util/abr.hh (revision 1375) +++ trunk/milena/mln/util/abr.hh (revision 1376) @@ -21,7 +21,7 @@ // file, or you compile this file and link it with other files to // produce an executable, this file does not by itself cause the // resulting executable to be covered by the GNU General Public -// License. +// License. This exception does not however invalidate any other // reasons why the executable file might be covered by the GNU General // Public License.