* 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