Olena-patches
Threads by month
- ----- 2025 -----
- 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
October 2012
- 9 participants
- 221 discussions
* mln/inner_border/extend.hh,
* mln/inner_border/extend_and_fill.hh,
* mln/inner_border/extend_and_fill_with_inner_border.hh,
* mln/inner_border/fill.hh,
* mln/inner_border/internal/on_frontiere.hh: New.
---
milena/ChangeLog | 10 ++
.../mln/{make/pixel.hh => inner_border/extend.hh} | 55 ++++++----
.../extend_and_fill.hh} | 68 ++++++------
.../extend_and_fill_with_inner_border.hh | 99 +++++++++++++++++
milena/mln/{debug/iota.hh => inner_border/fill.hh} | 86 ++++++---------
milena/mln/inner_border/internal/on_frontiere.hh | 113 ++++++++++++++++++++
6 files changed, 323 insertions(+), 108 deletions(-)
copy milena/mln/{make/pixel.hh => inner_border/extend.hh} (55%)
copy milena/mln/{subsampling/gaussian_subsampling.hh => inner_border/extend_and_fill.hh} (52%)
create mode 100644 milena/mln/inner_border/extend_and_fill_with_inner_border.hh
copy milena/mln/{debug/iota.hh => inner_border/fill.hh} (56%)
create mode 100644 milena/mln/inner_border/internal/on_frontiere.hh
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 2413cb2..1bfdd14 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,13 @@
+2012-10-24 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Add inner_border routines.
+
+ * mln/inner_border/extend.hh,
+ * mln/inner_border/extend_and_fill.hh,
+ * mln/inner_border/extend_and_fill_with_inner_border.hh,
+ * mln/inner_border/fill.hh,
+ * mln/inner_border/internal/on_frontiere.hh: New.
+
2012-10-23 Guillaume Lazzara <z(a)lrde.epita.fr>
Add data::compute_in_inner_border.
diff --git a/milena/mln/make/pixel.hh b/milena/mln/inner_border/extend.hh
similarity index 55%
copy from milena/mln/make/pixel.hh
copy to milena/mln/inner_border/extend.hh
index 9f9f776..d5172a2 100644
--- a/milena/mln/make/pixel.hh
+++ b/milena/mln/inner_border/extend.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -23,54 +23,65 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef MLN_MAKE_PIXEL_HH
-# define MLN_MAKE_PIXEL_HH
+#ifndef MLN_INNER_BORDER_EXTEND_HH
+# define MLN_INNER_BORDER_EXTEND_HH
/// \file
-/// \brief Routine to construct an mln::pixel.
+///
+/// \brief Extend the inner border of an image.
-# include <mln/core/concept/image.hh>
-# include <mln/core/pixel.hh>
+# include <mln/core/image/image2d.hh>
+# include <mln/data/paste.hh>
namespace mln
{
- namespace make
+ namespace inner_border
{
- /// Create a mln::pixel from a constant image \p ima and a point \p p.
+ /// \brief Extend the inner border of an image.
template <typename I>
- mln::pixel<const I> pixel(const Image<I>& ima, const mln_psite(I)& p);
+ mln_concrete(I)
+ extend(const Image<I>& input, unsigned inner_border_size);
- /// Create a mln::pixel from a mutable image \p ima and a point \p p.
+ /// \overload
+ /// inner_border_size is set to 1.
template <typename I>
- mln::pixel<I> pixel(Image<I>& ima, const mln_psite(I)& p);
+ mln_concrete(I)
+ extend(const Image<I>& input);
# ifndef MLN_INCLUDE_ONLY
template <typename I>
- inline
- mln::pixel<const I> pixel(const Image<I>& ima, const mln_psite(I)& p)
+ mln_concrete(I)
+ extend(const Image<I>& input_, unsigned inner_border_size)
{
- mln::pixel<const I> tmp(exact(ima), p);
- return tmp;
+ trace::entering("mln::inner_border::extend");
+ mln_precondition(exact(input).is_valid());
+ const I& input = exact(input_);
+
+ box2d b = input.domain(), bb = b;
+ bb.enlarge(inner_border_size);
+ mln_concrete(I) output(bb);
+ data::paste(input, output);
+
+ trace::exiting("mln::inner_border::extend");
+ return output;
}
template <typename I>
- inline
- mln::pixel<I> pixel(Image<I>& ima, const mln_psite(I)& p)
+ mln_concrete(I)
+ extend(const Image<I>& input)
{
- mln::pixel<I> tmp(exact(ima), p);
- return tmp;
+ return extend(input, 1);
}
# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace mln::make
+ } // end of namespace mln::inner_border
} // end of namespace mln
-
-#endif // ! MLN_MAKE_PIXEL_HH
+#endif // ! MLN_INNER_BORDER_EXTEND_HH
diff --git a/milena/mln/subsampling/gaussian_subsampling.hh b/milena/mln/inner_border/extend_and_fill.hh
similarity index 52%
copy from milena/mln/subsampling/gaussian_subsampling.hh
copy to milena/mln/inner_border/extend_and_fill.hh
index 8855b9c..b2804fc 100644
--- a/milena/mln/subsampling/gaussian_subsampling.hh
+++ b/milena/mln/inner_border/extend_and_fill.hh
@@ -1,5 +1,4 @@
-// Copyright (C) 2008, 2009, 2011 EPITA Research and Development
-// Laboratory (LRDE)
+// Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -24,67 +23,64 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef MLN_SUBSAMPLING_GAUSSIAN_SUBSAMPLING_HH
-# define MLN_SUBSAMPLING_GAUSSIAN_SUBSAMPLING_HH
+#ifndef MLN_INNER_BORDER_EXTEND_AND_FILL_HH
+# define MLN_INNER_BORDER_EXTEND_AND_FILL_HH
/// \file
///
-/// Produce a subsampled image
-
-# include <mln/geom/ncols.hh>
-# include <mln/geom/nrows.hh>
-
-
-# include <mln/linear/gaussian.hh>
-# include <mln/subsampling/subsampling.hh>
+/// \brief Extend the inner border of an image.
+# include <mln/inner_border/extend.hh>
+# include <mln/inner_border/fill.hh>
namespace mln
{
- namespace subsampling
+ namespace inner_border
{
- /// Gaussian subsampling FIXME : doxy
+ /// \brief Extend the inner border of an image and fill it with a
+ /// value.
template <typename I>
- inline
mln_concrete(I)
- gaussian_subsampling(const Image<I>& input, float sigma,
- const mln_dpsite(I)& first_p,
- const mln_deduce(I, site, coord)& gap);
+ extend_and_fill(const Image<I>& input, unsigned inner_border_size,
+ const mln_value(I)& value);
-# ifndef MLN_INCLUDE_ONLY
+ /// \overload
+ /// inner_border_size is set to 1.
+ template <typename I>
+ mln_concrete(I)
+ extend_and_fill(const Image<I>& input, const mln_value(I)& value);
+# ifndef MLN_INCLUDE_ONLY
template <typename I>
- inline
mln_concrete(I)
- gaussian_subsampling(const Image<I>& input, float sigma,
- const mln_dpsite(I)& first_p,
- const mln_deduce(I, site, coord)& gap)
+ extend_and_fill(const Image<I>& input, unsigned inner_border_size,
+ const mln_value(I)& value)
{
- trace::entering("subsampling::gaussian_subsampling");
+ trace::entering("mln::inner_border::extend_and_fill");
mln_precondition(exact(input).is_valid());
- (void) sigma;
-
- mln_concrete(I) temp(exact(input).domain());
- mln_concrete(I) output(geom::nrows(input) / gap,
- geom::ncols(input) / gap); //FIXME : image2d only
+ mln_concrete(I) output = inner_border::extend(input, inner_border_size);
+ inner_border::fill(output, inner_border_size, value);
- linear::gaussian(input, 0.1, temp);
- output = impl::subsampling_(exact(temp), first_p, gap);
-
- trace::exiting("subsampling::gaussian_subsampling");
+ trace::exiting("mln::inner_border::extend_and_fill");
return output;
}
+ template <typename I>
+ mln_concrete(I)
+ extend_and_fill(const Image<I>& input, const mln_value(I)& value)
+ {
+ return extend_and_fill(input, 1, value);
+ }
+
# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace mln::subsampling
+ } // end of namespace mln::inner_border
} // end of namespace mln
-
-#endif // ! MLN_SUBSAMPLING_GAUSSIAN_SUBSAMPLING_HH
+#endif // ! MLN_INNER_BORDER_EXTEND_AND_FILL_HH
diff --git a/milena/mln/inner_border/extend_and_fill_with_inner_border.hh b/milena/mln/inner_border/extend_and_fill_with_inner_border.hh
new file mode 100644
index 0000000..8c4db27
--- /dev/null
+++ b/milena/mln/inner_border/extend_and_fill_with_inner_border.hh
@@ -0,0 +1,99 @@
+// Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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_INNER_BORDER_EXTEND_AND_FILL_WITH_INNER_BORDER_HH
+# define MLN_INNER_BORDER_EXTEND_AND_FILL_WITH_INNER_BORDER_HH
+
+/// \file
+///
+/// \brief Extend the inner border of an image.
+
+# include <mln/data/compute_in_inner_border.hh>
+# include <mln/inner_border/extend.hh>
+# include <mln/inner_border/fill.hh>
+
+
+namespace mln
+{
+
+ namespace inner_border
+ {
+
+ /// \brief Extend the inner border of an image and fill it with a
+ /// value.
+ template <typename I, typename A>
+ mln_concrete(I)
+ extend_and_fill_with_inner_border(const Image<I>& input,
+ unsigned old_inner_border_size,
+ const Accumulator<A>& accu,
+ unsigned inner_border_size_for_accu);
+
+ /// \overload
+ /// old_inner_border_size and inner_border_size_for_accu are set to 1.
+ template <typename I, typename A>
+ mln_concrete(I)
+ extend_and_fill_with_inner_border(const Image<I>& input,
+ const Accumulator<A>& accu);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I, typename A>
+ mln_concrete(I)
+ extend_and_fill_with_inner_border(const Image<I>& input,
+ unsigned inner_border_size,
+ const Accumulator<A>& accu,
+ unsigned inner_border_size_for_accu)
+ {
+ trace::entering("mln::inner_border::extend_and_fill_with_inner_border");
+// mlc_converts_to(mln_result(A),mln_value(I))::check();
+ mln_precondition(exact(input).is_valid());
+
+ mln_result(A)
+ v = data::compute_in_inner_border(accu,
+ input, inner_border_size_for_accu);
+ mln_concrete(I) output = inner_border::extend(input, inner_border_size);
+ inner_border::fill(output, inner_border_size, static_cast<mln_value(I)>(v));
+
+ trace::exiting("mln::inner_border::extend_and_fill_with_inner_border");
+ return output;
+ }
+
+
+ template <typename I, typename A>
+ mln_concrete(I)
+ extend_and_fill_with_inner_border(const Image<I>& input,
+ const Accumulator<A>& accu)
+ {
+ return extend_and_fill_with_inner_border(input, 1, accu, 1);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::inner_border
+
+} // end of namespace mln
+
+#endif // ! MLN_INNER_BORDER_EXTEND_AND_FILL_WITH_INNER_BORDER_HH
diff --git a/milena/mln/debug/iota.hh b/milena/mln/inner_border/fill.hh
similarity index 56%
copy from milena/mln/debug/iota.hh
copy to milena/mln/inner_border/fill.hh
index 3e569b9..ccee289 100644
--- a/milena/mln/debug/iota.hh
+++ b/milena/mln/inner_border/fill.hh
@@ -1,5 +1,4 @@
-// Copyright (C) 2007, 2008, 2009, 2011 EPITA Research and Development
-// Laboratory (LRDE)
+// Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -24,81 +23,68 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef MLN_DEBUG_IOTA_HH
-# define MLN_DEBUG_IOTA_HH
+#ifndef MLN_INNER_BORDER_FILL_HH
+# define MLN_INNER_BORDER_FILL_HH
-/*! \file
- *
- * \brief Fill an image with successive values.
- */
-
-# include <mln/core/concept/image.hh>
-
-// Specializations are in:
-# include <mln/debug/iota.spe.hh>
+/// \file
+///
+/// \brief Fill the inner border of an image.
+# include <mln/core/image/image2d.hh>
+# include <mln/data/paste.hh>
+# include <mln/inner_border/internal/on_frontiere.hh>
namespace mln
{
- namespace debug
+ namespace inner_border
{
- /*! Fill the image \p input with successive values.
- *
- * \param[in,out] input The image in which values are
- * assigned.
- */
+ /// \brief Fill the inner border of an image.
template <typename I>
- void iota(Image<I>& input, unsigned base_index);
-
-
-# ifndef MLN_INCLUDE_ONLY
-
- namespace impl
- {
+ void
+ fill(Image<I>& input, unsigned border_size,
+ const mln_value(I)& value);
- template <typename I>
- inline
- void
- iota(trait::image::speed::any, I& input, unsigned base_index)
- {
- unsigned i = base_index;
- mln_piter(I) p(input.domain());
- for_all(p)
- input(p) = ++i % mln_max(mln_value(I));
- }
+ /// \overload
+ /// The border_size is set to 1.
+ template <typename I>
+ void
+ fill(Image<I>& input, const mln_value(I)& value);
- } // end of namespace mln::debug::impl
+# ifndef MLN_INCLUDE_ONLY
template <typename I>
- inline
void
- iota(Image<I>& input)
+ fill(Image<I>& input_, unsigned border_size,
+ const mln_value(I)& value)
{
- iota(input, 0);
- }
+ trace::entering("mln::inner_border::fill");
+ mln_precondition(exact(input).is_valid());
+ I& input = exact(input_);
+ mln_piter(I) p(input.domain());
+ for_all(p)
+ if (internal::on_frontiere(p, input.domain(), border_size))
+ input(p) = value;
+
+ trace::exiting("mln::inner_border::fill");
+ }
template <typename I>
- inline
void
- iota(Image<I>& input, unsigned base_index)
+ fill(Image<I>& input, const mln_value(I)& value)
{
- trace::entering("debug::iota");
- mln_precondition(exact(input).is_valid());
- impl::iota(mln_trait_image_speed(I)(), exact(input), base_index);
- trace::exiting("debug::iota");
+ fill(input, 1, value);
}
-
# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace mln::debug
+ } // end of namespace mln::inner_border
} // end of namespace mln
+#endif // ! MLN_INNER_BORDER_FILL_HH
-#endif // ! MLN_DEBUG_IOTA_HH
diff --git a/milena/mln/inner_border/internal/on_frontiere.hh b/milena/mln/inner_border/internal/on_frontiere.hh
new file mode 100644
index 0000000..49430a8
--- /dev/null
+++ b/milena/mln/inner_border/internal/on_frontiere.hh
@@ -0,0 +1,113 @@
+// Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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_INNER_BORDER_ON_FRONTIERE_HH
+# define MLN_INNER_BORDER_ON_FRONTIERE_HH
+
+/// \file
+///
+/// \brief Returns true if a site is included in the inner border of
+/// the image.
+
+# include <mln/core/image/image2d.hh>
+# include <mln/data/paste.hh>
+
+
+namespace mln
+{
+
+ namespace inner_border
+ {
+
+ namespace internal
+ {
+
+ /// \brief Returns true if a site is included in the inner
+ /// border of the image.
+ template <typename P>
+ bool
+ on_frontiere(const mln_site(box<P>)& p, const box<P>& b,
+ def::coord inner_border_size);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ // Implementation
+
+ inline
+ bool
+ on_frontiere_2d(const point2d& p, const box2d& b,
+ def::coord inner_border_size)
+ {
+ for (int d = 0; d < 2; ++d)
+ if ((p[d] >= b.pmin()[d]
+ && p[d] < (b.pmin()[d] + inner_border_size))
+ ||
+ (p[d] <= b.pmax()[d]
+ && p[d] > b.pmax()[d] - inner_border_size))
+ return true;
+ return false;
+ }
+
+ // Dispatch
+
+ inline
+ bool
+ on_frontiere_dispatch(const point2d& p, const box2d& b,
+ def::coord inner_border_size)
+ {
+ return on_frontiere_2d(p, b, inner_border_size);
+ }
+
+ template <typename P>
+ bool
+ on_frontiere_dispatch(const mln_site(box<P>)& p, const box<P>& b,
+ def::coord inner_border_size)
+ {
+ mlc_abort(P)::check(); // Not implemented.
+ return false;
+ }
+
+
+ // Facade
+
+ template <typename P>
+ bool
+ on_frontiere(const mln_site(box<P>)& p, const box<P>& b,
+ def::coord inner_border_size)
+ {
+ return on_frontiere_dispatch(p, b, inner_border_size);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::inner_border::internal
+
+ } // end of namespace mln::inner_border
+
+} // end of namespace mln
+
+#endif // ! MLN_INNER_BORDER_ON_FRONTIERE_HH
+
--
1.7.2.5
1
0

[Olena] #257: Overhaul and supplement Milena's hierarchy of namespaces and directories
by Olena Trac 24 Oct '12
by Olena Trac 24 Oct '12
24 Oct '12
#257: Overhaul and supplement Milena's hierarchy of namespaces and directories
----------------------+-----------------------------------------------------
Reporter: levill_r | Owner: Olena Team
Type: proposal | Status: new
Priority: major | Milestone:
Component: Milena | Version: 2.0
Keywords: indexing |
----------------------+-----------------------------------------------------
Following a discussion started by Jonathan on the organization of Milena's
contents (resp. files) in a tree of namespaces (resp. directories), I
suggest we try to rethink and improve this classification.
But more importantly, we should think about the concepts behind Milena
that can may come in handy for users of the library. We shall then reify
these concepts as keywords or tags, and use them to annotate the
documentation (e.g., produce one index or more, possibly organized in one
or several hierarchies), in order to provide users with an efficient tool
to search the library.
--
Ticket URL: <https://trac.lrde.epita.fr/olena/ticket/257>
Olena <http://olena.lrde.epita.fr>
Olena, a software platform dedicated to image processing.
1
0
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Olena, a generic and efficient image processing platform".
The branch exp/khalimsky has been updated
via fd94360102b88b25a7f6bbed8046fc329871c6b3 (commit)
from e4e04ba3c3fb549d9ad8778ac897c823e29b38d3 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
fd94360 Add data::compute_in_inner_border.
-----------------------------------------------------------------------
Summary of changes:
milena/ChangeLog | 9 +
milena/mln/data/compute_in_inner_border.hh | 184 ++++++++++++++++++++
milena/tests/data/Makefile.am | 2 +
.../compute_in_inner_border.cc} | 28 ++--
4 files changed, 211 insertions(+), 12 deletions(-)
create mode 100644 milena/mln/data/compute_in_inner_border.hh
copy milena/tests/{core/image/vmorph/fun_image.cc => data/compute_in_inner_border.cc} (75%)
hooks/post-receive
--
Olena, a generic and efficient image processing platform
1
0

23 Oct '12
* mln/data/compute_in_inner_border.hh,
* tests/data/compute_in_inner_border.cc: New.
* tests/data/Makefile.am: New target.
---
milena/ChangeLog | 9 +
milena/mln/data/compute_in_inner_border.hh | 184 ++++++++++++++++++++
milena/tests/data/Makefile.am | 2 +
.../compute_in_inner_border.cc} | 28 ++--
4 files changed, 211 insertions(+), 12 deletions(-)
create mode 100644 milena/mln/data/compute_in_inner_border.hh
copy milena/tests/{core/image/vmorph/fun_image.cc => data/compute_in_inner_border.cc} (75%)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 5b58c66..2413cb2 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,14 @@
2012-10-23 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Add data::compute_in_inner_border.
+
+ * mln/data/compute_in_inner_border.hh,
+ * tests/data/compute_in_inner_border.cc: New.
+
+ * tests/data/Makefile.am: New target.
+
+2012-10-23 Guillaume Lazzara <z(a)lrde.epita.fr>
+
* mln/world/kn/safe_cast.hh: Add more conversions.
2012-10-23 Guillaume Lazzara <z(a)lrde.epita.fr>
diff --git a/milena/mln/data/compute_in_inner_border.hh b/milena/mln/data/compute_in_inner_border.hh
new file mode 100644
index 0000000..20e8a37
--- /dev/null
+++ b/milena/mln/data/compute_in_inner_border.hh
@@ -0,0 +1,184 @@
+// Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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_DATA_COMPUTE_IN_INNER_BORDER_HH
+# define MLN_DATA_COMPUTE_IN_INNER_BORDER_HH
+
+/// \file
+///
+/// Compute an accumulator onto the inner border pixel values.
+
+# include <mln/core/concept/image.hh>
+# include <mln/core/concept/accumulator.hh>
+# include <mln/geom/nrows.hh>
+# include <mln/geom/ncols.hh>
+
+namespace mln
+{
+
+ namespace data
+ {
+
+ /// Compute an accumulator onto the inner border pixel values of
+ /// the image \p input. Be ware that the given accumulator won't
+ /// be modified and won't store any result.
+ ///
+ /// \param[in] a An accumulator.
+ /// \param[in] input The input image.
+ /// \param[in] inner_border_thickness The inner border thickness
+ /// considered.
+ /// \return The accumulator result.
+ ///
+ /// It fully relies on data::update.
+ //
+ template <typename A, typename I>
+ mln_result(A)
+ compute_in_inner_border(const Accumulator<A>& a, const Image<I>& input,
+ unsigned inner_border_thickness);
+
+
+ /// Compute an accumulator onto the inner border pixel values of
+ /// the image \p input.
+ ///
+ /// \param[in, out] a An accumulator.
+ /// \param[in] input The input image.
+ /// \param[in] inner_border_thickness The inner border thickness
+ /// considered.
+ /// \return The accumulator result.
+ ///
+ /// It fully relies on data::update.
+ //
+ template <typename A, typename I>
+ mln_result(A)
+ compute_in_inner_border(Accumulator<A>& a, const Image<I>& input,
+ unsigned inner_border_thickness);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ template <typename A, typename I>
+ mln_result(A)
+ compute_in_inner_border(const Accumulator<A>& a_, const Image<I>& input,
+ unsigned inner_border_thickness)
+ {
+ (void) a_;
+ A a;
+ return compute_in_inner_border(a, input, inner_border_thickness);
+ }
+
+
+ template <typename A, typename I>
+ mln_result(A)
+ compute_in_inner_border(Accumulator<A>& a_, const Image<I>& input_,
+ unsigned inner_border_thickness)
+ {
+ trace::entering("mln::data::compute_in_inner_border");
+ mln_precondition(exact(input_).is_valid());
+ mln_precondition(inner_border_thickness > 0);
+ mln_precondition(geom::nrows(input_) >= inner_border_thickness);
+ mln_precondition(geom::ncols(input_) >= inner_border_thickness);
+
+ A a = exact(a_);
+ const I& input = exact(input_);
+
+ a.init();
+
+ unsigned inner_border_thickness_1 = inner_border_thickness - 1;
+ unsigned nrows_1 = geom::nrows(input) - 1;
+ unsigned ncols_1 = geom::ncols(input) - 1;
+
+ typedef mln_box(I) B;
+
+ /*
+ .--------------------.
+ | b_top |<------ Image domain
+ |--------------------|
+ | | | |
+ |b| |b|
+ | | | |
+ |l| |r|
+ |e| |i|
+ |f| |g|
+ |t| |h|
+ | | |t|
+ |--------------------|
+ | b_bot |
+ .--------------------.
+
+ */
+ B b_top = B(input.domain().pmin(),
+ input.domain().pmin()
+ + inner_border_thickness_1 * down
+ + ncols_1 * right);
+ mln_piter(I) p_top(b_top);
+
+ B b_bot = B(input.domain().pmax()
+ + inner_border_thickness_1 * up
+ + ncols_1 * left,
+ input.domain().pmax());
+ mln_piter(I) p_bot(b_bot);
+
+ B b_left = B(input.domain().pmin()
+ + inner_border_thickness * down,
+ input.domain().pmin()
+ + inner_border_thickness_1 * right
+ + (nrows_1 - inner_border_thickness) * down);
+ mln_piter(I) p_left(b_left);
+
+ B b_right = B(input.domain().pmax()
+ + inner_border_thickness_1 * left
+ + (nrows_1 - inner_border_thickness) * up,
+ input.domain().pmax()
+ + inner_border_thickness * up);
+ mln_piter(I) p_right(b_right);
+
+ mln_assertion(b_right.nsites() == b_left.nsites());
+ mln_assertion(b_top.nsites() == b_bot.nsites());
+
+ for_all_2(p_top, p_bot)
+ {
+ a.take(input(p_top));
+ a.take(input(p_bot));
+ }
+
+ for_all_2(p_left, p_right)
+ {
+ a.take(input(p_left));
+ a.take(input(p_right));
+ }
+
+ trace::exiting("mln::data::compute_in_inner_border");
+ return a;
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::data
+
+} // end of namespace mln
+
+#endif // ! MLN_DATA_COMPUTE_IN_INNER_BORDER_HH
diff --git a/milena/tests/data/Makefile.am b/milena/tests/data/Makefile.am
index 4b04dfb..38eaa30 100644
--- a/milena/tests/data/Makefile.am
+++ b/milena/tests/data/Makefile.am
@@ -24,6 +24,7 @@ check_PROGRAMS = \
compare \
compute \
compute_in_window \
+ compute_in_inner_border \
convert \
fill \
fill_with_image \
@@ -47,6 +48,7 @@ apply_SOURCES = apply.cc
compare_SOURCES = compare.cc
compute_SOURCES = compute.cc
compute_in_window_SOURCES = compute_in_window.cc
+compute_in_inner_border_SOURCES = compute_in_inner_border.cc
convert_SOURCES = convert.cc
fill_SOURCES = fill.cc
fill_with_image_SOURCES = fill_with_image.cc
diff --git a/milena/tests/core/image/vmorph/fun_image.cc b/milena/tests/data/compute_in_inner_border.cc
similarity index 75%
copy from milena/tests/core/image/vmorph/fun_image.cc
copy to milena/tests/data/compute_in_inner_border.cc
index 673c391..da73bd2 100644
--- a/milena/tests/core/image/vmorph/fun_image.cc
+++ b/milena/tests/data/compute_in_inner_border.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -24,24 +24,28 @@
// executable file might be covered by the GNU General Public License.
#include <mln/core/image/image2d.hh>
-#include <mln/core/image/vmorph/fun_image.hh>
-#include <mln/data/compare.hh>
+#include <mln/data/compute_in_inner_border.hh>
#include <mln/debug/iota.hh>
-#include <mln/fun/v2v/inc.hh>
-
-
+#include <mln/accu/stat/mean.hh>
int main()
{
using namespace mln;
-
- image2d<int> ima(2, 2);
+ image2d<int> ima(10, 10);
debug::iota(ima);
- int vals[] = { 2, 3,
- 4, 5 };
+ {
+ accu::stat::mean<int> m;
+ float mean = data::compute_in_inner_border(m, ima, 1);
+ mln_assertion(mean == 50.5);
+ }
+
+ {
+ accu::stat::mean<int> m;
+ float mean = data::compute_in_inner_border(m, ima, 2);
+ mln_assertion(mean == 50.5);
+ }
+
- fun::v2v::inc<int> f;
- mln_assertion((f << ima) == make::image2d(vals));
}
--
1.7.2.5
1
0
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Olena, a generic and efficient image processing platform".
The branch exp/khalimsky has been updated
via e4e04ba3c3fb549d9ad8778ac897c823e29b38d3 (commit)
via 1f73c20aa96c1e7d828634f2d31b2efd801fde67 (commit)
via 1acdaf876336b54a00b82aaab48137d162849c19 (commit)
from dab9373645b13d4b42381d31ff11cbf8538f1810 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
e4e04ba mln/world/kn/safe_cast.hh: Add more conversions.
1f73c20 Add immerse_with_border.
1acdaf8 mln/value/intsub.hh: Add operator=(literal::zero).
-----------------------------------------------------------------------
Summary of changes:
milena/ChangeLog | 32 ++++
milena/mln/value/intsub.hh | 9 +
milena/mln/world/k1/immerse_with_inner_border.hh | 168 ++++++++++++++++++
milena/mln/world/k2/immerse_with_inner_border.hh | 172 +++++++++++++++++++
milena/mln/world/kn/immerse.hh | 42 +----
milena/mln/world/kn/immerse_with_inner_border.hh | 179 ++++++++++++++++++++
milena/mln/world/kn/internal/domain_from_k0.hh | 103 +++++++++++
.../kn/internal/fill_primary_2_faces_from_input.hh | 118 +++++++++++++
milena/mln/world/kn/internal/immerse_point.hh | 37 ++++-
milena/mln/world/kn/safe_cast.hh | 12 ++-
milena/tests/world/k1/Makefile.am | 2 +
milena/tests/world/k1/immerse_with_inner_border.cc | 93 ++++++++++
milena/tests/world/k2/Makefile.am | 2 +
milena/tests/world/k2/immerse.cc | 18 +-
milena/tests/world/k2/immerse_with_inner_border.cc | 92 ++++++++++
milena/tests/world/kn/Makefile.am | 2 +
milena/tests/world/kn/immerse.cc | 57 +++----
milena/tests/world/kn/immerse_with_inner_border.cc | 136 +++++++++++++++
18 files changed, 1194 insertions(+), 80 deletions(-)
create mode 100644 milena/mln/world/k1/immerse_with_inner_border.hh
create mode 100644 milena/mln/world/k2/immerse_with_inner_border.hh
create mode 100644 milena/mln/world/kn/immerse_with_inner_border.hh
create mode 100644 milena/mln/world/kn/internal/domain_from_k0.hh
create mode 100644 milena/mln/world/kn/internal/fill_primary_2_faces_from_input.hh
create mode 100644 milena/tests/world/k1/immerse_with_inner_border.cc
create mode 100644 milena/tests/world/k2/immerse_with_inner_border.cc
create mode 100644 milena/tests/world/kn/immerse_with_inner_border.cc
hooks/post-receive
--
Olena, a generic and efficient image processing platform
1
0

olena-2.0-127-ge4e04ba mln/world/kn/safe_cast.hh: Add more conversions.
by Guillaume Lazzara 23 Oct '12
by Guillaume Lazzara 23 Oct '12
23 Oct '12
---
milena/ChangeLog | 4 ++++
milena/mln/world/kn/safe_cast.hh | 12 +++++++++++-
2 files changed, 15 insertions(+), 1 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index af00618..5b58c66 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,9 @@
2012-10-23 Guillaume Lazzara <z(a)lrde.epita.fr>
+ * mln/world/kn/safe_cast.hh: Add more conversions.
+
+2012-10-23 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Add immerse_with_border.
* mln/world/k1/immerse_with_inner_border.hh,
diff --git a/milena/mln/world/kn/safe_cast.hh b/milena/mln/world/kn/safe_cast.hh
index e21bdc7..31fe3cd 100644
--- a/milena/mln/world/kn/safe_cast.hh
+++ b/milena/mln/world/kn/safe_cast.hh
@@ -88,7 +88,9 @@ namespace mln
template <unsigned n>
void safe_cast_(const interval<intsub<n> >& from, value::int_u8& to)
{
- to = intsub<n>(from.to_interop());
+ if (!from.is_degenerated())
+ abort();
+ to = intsub<n>(from.first());
}
template <unsigned n>
@@ -100,6 +102,14 @@ namespace mln
}
template <unsigned n>
+ void safe_cast_(const interval<intsub<n> >& from, intsub<n>& to)
+ {
+ if (!from.is_degenerated())
+ abort();
+ to = from.first();
+ }
+
+ template <unsigned n>
void safe_cast_(const int& from, interval<intsub<n> >& to)
{
to = interval<intsub<n> >(from);
--
1.7.2.5
1
0
* mln/world/k1/immerse_with_inner_border.hh,
* mln/world/k2/immerse_with_inner_border.hh,
* mln/world/kn/immerse_with_inner_border.hh,
* mln/world/kn/internal/domain_from_k0.hh,
* mln/world/kn/internal/fill_primary_2_faces_from_input.hh,
* tests/world/k1/immerse_with_inner_border.cc,
* tests/world/k2/immerse_with_inner_border.cc,
* tests/world/kn/immerse_with_inner_border.cc: New.
* mln/world/kn/immerse.hh,
* mln/world/kn/internal/immerse_point.hh: Rely on
immerse_with_inner_border.
* tests/world/k1/Makefile.am,
* tests/world/k2/Makefile.am,
* tests/world/kn/Makefile.am: Update targets.
* tests/world/k2/immerse.cc,
* tests/world/kn/immerse.cc: Fix tests.
---
milena/ChangeLog | 24 +++
milena/mln/world/k1/immerse_with_inner_border.hh | 168 ++++++++++++++++++
milena/mln/world/k2/immerse_with_inner_border.hh | 172 +++++++++++++++++++
milena/mln/world/kn/immerse.hh | 42 +----
milena/mln/world/kn/immerse_with_inner_border.hh | 179 ++++++++++++++++++++
milena/mln/world/kn/internal/domain_from_k0.hh | 103 +++++++++++
.../kn/internal/fill_primary_2_faces_from_input.hh | 118 +++++++++++++
milena/mln/world/kn/internal/immerse_point.hh | 37 ++++-
milena/tests/world/k1/Makefile.am | 2 +
milena/tests/world/k1/immerse_with_inner_border.cc | 93 ++++++++++
milena/tests/world/k2/Makefile.am | 2 +
milena/tests/world/k2/immerse.cc | 18 +-
milena/tests/world/k2/immerse_with_inner_border.cc | 92 ++++++++++
milena/tests/world/kn/Makefile.am | 2 +
milena/tests/world/kn/immerse.cc | 57 +++----
milena/tests/world/kn/immerse_with_inner_border.cc | 136 +++++++++++++++
16 files changed, 1166 insertions(+), 79 deletions(-)
create mode 100644 milena/mln/world/k1/immerse_with_inner_border.hh
create mode 100644 milena/mln/world/k2/immerse_with_inner_border.hh
create mode 100644 milena/mln/world/kn/immerse_with_inner_border.hh
create mode 100644 milena/mln/world/kn/internal/domain_from_k0.hh
create mode 100644 milena/mln/world/kn/internal/fill_primary_2_faces_from_input.hh
create mode 100644 milena/tests/world/k1/immerse_with_inner_border.cc
create mode 100644 milena/tests/world/k2/immerse_with_inner_border.cc
create mode 100644 milena/tests/world/kn/immerse_with_inner_border.cc
diff --git a/milena/ChangeLog b/milena/ChangeLog
index e939e2c..af00618 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,29 @@
2012-10-23 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Add immerse_with_border.
+
+ * mln/world/k1/immerse_with_inner_border.hh,
+ * mln/world/k2/immerse_with_inner_border.hh,
+ * mln/world/kn/immerse_with_inner_border.hh,
+ * mln/world/kn/internal/domain_from_k0.hh,
+ * mln/world/kn/internal/fill_primary_2_faces_from_input.hh,
+ * tests/world/k1/immerse_with_inner_border.cc,
+ * tests/world/k2/immerse_with_inner_border.cc,
+ * tests/world/kn/immerse_with_inner_border.cc: New.
+
+ * mln/world/kn/immerse.hh,
+ * mln/world/kn/internal/immerse_point.hh: Rely on
+ immerse_with_inner_border.
+
+ * tests/world/k1/Makefile.am,
+ * tests/world/k2/Makefile.am,
+ * tests/world/kn/Makefile.am: Update targets.
+
+ * tests/world/k2/immerse.cc,
+ * tests/world/kn/immerse.cc: Fix tests.
+
+2012-10-23 Guillaume Lazzara <z(a)lrde.epita.fr>
+
* mln/value/intsub.hh: Add operator=(literal::zero).
2012-10-23 Guillaume Lazzara <z(a)lrde.epita.fr>
diff --git a/milena/mln/world/k1/immerse_with_inner_border.hh b/milena/mln/world/k1/immerse_with_inner_border.hh
new file mode 100644
index 0000000..7cfeb00
--- /dev/null
+++ b/milena/mln/world/k1/immerse_with_inner_border.hh
@@ -0,0 +1,168 @@
+// Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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_WORLD_K1_IMMERSE_WITH_INNER_BORDER_HH
+# define MLN_WORLD_K1_IMMERSE_WITH_INNER_BORDER_HH
+
+/// \file
+///
+/// \brief Immerse a 2D image into K1 with additional border pixels.
+
+# include <mln/core/concept/image.hh>
+# include <mln/world/kn/immerse_with_inner_border.hh>
+
+
+
+namespace mln
+{
+
+ namespace world
+ {
+
+ namespace k1
+ {
+ /*! \brief Immerse a 2D image into K1 with additional border
+ /// pixels.
+
+ \param[in] ima A 2D image.
+ \param[in] n Set in which space K\p n to immerse \p ima.
+ \param[in] new_value_type An instance of the output value type.
+ \param[in] inner_border_thickness Define the inner border size.
+
+ By default, the output image is not initialized except the
+ primary 2-faces.
+
+ \verbatim
+ 0 1
+
+ 0 X Y
+ \endverbatim
+
+ immersion with inner_border_thickness = 1 -->
+
+ \verbatim
+ 0 2 4 6
+ + - + - + - + - +
+ 0 | b | b | b | b |
+ + - + - + - + - +
+ 2 | b | X | Y | b |
+ + - + - + - + - +
+ 4 | b | b | b | b |
+ + - + - + - + - +
+ \endverbatim
+ */
+ template <typename I, typename V>
+ mln_ch_value(I,V)
+ immerse_with_inner_border(const Image<I>& ima,
+ const V& new_value_type,
+ unsigned inner_border_thickness);
+
+ /// \overload
+ /// This overload initializes the output image with \p
+ /// default_value.
+ template <typename I, typename V>
+ mln_ch_value(I,V)
+ immerse_with_inner_border(const Image<I>& ima,
+ const V& new_value_type,
+ const V& default_value,
+ unsigned inner_border_thickness);
+
+ /// \overload
+ /// The output image has the same type as \p ima.
+ template <typename I>
+ mln_concrete(I)
+ immerse_with_inner_border(const Image<I>& ima,
+ unsigned inner_border_thickness);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I, typename V>
+ mln_ch_value(I,V)
+ immerse_with_inner_border(const Image<I>& ima,
+ const V& new_value_type,
+ unsigned inner_border_thickness)
+ {
+ trace::entering("mln::world::k1::immerse_with_inner_border");
+ mln_precondition(exact(ima).is_valid());
+
+ mln_ch_value(I,V)
+ output = world::kn::immerse_with_inner_border(ima,
+ 1,
+ new_value_type,
+ inner_border_thickness);
+
+ trace::exiting("mln::world::k1::immerse_with_inner_border");
+ return output;
+ }
+
+ template <typename I, typename V>
+ mln_ch_value(I,V)
+ immerse_with_inner_border(const Image<I>& ima,
+ const V& new_value_type,
+ const V& default_value,
+ unsigned inner_border_thickness)
+ {
+ trace::entering("mln::world::k1::immerse_with_inner_border");
+ mln_precondition(exact(ima).is_valid());
+
+ mln_ch_value(I,V)
+ output = world::kn::immerse_with_inner_border(ima,
+ 1,
+ new_value_type,
+ default_value,
+ inner_border_thickness);
+
+ trace::exiting("mln::world::k1::immerse_with_inner_border");
+ return output;
+ }
+
+ template <typename I>
+ mln_concrete(I)
+ immerse_with_inner_border(const Image<I>& ima,
+ unsigned inner_border_thickness)
+ {
+ trace::entering("mln::world::k1::immerse_with_inner_border");
+ mln_precondition(exact(ima).is_valid());
+
+ typedef mln_value(I) V;
+ mln_concrete(I)
+ output = immerse_with_inner_border(ima, 1, V(),
+ inner_border_thickness);
+
+ trace::exiting("mln::world::k1::immerse_with_inner_border");
+ return output;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::world::k1
+
+ } // end of namespace mln::world
+
+} // end of namespace mln
+
+
+#endif // ! MLN_WORLD_K1_IMMERSE_WITH_INNER_BORDER_HH
diff --git a/milena/mln/world/k2/immerse_with_inner_border.hh b/milena/mln/world/k2/immerse_with_inner_border.hh
new file mode 100644
index 0000000..46c3675
--- /dev/null
+++ b/milena/mln/world/k2/immerse_with_inner_border.hh
@@ -0,0 +1,172 @@
+// Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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_WORLD_K2_IMMERSE_WITH_INNER_BORDER_HH
+# define MLN_WORLD_K2_IMMERSE_WITH_INNER_BORDER_HH
+
+/// \file
+///
+/// \brief Immerse a 2D image into K2 with additional border pixels.
+
+# include <mln/core/concept/image.hh>
+# include <mln/world/kn/immerse_with_inner_border.hh>
+
+
+
+namespace mln
+{
+
+ namespace world
+ {
+
+ namespace k2
+ {
+ /*! \brief Immerse a 2D image into K2 with additional border
+ /// pixels.
+
+ \param[in] ima A 2D image.
+ \param[in] n Set in which space K\p n to immerse \p ima.
+ \param[in] new_value_type An instance of the output value type.
+ \param[in] inner_border_thickness Define the inner border size.
+
+ By default, the output image is not initialized except the
+ primary 2-faces.
+
+ \verbatim
+ 0 1
+
+ 0 X Y
+ \endverbatim
+
+ immersion with inner_border_thickness = 1 -->
+
+ \verbatim
+ 0 4 8 12
+ + - + - + - + - + - + - + - +
+ 0 | b | | b | | b | | b |
+ + - + - + - + - + - + - + - +
+ | | | | | | | |
+ + - + - + - + - + - + - + - +
+ 4 | b | | X | | Y | | b |
+ + - + - + - + - + - + - + - +
+ | | | | | | | |
+ + - + - + - + - + - + - + - +
+ 8 | b | | b | | b | | b |
+ + - + - + - + - + - + - + - +
+ \endverbatim
+ */
+ template <typename I, typename V>
+ mln_ch_value(I,V)
+ immerse_with_inner_border(const Image<I>& ima,
+ const V& new_value_type,
+ unsigned inner_border_thickness);
+
+ /// \overload
+ /// This overload initializes the output image with \p
+ /// default_value.
+ template <typename I, typename V>
+ mln_ch_value(I,V)
+ immerse_with_inner_border(const Image<I>& ima,
+ const V& new_value_type,
+ const V& default_value,
+ unsigned inner_border_thickness);
+
+ /// \overload
+ /// The output image has the same type as \p ima.
+ template <typename I>
+ mln_concrete(I)
+ immerse_with_inner_border(const Image<I>& ima,
+ unsigned inner_border_thickness);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I, typename V>
+ mln_ch_value(I,V)
+ immerse_with_inner_border(const Image<I>& ima,
+ const V& new_value_type,
+ unsigned inner_border_thickness)
+ {
+ trace::entering("mln::world::k2::immerse_with_inner_border");
+ mln_precondition(exact(ima).is_valid());
+
+ mln_ch_value(I,V)
+ output = world::kn::immerse_with_inner_border(ima,
+ 2,
+ new_value_type,
+ inner_border_thickness);
+
+ trace::exiting("mln::world::k2::immerse_with_inner_border");
+ return output;
+ }
+
+ template <typename I, typename V>
+ mln_ch_value(I,V)
+ immerse_with_inner_border(const Image<I>& ima,
+ const V& new_value_type,
+ const V& default_value,
+ unsigned inner_border_thickness)
+ {
+ trace::entering("mln::world::k2::immerse_with_inner_border");
+ mln_precondition(exact(ima).is_valid());
+
+ mln_ch_value(I,V)
+ output = world::kn::immerse_with_inner_border(ima,
+ 2,
+ new_value_type,
+ default_value,
+ inner_border_thickness);
+
+ trace::exiting("mln::world::k2::immerse_with_inner_border");
+ return output;
+ }
+
+ template <typename I>
+ mln_concrete(I)
+ immerse_with_inner_border(const Image<I>& ima,
+ unsigned inner_border_thickness)
+ {
+ trace::entering("mln::world::k2::immerse_with_inner_border");
+ mln_precondition(exact(ima).is_valid());
+
+ typedef mln_value(I) V;
+ mln_concrete(I)
+ output = immerse_with_inner_border(ima, 2, V(),
+ inner_border_thickness);
+
+ trace::exiting("mln::world::k2::immerse_with_inner_border");
+ return output;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::world::k2
+
+ } // end of namespace mln::world
+
+} // end of namespace mln
+
+
+#endif // ! MLN_WORLD_K2_IMMERSE_WITH_INNER_BORDER_HH
diff --git a/milena/mln/world/kn/immerse.hh b/milena/mln/world/kn/immerse.hh
index 8d5f578..6359e87 100644
--- a/milena/mln/world/kn/immerse.hh
+++ b/milena/mln/world/kn/immerse.hh
@@ -32,9 +32,7 @@
# include <mln/core/concept/image.hh>
# include <mln/core/concept/box.hh>
-
-# include <mln/world/kn/internal/immerse_point.hh>
-# include <mln/world/kn/safe_cast.hh>
+# include <mln/world/kn/immerse_with_inner_border.hh>
namespace mln
{
@@ -88,28 +86,6 @@ namespace mln
# ifndef MLN_INCLUDE_ONLY
- namespace internal
- {
-
- /// \brief Return the equivalent domain in Kn from a domain in
- /// K0.
- template <typename B>
- inline
- B domain_from_K0(const Box<B>& b_, const unsigned n)
- {
- mln_precondition(exact(b_).is_valid());
- const B& b = exact(b_);
-
- mln_deduce(B, site, delta) one;
- one.set_all(1);
- return B(immerse_point(b.pmin(), n) - one,
- immerse_point(b.pmax(), n) + one);
- }
-
- } // end of namespace mln::world::kn::internal
-
-
-
template <typename I, typename V>
mln_ch_value(I, V)
@@ -122,12 +98,7 @@ namespace mln
(void) new_value_type;
mln_ch_value(I,V)
- output(internal::domain_from_K0(ima.domain(), n));
-
- // Filling Primary 2-Faces
- mln_piter(I) p(ima.domain());
- for_all(p)
- output(internal::immerse_point(p, n)) = safe_cast(ima(p));
+ output = immerse_with_inner_border(ima, n, new_value_type, 0);
trace::exiting("mln::world::kn::immerse");
return output;
@@ -145,13 +116,8 @@ namespace mln
(void) new_value_type;
mln_ch_value(I,V)
- output(internal::domain_from_K0(ima.domain(), n));
- data::fill(output, default_value);
-
- // Filling Primary 2-Faces
- mln_piter(I) p(ima.domain());
- for_all(p)
- output(internal::immerse_point(p, n)) = safe_cast(ima(p));
+ output = immerse_with_inner_border(ima, n, new_value_type,
+ default_value, 0);
trace::exiting("mln::world::kn::immerse");
return output;
diff --git a/milena/mln/world/kn/immerse_with_inner_border.hh b/milena/mln/world/kn/immerse_with_inner_border.hh
new file mode 100644
index 0000000..22453bc
--- /dev/null
+++ b/milena/mln/world/kn/immerse_with_inner_border.hh
@@ -0,0 +1,179 @@
+// Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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_WORLD_KN_IMMERSE_WITH_INNER_BORDER_HH
+# define MLN_WORLD_KN_IMMERSE_WITH_INNER_BORDER_HH
+
+/// \file
+///
+/// \brief Immerse a 2D image into Kn with additional border pixels.
+
+# include <mln/core/concept/image.hh>
+# include <mln/data/fill.hh>
+# include <mln/world/kn/internal/domain_from_k0.hh>
+# include <mln/world/kn/internal/fill_primary_2_faces_from_input.hh>
+
+
+namespace mln
+{
+
+ namespace world
+ {
+
+ namespace kn
+ {
+ /*! \brief Immerse a 2D image into Kn with additional border
+ /// pixels.
+
+ \param[in] ima A 2D image.
+ \param[in] n Set in which space K\p n to immerse \p ima.
+ \param[in] new_value_type An instance of the output value type.
+ \param[in] inner_border_thickness Define the inner border size.
+
+ By default, the output image is not initialized except the
+ primary 2-faces.
+
+ \verbatim
+ 0 1
+
+ 0 X Y
+ \endverbatim
+
+ immersion with n = 2 and inner_border_thickness = 1 -->
+
+ \verbatim
+ 0 4 8 12
+ + - + - + - + - + - + - + - +
+ 0 | b | | b | | b | | b |
+ + - + - + - + - + - + - + - +
+ | | | | | | | |
+ + - + - + - + - + - + - + - +
+ 4 | b | | X | | Y | | b |
+ + - + - + - + - + - + - + - +
+ | | | | | | | |
+ + - + - + - + - + - + - + - +
+ 8 | b | | b | | b | | b |
+ + - + - + - + - + - + - + - +
+ \endverbatim
+ */
+ template <typename I, typename V>
+ mln_ch_value(I,V)
+ immerse_with_inner_border(const Image<I>& ima,
+ unsigned n,
+ const V& new_value_type,
+ unsigned inner_border_thickness);
+
+ /// \overload
+ /// This overload initializes the output image with \p
+ /// default_value.
+ template <typename I, typename V>
+ mln_ch_value(I,V)
+ immerse_with_inner_border(const Image<I>& ima,
+ unsigned n,
+ const V& new_value_type,
+ const V& default_value,
+ unsigned inner_border_thickness);
+
+ /// \overload
+ /// The output image has the same type as \p ima.
+ template <typename I>
+ mln_concrete(I)
+ immerse_with_inner_border(const Image<I>& ima,
+ unsigned n,
+ unsigned inner_border_thickness);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I, typename V>
+ mln_ch_value(I,V)
+ immerse_with_inner_border(const Image<I>& ima_,
+ unsigned n,
+ const V& new_value_type,
+ unsigned inner_border_thickness)
+ {
+ trace::entering("mln::world::kn::immerse_with_inner_border");
+ mln_precondition(exact(ima_).is_valid());
+ (void) new_value_type;
+
+ const I& ima = exact(ima_);
+
+ mln_ch_value(I,V)
+ output(internal::domain_from_k0(ima.domain(), n,
+ inner_border_thickness));
+
+ internal::fill_primary_2_faces_from_input(output, n, ima,
+ inner_border_thickness);
+
+ trace::exiting("mln::world::kn::immerse_with_inner_border");
+ return output;
+ }
+
+ template <typename I, typename V>
+ mln_ch_value(I,V)
+ immerse_with_inner_border(const Image<I>& ima_,
+ unsigned n,
+ const V& new_value_type,
+ const V& default_value,
+ unsigned inner_border_thickness)
+ {
+ trace::entering("mln::world::kn::immerse_with_inner_border");
+ mln_precondition(exact(ima_).is_valid());
+ (void) new_value_type;
+
+ const I& ima = exact(ima_);
+
+ mln_ch_value(I,V)
+ output(internal::domain_from_k0(ima.domain(), n,
+ inner_border_thickness));
+ data::fill(output, default_value);
+
+ internal::fill_primary_2_faces_from_input(output, n, ima,
+ inner_border_thickness);
+
+ trace::exiting("mln::world::kn::immerse_with_inner_border");
+ return output;
+ }
+
+ template <typename I>
+ mln_concrete(I)
+ immerse_with_inner_border(const Image<I>& ima,
+ unsigned n,
+ unsigned inner_border_thickness)
+ {
+ typedef mln_value(I) V;
+ return immerse_with_inner_border(ima, n, V(), inner_border_thickness);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::world::kn
+
+ } // end of namespace mln::world
+
+} // end of namespace mln
+
+
+#endif // ! MLN_WORLD_KN_IMMERSE_WITH_INNER_BORDER_HH
diff --git a/milena/mln/world/kn/internal/domain_from_k0.hh b/milena/mln/world/kn/internal/domain_from_k0.hh
new file mode 100644
index 0000000..1950280
--- /dev/null
+++ b/milena/mln/world/kn/internal/domain_from_k0.hh
@@ -0,0 +1,103 @@
+// Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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
+///
+/// \brief Return the equivalent domain in Kn from a domain in
+/// K0.
+
+#ifndef MLN_WORLD_KN_DOMAIN_FROM_K0_HH
+# define MLN_WORLD_KN_DOMAIN_FROM_K0_HH
+
+# include <mln/core/concept/box.hh>
+# include <mln/world/kn/internal/immerse_point.hh>
+
+namespace mln
+{
+
+ namespace world
+ {
+
+ namespace kn
+ {
+
+ namespace internal
+ {
+
+ /// \brief Return the equivalent domain in Kn from a domain in
+ /// K0.
+ template <typename B>
+ B
+ domain_from_k0(const Box<B>& b, const unsigned n,
+ unsigned inner_border_thickness);
+
+ /// \overload
+ /// \p inner_border_thickness is set to 0.
+ template <typename B>
+ B
+ domain_from_k0(const Box<B>& b, const unsigned n);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ template <typename B>
+ B
+ domain_from_k0(const Box<B>& b_, const unsigned n,
+ unsigned inner_border_thickness)
+ {
+ mln_precondition(exact(b_).is_valid());
+ const B& b = exact(b_);
+
+ mln_deduce(B, site, delta) one;
+ one.set_all(1);
+ B bout = B(immerse_point(b.pmin(), n, inner_border_thickness)
+ - (inner_border_thickness * 2 * one) - one,
+ immerse_point(b.pmax(), n, inner_border_thickness)
+ + (std::pow(2,n) - 1) * one + (inner_border_thickness * 2 * one));
+ return bout;
+ }
+
+
+ template <typename B>
+ B
+ domain_from_k0(const Box<B>& b, const unsigned n)
+ {
+ return domain_from_K0(b, n, 0);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::work::kn::internal
+
+ } // end of namespace mln::world::kn
+
+ } // end of namespace mln::world
+
+} // end of namespace mln
+
+#endif // ! MLN_WORLD_KN_DOMAIN_FROM_K0_HH
+
+
diff --git a/milena/mln/world/kn/internal/fill_primary_2_faces_from_input.hh b/milena/mln/world/kn/internal/fill_primary_2_faces_from_input.hh
new file mode 100644
index 0000000..5884771
--- /dev/null
+++ b/milena/mln/world/kn/internal/fill_primary_2_faces_from_input.hh
@@ -0,0 +1,118 @@
+// Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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
+///
+/// \brief Fill primary 2-faces from a Kn image using original pixel
+/// as values.
+
+#ifndef MLN_WORLD_KN_FILL_PRIMARY_2_FACES_FROM_INPUT_HH
+# define MLN_WORLD_KN_FILL_PRIMARY_2_FACES_FROM_INPUT_HH
+
+# include <mln/world/kn/internal/immerse_point.hh>
+# include <mln/world/kn/safe_cast.hh>
+
+namespace mln
+{
+
+ namespace world
+ {
+
+ namespace kn
+ {
+
+ namespace internal
+ {
+
+ /// \brief Fill primary 2-faces from a Kn image using original pixel
+ /// as values.
+ template <typename I, typename J>
+ void
+ fill_primary_2_faces_from_input(Image<I>& ima_kn,
+ unsigned n,
+ const Image<J>& ima,
+ const unsigned inner_border_thickness);
+
+ /// \overload
+ /// \p inner_border_thickness is set to 0.
+ template <typename I, typename J>
+ void
+ fill_primary_2_faces_from_input(Image<I>& ima_kn,
+ unsigned n,
+ const Image<J>& ima);
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ template <typename I, typename J>
+ void
+ fill_primary_2_faces_from_input(Image<I>& ima_kn_,
+ unsigned n,
+ const Image<J>& ima_,
+ const unsigned inner_border_thickness)
+ {
+ trace::entering("mln::world::kn::internal::fill_primary_2_faces_from_input");
+ mlc_equal(mln_site(I), mln_site(J))::check();
+ mln_precondition(exact(ima_).is_valid());
+ mln_precondition(exact(ima_kn_).is_valid());
+ mln_precondition(exact(ima_).domain() <= exact(ima_kn_).domain());
+
+ I& ima_kn = exact(ima_kn_);
+ const J& ima = exact(ima_);
+
+ // Filling Primary 2-Faces
+ mln_piter(J) p(ima.domain());
+ for_all(p)
+ {
+ mln_site(I) pout = internal::immerse_point(p, n, inner_border_thickness);
+ ima_kn(pout) = safe_cast(ima(p));
+ }
+
+ trace::exiting("mln::world::kn::internal::fill_primary_2_faces_from_input");
+ }
+
+
+ template <typename I, typename J>
+ void
+ fill_primary_2_faces_from_input(Image<I>& ima_kn,
+ unsigned n,
+ const Image<J>& ima)
+ {
+ return fill_primary_2_faces_from_input(ima_kn, n, ima, 0);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::work::kn::internal
+
+ } // end of namespace mln::world::kn
+
+ } // end of namespace mln::world
+
+} // end of namespace mln
+
+#endif // ! MLN_WORLD_KN_FILL_PRIMARY_2_FACES_FROM_INPUT_HH
+
+
diff --git a/milena/mln/world/kn/internal/immerse_point.hh b/milena/mln/world/kn/internal/immerse_point.hh
index 9dd46c7..538c8ed 100644
--- a/milena/mln/world/kn/internal/immerse_point.hh
+++ b/milena/mln/world/kn/internal/immerse_point.hh
@@ -30,6 +30,7 @@
#ifndef MLN_WORLD_KN_IMMERSE_POINT_HH
# define MLN_WORLD_KN_IMMERSE_POINT_HH
+# include <cmath>
# include <mln/core/alias/point2d.hh>
namespace mln
@@ -49,9 +50,21 @@ namespace mln
/// in K0.
point2d immerse_point(const def::coord& row,
const def::coord& col,
+ const unsigned n,
+ const unsigned inner_border_thickness);
+
+ /// \overload
+ /// \p inner_border_thickness is set to 0.
+ point2d immerse_point(const def::coord& row,
+ const def::coord& col,
const unsigned n);
/// \overload
+ point2d immerse_point(const point2d& p, const unsigned n,
+ const unsigned inner_border_thickness);
+
+ /// \overload
+ /// \p inner_border_thickness is set to 0.
point2d immerse_point(const point2d& p, const unsigned n);
@@ -59,21 +72,39 @@ namespace mln
inline
+ point2d immerse_point(const point2d& p, const unsigned n,
+ const unsigned inner_border_thickness)
+ {
+ return immerse_point(p.row(), p.col(), n,
+ inner_border_thickness);
+ }
+
+ inline
point2d immerse_point(const point2d& p, const unsigned n)
{
- return immerse_point(p.row(), p.col(), n);
+ return immerse_point(p.row(), p.col(), n, 0);
}
inline
point2d immerse_point(const def::coord& row,
const def::coord& col,
- const unsigned n)
+ const unsigned n,
+ const unsigned inner_border_thickness)
{
- point2d tmp(std::pow(2u, n) * row, std::pow(2u, n) * col);
+ point2d tmp(std::pow(2u, n) * row + 2 * inner_border_thickness,
+ std::pow(2u, n) * col + 2* inner_border_thickness);
return tmp;
}
+ inline
+ point2d immerse_point(const def::coord& row,
+ const def::coord& col,
+ const unsigned n)
+ {
+ return immerse_point(row, col, n, 0);
+ }
+
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/tests/world/k1/Makefile.am b/milena/tests/world/k1/Makefile.am
index 5c42124..3ff9c81 100644
--- a/milena/tests/world/k1/Makefile.am
+++ b/milena/tests/world/k1/Makefile.am
@@ -23,6 +23,7 @@ check_PROGRAMS = \
fill_0_from_primary_faces \
immerse \
immerse_with \
+ immerse_with_inner_border \
immerse_and_duplicate_2_to_1_faces \
immerse_and_duplicate_2_to_0_1_faces \
is_primary_face \
@@ -34,6 +35,7 @@ fill_1_from_2_faces_SOURCES = fill_1_from_2_faces.cc
fill_0_from_primary_faces_SOURCES = fill_0_from_primary_faces.cc
immerse_SOURCES = immerse.cc
immerse_with_SOURCES = immerse_with.cc
+immerse_with_inner_border_SOURCES = immerse_with_inner_border.cc
immerse_and_duplicate_2_to_1_faces_SOURCES = immerse_and_duplicate_2_to_1_faces.cc
immerse_and_duplicate_2_to_0_1_faces_SOURCES = immerse_and_duplicate_2_to_0_1_faces.cc
is_primary_face_SOURCES = is_primary_face.cc
diff --git a/milena/tests/world/k1/immerse_with_inner_border.cc b/milena/tests/world/k1/immerse_with_inner_border.cc
new file mode 100644
index 0000000..3c1082b
--- /dev/null
+++ b/milena/tests/world/k1/immerse_with_inner_border.cc
@@ -0,0 +1,93 @@
+// Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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
+
+#include <mln/core/image/image2d.hh>
+#include <mln/world/k1/immerse_with_inner_border.hh>
+#include <mln/data/compare.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ int ivals[][2] = {
+ {1, 2},
+ {3, 4}
+ };
+ image2d<int> ima = make::image(ivals);
+
+ int val_k1wob[][5] = {
+ {0, 0, 0, 0, 0},
+ {0, 1, 0, 2, 0},
+ {0, 0, 0, 0, 0},
+ {0, 3, 0, 4, 0},
+ {0, 0, 0, 0, 0},
+ };
+ image2d<int> k1wob = make::image(val_k1wob, point2d(-1,-1));
+
+ int val_k1b[][9] = {
+ {0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 1, 0, 2, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 3, 0, 4, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0}
+ };
+ image2d<int> k1b = make::image(val_k1b, point2d(-1,-1));
+
+ // K1 with border.
+ {
+ image2d<long> immersed = world::k1::immerse_with_inner_border(ima, long(), 1);
+ mln_assertion(immersed.domain() == k1b.domain());
+ mln_assertion(immersed(point2d(2,2)) == 1);
+ mln_assertion(immersed(point2d(2,4)) == 2);
+ mln_assertion(immersed(point2d(4,2)) == 3);
+ mln_assertion(immersed(point2d(4,4)) == 4);
+ }
+ {
+ image2d<long> immersed = world::k1::immerse_with_inner_border(ima, long(), 0l, 1);
+ mln_assertion(immersed == k1b);
+ }
+ {
+ image2d<int> immersed = world::k1::immerse_with_inner_border(ima, 1);
+ mln_assertion(immersed.domain() == k1b.domain());
+ mln_assertion(immersed(point2d(2,2)) == 1);
+ mln_assertion(immersed(point2d(2,4)) == 2);
+ mln_assertion(immersed(point2d(4,2)) == 3);
+ mln_assertion(immersed(point2d(4,4)) == 4);
+ }
+
+ // K1 without border.
+ {
+ image2d<long> immersed = world::k1::immerse_with_inner_border(ima, long(), 0l, 0);
+ mln_assertion(immersed == k1wob);
+ }
+
+}
diff --git a/milena/tests/world/k2/Makefile.am b/milena/tests/world/k2/Makefile.am
index 84b0801..c94bd50 100644
--- a/milena/tests/world/k2/Makefile.am
+++ b/milena/tests/world/k2/Makefile.am
@@ -24,6 +24,7 @@ check_PROGRAMS = \
is_non_primary_2_face_vertical \
is_primary_2_face \
immerse \
+ immerse_with_inner_border \
un_immerse
fill_non_primary_from_primary_2_faces_SOURCES = fill_non_primary_from_primary_2_faces.cc
@@ -33,6 +34,7 @@ is_non_primary_2_face_horizontal_SOURCES = is_non_primary_2_face_horizontal.cc
is_non_primary_2_face_vertical_SOURCES = is_non_primary_2_face_vertical.cc
is_primary_2_face_SOURCES = is_primary_2_face.cc
immerse_SOURCES = immerse.cc
+immerse_with_inner_border_SOURCES = immerse_with_inner_border.cc
un_immerse_SOURCES = un_immerse.cc
TESTS = $(check_PROGRAMS)
diff --git a/milena/tests/world/k2/immerse.cc b/milena/tests/world/k2/immerse.cc
index d00f095..29fb4e4 100644
--- a/milena/tests/world/k2/immerse.cc
+++ b/milena/tests/world/k2/immerse.cc
@@ -39,14 +39,16 @@ int main()
};
image2d<int> ima = make::image(ivals);
- int fvals[][7] = {
- {5, 5, 5, 5, 5, 5, 5},
- {5, 1, 5, 5, 5, 2, 5},
- {5, 5, 5, 5, 5, 5, 5},
- {5, 5, 5, 5, 5, 5, 5},
- {5, 5, 5, 5, 5, 5, 5},
- {5, 3, 5, 5, 5, 4, 5},
- {5, 5, 5, 5, 5, 5, 5}
+ int fvals[][9] = {
+ {5, 5, 5, 5, 5, 5, 5, 5, 5},
+ {5, 1, 5, 5, 5, 2, 5, 5, 5},
+ {5, 5, 5, 5, 5, 5, 5, 5, 5},
+ {5, 5, 5, 5, 5, 5, 5, 5, 5},
+ {5, 5, 5, 5, 5, 5, 5, 5, 5},
+ {5, 3, 5, 5, 5, 4, 5, 5, 5},
+ {5, 5, 5, 5, 5, 5, 5, 5, 5},
+ {5, 5, 5, 5, 5, 5, 5, 5, 5},
+ {5, 5, 5, 5, 5, 5, 5, 5, 5}
};
image2d<int> ref_fill = make::image(fvals, point2d(-1,-1));
diff --git a/milena/tests/world/k2/immerse_with_inner_border.cc b/milena/tests/world/k2/immerse_with_inner_border.cc
new file mode 100644
index 0000000..addbb5a
--- /dev/null
+++ b/milena/tests/world/k2/immerse_with_inner_border.cc
@@ -0,0 +1,92 @@
+// Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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
+
+#include <mln/core/image/image2d.hh>
+#include <mln/world/k2/immerse_with_inner_border.hh>
+#include <mln/data/compare.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ int ivals[][2] = {
+ {1, 2},
+ {3, 4}
+ };
+ image2d<int> ima = make::image(ivals);
+
+ int val_k2wob[][9] = {
+ {0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 1, 0, 0, 0, 2, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 3, 0, 0, 0, 4, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0},
+ };
+ image2d<int> k2wob = make::image(val_k2wob, point2d(-1,-1));
+
+ int val_k2b[][13] = {
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 3, 0, 0, 0, 4, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ };
+ image2d<int> k2b = make::image(val_k2b, point2d(-1,-1));
+
+ // K2 with border
+ {
+ image2d<long> immersed = world::k2::immerse_with_inner_border(ima, long(), 0l, 1);
+ mln_assertion(immersed == k2b);
+ }
+
+ // K2 without border
+ {
+ image2d<long> immersed = world::k2::immerse_with_inner_border(ima, long(), 0l, 0);
+ mln_assertion(immersed == k2wob);
+ }
+ {
+ image2d<long> immersed = world::k2::immerse_with_inner_border(ima, long(), 0);
+ mln_assertion(immersed == k2wob);
+ }
+ {
+ image2d<int> immersed = world::k2::immerse_with_inner_border(ima, 0);
+ mln_assertion(immersed == k2wob);
+ }
+}
diff --git a/milena/tests/world/kn/Makefile.am b/milena/tests/world/kn/Makefile.am
index f88c698..866ae00 100644
--- a/milena/tests/world/kn/Makefile.am
+++ b/milena/tests/world/kn/Makefile.am
@@ -24,6 +24,7 @@ check_PROGRAMS = \
fill_1_from_aux_2_faces \
fill_2_from_1_faces \
immerse \
+ immerse_with_inner_border \
is_0_face \
is_0_or_1_face \
is_1_face \
@@ -40,6 +41,7 @@ fill_1_from_2_faces_SOURCES = fill_1_from_2_faces.cc
fill_1_from_aux_2_faces_SOURCES = fill_1_from_aux_2_faces.cc
fill_2_from_1_faces_SOURCES = fill_2_from_1_faces.cc
immerse_SOURCES = immerse.cc
+immerse_with_inner_border_SOURCES = immerse_with_inner_border.cc
is_0_face_SOURCES = is_0_face.cc
is_0_or_1_face_SOURCES = is_0_or_1_face.cc
is_1_face_SOURCES = is_1_face.cc
diff --git a/milena/tests/world/kn/immerse.cc b/milena/tests/world/kn/immerse.cc
index 9419a67..7b532e7 100644
--- a/milena/tests/world/kn/immerse.cc
+++ b/milena/tests/world/kn/immerse.cc
@@ -39,51 +39,48 @@ int main()
};
image2d<int> ima = make::image(ivals);
- int fvals[][19] = {
- {5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5},
- {5, 1, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 2, 5},
- {5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5},
- {5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5},
- {5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5},
- {5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5},
- {5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5},
- {5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5},
- {5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5},
- {5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5},
- {5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5},
- {5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5},
- {5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5},
- {5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5},
- {5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5},
- {5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5},
- {5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5},
- {5, 3, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 5},
- {5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5}
+ int fvals[][17] = {
+ {5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5},
+ {5, 1, 5, 5, 5, 5, 5, 5, 5, 2, 5, 5, 5, 5, 5, 5, 5},
+ {5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5},
+ {5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5},
+ {5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5},
+ {5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5},
+ {5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5},
+ {5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5},
+ {5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5},
+ {5, 3, 5, 5, 5, 5, 5, 5, 5, 4, 5, 5, 5, 5, 5, 5, 5},
+ {5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5},
+ {5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5},
+ {5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5},
+ {5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5},
+ {5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5},
+ {5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5},
+ {5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5}
};
image2d<int> ref_fill = make::image(fvals, point2d(-1,-1));
{
- image2d<int> immersed = world::kn::immerse(ima, 4);
-
+ image2d<int> immersed = world::kn::immerse(ima, 3);
mln_assertion(immersed.domain() == ref_fill.domain());
mln_assertion(immersed(point2d(0,0)) == 1);
- mln_assertion(immersed(point2d(0,16)) == 2);
- mln_assertion(immersed(point2d(16,0)) == 3);
- mln_assertion(immersed(point2d(16,16)) == 4);
+ mln_assertion(immersed(point2d(0,8)) == 2);
+ mln_assertion(immersed(point2d(8,0)) == 3);
+ mln_assertion(immersed(point2d(8,8)) == 4);
}
{
- image2d<long> immersed = world::kn::immerse(ima, 4, long());
+ image2d<long> immersed = world::kn::immerse(ima, 3, long());
mln_assertion(immersed.domain() == ref_fill.domain());
mln_assertion(immersed(point2d(0,0)) == 1);
- mln_assertion(immersed(point2d(0,16)) == 2);
- mln_assertion(immersed(point2d(16,0)) == 3);
- mln_assertion(immersed(point2d(16,16)) == 4);
+ mln_assertion(immersed(point2d(0,8)) == 2);
+ mln_assertion(immersed(point2d(8,0)) == 3);
+ mln_assertion(immersed(point2d(8,8)) == 4);
}
{
- image2d<long> immersed = world::kn::immerse(ima, 4, long(), 5l);
+ image2d<long> immersed = world::kn::immerse(ima, 3, long(), 5l);
mln_assertion(immersed == ref_fill);
}
diff --git a/milena/tests/world/kn/immerse_with_inner_border.cc b/milena/tests/world/kn/immerse_with_inner_border.cc
new file mode 100644
index 0000000..d0d59c7
--- /dev/null
+++ b/milena/tests/world/kn/immerse_with_inner_border.cc
@@ -0,0 +1,136 @@
+// Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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
+
+#include <mln/core/image/image2d.hh>
+#include <mln/world/kn/immerse_with_inner_border.hh>
+#include <mln/data/compare.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ int ivals[][2] = {
+ {1, 2},
+ {3, 4}
+ };
+ image2d<int> ima = make::image(ivals);
+
+ int val_k1wob[][5] = {
+ {0, 0, 0, 0, 0},
+ {0, 1, 0, 2, 0},
+ {0, 0, 0, 0, 0},
+ {0, 3, 0, 4, 0},
+ {0, 0, 0, 0, 0},
+ };
+ image2d<int> k1wob = make::image(val_k1wob, point2d(-1,-1));
+
+ int val_k1b[][9] = {
+ {0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 1, 0, 2, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 3, 0, 4, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0}
+ };
+ image2d<int> k1b = make::image(val_k1b, point2d(-1,-1));
+
+ int val_k2wob[][9] = {
+ {0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 1, 0, 0, 0, 2, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 3, 0, 0, 0, 4, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0},
+ };
+ image2d<int> k2wob = make::image(val_k2wob, point2d(-1,-1));
+
+ int val_k2b[][13] = {
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 3, 0, 0, 0, 4, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ };
+ image2d<int> k2b = make::image(val_k2b, point2d(-1,-1));
+
+ // K1 with border.
+ {
+ image2d<long> immersed = world::kn::immerse_with_inner_border(ima, 1, long(), 1);
+ mln_assertion(immersed.domain() == k1b.domain());
+ mln_assertion(immersed(point2d(2,2)) == 1);
+ mln_assertion(immersed(point2d(2,4)) == 2);
+ mln_assertion(immersed(point2d(4,2)) == 3);
+ mln_assertion(immersed(point2d(4,4)) == 4);
+ }
+ {
+ image2d<long> immersed = world::kn::immerse_with_inner_border(ima, 1, long(), 0l, 1);
+ mln_assertion(immersed == k1b);
+ }
+ {
+ image2d<int> immersed = world::kn::immerse_with_inner_border(ima, 1, 1);
+ mln_assertion(immersed.domain() == k1b.domain());
+ mln_assertion(immersed(point2d(2,2)) == 1);
+ mln_assertion(immersed(point2d(2,4)) == 2);
+ mln_assertion(immersed(point2d(4,2)) == 3);
+ mln_assertion(immersed(point2d(4,4)) == 4);
+ }
+
+ // K2 with border
+ {
+ image2d<long> immersed = world::kn::immerse_with_inner_border(ima, 2, long(), 0l, 1);
+ mln_assertion(immersed == k2b);
+ }
+
+
+ // K1 without border.
+ {
+ image2d<long> immersed = world::kn::immerse_with_inner_border(ima, 1, long(), 0l, 0);
+ mln_assertion(immersed == k1wob);
+ }
+
+ // K2 without border
+ {
+ image2d<long> immersed = world::kn::immerse_with_inner_border(ima, 2, long(), 0l, 0);
+ mln_assertion(immersed == k2wob);
+ }
+
+}
--
1.7.2.5
1
0

olena-2.0-125-g1acdaf8 mln/value/intsub.hh: Add operator=(literal::zero).
by Guillaume Lazzara 23 Oct '12
by Guillaume Lazzara 23 Oct '12
23 Oct '12
---
milena/ChangeLog | 4 ++++
milena/mln/value/intsub.hh | 9 +++++++++
2 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index a02e163..e939e2c 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,9 @@
2012-10-23 Guillaume Lazzara <z(a)lrde.epita.fr>
+ * mln/value/intsub.hh: Add operator=(literal::zero).
+
+2012-10-23 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Improve support for mean and median functions.
* mln/fun/vv2v/median.hh,
diff --git a/milena/mln/value/intsub.hh b/milena/mln/value/intsub.hh
index 5cf6ca5..ae71803 100644
--- a/milena/mln/value/intsub.hh
+++ b/milena/mln/value/intsub.hh
@@ -148,6 +148,7 @@ namespace mln
template <unsigned m>
intsub<n>& operator=(const intsub<m>& rhs);
intsub<n>& operator=(const intsub<n>& rhs);
+ intsub<n>& operator=(const literal::zero_t&);
intsub<n>& operator=(int i);
intsub<n>& operator=(float i);
intsub<n>& operator=(double i);
@@ -354,6 +355,14 @@ namespace mln
template <unsigned n>
intsub<n>&
+ intsub<n>::operator=(const literal::zero_t&)
+ {
+ this->v_ = 0;
+ return *this;
+ }
+
+ template <unsigned n>
+ intsub<n>&
intsub<n>::operator=(int i)
{
this->v_ = n * i;
--
1.7.2.5
1
0
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Olena, a generic and efficient image processing platform".
The branch exp/khalimsky has been updated
via dab9373645b13d4b42381d31ff11cbf8538f1810 (commit)
from c10b09b7b512f4ee639d353b79e23bbfacb05f98 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
dab9373 Improve support for mean and median functions.
-----------------------------------------------------------------------
Summary of changes:
milena/ChangeLog | 24 +++++
milena/mln/fun/vv2v/mean.hh | 3 +-
milena/mln/fun/vv2v/median.hh | 77 ++++++++++++++++
milena/mln/fun/vvvv2v/mean.hh | 3 +-
milena/mln/fun/vvvv2v/median.hh | 78 ++++++++++++++++
milena/mln/math/mean.hh | 24 +++---
milena/mln/math/median.hh | 172 ++++++++++++++++++++++++++++++++++++
milena/mln/trait/routine/mean.hh | 16 +++-
milena/mln/trait/routine/median.hh | 79 ++++++++++++++++
milena/mln/value/intsub.hh | 66 +++++---------
milena/tests/fun/vv2v/Makefile.am | 7 ++-
milena/tests/fun/vv2v/mean.cc | 71 +++++++++++++++
milena/tests/fun/vv2v/median.cc | 71 +++++++++++++++
milena/tests/math/Makefile.am | 13 +++-
milena/tests/math/mean.cc | 47 ++++++++++
milena/tests/math/median.cc | 90 +++++++++++++++++++
16 files changed, 779 insertions(+), 62 deletions(-)
create mode 100644 milena/mln/fun/vv2v/median.hh
create mode 100644 milena/mln/fun/vvvv2v/median.hh
create mode 100644 milena/mln/math/median.hh
create mode 100644 milena/mln/trait/routine/median.hh
create mode 100644 milena/tests/fun/vv2v/mean.cc
create mode 100644 milena/tests/fun/vv2v/median.cc
create mode 100644 milena/tests/math/mean.cc
create mode 100644 milena/tests/math/median.cc
hooks/post-receive
--
Olena, a generic and efficient image processing platform
1
0

olena-2.0-124-gdab9373 Improve support for mean and median functions.
by Guillaume Lazzara 23 Oct '12
by Guillaume Lazzara 23 Oct '12
23 Oct '12
* mln/fun/vv2v/median.hh,
* mln/fun/vvvv2v/median.hh,
* mln/math/median.hh,
* mln/trait/routine/median.hh,
* tests/fun/vv2v/mean.cc,
* tests/fun/vv2v/median.cc,
* tests/math/mean.cc,
* tests/math/median.cc: New.
* mln/fun/vv2v/mean.hh,
* mln/fun/vvvv2v/mean.hh,
* mln/math/mean.hh,
* mln/value/intsub.hh: Use a dedicated trait to deduce the return
type of mean() function.
* mln/trait/routine/mean.hh: Add more specializations.
* tests/fun/vv2v/Makefile.am,
* tests/math/Makefile.am: Update targets.
---
milena/ChangeLog | 24 +++++
milena/mln/fun/vv2v/mean.hh | 3 +-
milena/mln/fun/vv2v/median.hh | 77 ++++++++++++++++
milena/mln/fun/vvvv2v/mean.hh | 3 +-
milena/mln/fun/vvvv2v/median.hh | 78 ++++++++++++++++
milena/mln/math/mean.hh | 24 +++---
milena/mln/math/median.hh | 172 ++++++++++++++++++++++++++++++++++++
milena/mln/trait/routine/mean.hh | 16 +++-
milena/mln/trait/routine/median.hh | 79 ++++++++++++++++
milena/mln/value/intsub.hh | 66 +++++---------
milena/tests/fun/vv2v/Makefile.am | 7 ++-
milena/tests/fun/vv2v/mean.cc | 71 +++++++++++++++
milena/tests/fun/vv2v/median.cc | 71 +++++++++++++++
milena/tests/math/Makefile.am | 13 +++-
milena/tests/math/mean.cc | 47 ++++++++++
milena/tests/math/median.cc | 90 +++++++++++++++++++
16 files changed, 779 insertions(+), 62 deletions(-)
create mode 100644 milena/mln/fun/vv2v/median.hh
create mode 100644 milena/mln/fun/vvvv2v/median.hh
create mode 100644 milena/mln/math/median.hh
create mode 100644 milena/mln/trait/routine/median.hh
create mode 100644 milena/tests/fun/vv2v/mean.cc
create mode 100644 milena/tests/fun/vv2v/median.cc
create mode 100644 milena/tests/math/mean.cc
create mode 100644 milena/tests/math/median.cc
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 704143a..a02e163 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,29 @@
2012-10-23 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Improve support for mean and median functions.
+
+ * mln/fun/vv2v/median.hh,
+ * mln/fun/vvvv2v/median.hh,
+ * mln/math/median.hh,
+ * mln/trait/routine/median.hh,
+ * tests/fun/vv2v/mean.cc,
+ * tests/fun/vv2v/median.cc,
+ * tests/math/mean.cc,
+ * tests/math/median.cc: New.
+
+ * mln/fun/vv2v/mean.hh,
+ * mln/fun/vvvv2v/mean.hh,
+ * mln/math/mean.hh,
+ * mln/value/intsub.hh: Use a dedicated trait to deduce the return
+ type of mean() function.
+
+ * mln/trait/routine/mean.hh: Add more specializations.
+
+ * tests/fun/vv2v/Makefile.am,
+ * tests/math/Makefile.am: Update targets.
+
+2012-10-23 Guillaume Lazzara <z(a)lrde.epita.fr>
+
* mln/accu/stat/median_h_interval.hh: Make it inherit from
accumulator base.
diff --git a/milena/mln/fun/vv2v/mean.hh b/milena/mln/fun/vv2v/mean.hh
index 65e9f63..809d394 100644
--- a/milena/mln/fun/vv2v/mean.hh
+++ b/milena/mln/fun/vv2v/mean.hh
@@ -31,6 +31,7 @@
/// Functor that computes the mean of two values.
# include <mln/core/concept/function.hh>
+# include <mln/trait/routine/mean.hh>
# include <mln/math/mean.hh>
@@ -44,7 +45,7 @@ namespace mln
{
/// \brief A functor computing the mean of two values.
- template <typename V, typename R = V>
+ template <typename V, typename R = mln_trait_routine_mean(2,V) >
struct mean : public Function_vv2v< mean<V,R> >,
private mlc_converts_to(R,V)::check_t
{
diff --git a/milena/mln/fun/vv2v/median.hh b/milena/mln/fun/vv2v/median.hh
new file mode 100644
index 0000000..a5a451a
--- /dev/null
+++ b/milena/mln/fun/vv2v/median.hh
@@ -0,0 +1,77 @@
+// Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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_FUN_VV2V_MEDIAN_HH
+# define MLN_FUN_VV2V_MEDIAN_HH
+
+/// \file
+///
+/// Functor that computes the median of two values.
+
+# include <mln/core/concept/function.hh>
+# include <mln/trait/routine/median.hh>
+# include <mln/math/median.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace vv2v
+ {
+
+ /// \brief A functor computing the median of two values.
+ template <typename V, typename R = mln_trait_routine_median(V) >
+ struct median : public Function_vv2v< median<V,R> >,
+ private mlc_converts_to(R,V)::check_t
+ {
+ typedef R result;
+ typedef V argument;
+ R operator()(const V& v1, const V& v2) const;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename V, typename R>
+ inline
+ R
+ median<V,R>::operator()(const V& v1, const V& v2) const
+ {
+ return R(mln::math::mean(v1, v2));
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::vv2v
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_VV2V_MEDIAN_HH
diff --git a/milena/mln/fun/vvvv2v/mean.hh b/milena/mln/fun/vvvv2v/mean.hh
index d9810ab..7cc14e9 100644
--- a/milena/mln/fun/vvvv2v/mean.hh
+++ b/milena/mln/fun/vvvv2v/mean.hh
@@ -31,6 +31,7 @@
/// Functor that computes the mean of two values.
# include <mln/core/concept/function.hh>
+# include <mln/trait/routine/mean.hh>
# include <mln/math/mean.hh>
@@ -46,7 +47,7 @@ namespace mln
// FIXME: Doc.
/// \brief A functor computing the mean of two values.
- template <typename T, typename R=T>
+ template <typename T, typename R = mln_trait_routine_mean(4,T) >
struct mean : public Function_vvvv2v< mean<T> >
{
typedef R result;
diff --git a/milena/mln/fun/vvvv2v/median.hh b/milena/mln/fun/vvvv2v/median.hh
new file mode 100644
index 0000000..e08dabd
--- /dev/null
+++ b/milena/mln/fun/vvvv2v/median.hh
@@ -0,0 +1,78 @@
+// Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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_FUN_VVVV2V_MEDIAN_HH
+# define MLN_FUN_VVVV2V_MEDIAN_HH
+
+/// \file
+///
+/// Functor that computes the median of two values.
+
+# include <mln/core/concept/function.hh>
+# include <mln/trait/routine/median.hh>
+# include <mln/math/median.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace vvvv2v
+ {
+
+ // FIXME: Doc.
+
+ /// \brief A functor computing the median of two values.
+ template <typename T, typename R = mln_trait_routine_median(T) >
+ struct median : public Function_vvvv2v< median<T> >
+ {
+ typedef T argument;
+ typedef R result;
+ R operator()(const T& v1, const T& v2, const T& v3, const T& v4) const;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename T, typename R>
+ inline
+ R
+ median<T,R>::operator()(const T& v1, const T& v2, const T& v3, const T& v4) const
+ {
+ return R(mln::math::median(v1, v2, v3, v4));
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::vvvv2v
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_VVVV2V_MEDIAN_HH
diff --git a/milena/mln/math/mean.hh b/milena/mln/math/mean.hh
index d9c95fc..86a5efc 100644
--- a/milena/mln/math/mean.hh
+++ b/milena/mln/math/mean.hh
@@ -26,7 +26,7 @@
#ifndef MLN_MATH_MEAN_HH
# define MLN_MATH_MEAN_HH
-# include <mln/trait/op/div.hh>
+# include <mln/trait/routine/mean.hh>
# include <mln/metal/converts_to.hh>
/*! \file
@@ -43,23 +43,23 @@ namespace mln
/// Return the mean of two values.
template <typename T>
- mln_trait_op_div(T,double)
+ mln_trait_routine_mean(2,T)
mean(const T& v1, const T& v2);
/// \overload \pre Type U must be convertible towards type T.
template <typename T, typename U>
- mln_trait_op_div(T,double)
+ mln_trait_routine_mean(2,T)
mean(const T& v1, const U& v2);
/// Return the mean of four values.
template <typename T>
- mln_trait_op_div(T,double)
+ mln_trait_routine_mean(4,T)
mean(const T& v1, const T& v2, const T& v3, const T& v4);
/// \overload \pre Type T2, T3 and T4 must be convertible towards
/// type T.
template <typename T, typename T2, typename T3, typename T4>
- mln_trait_op_div(T,double)
+ mln_trait_routine_mean(4,T)
mean(const T& v1, const T2& v2, const T3& v3, const T4& v4);
@@ -69,7 +69,7 @@ namespace mln
/// \internal Generic implementation of the mean of two values.
template <typename T>
- mln_trait_op_div(T,double)
+ mln_trait_routine_mean(2,T)
mean_(const T& v1, const T& v2)
{
return (v1 + v2) / 2.;
@@ -77,24 +77,24 @@ namespace mln
/// \internal Generic implementation of the mean of four values.
template <typename T>
- mln_trait_op_div(T,double)
+ mln_trait_routine_mean(4,T)
mean_(const T& v1, const T& v2, const T& v3, const T& v4)
{
- return (v1 + v2 + v3 + v4) / 4;
+ return (v1 + v2 + v3 + v4) / 4.;
}
namespace math
{
template <typename T>
- mln_trait_op_div(T,double)
+ mln_trait_routine_mean(2,T)
mean(const T& v1, const T& v2)
{
return mean_(exact(v1), exact(v2));
}
template <typename T, typename U>
- mln_trait_op_div(T,double)
+ mln_trait_routine_mean(2,T)
mean(const T& v1, const U& v2)
{
mlc_converts_to(U,T)::check();
@@ -102,14 +102,14 @@ namespace mln
}
template <typename T>
- mln_trait_op_div(T,double)
+ mln_trait_routine_mean(4,T)
mean(const T& v1, const T& v2, const T& v3, const T& v4)
{
return mean_(v1, T(v2), T(v3), T(v4));
}
template <typename T, typename T2, typename T3, typename T4>
- mln_trait_op_div(T,double)
+ mln_trait_routine_mean(4,T)
mean(const T& v1, const T2& v2, const T3& v3, const T4& v4)
{
mlc_converts_to(T2,T)::check();
diff --git a/milena/mln/math/median.hh b/milena/mln/math/median.hh
new file mode 100644
index 0000000..9338b90
--- /dev/null
+++ b/milena/mln/math/median.hh
@@ -0,0 +1,172 @@
+// Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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_MATH_MEDIAN_HH
+# define MLN_MATH_MEDIAN_HH
+
+# include <mln/trait/routine/median.hh>
+# include <mln/math/mean.hh>
+# include <mln/metal/converts_to.hh>
+
+/*! \file
+ *
+ * \brief Define median routine.
+ */
+
+
+namespace mln
+{
+
+ namespace math
+ {
+
+ /// Return the median of two values.
+ template <typename T>
+ mln_trait_routine_median(T)
+ median(const T& v1, const T& v2);
+
+ /// \overload \pre Type U must be convertible towards type T.
+ template <typename T, typename U>
+ mln_trait_routine_median(T)
+ median(const T& v1, const U& v2);
+
+ /// Return the median of four values.
+ template <typename T>
+ mln_trait_routine_median(T)
+ median(const T& v1, const T& v2, const T& v3, const T& v4);
+
+ /// \overload \pre Type T2, T3 and T4 must be convertible towards
+ /// type T.
+ template <typename T, typename T2, typename T3, typename T4>
+ mln_trait_routine_median(T)
+ median(const T& v1, const T2& v2, const T3& v3, const T4& v4);
+
+
+ } // end of namespace mln::math
+
+# ifndef MLN_INCLUDE_ONLY
+
+ /// \internal Generic implementation of the median of four values.
+ template <typename T>
+ mln_trait_routine_median(T)
+ median_(const T& v1, const T& v2, const T& v3, const T& v4)
+ {
+ if (v1 <= v2)
+ if (v2 <= v3)
+ if (v3 <= v4)
+ return mean_(v2, v3);
+ else // v3 > v4
+ if (v4 <= v1)
+ return mean_(v1,v2);
+ else // v4 > v1
+ return mean_(v4,v2);
+ else // v2 > v3
+ if (v1 <= v3)
+ if (v2 <= v4)
+ return mean_(v3, v2);
+ else // v2 > v4
+ if (v4 <= v1)
+ return mean_(v1, v3);
+ else // v4 > v1
+ return mean_(v4, v3);
+ else // v1 > v3
+ if (v2 <= v4)
+ return mean_(v1,v2);
+ else // v2 > v4
+ if (v4 <= v3)
+ return mean_(v3,v1);
+ else // v4 > v3
+ return mean_(v4,v1);
+ else // v1 > v2
+ if (v1 <= v3)
+ if (v4 <= v3)
+ if (v4 <= v2)
+ return mean_(v2, v1);
+ else // v4 > v2
+ return mean_(v1, v4);
+ else // v4 > v2
+ return mean_(v1, v3);
+ else // v1 > v3
+ if (v2 <= v3)
+ if (v4 <= v1)
+ if (v4 <= v2)
+ return mean_(v2, v3);
+ else // v4 > v2
+ return mean_(v4, v3);
+ else // v4 > v1
+ return mean_(v3, v1);
+ else // v2 > v3
+ if (v4 <= v1)
+ if (v3 <= v4)
+ return mean_(v4, v2);
+ else // v3 > v4
+ return mean_(v3, v2);
+ else // v4 > v1
+ return mean_(v2, v1);
+ }
+
+ namespace math
+ {
+
+ template <typename T>
+ mln_trait_routine_median(T)
+ median(const T& v1, const T& v2)
+ {
+ return mean_(exact(v1), exact(v2));
+ }
+
+ template <typename T, typename U>
+ mln_trait_routine_median(T)
+ median(const T& v1, const U& v2)
+ {
+ mlc_converts_to(U,T)::check();
+ return mean_(v1, T(v2));
+ }
+
+ template <typename T>
+ mln_trait_routine_median(T)
+ median(const T& v1, const T& v2, const T& v3, const T& v4)
+ {
+ return median_(v1, T(v2), T(v3), T(v4));
+ }
+
+ template <typename T, typename T2, typename T3, typename T4>
+ mln_trait_routine_median(T)
+ median(const T& v1, const T2& v2, const T3& v3, const T4& v4)
+ {
+ mlc_converts_to(T2,T)::check();
+ mlc_converts_to(T3,T)::check();
+ mlc_converts_to(T4,T)::check();
+ return median_(v1, T(v2), T(v3), T(v4));
+ }
+
+ } // end of namespace mln::math
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MATH_MEDIAN_HH
diff --git a/milena/mln/trait/routine/mean.hh b/milena/mln/trait/routine/mean.hh
index 6d96344..8cdbcc2 100644
--- a/milena/mln/trait/routine/mean.hh
+++ b/milena/mln/trait/routine/mean.hh
@@ -26,8 +26,8 @@
#ifndef MLN_TRAIT_ROUTINE_MEAN_HH
# define MLN_TRAIT_ROUTINE_MEAN_HH
-# define mln_trait_routine_mean(n,T) typename mln::trait::routine::mean<n,T>::ret
-# define mln_trait_routine_mean_(n,T) mln::trait::routine::mean<n,T>::ret
+# define mln_trait_routine_mean(n,T) typename mln::trait::routine::mean< n,T >::ret
+# define mln_trait_routine_mean_(n,T) mln::trait::routine::mean< n,T >::ret
namespace mln
{
@@ -58,6 +58,18 @@ namespace mln
typedef mln::value::intsub<nvalues> ret;
};
+ template <unsigned nvalues>
+ struct mean< nvalues, float >
+ {
+ typedef float ret;
+ };
+
+ template <unsigned nvalues>
+ struct mean< nvalues, double >
+ {
+ typedef double ret;
+ };
+
} // end of namespace mln::trait::routine
} // end of namespace mln::routine
diff --git a/milena/mln/trait/routine/median.hh b/milena/mln/trait/routine/median.hh
new file mode 100644
index 0000000..40ea41e
--- /dev/null
+++ b/milena/mln/trait/routine/median.hh
@@ -0,0 +1,79 @@
+// Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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_TRAIT_ROUTINE_MEDIAN_HH
+# define MLN_TRAIT_ROUTINE_MEDIAN_HH
+
+# define mln_trait_routine_median(T) typename mln::trait::routine::median< T >::ret
+# define mln_trait_routine_median_(T) mln::trait::routine::median< T >::ret
+
+namespace mln
+{
+
+ // Forward Declaration
+ namespace value { template <unsigned n> class intsub; }
+
+ namespace trait
+ {
+
+ namespace routine
+ {
+
+ // median
+
+ template <typename T>
+ struct median
+ {
+ // undef
+ };
+
+
+ // specializations
+
+ template <>
+ struct median< int >
+ {
+ typedef mln::value::intsub<2> ret;
+ };
+
+ template <>
+ struct median< float >
+ {
+ typedef float ret;
+ };
+
+ template <>
+ struct median< double >
+ {
+ typedef double ret;
+ };
+
+ } // end of namespace mln::trait::routine
+
+ } // end of namespace mln::routine
+
+} // end of namespace mln
+
+#endif // ! MLN_TRAIT_ROUTINE_MEDIAN_HH
diff --git a/milena/mln/value/intsub.hh b/milena/mln/value/intsub.hh
index eaff527..5cf6ca5 100644
--- a/milena/mln/value/intsub.hh
+++ b/milena/mln/value/intsub.hh
@@ -37,6 +37,7 @@
# include <algorithm>
# include <mln/core/routine/ops.hh>
# include <mln/trait/routine/mean.hh>
+# include <mln/trait/routine/median.hh>
# include <mln/value/ops.hh>
# include <mln/value/builtin/ops.hh>
# include <mln/value/internal/value_like.hh>
@@ -109,6 +110,12 @@ namespace mln
typedef mln::value::intsub<nvalues * n> ret;
};
+ template <unsigned n>
+ struct median< mln::value::intsub<n> >
+ {
+ typedef mln::value::intsub<2*n> ret;
+ };
+
} // end of namespace mln::trait::routine
} // end of namespace mln::trait
@@ -205,21 +212,19 @@ namespace mln
/// Specific implementation of the mean function.
template <unsigned n>
- intsub<2*n> mean(const intsub<n>& v1, const intsub<n>& v2);
+ mln_trait_routine_mean(2,intsub<n>)
+ mean_(const intsub<n>& v1, const intsub<n>& v2);
/// Specific implementation of the mean function.
template <unsigned n>
- intsub<4*n> mean(const intsub<n>& v1, const intsub<n>& v2,
- const intsub<n>& v3, const intsub<n>& v4);
+ mln_trait_routine_mean(4,intsub<n>)
+ mean_(const intsub<n>& v1, const intsub<n>& v2,
+ const intsub<n>& v3, const intsub<n>& v4);
/// Specific implementation of the median function.
template <unsigned n>
- intsub<2*n> median(const intsub<n>& v1, const intsub<n>& v2);
-
- /// Specific implementation of the median function.
- template <unsigned n>
- intsub<4*n> median(const intsub<n>& v1, const intsub<n>& v2,
- const intsub<n>& v3, const intsub<n>& v4);
+ mln_trait_routine_median(intsub<n>)
+ median_(const intsub<n>& v1, const intsub<n>& v2);
// Iota
@@ -484,55 +489,28 @@ namespace mln
return intsub<n>::make_from_enc_(v1.to_enc() > v2.to_enc() ? v1.to_enc() : v2.to_enc());
}
- // FIXME: Make use of mean_() overloads with math::mean. Require
- // to fix an issue with the return type which differs according to
- // the overload : with 2 (intsub<2*n>) or 4 (intsub<4*n>)
- // arguments.
template <unsigned n>
- intsub<2*n> mean(const intsub<n>& v1, const intsub<n>& v2)
+ mln_trait_routine_mean(2,intsub<n>)
+ mean_(const intsub<n>& v1, const intsub<n>& v2)
{
return intsub<2*n>::make_from_enc_((v1.to_enc() + v2.to_enc()));
}
- // FIXME: Make use of mean_() overloads with math::mean. Require
- // to fix an issue with the return type which differs according to
- // the overload : with 2 (intsub<2*n>) or 4 (intsub<4*n>)
- // arguments.
template <unsigned n>
- intsub<4*n> mean(const intsub<n>& v1, const intsub<n>& v2,
- const intsub<n>& v3, const intsub<n>& v4)
+ mln_trait_routine_mean(4,intsub<n>)
+ mean_(const intsub<n>& v1, const intsub<n>& v2,
+ const intsub<n>& v3, const intsub<n>& v4)
{
return mean_(mean_(v1, v2), mean_(v3, v4));
}
- // FIXME: Make use of median_() overloads with
- // math::median. Require to fix an issue with the return type
- // which differs according to the overload : with 2 (intsub<2*n>)
- // or 4 (intsub<4*n>) arguments.
template <unsigned n>
- intsub<2*n> median(const intsub<n>& v1, const intsub<n>& v2)
+ mln_trait_routine_median(intsub<n>)
+ median_(const intsub<n>& v1, const intsub<n>& v2)
{
- return mean(v1, v2);
- }
-
- // FIXME: Make use of median_() overloads with
- // math::median. Require to fix an issue with the return type
- // which differs according to the overload : with 2 (intsub<2*n>)
- // or 4 (intsub<4*n>) arguments.
- template <unsigned n>
- intsub<4*n> median(const intsub<n>& v1, const intsub<n>& v2,
- const intsub<n>& v3, const intsub<n>& v4)
- {
- std::vector<intsub<n> > vec(4);
- vec.push_back(v1);
- vec.push_back(v2);
- vec.push_back(v3);
- vec.push_back(v4);
- std::sort(vec.begin(), vec.end());
- return mean(vec[1], vec[2]);
+ return mean_(v1, v2);
}
-
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::value
diff --git a/milena/tests/fun/vv2v/Makefile.am b/milena/tests/fun/vv2v/Makefile.am
index d180e3d..47ae244 100644
--- a/milena/tests/fun/vv2v/Makefile.am
+++ b/milena/tests/fun/vv2v/Makefile.am
@@ -1,4 +1,5 @@
-# Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE).
+# Copyright (C) 2008, 2009, 2012 EPITA Research and Development
+# Laboratory (LRDE).
#
# This file is part of Olena.
#
@@ -18,8 +19,12 @@ include $(top_srcdir)/milena/tests/tests.mk
check_PROGRAMS = \
max \
+ mean \
+ median \
min
+mean_SOURCES = mean.cc
+median_SOURCES = median.cc
max_SOURCES = max.cc
min_SOURCES = min.cc
diff --git a/milena/tests/fun/vv2v/mean.cc b/milena/tests/fun/vv2v/mean.cc
new file mode 100644
index 0000000..fc11025
--- /dev/null
+++ b/milena/tests/fun/vv2v/mean.cc
@@ -0,0 +1,71 @@
+// Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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.
+
+#include <mln/fun/vv2v/mean.hh>
+#include <mln/value/intsub.hh>
+
+using namespace mln;
+
+void do_it(float v1, float v2, float res)
+{
+
+ {
+ fun::vv2v::mean<value::intsub<2> > f;
+ mln_assertion(f(v1, v2) == res);
+ }
+
+ {
+ fun::vv2v::mean<int> f;
+ mln_assertion(f(v1, v2) == res);
+ }
+
+ {
+ fun::vv2v::mean<float> f;
+ mln_assertion(f(v1, v2) == res);
+ }
+}
+
+
+void do_it2(float v1, float v2, float res)
+{
+ {
+ fun::vv2v::mean<value::intsub<2> > f;
+ mln_assertion(f(v1, v2) == res);
+ }
+
+ {
+ fun::vv2v::mean<float> f;
+ mln_assertion(f(v1, v2) == res);
+ }
+}
+
+
+int main()
+{
+ do_it(3, 4, 3.5);
+ do_it(0, 4, 2);
+
+ do_it2(0, 4.5, 2.25);
+}
diff --git a/milena/tests/fun/vv2v/median.cc b/milena/tests/fun/vv2v/median.cc
new file mode 100644
index 0000000..1bf83d6
--- /dev/null
+++ b/milena/tests/fun/vv2v/median.cc
@@ -0,0 +1,71 @@
+// Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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.
+
+#include <mln/fun/vv2v/median.hh>
+#include <mln/value/intsub.hh>
+
+using namespace mln;
+
+void do_it(float v1, float v2, float res)
+{
+
+ {
+ fun::vv2v::median<value::intsub<2> > f;
+ mln_assertion(f(v1, v2) == res);
+ }
+
+ {
+ fun::vv2v::median<int> f;
+ mln_assertion(f(v1, v2) == res);
+ }
+
+ {
+ fun::vv2v::median<float> f;
+ mln_assertion(f(v1, v2) == res);
+ }
+}
+
+
+void do_it2(float v1, float v2, float res)
+{
+ {
+ fun::vv2v::median<value::intsub<2> > f;
+ mln_assertion(f(v1, v2) == res);
+ }
+
+ {
+ fun::vv2v::median<float> f;
+ mln_assertion(f(v1, v2) == res);
+ }
+}
+
+
+int main()
+{
+ do_it(3, 4, 3.5);
+ do_it(0, 4, 2);
+
+ do_it2(0, 4.5, 2.25);
+}
diff --git a/milena/tests/math/Makefile.am b/milena/tests/math/Makefile.am
index 4c3ccb4..864e21c 100644
--- a/milena/tests/math/Makefile.am
+++ b/milena/tests/math/Makefile.am
@@ -1,4 +1,5 @@
-# Copyright (C) 2007, 2009 EPITA Research and Development Laboratory (LRDE).
+# Copyright (C) 2007, 2009, 2012 EPITA Research and Development
+# Laboratory (LRDE).
#
# This file is part of Olena.
#
@@ -15,3 +16,13 @@
# along with Olena. If not, see <http://www.gnu.org/licenses/>.
include $(top_srcdir)/milena/tests/tests.mk
+
+check_PROGRAMS = \
+ mean \
+ median
+
+mean_SOURCES = mean.cc
+median_SOURCES = median.cc
+
+
+TESTS = $(check_PROGRAMS)
diff --git a/milena/tests/math/mean.cc b/milena/tests/math/mean.cc
new file mode 100644
index 0000000..a62cab6
--- /dev/null
+++ b/milena/tests/math/mean.cc
@@ -0,0 +1,47 @@
+// Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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.
+
+#include <mln/math/mean.hh>
+#include <mln/value/intsub.hh>
+
+int main()
+{
+ using namespace mln;
+
+ mln_assertion(math::mean(2,3) == 2.5);
+
+ {
+ value::intsub<2> v1(1.5);
+ value::intsub<2> v2(2);
+ mln_assertion(math::mean(v1, v2) == 1.75);
+ }
+
+ mln_assertion(math::mean(1,2,3,4) == 2.5);
+
+ {
+ value::intsub<2> v1(1), v2(2), v3(3), v4(5);
+ mln_assertion(math::mean(v1, v2, v3, v4) == 2.75);
+ }
+}
diff --git a/milena/tests/math/median.cc b/milena/tests/math/median.cc
new file mode 100644
index 0000000..5c0a58d
--- /dev/null
+++ b/milena/tests/math/median.cc
@@ -0,0 +1,90 @@
+// Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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.
+
+#include <mln/math/median.hh>
+#include <mln/value/intsub.hh>
+
+template <typename T>
+void do_it(std::vector<T>& vec, float res)
+{
+ for (int i = 0; i < 3; ++i)
+ {
+ for (int j = 0; j < 3; ++j)
+ {
+ for (int k = 0; k < 3; ++k)
+ {
+ mln_assertion(mln::math::median(vec[0], vec[1], vec[2], vec[3]) == res);
+ std::swap(vec[k], vec[k + 1]);
+ }
+ }
+ }
+}
+
+int main()
+{
+ using namespace mln;
+
+ {
+ mln_assertion(math::median(2,3) == 2.5);
+ }
+
+ {
+ value::intsub<2> v1(1.5);
+ value::intsub<2> v2(2);
+ mln_assertion(math::median(v1, v2) == 1.75);
+ }
+
+ {
+ std::vector<int> vec(4);
+ vec[0] = 1;
+ vec[1] = 2;
+ vec[2] = 3;
+ vec[3] = 4;
+
+ do_it(vec, 2.5);
+ }
+
+ {
+ std::vector<int> vec(4);
+ vec[0] = 0;
+ vec[1] = 0;
+ vec[2] = 6;
+ vec[3] = 24;
+
+ do_it(vec, 3);
+ }
+
+
+ {
+ std::vector<value::intsub<2> > vec(4);
+ vec[0] = 2;
+ vec[1] = 1.5;
+ vec[2] = 3;
+ vec[3] = 5;
+
+ do_it(vec, 2.5);
+ }
+
+}
--
1.7.2.5
1
0