Olena-patches
Threads by month
- ----- 2025 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- 9625 discussions
Re: [Olena-patches] milena r1509: Review display directory and add tests.
by Guillaume Duhamel 21 Nov '07
by Guillaume Duhamel 21 Nov '07
21 Nov '07
Guillaume Duhamel wrote:
> URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
>
> ChangeLog:
> 2007-11-21 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
>
> Review.
>
> * mln/display/color_pretty.hh,
> * mln/display/remove.hh,
> * mln/display/save.hh,
> * mln/display/save_and_show.hh,
> * mln/display/show.hh: Fix enhancement, add doc and tracing,
> check typo.
>
> * tests/display/color_pretty.cc,
> * tests/display/save_and_show.cc,
> * tests/display/show.cc: Tests for display routines.
>
> Typo
> * mln/level/transform.hh: Fix typo.
>
> ---
> mln/display/color_pretty.hh | 56 +++++++++++++++++++++++++++++--
> mln/display/remove.hh | 15 +++++++-
> mln/display/save.hh | 38 ++++++++++++++-------
> mln/display/save_and_show.hh | 44 +++++++++++++++---------
> mln/display/show.hh | 62 ++++++++++++++++++++++++++++++----
> tests/display/color_pretty.cc | 73 ++++++++++++++++++++++-------------------
> tests/display/save_and_show.cc | 13 +++----
> tests/display/show.cc | 12 +++++-
> 8 files changed, 229 insertions(+), 84 deletions(-)
>
> Index: trunk/milena/tests/display/show.cc
> ===================================================================
> --- trunk/milena/tests/display/show.cc (revision 1508)
> +++ trunk/milena/tests/display/show.cc (revision 1509)
> @@ -25,7 +25,7 @@
> // reasons why the executable file might be covered by the GNU General
> // Public License.
>
> -/*! \file tests/show.cc
> +/*! \file tests/display/show.cc
> *
> * \brief Tests on mln::display::show.
> */
> @@ -69,7 +69,15 @@
> {
> image_if_value<image2d<unsigned> > t = inplace (tmp | i);
> display::save (t);
> - display::show (t, "xv");
> + display::show (t, "xv", 1);
> }
> +
> +// image2d<value::rgb8> color_image (16, 16);
> +// for (int i = 0; i < 16; ++i)
> +// for (int j = 0; j < 16; ++j)
> +// color_image(point2d(i, j)) = value::rgb8(0,0,255);
> +// display::save (color_image);
> +// display::show (color_image, "xv");
> +
> display::remove ();
> }
> Index: trunk/milena/tests/display/save_and_show.cc
> ===================================================================
> --- trunk/milena/tests/display/save_and_show.cc (revision 1508)
> +++ trunk/milena/tests/display/save_and_show.cc (revision 1509)
> @@ -25,9 +25,9 @@
> // reasons why the executable file might be covered by the GNU General
> // Public License.
>
> -/*! \file tests/save_and_show.cc
> +/*! \file tests/display/save_and_show.cc
> *
> - * \brief Tests on mln::display::show.
> + * \brief Tests on mln::display::save_and_show.
> */
>
> # include <mln/core/image2d.hh>
> @@ -42,7 +42,7 @@
> # include <mln/display/show.hh>
> # include <mln/io/ppm/save.hh>
> # include <mln/display/save_and_show.hh>
> -
> +# include <mln/level/fill.hh>
>
> int main()
> {
> @@ -50,7 +50,6 @@
>
> unsigned max = 51;
>
> -
> image2d<bool> input = io::pbm::load("../../img/toto.pbm");
>
> // Create a weighted windows :
> @@ -66,9 +65,11 @@
> for (unsigned i = 2; i < 6; i += 2)
> {
> image_if_value<image2d<unsigned> > t = inplace (tmp | i);
> - display::save_and_show (t, "xv");
> + display::save_and_show (t, "xv", 1);
> }
>
> + /// FIXME: Uncomment this ASAP
> // image2d<value::rgb8> ima (100, 100);
> -// display::save_and_show (ima, "xv");
> +// level::fill(ima, value::rgb8 (0, 0, 255));
> +// display::save_and_show (ima, "xv", 1);
> }
> Index: trunk/milena/tests/display/color_pretty.cc
> ===================================================================
> --- trunk/milena/tests/display/color_pretty.cc (revision 1508)
> +++ trunk/milena/tests/display/color_pretty.cc (revision 1509)
> @@ -31,56 +31,63 @@
> */
>
> # include <mln/core/image2d.hh>
> -# include <mln/io/pbm/load.hh>
> -# include <mln/make/win_chamfer.hh>
> -# include <mln/geom/chamfer.hh>
> -# include <mln/value/rgb8.hh>
> +# include <mln/value/int_u8.hh>
> +# include <mln/level/fill.hh>
> +# include <mln/core/p_set.hh>
> # include <mln/core/sub_image.hh>
> -# include <mln/core/image_if_value.hh>
> # include <mln/core/inplace.hh>
> -# include <mln/core/w_window2d_int.hh>
> +# include <mln/value/rgb8.hh>
> # include <mln/display/color_pretty.hh>
> -# include <mln/io/ppm/save.hh>
> -# include <mln/core/p_set.hh>
> +# include <mln/level/compare.hh>
>
>
> int main()
> {
> using namespace mln;
> + using value::int_u8;
>
> - unsigned max = 51;
> + /// Test on color_pretty.
> + {
> + image2d<int_u8> ima (2, 2);
> + level::fill (ima, 51);
>
> + p_set<point2d > s;
> + s.insert(point2d(0, 0));
> + s.insert(point2d(1, 1));
> +
> + sub_image<image2d<int_u8>, p_set<point2d > > input = inplace(ima | s);
> + image2d<value::rgb8> out = display::color_pretty(input);
> +
> + value::rgb8 vs[2][2] = {
> + {value::rgb8(51, 51, 51), value::rgb8(255, 0, 0) },
> + {value::rgb8(255, 0, 0), value::rgb8(51, 51, 51)}
> + };
>
> - image2d<bool> input = io::pbm::load("../../img/toto.pbm");
> + image2d<value::rgb8> ref (make::image2d(vs));
> + mln_assertion (ref == out);
> + }
>
> - // Create a weighted windows :
> - // 0 2 0
> - // 2 p 2
> - // 0 2 0
> - const w_window2d_int& w_win = make::mk_chamfer_3x3_int<2, 0> ();
>
> - // Call chamfer for a distance image.
> - image2d<unsigned> tmp = geom::chamfer(input, w_win, max);
> + /// Test on color_pretty_rgb.
> + {
> + image2d<value::rgb8> ima (2, 2);
>
> p_set<point2d > s1;
> p_set<point2d > s2;
> p_set<point2d > s3;
>
> - for (int i = 200; i < 300; ++i)
> - for (int j = 0; j < 100; ++j)
> - s2.insert(point2d(i, j));
> + s1.insert(point2d(0, 0));
> + s2.insert(point2d(0, 1));
> + s3.insert(point2d(1, 0));
> +
> + image2d<value::rgb8> out = display::color_pretty_rgb(ima, s1, s2, s3);
> +
> + value::rgb8 vs[2][2] = {
> + {value::rgb8(255, 0, 0), value::rgb8(0, 255, 0) },
> + {value::rgb8(0, 0, 255), value::rgb8(0, 0, 0)}
> + };
>
> - 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_rgb(tmp, s1, s2, s3);
> -
> -// // Save output image from color in out.ppm.
> -// io::ppm::save(out, "out.ppm");
> -
> -// std::cout << "out.ppm generate" << std::endl;
> + image2d<value::rgb8> ref (make::image2d(vs));
> + mln_assertion (ref == out);
> + }
> }
> Index: trunk/milena/mln/level/transform.hh
> ===================================================================
> Index: trunk/milena/mln/display/color_pretty.hh
> ===================================================================
> --- trunk/milena/mln/display/color_pretty.hh (revision 1508)
> +++ trunk/milena/mln/display/color_pretty.hh (revision 1509)
> @@ -41,6 +41,7 @@
> # include <mln/level/fill.hh>
> # include <mln/level/paste.hh>
> # include <mln/core/p_set.hh>
> +# include <mln/metal/is_not.hh>
>
> namespace mln
> {
> @@ -48,10 +49,36 @@
> namespace display
> {
>
> + /*! Return new image colored from an image \p input_. with the
> + * color red for the pixels not in the domain of \p input_.
> + *
> + * \param[in] ima The image in gray level to color.
> + *
> + * \return colored image from \p input_ in rgb8 with red for the
> + * color filled when the point is in bounding box of \p input_ but
> + * not defined.
> + *
> + * \pre \p input_ has to be initialized.
> + * \pre \p input_ values isn't color.
> + *
> + */
> template <typename I>
> typename trait::image_from_mesh < mln_mesh(I), value::rgb8 >::ret
> color_pretty(const Image<I>& input_);
>
> +
> + /*! Return new image colored from an image \p input_. with the
> + * color red for the pixels not in the domain of \p input_.
> + *
> + * \param[in] ima The image whose domain let to define the domain
> + * of the returned image.
> + * \param[in] s1_ The p_set where the points will be colored in red.
> + * \param[in] s2_ The p_set where the points will be colored in green.
> + * \param[in] s3_ The p_set where the points will be colored in blue.
> + *
> + * \return colored image from \p input_ domain which be filled in rgb8.
> + *
> + */
> template <typename I>
> typename trait::image_from_mesh < mln_mesh(I), value::rgb8 >::ret
> color_pretty_rgb(const Image<I>& input_,
> @@ -67,7 +94,6 @@
> value::rgb8
> color_value(V v)
> {
> - //r = v * (mln_max(V) / mln_max(value::int_u8) );
> return value::rgb8(v, v, v);
> }
>
> @@ -90,6 +116,8 @@
> typename trait::image_from_mesh < mln_mesh(I), value::rgb8 >::ret
> color_pretty(const Image<I>& input_)
> {
> + trace::entering("display::impl::color_pretty");
> +
> const I& input = exact (input_);
>
> image2d<value::rgb8> output(input.domain().bbox());
> @@ -101,6 +129,8 @@
> for_all(p)
> output(p) = value::rgb8(color_value(input(p)));
> }
> +
> + trace::exiting("display::impl::color_pretty");
> return output;
> }
>
> @@ -142,12 +172,25 @@
>
> } // end of namespace mln::display::impl
>
> +
> /// Facade.
> +
> template <typename I>
> typename trait::image_from_mesh < mln_mesh(I), value::rgb8 >::ret
> color_pretty(const Image<I>& input_)
> {
> - return impl::color_pretty(input_);
> + trace::entering("display::color_pretty");
> +
> + const I& input = exact(input_);
> + mln_precondition(input.has_data());
> +
> + mlc_is_not(mln_trait_value_kind(mln_value(I)) (),
> + trait::value::kind::color)::check();
> +
> + image2d<value::rgb8> output = impl::color_pretty(input);
> +
> + trace::exiting("display::color_pretty");
> + return output;
> }
>
> template <typename I>
> @@ -157,7 +200,14 @@
> const p_set<mln_point(I) >& s2_,
> const p_set<mln_point(I) >& s3_)
> {
> - return impl::color_pretty_rgb(input_, s1_, s2_, s3_);
> + trace::entering("display::color_pretty_rgb");
> +
> + const I& input = exact(input_);
> +
> + image2d<value::rgb8> output = impl::color_pretty_rgb(input_, s1_, s2_, s3_);
> +
> + trace::exiting("display::color_pretty_rgb");
> + return output;
> }
>
> # endif // !MLN_INCLUDE_ONLY
> Index: trunk/milena/mln/display/remove.hh
> ===================================================================
> --- trunk/milena/mln/display/remove.hh (revision 1508)
> +++ trunk/milena/mln/display/remove.hh (revision 1509)
> @@ -30,7 +30,7 @@
>
> /*! \file mln/display/remove.hh
> *
> - * \brief Remove all temporary files creat by display::save.
> + * \brief Remove all temporary files create by display::save.
> *
> */
>
> @@ -47,6 +47,10 @@
> namespace display
> {
>
> + /*! Remove all temporary images which are created by the routine
> + * save.
> + *
> + */
> void
> remove();
>
> @@ -58,6 +62,7 @@
> void
> remove()
> {
> + trace::entering("display::impl::remove");
>
> for (std::map<void*, std::string>::const_iterator it = map_saved_image_tmp_.begin ();
> it != map_saved_image_tmp_.end ();
> @@ -66,6 +71,8 @@
> std::string s = "rm -f " + (*it).second;
> system (s.c_str ());
> }
> +
> + trace::exiting("display::impl::remove");
> }
>
> } // end of namespace mln::display::impl
> @@ -74,7 +81,11 @@
> void
> remove()
> {
> - return impl::remove();
> + trace::entering("display::remove");
> +
> + impl::remove();
> +
> + trace::exiting("display::remove");
> }
>
> # endif // !MLN_INCLUDE_ONLY
> Index: trunk/milena/mln/display/save.hh
> ===================================================================
> --- trunk/milena/mln/display/save.hh (revision 1508)
> +++ trunk/milena/mln/display/save.hh (revision 1509)
> @@ -49,24 +49,31 @@
> namespace display
> {
>
> + /*! Map which stocks the location of the saved file by the id of
> + * the image.
> + *
> + */
> std::map<void*, std::string> map_saved_image_tmp_;
>
> + /*! Save an image in a temporary file in ppm format.
> + *
> + * \param[in] input_ the image to save.
> + *
> + */
> template <typename I>
> void
> save(const Image<I>& input_);
>
> - template <typename I>
> - void
> - save_color(const Image<I>& input_);
> -
> # ifndef MLN_INCLUDE_ONLY
>
> namespace impl
> {
> template <typename I>
> void
> - save(const Image<I>& input_)
> + save(trait::value::kind::any, const Image<I>& input_)
> {
> + trace::entering("display::impl::save");
> +
> const I& input = exact (input_);
> image2d<value::rgb8> out = display::color_pretty(input);
>
> @@ -80,12 +87,16 @@
> io::ppm::save(out, path_tmp);
>
> map_saved_image_tmp_[(void*)input.id_ ()] = path_tmp;
> +
> + trace::exiting("display::impl::save");
> }
>
> template <typename I>
> void
> - save_color(const Image<I>& input_)
> + save(trait::value::kind::color, const Image<I>& input_)
> {
> + trace::entering("display::impl::save");
> +
> const I& input = exact (input_);
>
> /// Use of mkstemp instead tempmap.
> @@ -98,6 +109,8 @@
> io::ppm::save(input, path_tmp);
>
> map_saved_image_tmp_[(void*)input.id_ ()] = path_tmp;
> +
> + trace::exiting("display::impl::save");
> }
>
> } // end of namespace mln::display::impl
> @@ -107,14 +120,13 @@
> void
> save(const Image<I>& input_)
> {
> - return impl::save(input_);
> - }
> + trace::entering("display::save");
>
> - template <typename I>
> - void
> - save_color(const Image<I>& input_)
> - {
> - return impl::save_color(input_);
> + const I& input = exact(input_);
> + mln_precondition(input.has_data());
> + impl::save(mln_trait_value_kind(mln_value(I)) (), input);
> +
> + trace::exiting("display::save");
> }
>
> # endif // !MLN_INCLUDE_ONLY
> Index: trunk/milena/mln/display/save_and_show.hh
> ===================================================================
> --- trunk/milena/mln/display/save_and_show.hh (revision 1508)
> +++ trunk/milena/mln/display/save_and_show.hh (revision 1509)
> @@ -43,9 +43,22 @@
> namespace display
> {
>
> + /*! Save and show an image \p input_, which displays whith \p cmd
> + * viewer in \p time seconds.
> + *
> + * \param[in] input_ the image to show.
> + * \param[in] cmd The string which contains the programm of the
> + * viewer which the user want to display with. By default its
> + * value is "xv".
> + * \param[in] time The number of second of
> + * display, 0 display permanently. By default the value is 0.
> + *
> + * \warning This routine doesn't erase the temporary created file.
> + *
> + */
> template <typename I>
> void
> - save_and_show(const Image<I>& input_, std::string cmd);
> + save_and_show(const Image<I>& input_, std::string cmd = "xv", int time = 0);
>
> # ifndef MLN_INCLUDE_ONLY
>
> @@ -53,21 +66,15 @@
> {
> template <typename I>
> void
> - save_and_show_(trait::value::kind::color,
> - const Image<I>& input, std::string cmd)
> + save_and_show_(const Image<I>& input,
> + std::string cmd, int time)
> {
> - save_color(input);
> - show(input, cmd);
> - }
> + trace::entering("display::impl::save_and_show_");
>
> - template <typename I>
> - void
> - save_and_show_(trait::value::kind::any,
> - const Image<I>& input,
> - std::string cmd)
> - {
> - save(input);
> - show(input, cmd);
> + display::save(input);
> + show(input, cmd, time);
> +
> + trace::exiting("display::impl::save_and_show_");
> }
>
> } // end of namespace mln::display::impl
> @@ -75,10 +82,13 @@
> /// Facade.
> template <typename I>
> void
> - save_and_show(const Image<I>& input_, std::string cmd)
> + save_and_show(const Image<I>& input_, std::string cmd = "xv", int time = 0)
> {
> - impl::save_and_show_(mln_trait_value_kind(mln_value(I)) (),
> - input_, cmd);
> + trace::entering("display::save_and_show");
> +
> + impl::save_and_show_(input_, cmd, time);
> +
> + trace::exiting("display::save_and_show");
> }
>
> # endif // !MLN_INCLUDE_ONLY
> Index: trunk/milena/mln/display/show.hh
> ===================================================================
> --- trunk/milena/mln/display/show.hh (revision 1508)
> +++ trunk/milena/mln/display/show.hh (revision 1509)
> @@ -47,9 +47,22 @@
> namespace display
> {
>
> + /*! Show an image \p input_ previously saved by display::save,
> + * which displays whith \p cmd viewer in \p time seconds.
> + *
> + * \param[in] input_ the image to show.
> + * \param[in] cmd The string which contains the programm of the
> + * viewer which the user want to display with. By default its
> + * value is "xv".
> + * \param[in] time The number of second of
> + * display, 0 display permanently. By default the value is 0.
> + *
> + * \pre the image \p input_ is previously saved is map_saved_image_tmp_.
> + *
> + */
> template <typename I>
> void
> - show(const Image<I>& input_, std::string cmd = "xv");
> + show(const Image<I>& input_, std::string cmd = "xv", int time = 0);
>
> # ifndef MLN_INCLUDE_ONLY
>
> @@ -57,15 +70,43 @@
> {
>
> template <typename I>
> + bool
> + check_saved(const Image<I>& input_)
> + {
> + const I& input = exact(input_);
> +
> + typename std::map<void*, std::string>::iterator it = map_saved_image_tmp_.begin();
> +
> + for (; it != map_saved_image_tmp_.end(); ++it)
> + if ((*it).first == input.id_())
> + return true;
> + return false;
> + }
> +
> + template <typename I>
> void
> - show(const Image<I>& input_, std::string cmd)
> + show(const Image<I>& input_, std::string cmd, int time)
> {
> + trace::entering("display::impl::show");
> +
> const I& input = exact (input_);
>
> - std::string s = cmd + " " + map_saved_image_tmp_[(void*)input.id_ ()] + " &";
> - system (s.c_str ());
> - s = "sleep 3 && pkill " + cmd;
> - system (s.c_str ());
> + std::stringstream st;
> + if (time)
> + {
> + st << cmd << " " << map_saved_image_tmp_[(void*)input.id_()] << " &";
> + system(st.str().c_str());
> + st.str("");
> + st << "sleep " << time << " && pkill " << cmd;
> + system(st.str().c_str());
> + }
> + else
> + {
> + st << cmd << " " << map_saved_image_tmp_[(void*)input.id_()];
> + system(st.str().c_str());
> + }
> +
> + trace::exiting("display::impl::show");
> }
>
> } // end of namespace mln::display::impl
> @@ -73,9 +114,14 @@
> /// Facade.
> template <typename I>
> void
> - show(const Image<I>& input_, std::string cmd = "xv")
> + show(const Image<I>& input_, std::string cmd = "xv", int time = 0)
> {
> - return impl::show(input_, cmd);
> + trace::entering("display::show");
> +
> + mln_precondition(impl::check_saved(input_));
> + impl::show(input_, cmd, time);
> +
> + trace::entering("display::show");
> }
>
> # endif // !MLN_INCLUDE_ONLY
>
fix title.
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-11-21 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Review.
* mln/display/color_pretty.hh,
* mln/display/remove.hh,
* mln/display/save.hh,
* mln/display/save_and_show.hh,
* mln/display/show.hh: Fix enhancement, add doc and tracing,
check typo.
* tests/display/color_pretty.cc,
* tests/display/save_and_show.cc,
* tests/display/show.cc: Tests for display routines.
Typo
* mln/level/transform.hh: Fix typo.
---
mln/display/color_pretty.hh | 56 +++++++++++++++++++++++++++++--
mln/display/remove.hh | 15 +++++++-
mln/display/save.hh | 38 ++++++++++++++-------
mln/display/save_and_show.hh | 44 +++++++++++++++---------
mln/display/show.hh | 62 ++++++++++++++++++++++++++++++----
tests/display/color_pretty.cc | 73 ++++++++++++++++++++++-------------------
tests/display/save_and_show.cc | 13 +++----
tests/display/show.cc | 12 +++++-
8 files changed, 229 insertions(+), 84 deletions(-)
Index: trunk/milena/tests/display/show.cc
===================================================================
--- trunk/milena/tests/display/show.cc (revision 1508)
+++ trunk/milena/tests/display/show.cc (revision 1509)
@@ -25,7 +25,7 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/show.cc
+/*! \file tests/display/show.cc
*
* \brief Tests on mln::display::show.
*/
@@ -69,7 +69,15 @@
{
image_if_value<image2d<unsigned> > t = inplace (tmp | i);
display::save (t);
- display::show (t, "xv");
+ display::show (t, "xv", 1);
}
+
+// image2d<value::rgb8> color_image (16, 16);
+// for (int i = 0; i < 16; ++i)
+// for (int j = 0; j < 16; ++j)
+// color_image(point2d(i, j)) = value::rgb8(0,0,255);
+// display::save (color_image);
+// display::show (color_image, "xv");
+
display::remove ();
}
Index: trunk/milena/tests/display/save_and_show.cc
===================================================================
--- trunk/milena/tests/display/save_and_show.cc (revision 1508)
+++ trunk/milena/tests/display/save_and_show.cc (revision 1509)
@@ -25,9 +25,9 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/save_and_show.cc
+/*! \file tests/display/save_and_show.cc
*
- * \brief Tests on mln::display::show.
+ * \brief Tests on mln::display::save_and_show.
*/
# include <mln/core/image2d.hh>
@@ -42,7 +42,7 @@
# include <mln/display/show.hh>
# include <mln/io/ppm/save.hh>
# include <mln/display/save_and_show.hh>
-
+# include <mln/level/fill.hh>
int main()
{
@@ -50,7 +50,6 @@
unsigned max = 51;
-
image2d<bool> input = io::pbm::load("../../img/toto.pbm");
// Create a weighted windows :
@@ -66,9 +65,11 @@
for (unsigned i = 2; i < 6; i += 2)
{
image_if_value<image2d<unsigned> > t = inplace (tmp | i);
- display::save_and_show (t, "xv");
+ display::save_and_show (t, "xv", 1);
}
+ /// FIXME: Uncomment this ASAP
// image2d<value::rgb8> ima (100, 100);
-// display::save_and_show (ima, "xv");
+// level::fill(ima, value::rgb8 (0, 0, 255));
+// display::save_and_show (ima, "xv", 1);
}
Index: trunk/milena/tests/display/color_pretty.cc
===================================================================
--- trunk/milena/tests/display/color_pretty.cc (revision 1508)
+++ trunk/milena/tests/display/color_pretty.cc (revision 1509)
@@ -31,56 +31,63 @@
*/
# include <mln/core/image2d.hh>
-# include <mln/io/pbm/load.hh>
-# include <mln/make/win_chamfer.hh>
-# include <mln/geom/chamfer.hh>
-# include <mln/value/rgb8.hh>
+# include <mln/value/int_u8.hh>
+# include <mln/level/fill.hh>
+# include <mln/core/p_set.hh>
# include <mln/core/sub_image.hh>
-# include <mln/core/image_if_value.hh>
# include <mln/core/inplace.hh>
-# include <mln/core/w_window2d_int.hh>
+# include <mln/value/rgb8.hh>
# include <mln/display/color_pretty.hh>
-# include <mln/io/ppm/save.hh>
-# include <mln/core/p_set.hh>
+# include <mln/level/compare.hh>
int main()
{
using namespace mln;
+ using value::int_u8;
- unsigned max = 51;
+ /// Test on color_pretty.
+ {
+ image2d<int_u8> ima (2, 2);
+ level::fill (ima, 51);
+ p_set<point2d > s;
+ s.insert(point2d(0, 0));
+ s.insert(point2d(1, 1));
+
+ sub_image<image2d<int_u8>, p_set<point2d > > input = inplace(ima | s);
+ image2d<value::rgb8> out = display::color_pretty(input);
+
+ value::rgb8 vs[2][2] = {
+ {value::rgb8(51, 51, 51), value::rgb8(255, 0, 0) },
+ {value::rgb8(255, 0, 0), value::rgb8(51, 51, 51)}
+ };
- image2d<bool> input = io::pbm::load("../../img/toto.pbm");
+ image2d<value::rgb8> ref (make::image2d(vs));
+ mln_assertion (ref == out);
+ }
- // Create a weighted windows :
- // 0 2 0
- // 2 p 2
- // 0 2 0
- const w_window2d_int& w_win = make::mk_chamfer_3x3_int<2, 0> ();
- // Call chamfer for a distance image.
- image2d<unsigned> tmp = geom::chamfer(input, w_win, max);
+ /// Test on color_pretty_rgb.
+ {
+ image2d<value::rgb8> ima (2, 2);
p_set<point2d > s1;
p_set<point2d > s2;
p_set<point2d > s3;
- for (int i = 200; i < 300; ++i)
- for (int j = 0; j < 100; ++j)
- s2.insert(point2d(i, j));
+ s1.insert(point2d(0, 0));
+ s2.insert(point2d(0, 1));
+ s3.insert(point2d(1, 0));
+
+ image2d<value::rgb8> out = display::color_pretty_rgb(ima, s1, s2, s3);
+
+ value::rgb8 vs[2][2] = {
+ {value::rgb8(255, 0, 0), value::rgb8(0, 255, 0) },
+ {value::rgb8(0, 0, 255), value::rgb8(0, 0, 0)}
+ };
- 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_rgb(tmp, s1, s2, s3);
-
-// // Save output image from color in out.ppm.
-// io::ppm::save(out, "out.ppm");
-
-// std::cout << "out.ppm generate" << std::endl;
+ image2d<value::rgb8> ref (make::image2d(vs));
+ mln_assertion (ref == out);
+ }
}
Index: trunk/milena/mln/level/transform.hh
===================================================================
Index: trunk/milena/mln/display/color_pretty.hh
===================================================================
--- trunk/milena/mln/display/color_pretty.hh (revision 1508)
+++ trunk/milena/mln/display/color_pretty.hh (revision 1509)
@@ -41,6 +41,7 @@
# include <mln/level/fill.hh>
# include <mln/level/paste.hh>
# include <mln/core/p_set.hh>
+# include <mln/metal/is_not.hh>
namespace mln
{
@@ -48,10 +49,36 @@
namespace display
{
+ /*! Return new image colored from an image \p input_. with the
+ * color red for the pixels not in the domain of \p input_.
+ *
+ * \param[in] ima The image in gray level to color.
+ *
+ * \return colored image from \p input_ in rgb8 with red for the
+ * color filled when the point is in bounding box of \p input_ but
+ * not defined.
+ *
+ * \pre \p input_ has to be initialized.
+ * \pre \p input_ values isn't color.
+ *
+ */
template <typename I>
typename trait::image_from_mesh < mln_mesh(I), value::rgb8 >::ret
color_pretty(const Image<I>& input_);
+
+ /*! Return new image colored from an image \p input_. with the
+ * color red for the pixels not in the domain of \p input_.
+ *
+ * \param[in] ima The image whose domain let to define the domain
+ * of the returned image.
+ * \param[in] s1_ The p_set where the points will be colored in red.
+ * \param[in] s2_ The p_set where the points will be colored in green.
+ * \param[in] s3_ The p_set where the points will be colored in blue.
+ *
+ * \return colored image from \p input_ domain which be filled in rgb8.
+ *
+ */
template <typename I>
typename trait::image_from_mesh < mln_mesh(I), value::rgb8 >::ret
color_pretty_rgb(const Image<I>& input_,
@@ -67,7 +94,6 @@
value::rgb8
color_value(V v)
{
- //r = v * (mln_max(V) / mln_max(value::int_u8) );
return value::rgb8(v, v, v);
}
@@ -90,6 +116,8 @@
typename trait::image_from_mesh < mln_mesh(I), value::rgb8 >::ret
color_pretty(const Image<I>& input_)
{
+ trace::entering("display::impl::color_pretty");
+
const I& input = exact (input_);
image2d<value::rgb8> output(input.domain().bbox());
@@ -101,6 +129,8 @@
for_all(p)
output(p) = value::rgb8(color_value(input(p)));
}
+
+ trace::exiting("display::impl::color_pretty");
return output;
}
@@ -142,12 +172,25 @@
} // end of namespace mln::display::impl
+
/// Facade.
+
template <typename I>
typename trait::image_from_mesh < mln_mesh(I), value::rgb8 >::ret
color_pretty(const Image<I>& input_)
{
- return impl::color_pretty(input_);
+ trace::entering("display::color_pretty");
+
+ const I& input = exact(input_);
+ mln_precondition(input.has_data());
+
+ mlc_is_not(mln_trait_value_kind(mln_value(I)) (),
+ trait::value::kind::color)::check();
+
+ image2d<value::rgb8> output = impl::color_pretty(input);
+
+ trace::exiting("display::color_pretty");
+ return output;
}
template <typename I>
@@ -157,7 +200,14 @@
const p_set<mln_point(I) >& s2_,
const p_set<mln_point(I) >& s3_)
{
- return impl::color_pretty_rgb(input_, s1_, s2_, s3_);
+ trace::entering("display::color_pretty_rgb");
+
+ const I& input = exact(input_);
+
+ image2d<value::rgb8> output = impl::color_pretty_rgb(input_, s1_, s2_, s3_);
+
+ trace::exiting("display::color_pretty_rgb");
+ return output;
}
# endif // !MLN_INCLUDE_ONLY
Index: trunk/milena/mln/display/remove.hh
===================================================================
--- trunk/milena/mln/display/remove.hh (revision 1508)
+++ trunk/milena/mln/display/remove.hh (revision 1509)
@@ -30,7 +30,7 @@
/*! \file mln/display/remove.hh
*
- * \brief Remove all temporary files creat by display::save.
+ * \brief Remove all temporary files create by display::save.
*
*/
@@ -47,6 +47,10 @@
namespace display
{
+ /*! Remove all temporary images which are created by the routine
+ * save.
+ *
+ */
void
remove();
@@ -58,6 +62,7 @@
void
remove()
{
+ trace::entering("display::impl::remove");
for (std::map<void*, std::string>::const_iterator it = map_saved_image_tmp_.begin ();
it != map_saved_image_tmp_.end ();
@@ -66,6 +71,8 @@
std::string s = "rm -f " + (*it).second;
system (s.c_str ());
}
+
+ trace::exiting("display::impl::remove");
}
} // end of namespace mln::display::impl
@@ -74,7 +81,11 @@
void
remove()
{
- return impl::remove();
+ trace::entering("display::remove");
+
+ impl::remove();
+
+ trace::exiting("display::remove");
}
# endif // !MLN_INCLUDE_ONLY
Index: trunk/milena/mln/display/save.hh
===================================================================
--- trunk/milena/mln/display/save.hh (revision 1508)
+++ trunk/milena/mln/display/save.hh (revision 1509)
@@ -49,24 +49,31 @@
namespace display
{
+ /*! Map which stocks the location of the saved file by the id of
+ * the image.
+ *
+ */
std::map<void*, std::string> map_saved_image_tmp_;
+ /*! Save an image in a temporary file in ppm format.
+ *
+ * \param[in] input_ the image to save.
+ *
+ */
template <typename I>
void
save(const Image<I>& input_);
- template <typename I>
- void
- save_color(const Image<I>& input_);
-
# ifndef MLN_INCLUDE_ONLY
namespace impl
{
template <typename I>
void
- save(const Image<I>& input_)
+ save(trait::value::kind::any, const Image<I>& input_)
{
+ trace::entering("display::impl::save");
+
const I& input = exact (input_);
image2d<value::rgb8> out = display::color_pretty(input);
@@ -80,12 +87,16 @@
io::ppm::save(out, path_tmp);
map_saved_image_tmp_[(void*)input.id_ ()] = path_tmp;
+
+ trace::exiting("display::impl::save");
}
template <typename I>
void
- save_color(const Image<I>& input_)
+ save(trait::value::kind::color, const Image<I>& input_)
{
+ trace::entering("display::impl::save");
+
const I& input = exact (input_);
/// Use of mkstemp instead tempmap.
@@ -98,6 +109,8 @@
io::ppm::save(input, path_tmp);
map_saved_image_tmp_[(void*)input.id_ ()] = path_tmp;
+
+ trace::exiting("display::impl::save");
}
} // end of namespace mln::display::impl
@@ -107,14 +120,13 @@
void
save(const Image<I>& input_)
{
- return impl::save(input_);
- }
+ trace::entering("display::save");
- template <typename I>
- void
- save_color(const Image<I>& input_)
- {
- return impl::save_color(input_);
+ const I& input = exact(input_);
+ mln_precondition(input.has_data());
+ impl::save(mln_trait_value_kind(mln_value(I)) (), input);
+
+ trace::exiting("display::save");
}
# endif // !MLN_INCLUDE_ONLY
Index: trunk/milena/mln/display/save_and_show.hh
===================================================================
--- trunk/milena/mln/display/save_and_show.hh (revision 1508)
+++ trunk/milena/mln/display/save_and_show.hh (revision 1509)
@@ -43,9 +43,22 @@
namespace display
{
+ /*! Save and show an image \p input_, which displays whith \p cmd
+ * viewer in \p time seconds.
+ *
+ * \param[in] input_ the image to show.
+ * \param[in] cmd The string which contains the programm of the
+ * viewer which the user want to display with. By default its
+ * value is "xv".
+ * \param[in] time The number of second of
+ * display, 0 display permanently. By default the value is 0.
+ *
+ * \warning This routine doesn't erase the temporary created file.
+ *
+ */
template <typename I>
void
- save_and_show(const Image<I>& input_, std::string cmd);
+ save_and_show(const Image<I>& input_, std::string cmd = "xv", int time = 0);
# ifndef MLN_INCLUDE_ONLY
@@ -53,21 +66,15 @@
{
template <typename I>
void
- save_and_show_(trait::value::kind::color,
- const Image<I>& input, std::string cmd)
+ save_and_show_(const Image<I>& input,
+ std::string cmd, int time)
{
- save_color(input);
- show(input, cmd);
- }
+ trace::entering("display::impl::save_and_show_");
- template <typename I>
- void
- save_and_show_(trait::value::kind::any,
- const Image<I>& input,
- std::string cmd)
- {
- save(input);
- show(input, cmd);
+ display::save(input);
+ show(input, cmd, time);
+
+ trace::exiting("display::impl::save_and_show_");
}
} // end of namespace mln::display::impl
@@ -75,10 +82,13 @@
/// Facade.
template <typename I>
void
- save_and_show(const Image<I>& input_, std::string cmd)
+ save_and_show(const Image<I>& input_, std::string cmd = "xv", int time = 0)
{
- impl::save_and_show_(mln_trait_value_kind(mln_value(I)) (),
- input_, cmd);
+ trace::entering("display::save_and_show");
+
+ impl::save_and_show_(input_, cmd, time);
+
+ trace::exiting("display::save_and_show");
}
# endif // !MLN_INCLUDE_ONLY
Index: trunk/milena/mln/display/show.hh
===================================================================
--- trunk/milena/mln/display/show.hh (revision 1508)
+++ trunk/milena/mln/display/show.hh (revision 1509)
@@ -47,9 +47,22 @@
namespace display
{
+ /*! Show an image \p input_ previously saved by display::save,
+ * which displays whith \p cmd viewer in \p time seconds.
+ *
+ * \param[in] input_ the image to show.
+ * \param[in] cmd The string which contains the programm of the
+ * viewer which the user want to display with. By default its
+ * value is "xv".
+ * \param[in] time The number of second of
+ * display, 0 display permanently. By default the value is 0.
+ *
+ * \pre the image \p input_ is previously saved is map_saved_image_tmp_.
+ *
+ */
template <typename I>
void
- show(const Image<I>& input_, std::string cmd = "xv");
+ show(const Image<I>& input_, std::string cmd = "xv", int time = 0);
# ifndef MLN_INCLUDE_ONLY
@@ -57,15 +70,43 @@
{
template <typename I>
+ bool
+ check_saved(const Image<I>& input_)
+ {
+ const I& input = exact(input_);
+
+ typename std::map<void*, std::string>::iterator it = map_saved_image_tmp_.begin();
+
+ for (; it != map_saved_image_tmp_.end(); ++it)
+ if ((*it).first == input.id_())
+ return true;
+ return false;
+ }
+
+ template <typename I>
void
- show(const Image<I>& input_, std::string cmd)
+ show(const Image<I>& input_, std::string cmd, int time)
{
+ trace::entering("display::impl::show");
+
const I& input = exact (input_);
- std::string s = cmd + " " + map_saved_image_tmp_[(void*)input.id_ ()] + " &";
- system (s.c_str ());
- s = "sleep 3 && pkill " + cmd;
- system (s.c_str ());
+ std::stringstream st;
+ if (time)
+ {
+ st << cmd << " " << map_saved_image_tmp_[(void*)input.id_()] << " &";
+ system(st.str().c_str());
+ st.str("");
+ st << "sleep " << time << " && pkill " << cmd;
+ system(st.str().c_str());
+ }
+ else
+ {
+ st << cmd << " " << map_saved_image_tmp_[(void*)input.id_()];
+ system(st.str().c_str());
+ }
+
+ trace::exiting("display::impl::show");
}
} // end of namespace mln::display::impl
@@ -73,9 +114,14 @@
/// Facade.
template <typename I>
void
- show(const Image<I>& input_, std::string cmd = "xv")
+ show(const Image<I>& input_, std::string cmd = "xv", int time = 0)
{
- return impl::show(input_, cmd);
+ trace::entering("display::show");
+
+ mln_precondition(impl::check_saved(input_));
+ impl::show(input_, cmd, time);
+
+ trace::entering("display::show");
}
# endif // !MLN_INCLUDE_ONLY
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
===================================================================
--- ChangeLog (revision 1507)
+++ ChangeLog (revision 1508)
@@ -32,40 +32,6 @@
* tests/win/cube3d.cc: New tests.
* tests/canvas/Makefile.am: Fix subdirs.
-2007-11-21 Simon Nivault <simon.nivault(a)lrde.epita.fr>
-
- Review win directory and add tests.
- * mln/win/backdiag2d.hh,
- * mln/win/cube3d.hh,
- * mln/win/diag2d.hh,
- * mln/win/disk2d.hh,
- * mln/win/hline2d.hh,
- * mln/win/line.hh,
- * mln/win/octagon2d.hh,
- * mln/win/rectangle2d.hh,
- * mln/win/segment1d.hh,
- * mln/win/vline2d.hh: Review.
-
- * tests/Makefile.am,
- * tests/win/Makefile.am: Update.
-
- * tests/win_backdiag2d.cc,
- * tests/win_diag2d.cc,
- * tests/win_disk2d.cc,
- * tests/win_hline2d.cc,
- * tests/win_octagon2d.cc,
- * tests/win_rectangle2d.cc: Rename as...
- * tests/win/backdiag2d.cc,
- * tests/win/diag2d.cc,
- * tests/win/disk2d.cc,
- * tests/win/hline2d.cc,
- * tests/win/octagon2d.cc,
- * tests/win/rectangle2d.cc: ...this.
- * tests/win/segment1d.cc,
- * tests/win/vline2d.cc,
- * tests/win/cube3d.cc: New tests.
- * tests/canvas/Makefile.am: Fix subdirs.
-
2007-11-21 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Little fix in test/Makefile.am.
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-11-21 Simon Nivault <simon.nivault(a)lrde.epita.fr>
Review win directory and add tests.
* mln/win/backdiag2d.hh,
* mln/win/cube3d.hh,
* mln/win/diag2d.hh,
* mln/win/disk2d.hh,
* mln/win/hline2d.hh,
* mln/win/line.hh,
* mln/win/octagon2d.hh,
* mln/win/rectangle2d.hh,
* mln/win/segment1d.hh,
* mln/win/vline2d.hh: Review.
* tests/Makefile.am,
* tests/win/Makefile.am: Update.
* tests/win_backdiag2d.cc,
* tests/win_diag2d.cc,
* tests/win_disk2d.cc,
* tests/win_hline2d.cc,
* tests/win_octagon2d.cc,
* tests/win_rectangle2d.cc: Rename as...
* tests/win/backdiag2d.cc,
* tests/win/diag2d.cc,
* tests/win/disk2d.cc,
* tests/win/hline2d.cc,
* tests/win/octagon2d.cc,
* tests/win/rectangle2d.cc: ...this.
* tests/win/segment1d.cc,
* tests/win/vline2d.cc,
* tests/win/cube3d.cc: New tests.
* tests/canvas/Makefile.am: Fix subdirs.
---
0 files changed
--
--
Simon NIVAULT aka Pollux
EPITA 2009 - stagiaire LRDE milena
@ : simonnivault(a)hotmail.com
"La derision est l'ultime defi au malheur"
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-11-21 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Little fix in test/Makefile.am.
* milena/tests/Makefile.am: Fix warning.
---
Makefile.am | 1 -
1 file changed, 1 deletion(-)
Index: trunk/milena/tests/Makefile.am
===================================================================
--- trunk/milena/tests/Makefile.am (revision 1504)
+++ trunk/milena/tests/Makefile.am (revision 1505)
@@ -287,7 +287,6 @@
safe_image_SOURCES = safe_image.cc
seed2tiling_SOURCES = seed2tiling.cc
-set_p_SOURCES = set_p.cc
sparse_image_SOURCES = sparse_image.cc
stack_SOURCES = stack.cc
sub_image_SOURCES = sub_image.cc
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-11-20 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Remove border_* subdirectories.
* tests/border_duplicate/test_border_duplicate_image1d_1.cc: Remove.
* tests/border_duplicate/test_border_duplicate_image1d_2.cc: Remove.
* tests/border_duplicate/test_border_duplicate_image1d_3.cc: Remove.
* tests/border_duplicate/test_border_duplicate_image1d_4.cc: Remove.
* tests/border_duplicate/test_border_duplicate_image1d_5.cc: Remove.
* tests/border_duplicate/test_border_duplicate_image2d_1.cc: Remove.
* tests/border_duplicate/test_border_duplicate_image2d_2.cc: Remove.
* tests/border_duplicate/test_border_duplicate_image2d_3.cc: Remove.
* tests/border_duplicate/test_border_duplicate_image2d_4.cc: Remove.
* tests/border_duplicate/test_border_duplicate_image3d_1.cc: Remove.
* tests/border_duplicate/test_border_duplicate_image3d_2.cc: Remove.
* tests/border_duplicate/test_border_duplicate_image3d_3.cc: Remove.
* tests/border_duplicate/test_border_duplicate_image3d_4.cc: Remove.
* tests/border_duplicate: Remove.
* tests/border_fill/test_border_fill_image1d_1.cc: Remove.
* tests/border_fill/test_border_fill_image1d_2.cc: Remove.
* tests/border_fill/test_border_fill_image1d_3.cc: Remove.
* tests/border_fill/test_border_fill_image1d_4.cc: Remove.
* tests/border_fill/test_border_fill_image1d_5.cc: Remove.
* tests/border_fill/test_border_fill_image2d_1.cc: Remove.
* tests/border_fill/test_border_fill_image2d_2.cc: Remove.
* tests/border_fill/test_border_fill_image2d_3.cc: Remove.
* tests/border_fill/test_border_fill_image2d_4.cc: Remove.
* tests/border_fill/test_border_fill_image3d_1.cc: Remove.
* tests/border_fill/test_border_fill_image3d_2.cc: Remove.
* tests/border_fill/test_border_fill_image3d_3.cc: Remove.
* tests/border_fill/test_border_fill_image3d_4.cc: Remove.
* tests/border_fill: Remove.
---
0 files changed
Index: tests/border_duplicate/test_border_duplicate_image1d_1.cc (deleted)
===================================================================
Index: tests/border_duplicate/test_border_duplicate_image1d_2.cc (deleted)
===================================================================
Index: tests/border_duplicate/test_border_duplicate_image2d_1.cc (deleted)
===================================================================
Index: tests/border_duplicate/test_border_duplicate_image1d_3.cc (deleted)
===================================================================
Index: tests/border_duplicate/test_border_duplicate_image2d_2.cc (deleted)
===================================================================
Index: tests/border_duplicate/test_border_duplicate_image3d_1.cc (deleted)
===================================================================
Index: tests/border_duplicate/test_border_duplicate_image1d_4.cc (deleted)
===================================================================
Index: tests/border_duplicate/test_border_duplicate_image2d_3.cc (deleted)
===================================================================
Index: tests/border_duplicate/test_border_duplicate_image3d_2.cc (deleted)
===================================================================
Index: tests/border_duplicate/test_border_duplicate_image1d_5.cc (deleted)
===================================================================
Index: tests/border_duplicate/test_border_duplicate_image2d_4.cc (deleted)
===================================================================
Index: tests/border_duplicate/test_border_duplicate_image3d_3.cc (deleted)
===================================================================
Index: tests/border_duplicate/test_border_duplicate_image3d_4.cc (deleted)
===================================================================
Index: tests/border_fill/test_border_fill_image1d_3.cc (deleted)
===================================================================
Index: tests/border_fill/test_border_fill_image2d_2.cc (deleted)
===================================================================
Index: tests/border_fill/test_border_fill_image3d_1.cc (deleted)
===================================================================
Index: tests/border_fill/test_border_fill_image1d_4.cc (deleted)
===================================================================
Index: tests/border_fill/test_border_fill_image2d_3.cc (deleted)
===================================================================
Index: tests/border_fill/test_border_fill_image3d_2.cc (deleted)
===================================================================
Index: tests/border_fill/test_border_fill_image1d_5.cc (deleted)
===================================================================
Index: tests/border_fill/test_border_fill_image2d_4.cc (deleted)
===================================================================
Index: tests/border_fill/test_border_fill_image3d_3.cc (deleted)
===================================================================
Index: tests/border_fill/test_border_fill_image3d_4.cc (deleted)
===================================================================
Index: tests/border_fill/test_border_fill_image1d_1.cc (deleted)
===================================================================
Index: tests/border_fill/test_border_fill_image1d_2.cc (deleted)
===================================================================
Index: tests/border_fill/test_border_fill_image2d_1.cc (deleted)
===================================================================
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-11-20 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Add Makefile.am in border.
* Makefile.am: New.
---
Makefile.am | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
Index: trunk/milena/tests/border/Makefile.am
===================================================================
--- trunk/milena/tests/border/Makefile.am (revision 0)
+++ trunk/milena/tests/border/Makefile.am (revision 1502)
@@ -0,0 +1,20 @@
+## Process this file through Automake to create Makefile.in -*- Makefile -*-
+
+include $(top_srcdir)/milena/tests/tests.mk
+
+check_PROGRAMS = \
+ adjust \
+ duplicate \
+ fill \
+ find \
+ get \
+ resize
+
+adjust_SOURCES = adjust.cc
+duplicate_SOURCES = duplicate.cc
+fill_SOURCES = fill.cc
+find_SOURCES = find.cc
+get_SOURCES = get.cc
+resize_SOURCES = resize.cc
+
+TESTS = $(check_PROGRAMS)
1
0
20 Nov '07
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-11-20 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Add subdirectory draw in tests and fix tests/level.
* mln/display/all.hh: Add save_and_show.hh.
* tests/Makefile.am: Update for display.
* tests/display: New subdirectory tests.
* tests/display/Makefile.am: New Makefile.am for draw.
* tests/show.cc: Remove ...
* tests/display/show.cc: ... and replace here.
* tests/color_pretty.cc: Remove ...
* tests/display/color_pretty.cc: ... and replace here.
* tests/save_and_show.cc: Remove ...
* tests/display/save_and_show.cc: ... and replace here.
* tests/level/apply.cc,
* tests/level/saturate.cc: Fix warning.
---
mln/display/all.hh | 1
tests/Makefile.am | 10 ----
tests/display/Makefile.am | 14 ++++++
tests/display/color_pretty.cc | 86 +++++++++++++++++++++++++++++++++++++++++
tests/display/save_and_show.cc | 74 +++++++++++++++++++++++++++++++++++
tests/display/show.cc | 75 +++++++++++++++++++++++++++++++++++
tests/level/apply.cc | 1
tests/level/saturate.cc | 1
8 files changed, 250 insertions(+), 12 deletions(-)
Index: trunk/milena/tests/save_and_show.cc (deleted)
===================================================================
Index: trunk/milena/tests/show.cc (deleted)
===================================================================
Index: trunk/milena/tests/color_pretty.cc (deleted)
===================================================================
Index: trunk/milena/tests/level/apply.cc
===================================================================
--- trunk/milena/tests/level/apply.cc (revision 1500)
+++ trunk/milena/tests/level/apply.cc (revision 1501)
@@ -40,7 +40,6 @@
{
using namespace mln;
- const unsigned size = 1000;
image2d<int> ima(3, 3);
int vs[3][3] = {
{ 2, 2, 3 },
Index: trunk/milena/tests/level/saturate.cc
===================================================================
--- trunk/milena/tests/level/saturate.cc (revision 1500)
+++ trunk/milena/tests/level/saturate.cc (revision 1501)
@@ -40,7 +40,6 @@
{
using namespace mln;
- const unsigned size = 1000;
image2d<int> ima(3, 3);
int vs[3][3] = {
{ 2, 2, 3 },
Index: trunk/milena/tests/display/save_and_show.cc
===================================================================
--- trunk/milena/tests/display/save_and_show.cc (revision 0)
+++ trunk/milena/tests/display/save_and_show.cc (revision 1501)
@@ -0,0 +1,74 @@
+// 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.
+
+/*! \file tests/save_and_show.cc
+ *
+ * \brief Tests on mln::display::show.
+ */
+
+# include <mln/core/image2d.hh>
+# include <mln/io/pbm/load.hh>
+# include <mln/make/win_chamfer.hh>
+# include <mln/geom/chamfer.hh>
+# include <mln/value/rgb8.hh>
+# include <mln/core/sub_image.hh>
+# include <mln/core/image_if_value.hh>
+# include <mln/core/inplace.hh>
+# include <mln/core/w_window2d_int.hh>
+# include <mln/display/show.hh>
+# include <mln/io/ppm/save.hh>
+# include <mln/display/save_and_show.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ unsigned max = 51;
+
+
+ image2d<bool> input = io::pbm::load("../../img/toto.pbm");
+
+ // Create a weighted windows :
+ // 0 2 0
+ // 2 p 2
+ // 0 2 0
+ const w_window2d_int& w_win = make::mk_chamfer_3x3_int<2, 0> ();
+
+ // Call chamfer for a distance image.
+ image2d<unsigned> tmp = geom::chamfer(input, w_win, max);
+
+ // Call color_pretty for sub_image.
+ for (unsigned i = 2; i < 6; i += 2)
+ {
+ image_if_value<image2d<unsigned> > t = inplace (tmp | i);
+ display::save_and_show (t, "xv");
+ }
+
+// image2d<value::rgb8> ima (100, 100);
+// display::save_and_show (ima, "xv");
+}
Index: trunk/milena/tests/display/show.cc
===================================================================
--- trunk/milena/tests/display/show.cc (revision 0)
+++ trunk/milena/tests/display/show.cc (revision 1501)
@@ -0,0 +1,75 @@
+// 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.
+
+/*! \file tests/show.cc
+ *
+ * \brief Tests on mln::display::show.
+ */
+
+# include <mln/core/image2d.hh>
+# include <mln/io/pbm/load.hh>
+# include <mln/make/win_chamfer.hh>
+# include <mln/geom/chamfer.hh>
+# include <mln/value/rgb8.hh>
+# include <mln/core/sub_image.hh>
+# include <mln/core/image_if_value.hh>
+# include <mln/core/inplace.hh>
+# 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>
+
+
+int main()
+{
+ using namespace mln;
+
+ unsigned max = 51;
+
+
+ image2d<bool> input = io::pbm::load("../../img/toto.pbm");
+
+ // Create a weighted windows :
+ // 0 2 0
+ // 2 p 2
+ // 0 2 0
+ const w_window2d_int& w_win = make::mk_chamfer_3x3_int<2, 0> ();
+
+ // Call chamfer for a distance image.
+ image2d<unsigned> tmp = geom::chamfer(input, w_win, max);
+
+ // Call color_pretty for sub_image.
+ for (unsigned i = 2; i < 6; i += 2)
+ {
+ image_if_value<image2d<unsigned> > t = inplace (tmp | i);
+ display::save (t);
+ display::show (t, "xv");
+ }
+ display::remove ();
+}
Index: trunk/milena/tests/display/Makefile.am
===================================================================
--- trunk/milena/tests/display/Makefile.am (revision 0)
+++ trunk/milena/tests/display/Makefile.am (revision 1501)
@@ -0,0 +1,14 @@
+## Process this file through Automake to create Makefile.in -*- Makefile -*-
+
+include $(top_srcdir)/milena/tests/tests.mk
+
+check_PROGRAMS = \
+ show \
+ save_and_show \
+ color_pretty
+
+show_SOURCES = show.cc
+save_and_show_SOURCES = save_and_show.cc
+color_pretty_SOURCES = color_pretty.cc
+
+TESTS = $(check_PROGRAMS)
Index: trunk/milena/tests/display/color_pretty.cc
===================================================================
--- trunk/milena/tests/display/color_pretty.cc (revision 0)
+++ trunk/milena/tests/display/color_pretty.cc (revision 1501)
@@ -0,0 +1,86 @@
+// 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.
+
+/*! \file tests/color_pretty.cc
+ *
+ * \brief Tests on mln::display::color::pretty.
+ */
+
+# include <mln/core/image2d.hh>
+# include <mln/io/pbm/load.hh>
+# include <mln/make/win_chamfer.hh>
+# include <mln/geom/chamfer.hh>
+# include <mln/value/rgb8.hh>
+# include <mln/core/sub_image.hh>
+# include <mln/core/image_if_value.hh>
+# include <mln/core/inplace.hh>
+# include <mln/core/w_window2d_int.hh>
+# include <mln/display/color_pretty.hh>
+# include <mln/io/ppm/save.hh>
+# include <mln/core/p_set.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ unsigned max = 51;
+
+
+ image2d<bool> input = io::pbm::load("../../img/toto.pbm");
+
+ // Create a weighted windows :
+ // 0 2 0
+ // 2 p 2
+ // 0 2 0
+ const w_window2d_int& w_win = make::mk_chamfer_3x3_int<2, 0> ();
+
+ // Call chamfer for a distance image.
+ image2d<unsigned> tmp = geom::chamfer(input, w_win, max);
+
+ p_set<point2d > s1;
+ p_set<point2d > s2;
+ p_set<point2d > s3;
+
+ 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_rgb(tmp, s1, s2, s3);
+
+// // Save output image from color in out.ppm.
+// io::ppm::save(out, "out.ppm");
+
+// std::cout << "out.ppm generate" << std::endl;
+}
Index: trunk/milena/tests/Makefile.am
===================================================================
--- trunk/milena/tests/Makefile.am (revision 1500)
+++ trunk/milena/tests/Makefile.am (revision 1501)
@@ -14,7 +14,6 @@
accu_min \
accu_nil \
\
- border_get \
border_resize_image1d_1 \
border_resize_image1d_2 \
border_resize_image1d_3 \
@@ -33,7 +32,6 @@
canvas_browsing_fwd \
cast_image \
chamfer \
- color_pretty \
convert_to_image \
convert_to_tiles \
convert_to_vec_p \
@@ -100,7 +98,6 @@
level_paste \
level_sort_points \
level_transform \
- line2d \
linear_convolve \
linear_gaussian \
linear_lap \
@@ -113,7 +110,6 @@
\
main \
mat \
- mesh_image \
metal_converts_to \
metal_is \
metal_mat \
@@ -157,7 +153,6 @@
safe_image \
seed2tiling \
set_p \
- show \
sparse_image \
stack \
sub_image \
@@ -204,7 +199,6 @@
accu_min_SOURCES = accu_min.cc
accu_nil_SOURCES = accu_nil.cc
-border_get_SOURCES = border_get.cc
border_resize_image1d_1_SOURCES = border_resize_image1d_1.cc
border_resize_image1d_2_SOURCES = border_resize_image1d_2.cc
border_resize_image1d_3_SOURCES = border_resize_image1d_3.cc
@@ -223,7 +217,6 @@
canvas_browsing_fwd_SOURCES = canvas_browsing_fwd.cc
cast_image_SOURCES = cast_image.cc
chamfer_SOURCES = chamfer.cc
-color_pretty_SOURCES = color_pretty.cc
convert_to_image_SOURCES = convert_to_image.cc
convert_to_tiles_SOURCES = convert_to_tiles.cc
convert_to_vec_p_SOURCES = convert_to_vec_p.cc
@@ -289,7 +282,6 @@
level_paste_SOURCES = level_paste.cc
level_sort_points_SOURCES = level_sort_points.cc
level_transform_SOURCES = level_transform.cc
-line2d_SOURCES = line2d.cc
linear_convolve_SOURCES = linear_convolve.cc
linear_gaussian_SOURCES = linear_gaussian.cc
linear_lap_SOURCES = linear_lap.cc
@@ -302,7 +294,6 @@
main_SOURCES = main.cc
mat_SOURCES = mat.cc
-mesh_image_SOURCES = mesh_image.cc
metal_converts_to_SOURCES = metal_converts_to.cc
metal_is_SOURCES = metal_is.cc
metal_mat_SOURCES = metal_mat.cc
@@ -346,7 +337,6 @@
safe_image_SOURCES = safe_image.cc
seed2tiling_SOURCES = seed2tiling.cc
set_p_SOURCES = set_p.cc
-show_SOURCES = show.cc
sparse_image_SOURCES = sparse_image.cc
stack_SOURCES = stack.cc
sub_image_SOURCES = sub_image.cc
Index: trunk/milena/mln/display/all.hh
===================================================================
--- trunk/milena/mln/display/all.hh (revision 1500)
+++ trunk/milena/mln/display/all.hh (revision 1501)
@@ -48,6 +48,7 @@
# include <mln/display/color_pretty.hh>
# include <mln/display/remove.hh>
+# include <mln/display/save_and_show.hh>
# include <mln/display/save.hh>
# include <mln/display/show.hh>
1
0
milena r1500: Review draw, create tests subdirectory and fix bug in level
by Guillaume Duhamel 20 Nov '07
by Guillaume Duhamel 20 Nov '07
20 Nov '07
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-11-20 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Review draw, create tests subdirectory and fix bug in level.
Draw.
* mln/draw/line.hh
* mln/draw/mesh.hh: Fix doc and typo.
Tests.
* tests/Makefile.am: Update for draw.
* tests/draw: New subdirectory for draw tests.
* tests/draw/Makefile.am: New Makefile.am for draw.
* tests/line2d.cc: Remove ... .
* tests/draw/line.cc: and replace here and update test.
* tests/mesh_image.cc: Remove ... .
* tests/draw/mesh.cc: ... and replace here and update test.
Fix level bug.
* mln/level/fill.hh: Fix specialization bug.
---
mln/draw/line.hh | 15 ++++++++--
mln/draw/mesh.hh | 19 ++++++++++++
mln/level/fill.hh | 3 --
tests/Makefile.am | 1
tests/draw/Makefile.am | 12 ++++++++
tests/draw/line.cc | 68 +++++++++++++++++++++++++++++++++++++++++++++
tests/draw/mesh.cc | 73 +++++++++++++++++++++++++++++++++++++++++++++++++
7 files changed, 186 insertions(+), 5 deletions(-)
Index: trunk/milena/tests/line2d.cc (deleted)
===================================================================
Index: trunk/milena/tests/mesh_image.cc (deleted)
===================================================================
Index: trunk/milena/tests/Makefile.am
===================================================================
--- trunk/milena/tests/Makefile.am (revision 1499)
+++ trunk/milena/tests/Makefile.am (revision 1500)
@@ -6,6 +6,7 @@
level \
arith \
logical \
+ draw \
border
check_PROGRAMS = \
Index: trunk/milena/tests/draw/mesh.cc
===================================================================
--- trunk/milena/tests/draw/mesh.cc (revision 0)
+++ trunk/milena/tests/draw/mesh.cc (revision 1500)
@@ -0,0 +1,73 @@
+// 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.
+
+/*! \file tests/draw/mesh.cc
+ *
+ * \brief Tests on mln::draw::mesh.
+ */
+
+#include <mln/core/image2d.hh>
+#include <mln/core/point2d.hh>
+#include <mln/debug/println.hh>
+#include <mln/util/graph.hh>
+#include <mln/core/mesh_p.hh>
+#include <mln/core/mesh_psite.hh>
+#include <mln/draw/mesh.hh>
+#include <mln/core/mesh_image.hh>
+#include <mln/level/compare.hh>
+
+int
+main (void)
+{
+ using namespace mln;
+
+ int vs[3][3] = {
+ {2, 0, 0},
+ {0, 1, 0},
+ {0, 0, 2}
+ };
+
+ image2d<int> ref (make::image2d(vs));
+
+ util::graph<void> g;
+
+ g.add_node ();
+ g.add_node ();
+ g.add_edge (0, 1);
+ g.consistency ();
+
+ std::vector<point2d> v;
+ v.push_back (make::point2d (0,0));
+ v.push_back (make::point2d (2,2));
+
+ mesh_p<point2d> m(g, v);
+
+ image2d<int> ima (3, 3);
+ draw::mesh (ima, m, 2, 1);
+
+ mln_assertion (ima == ref);
+}
Index: trunk/milena/tests/draw/Makefile.am
===================================================================
--- trunk/milena/tests/draw/Makefile.am (revision 0)
+++ trunk/milena/tests/draw/Makefile.am (revision 1500)
@@ -0,0 +1,12 @@
+## Process this file through Automake to create Makefile.in -*- Makefile -*-
+
+include $(top_srcdir)/milena/tests/tests.mk
+
+check_PROGRAMS = \
+ line \
+ mesh
+
+line_SOURCES = line.cc
+mesh_SOURCES = mesh.cc
+
+TESTS = $(check_PROGRAMS)
Index: trunk/milena/tests/draw/line.cc
===================================================================
--- trunk/milena/tests/draw/line.cc (revision 0)
+++ trunk/milena/tests/draw/line.cc (revision 1500)
@@ -0,0 +1,68 @@
+// 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.
+
+/*! \file tests/draw/line.cc
+ *
+ * \brief Tests on mln::draw::line.
+ */
+
+#include <iterator>
+
+#include <mln/core/image2d.hh>
+#include <mln/core/sub_image.hh>
+#include <mln/core/inplace.hh>
+
+#include <mln/level/fill.hh>
+#include <mln/level/compare.hh>
+#include <mln/draw/line.hh>
+#include <mln/debug/println.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ point2d b = make::point2d(0,0), e = make::point2d(6,9);
+ line2d l(b, e);
+ mln_assertion(l.npoints() == 10);
+
+ image2d<bool> ima(10,10);
+ level::fill(ima, false);
+ draw::line(ima, b, e, true);
+
+ image2d<bool> ima2(10,10);
+ level::fill(ima2, false);
+ level::paste(pw::cst(true) | l, ima2);
+
+ mln_assertion(ima2 == ima);
+
+ image2d<bool> ima3(10,10);
+ level::fill(ima3, false);
+ level::fill(inplace(ima3 | l), true);
+
+ mln_assertion(ima3 == ima);
+}
Index: trunk/milena/mln/draw/line.hh
===================================================================
--- trunk/milena/mln/draw/line.hh (revision 1499)
+++ trunk/milena/mln/draw/line.hh (revision 1500)
@@ -46,8 +46,19 @@
namespace draw
{
- /// Draw a line at level \p v in image \p ima between the points
- /// \p beg and \p end.
+ /*! Draw a line at level \p v in image \p ima between the points
+ * \p beg and \p end.
+ *
+ * \param[in,out] ima The image to be drawn.
+ * \param[in] beg The start point to drawn line.
+ * \param[in] end The end point to drawn line.
+ * \param[in] v The value to assign to all drawn pixels.
+ *
+ * \pre \p ima has to be initialized.
+ * \pre \p ima has \p beg.
+ * \pre \p ima has \p end.
+ *
+ */
template <typename I>
void line(Image<I>& ima,
const mln_point(I)& beg, const mln_point(I)& end,
Index: trunk/milena/mln/draw/mesh.hh
===================================================================
--- trunk/milena/mln/draw/mesh.hh (revision 1499)
+++ trunk/milena/mln/draw/mesh.hh (revision 1500)
@@ -30,7 +30,7 @@
/*! \file mln/draw/mesh.hh
*
- * \brief Draw an image of type mesh_image into anothor kind of image.
+ * \brief Draw an image from type mesh_image.
*
*/
@@ -45,12 +45,29 @@
namespace draw
{
+ /*! Draw an image \p ima from a mesh_p \p m, with value \p node_v
+ * for nodes, value \p link_v for links and 0 for the background.
+ *
+ * \param[in,out] ima The image to be drawn.
+ * \param[in] m The mesh_p which contains nodes and links positions.
+ * \param[in] node_v The value to assign to pixels which contains nodes.
+ * \param[in] link_v The value to assign to pixels which contains links.
+ *
+ */
template <typename I, typename P>
void
mesh(Image<I>& ima, const mesh_p<P>& m,
mln_value(I) node_v,
mln_value(I) link_v);
+ /*! Draw an image \p ima from a mesh_image \p mesh.
+ * The background is filled to value 0.
+ *
+ * \param[in,out] ima The image to be drawn.
+ * \param[in] mesh The mesh_image which contains nodes, links
+ * positions and the values of it.
+ *
+ */
template <typename I, typename P, typename V>
void
mesh(Image<I>& ima, const mesh_image<P, V>& mesh);
Index: trunk/milena/mln/level/fill.hh
===================================================================
--- trunk/milena/mln/level/fill.hh (revision 1499)
+++ trunk/milena/mln/level/fill.hh (revision 1500)
@@ -138,8 +138,7 @@
namespace generic
{
template <typename I>
- void fill_with_value(trait::image::speed::any, I& ima,
- const mln_value(I)& value)
+ void fill_with_value(I& ima, const mln_value(I)& value)
{
trace::entering("level::impl::generic::fill_with_value");
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-11-19 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Review logical subdirectory and add tests.
Update
* mln/logical/and.hh,
* mln/logical/and_not.hh,
* mln/logical/not.hh,
* mln/logical/or.hh: Add tracing, generic namespace, remove
specializations and check typo.
* mln/logical/and.spe.hh,
* mln/logical/and_not.spe.hh,
* mln/logical/not.spe.hh,
* mln/logical/or.spe.hh: New specializations for logical.
Tests
* tests/Makefile.am: Add logical subdirectory.
* tests/logical: New subdirectory for logical checking.
* tests/logical/Makefile.am: Add test to check.
* tests/logical/and.cc,
* tests/logical/and_not.cc,
* tests/logical/not.cc,
* tests/logical/or.cc: New tests for logical.
---
mln/logical/and.hh | 24 ++++++------
mln/logical/and.spe.hh | 87 ++++++++++++++++++++++++++++++++++++++++++++
mln/logical/and_not.hh | 24 ++++++------
mln/logical/and_not.spe.hh | 88 +++++++++++++++++++++++++++++++++++++++++++++
mln/logical/not.hh | 19 +++++----
mln/logical/not.spe.hh | 84 ++++++++++++++++++++++++++++++++++++++++++
mln/logical/or.hh | 21 ++++------
mln/logical/or.spe.hh | 86 +++++++++++++++++++++++++++++++++++++++++++
tests/Makefile.am | 1
tests/logical/Makefile.am | 16 ++++++++
tests/logical/and.cc | 65 +++++++++++++++++++++++++++++++++
tests/logical/and_not.cc | 64 ++++++++++++++++++++++++++++++++
tests/logical/not.cc | 58 +++++++++++++++++++++++++++++
tests/logical/or.cc | 65 +++++++++++++++++++++++++++++++++
14 files changed, 657 insertions(+), 45 deletions(-)
Index: trunk/milena/tests/Makefile.am
===================================================================
--- trunk/milena/tests/Makefile.am (revision 1498)
+++ trunk/milena/tests/Makefile.am (revision 1499)
@@ -5,6 +5,7 @@
SUBDIRS = norm \
level \
arith \
+ logical \
border
check_PROGRAMS = \
Index: trunk/milena/tests/logical/not.cc
===================================================================
--- trunk/milena/tests/logical/not.cc (revision 0)
+++ trunk/milena/tests/logical/not.cc (revision 1499)
@@ -0,0 +1,58 @@
+// 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.
+
+/*! \file tests/logical/not.cc
+ *
+ * \brief Tests on mln::logical::not.
+ */
+
+#include <mln/core/image2d.hh>
+#include <mln/logical/not.hh>
+#include <mln/level/compare.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ bool vs[3][3] = {
+ {1, 0, 1},
+ {0, 1, 0},
+ {1, 0, 1}
+ };
+
+ bool ws[3][3] = {
+ {0, 1, 0},
+ {1, 0, 1},
+ {0, 1, 0}
+ };
+
+ image2d<bool> ima (make::image2d(vs));
+ image2d<bool> ref (make::image2d(ws));
+
+ mln_assertion (logical::not_(ima) == ref);
+}
Index: trunk/milena/tests/logical/or.cc
===================================================================
--- trunk/milena/tests/logical/or.cc (revision 0)
+++ trunk/milena/tests/logical/or.cc (revision 1499)
@@ -0,0 +1,65 @@
+// 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.
+
+/*! \file tests/logical/or.cc
+ *
+ * \brief Tests on mln::logical::or.
+ */
+
+#include <mln/core/image2d.hh>
+#include <mln/logical/or.hh>
+#include <mln/level/compare.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ bool vs[3][3] = {
+ {1, 0, 1},
+ {0, 1, 0},
+ {1, 0, 1}
+ };
+
+ bool us[3][3] = {
+ {1, 1, 1},
+ {0, 1, 0},
+ {1, 1, 1}
+ };
+
+ bool ws[3][3] = {
+ {1, 1, 1},
+ {0, 1, 0},
+ {1, 1, 1}
+ };
+
+ image2d<bool> ima1 (make::image2d(vs));
+ image2d<bool> ima2 (make::image2d(us));
+ image2d<bool> ref (make::image2d(ws));
+
+ mln_assertion (logical::or_(ima1, ima2) == ref);
+}
Index: trunk/milena/tests/logical/and.cc
===================================================================
--- trunk/milena/tests/logical/and.cc (revision 0)
+++ trunk/milena/tests/logical/and.cc (revision 1499)
@@ -0,0 +1,65 @@
+// 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.
+
+/*! \file tests/logical/and.cc
+ *
+ * \brief Tests on mln::logical::and.
+ */
+
+#include <mln/core/image2d.hh>
+#include <mln/logical/and.hh>
+#include <mln/level/compare.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ bool vs[3][3] = {
+ {1, 0, 1},
+ {0, 1, 0},
+ {1, 0, 1}
+ };
+
+ bool us[3][3] = {
+ {1, 1, 1},
+ {0, 1, 0},
+ {1, 1, 1}
+ };
+
+ bool ws[3][3] = {
+ {1, 0, 1},
+ {0, 1, 0},
+ {1, 0, 1}
+ };
+
+ image2d<bool> ima1 (make::image2d(vs));
+ image2d<bool> ima2 (make::image2d(us));
+ image2d<bool> ref (make::image2d(ws));
+
+ mln_assertion (logical::and_(ima1, ima2) == ref);
+}
Index: trunk/milena/tests/logical/and_not.cc
===================================================================
--- trunk/milena/tests/logical/and_not.cc (revision 0)
+++ trunk/milena/tests/logical/and_not.cc (revision 1499)
@@ -0,0 +1,64 @@
+// 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.
+
+/*! \file tests/logical/and_not.cc
+ *
+ * \brief Tests on mln::logical::and_not.
+ */
+
+#include <mln/core/image2d.hh>
+#include <mln/logical/and_not.hh>
+#include <mln/level/compare.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ bool vs[3][3] = {
+ {1, 0, 1},
+ {0, 1, 0},
+ {1, 0, 1}
+ };
+
+ bool us[3][3] = {
+ {1, 1, 1},
+ {0, 1, 0},
+ {0, 1, 0}
+ };
+
+ bool ws[3][3] = {
+ {0, 0, 0},
+ {0, 0, 0},
+ {1, 0, 1}
+ };
+
+ image2d<bool> ima1 (make::image2d(vs));
+ image2d<bool> ima2 (make::image2d(us));
+ image2d<bool> ref (make::image2d(ws));
+ mln_assertion (logical::and_not(ima1, ima2) == ref);
+}
Index: trunk/milena/tests/logical/Makefile.am
===================================================================
--- trunk/milena/tests/logical/Makefile.am (revision 0)
+++ trunk/milena/tests/logical/Makefile.am (revision 1499)
@@ -0,0 +1,16 @@
+## Process this file through Automake to create Makefile.in -*- Makefile -*-
+
+include $(top_srcdir)/milena/tests/tests.mk
+
+check_PROGRAMS = \
+ and \
+ and_not \
+ not \
+ or
+
+and_SOURCES = and.cc
+and_not_SOURCES = and_not.cc
+not_SOURCES = not.cc
+or_SOURCES = or.cc
+
+TESTS = $(check_PROGRAMS)
Index: trunk/milena/mln/logical/and_not.hh
===================================================================
--- trunk/milena/mln/logical/and_not.hh (revision 1498)
+++ trunk/milena/mln/logical/and_not.hh (revision 1499)
@@ -37,6 +37,9 @@
# include <mln/core/concept/image.hh>
+// Specializations are in:
+# include <mln/logical/and_not.spe.hh>
+
namespace mln
{
@@ -76,24 +79,19 @@
namespace impl
{
+ namespace generic
+ {
template <typename L, typename R, typename O>
- void and_not_(trait::image::speed::any, const L& lhs,
- trait::image::speed::any, const R& rhs, O& output)
+ void and_not_(const L& lhs, const R& rhs, O& output)
{
+ trace::entering("logical::impl::generic::and_not_");
+
mln_piter(L) p(lhs.domain());
for_all(p)
output(p) = lhs(p) && ! rhs(p);
- }
- template <typename L, typename R, typename O>
- void and_not_(trait::image::speed::fastest, const L& lhs,
- trait::image::speed::fastest, const R& rhs, O& output)
- {
- mln_pixter(const L) lp(lhs);
- mln_pixter(const R) rp(rhs);
- mln_pixter(O) op(output);
- for_all_3(lp, rp, op)
- op.val() = lp.val() && ! rp.val();
+ trace::exiting("logical::impl::generic::and_not_");
+ }
}
} // end of namespace mln::logical::impl
@@ -105,6 +103,7 @@
mln_concrete(L) and_not(const Image<L>& lhs, const Image<R>& rhs)
{
trace::entering("logical::and_not");
+
mln_precondition(exact(rhs).domain() == exact(lhs).domain());
mln_concrete(L) output;
@@ -120,6 +119,7 @@
void and_not_inplace(Image<L>& lhs, const Image<R>& rhs)
{
trace::entering("logical::and_not_inplace");
+
mln_precondition(exact(rhs).domain() >= exact(lhs).domain());
impl::and_not_(mln_trait_image_speed(L)(), exact(lhs),
Index: trunk/milena/mln/logical/and.hh
===================================================================
--- trunk/milena/mln/logical/and.hh (revision 1498)
+++ trunk/milena/mln/logical/and.hh (revision 1499)
@@ -37,6 +37,9 @@
# include <mln/core/concept/image.hh>
+// Specializations are in:
+# include <mln/logical/and.spe.hh>
+
namespace mln
{
@@ -76,26 +79,23 @@
namespace impl
{
+ namespace generic
+ {
+
template <typename L, typename R, typename O>
- void and__(trait::image::speed::any, const L& lhs,
- trait::image::speed::any, const R& rhs, O& output)
+ void and__(const L& lhs, const R& rhs, O& output)
{
+ trace::entering("logical::impl::generic::and__");
+
mln_piter(L) p(lhs.domain());
for_all(p)
output(p) = lhs(p) && rhs(p);
- }
- template <typename L, typename R, typename O>
- void and__(trait::image::speed::fastest, const L& lhs,
- trait::image::speed::fastest, const R& rhs, O& output)
- {
- mln_pixter(const L) lp(lhs);
- mln_pixter(const R) rp(rhs);
- mln_pixter(O) op(output);
- for_all_3(lp, rp, op)
- op.val() = lp.val() && rp.val();
+ trace::exiting("logical::impl::generic::and__");
}
+ } // end of namespace mln::logical::impl::generic
+
} // end of namespace mln::logical::impl
Index: trunk/milena/mln/logical/or.spe.hh
===================================================================
--- trunk/milena/mln/logical/or.spe.hh (revision 0)
+++ trunk/milena/mln/logical/or.spe.hh (revision 1499)
@@ -0,0 +1,86 @@
+// 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_LOGICAL_OR_SPE_HH
+# define MLN_LOGICAL_OR_SPE_HH
+
+/*! \file mln/logical/or.spe.hh
+ *
+ * \brief Specializations for mln::logical::or.
+ *
+ */
+
+# include <mln/core/concept/image.hh>
+
+# ifndef MLN_INCLUDE_ONLY
+
+namespace mln
+{
+
+ namespace logical
+ {
+
+ namespace impl
+ {
+
+ namespace generic
+ {
+ template <typename L, typename R, typename O>
+ void or__(const L& lhs, const R& rhs, O& output);
+ }
+
+ template <typename L, typename R, typename O>
+ void or__(trait::image::speed::any, const L& lhs,
+ trait::image::speed::any, const R& rhs, O& output)
+ {
+ generic::or__(lhs, rhs, output);
+ }
+
+ template <typename L, typename R, typename O>
+ void or__(trait::image::speed::fastest, const L& lhs,
+ trait::image::speed::fastest, const R& rhs, O& output)
+ {
+ trace::entering("logical::impl::or__");
+
+ mln_pixter(const L) lp(lhs);
+ mln_pixter(const R) rp(rhs);
+ mln_pixter(O) op(output);
+ for_all_3(lp, rp, op)
+ op.val() = lp.val() || rp.val();
+
+ trace::entering("logical::impl::or__");
+ }
+
+ } // end of namespace mln::logical::impl
+
+ } // end of namespace mln::logical
+
+} // end of namespace mln
+
+# endif // ! MLN_INCLUDE_ONLY
+
+#endif // ! MLN_LOGICAL_OR_SPE_HH
Index: trunk/milena/mln/logical/not.spe.hh
===================================================================
--- trunk/milena/mln/logical/not.spe.hh (revision 0)
+++ trunk/milena/mln/logical/not.spe.hh (revision 1499)
@@ -0,0 +1,84 @@
+// 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_LOGICAL_NOT_SPE_HH
+# define MLN_LOGICAL_NOT_SPE_HH
+
+/*! \file mln/logical/not.spe.hh
+ *
+ * \brief Specializations for mln::logical::not.
+ *
+ */
+
+# include <mln/core/concept/image.hh>
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+namespace mln
+{
+
+ namespace logical
+ {
+
+ namespace impl
+ {
+
+ namespace generic
+ {
+ template <typename I, typename O>
+ void not__(const I& input, O& output);
+ }
+
+ template <typename I, typename O>
+ void not__(trait::image::speed::any, const I& input, O& output)
+ {
+ generic::not__(input, output);
+ }
+
+ template <typename I, typename O>
+ void not__(trait::image::speed::fastest, const I& input, O& output)
+ {
+ trace::entering("logical::impl::not__");
+
+ mln_pixter(const I) ip(input);
+ mln_pixter(O) op(output);
+ for_all_2(ip, op)
+ op.val() = ! ip.val();
+
+ trace::exiting("logical::impl::not__");
+ }
+
+ } // end of namespace mln::logical::impl
+
+ } // end of namespace mln::logical
+
+} // end of namespace mln
+
+# endif // ! MLN_INCLUDE_ONLY
+
+#endif // ! MLN_LOGICAL_NOT_HH
Index: trunk/milena/mln/logical/and_not.spe.hh
===================================================================
--- trunk/milena/mln/logical/and_not.spe.hh (revision 0)
+++ trunk/milena/mln/logical/and_not.spe.hh (revision 1499)
@@ -0,0 +1,88 @@
+// 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_LOGICAL_AND_NOT_SPE_HH
+# define MLN_LOGICAL_AND_NOT_SPE_HH
+
+/*! \file mln/logical/and_not.spe.hh
+ *
+ * \brief Specializations for mln::logical::and_not.
+ *
+ */
+
+# include <mln/core/concept/image.hh>
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+namespace mln
+{
+
+ namespace logical
+ {
+
+ namespace impl
+ {
+
+ namespace generic
+ {
+ template <typename L, typename R, typename O>
+ void and_not_(const L& lhs, const R& rhs, O& output);
+ }
+
+
+ template <typename L, typename R, typename O>
+ void and_not_(trait::image::speed::any, const L& lhs,
+ trait::image::speed::any, const R& rhs, O& output)
+ {
+ generic::and_not_(lhs, rhs, output);
+ }
+
+ template <typename L, typename R, typename O>
+ void and_not_(trait::image::speed::fastest, const L& lhs,
+ trait::image::speed::fastest, const R& rhs, O& output)
+ {
+ trace::entering("logical::impl::and_not_");
+
+ mln_pixter(const L) lp(lhs);
+ mln_pixter(const R) rp(rhs);
+ mln_pixter(O) op(output);
+ for_all_3(lp, rp, op)
+ op.val() = lp.val() && ! rp.val();
+
+ trace::exiting("logical::impl::and_not_");
+ }
+
+ } // end of namespace mln::logical::impl
+
+ } // end of namespace mln::logical
+
+} // end of namespace mln
+
+# endif // ! MLN_INCLUDE_ONLY
+
+#endif // ! MLN_LOGICAL_AND_NOT_SPE_HH
Index: trunk/milena/mln/logical/and.spe.hh
===================================================================
--- trunk/milena/mln/logical/and.spe.hh (revision 0)
+++ trunk/milena/mln/logical/and.spe.hh (revision 1499)
@@ -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_LOGICAL_AND_SPE_HH
+# define MLN_LOGICAL_AND_SPE_HH
+
+/*! \file mln/logical/and.spe.hh
+ *
+ * \brief Specializations for mln::logical::and.
+ *
+ */
+
+# include <mln/core/concept/image.hh>
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+namespace mln
+{
+
+ namespace logical
+ {
+
+ namespace impl
+ {
+
+ namespace generic
+ {
+ template <typename L, typename R, typename O>
+ void and__(const L& lhs, const R& rhs, O& output);
+ }
+
+ template <typename L, typename R, typename O>
+ void and__(trait::image::speed::any, const L& lhs,
+ trait::image::speed::any, const R& rhs, O& output)
+ {
+ generic::and__(lhs, rhs, output);
+ }
+
+ template <typename L, typename R, typename O>
+ void and__(trait::image::speed::fastest, const L& lhs,
+ trait::image::speed::fastest, const R& rhs, O& output)
+ {
+ trace::entering("logical::impl::and__");
+
+ mln_pixter(const L) lp(lhs);
+ mln_pixter(const R) rp(rhs);
+ mln_pixter(O) op(output);
+ for_all_3(lp, rp, op)
+ op.val() = lp.val() && rp.val();
+
+ trace::exiting("logical::impl::and__");
+ }
+
+ } // end of namespace mln::logical::impl
+
+ } // end of namespace mln::logical
+
+} // end of namespace mln
+
+# endif // ! MLN_INCLUDE_ONLY
+
+#endif // ! MLN_LOGICAL_AND_SPE_HH
Index: trunk/milena/mln/logical/not.hh
===================================================================
--- trunk/milena/mln/logical/not.hh (revision 1498)
+++ trunk/milena/mln/logical/not.hh (revision 1499)
@@ -37,6 +37,9 @@
# include <mln/core/concept/image.hh>
+// Specializations are in:
+# include <mln/logical/not.spe.hh>
+
namespace mln
{
@@ -72,21 +75,19 @@
namespace impl
{
+ namespace generic
+ {
template <typename I, typename O>
- void not__(trait::image::speed::any, const I& input, O& output)
+ void not__(const I& input, O& output)
{
+ trace::entering("logical::impl::generic::not__");
+
mln_piter(I) p(input.domain());
for_all(p)
output(p) = ! input(p);
- }
- template <typename I, typename O>
- void not__(trait::image::speed::fastest, const I& input, O& output)
- {
- mln_pixter(const I) ip(input);
- mln_pixter(O) op(output);
- for_all_2(ip, op)
- op.val() = ! ip.val();
+ trace::exiting("logical::impl::generic::not__");
+ }
}
} // end of namespace mln::logical::impl
Index: trunk/milena/mln/logical/or.hh
===================================================================
--- trunk/milena/mln/logical/or.hh (revision 1498)
+++ trunk/milena/mln/logical/or.hh (revision 1499)
@@ -37,6 +37,8 @@
# include <mln/core/concept/image.hh>
+// Specializations are in:
+# include <mln/logical/or.spe.hh>
namespace mln
{
@@ -76,24 +78,19 @@
namespace impl
{
+ namespace generic
+ {
template <typename L, typename R, typename O>
- void or__(trait::image::speed::any, const L& lhs,
- trait::image::speed::any, const R& rhs, O& output)
+ void or__(const L& lhs, const R& rhs, O& output)
{
+ trace::entering("logical::impl::generic::or__");
+
mln_piter(L) p(lhs.domain());
for_all(p)
output(p) = lhs(p) || rhs(p);
- }
- template <typename L, typename R, typename O>
- void or__(trait::image::speed::fastest, const L& lhs,
- trait::image::speed::fastest, const R& rhs, O& output)
- {
- mln_pixter(const L) lp(lhs);
- mln_pixter(const R) rp(rhs);
- mln_pixter(O) op(output);
- for_all_3(lp, rp, op)
- op.val() = lp.val() || rp.val();
+ trace::exiting("logical::impl::generic::or__");
+ }
}
} // end of namespace mln::logical::impl
1
0