* mln/world/k1/fill_0_1_faces_internal_border.hh,
* tests/world/k1/fill_0_1_faces_internal_border.cc: New.
* tests/world/k1/Makefile.am: New target.
---
milena/ChangeLog | 9 ++
..._faces.hh => fill_0_1_faces_internal_border.hh} | 79 +++++++++----------
milena/tests/world/k1/Makefile.am | 2 +
...mmerse.cc => fill_0_1_faces_internal_border.cc} | 29 ++++---
4 files changed, 65 insertions(+), 54 deletions(-)
copy milena/mln/world/k1/{fill_0_from_primary_faces.hh =>
fill_0_1_faces_internal_border.hh} (53%)
copy milena/tests/world/k1/{un_immerse.cc => fill_0_1_faces_internal_border.cc} (76%)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 0744148..525ab23 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,12 @@
+2012-09-28 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ New routine for filling internal border in K1.
+
+ * mln/world/k1/fill_0_1_faces_internal_border.hh,
+ * tests/world/k1/fill_0_1_faces_internal_border.cc: New.
+
+ * tests/world/k1/Makefile.am: New target.
+
2012-09-27 Guillaume Lazzara <z(a)lrde.epita.fr>
* mln/world/k1/neighb2d.hh: New neighborhoods.
diff --git a/milena/mln/world/k1/fill_0_from_primary_faces.hh
b/milena/mln/world/k1/fill_0_1_faces_internal_border.hh
similarity index 53%
copy from milena/mln/world/k1/fill_0_from_primary_faces.hh
copy to milena/mln/world/k1/fill_0_1_faces_internal_border.hh
index db3aed8..0ee3d27 100644
--- a/milena/mln/world/k1/fill_0_from_primary_faces.hh
+++ b/milena/mln/world/k1/fill_0_1_faces_internal_border.hh
@@ -25,13 +25,13 @@
/// \file
///
-/// \brief Fill 1 faces in a K1 2D image using its primary faces.
+/// \brief Fill 0 and 1 faces border with a value in a K1 2D image.
-#ifndef MLN_WORLD_K1_FILL_0_FROM_PRIMARY_FACES_HH
-# define MLN_WORLD_K1_FILL_0_FROM_PRIMARY_FACES_HH
+#ifndef MLN_WORLD_K1_FILL_0_1_FACES_INTERNAL_BORDER_HH
+# define MLN_WORLD_K1_FILL_0_1_FACES_INTERNAL_BORDER_HH
# include <mln/core/alias/point2d.hh>
-# include <mln/world/k1/fill_0_from_2_faces.hh>
+# include <mln/world/k1/is_0_face.hh>
namespace mln
@@ -43,27 +43,23 @@ namespace mln
namespace k1
{
- /*! \brief Fill 0 faces in a K1 2D image using its primary faces.
+ /*! \brief Fill 0 and 1 faces border with a value in a K1 2D image.
\param[in,out] inout A 2D image immersed in K1.
- \param[in,out] f A functor computing a result from four values.
+ \param[in] v The border value.
- This function use the following neighborhood:
-
- \verbatim
- x x
- .
- x x
- \endverbatim
+ Example with \p v=1:
+ . - . - . 1 1 1 1 1
+ | o | o | 1 o | o 1
+ . - . - . -> 1 - . - 1
+ | o | o | 1 o | o 1
+ . - . - . 1 1 1 1 1
*/
- template <typename I, typename F>
- void fill_0_from_primary_faces(Image<I>& inout,
Function_vvvv2v<F>& f);
+ template <typename I>
+ void fill_0_1_faces_internal_border(Image<I>& inout, const
mln_value(I)& v);
- /// \overload
- template <typename I, typename A>
- void fill_0_from_primary_faces(Image<I>& inout, const
Accumulator<A>& accu);
# ifndef MLN_INCLUDE_ONLY
@@ -72,32 +68,31 @@ namespace mln
// Facade
- template <typename I, typename F>
- void fill_0_from_primary_faces(Image<I>& inout,
Function_vvvv2v<F>& f)
- {
- trace::entering("mln::world::k1::fill_0_from_primary_faces");
-
- mln_precondition(exact(inout).is_valid());
-
- fill_0_from_2_faces(inout, f);
-
- trace::exiting("mln::world::k1::fill_0_from_primary_faces");
- }
-
-
- template <typename I, typename A>
- void fill_0_from_primary_faces(Image<I>& inout, const
Accumulator<A>& accu)
+ template <typename I>
+ void fill_0_1_faces_internal_border(Image<I>& inout_, const
mln_value(I)& v)
{
- trace::entering("mln::world::k1::fill_0_from_primary_faces");
-
- mln_precondition(exact(inout).is_valid());
-
- fill_0_from_2_faces(inout, accu);
-
- trace::exiting("mln::world::k1::fill_0_from_primary_faces");
+ trace::entering("mln::world::k1::fill_0_1_faces_internal_border");
+
+ mln_precondition(exact(inout_).is_valid());
+ I& inout = exact(inout_);
+
+ // Horizontal borders
+ for (mln::def::coord col = geom::min_col(inout); col <= geom::max_col(inout); ++col)
+ {
+ inout.at_(geom::min_row(inout), col) = v;
+ inout.at_(geom::max_row(inout), col) = v;
+ }
+
+ // Vertical borders
+ for (mln::def::coord row = geom::min_row(inout); row <= geom::max_row(inout); ++row)
+ {
+ inout.at_(row, geom::min_col(inout)) = v;
+ inout.at_(row, geom::max_col(inout)) = v;
+ }
+
+ trace::exiting("mln::world::k1::fill_0_1_faces_internal_border");
}
-
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::world::k1
@@ -106,4 +101,4 @@ namespace mln
} // end of namespace mln
-#endif // ! MLN_WORLD_K1_FILL_0_FROM_PRIMARY_FACES_HH
+#endif // ! MLN_WORLD_K1_FILL_0_1_FACES_INTERNAL_BORDER_HH
diff --git a/milena/tests/world/k1/Makefile.am b/milena/tests/world/k1/Makefile.am
index 68866fb..0027267 100644
--- a/milena/tests/world/k1/Makefile.am
+++ b/milena/tests/world/k1/Makefile.am
@@ -18,6 +18,7 @@ include $(top_srcdir)/milena/tests/tests.mk
check_PROGRAMS = \
display_enlarged \
+ fill_0_1_faces_internal_border \
fill_0_from_1_faces \
fill_0_from_2_faces \
fill_0_from_primary_faces \
@@ -37,6 +38,7 @@ check_PROGRAMS = \
un_immerse
display_enlarged_SOURCES = display_enlarged.cc
+fill_0_1_faces_border_SOURCES = fill_0_1_faces_border.cc
fill_0_from_1_faces_SOURCES = fill_0_from_1_faces.cc
fill_0_from_2_faces_SOURCES = fill_0_from_2_faces.cc
fill_0_from_primary_faces_SOURCES = fill_0_from_primary_faces.cc
diff --git a/milena/tests/world/k1/un_immerse.cc
b/milena/tests/world/k1/fill_0_1_faces_internal_border.cc
similarity index 76%
copy from milena/tests/world/k1/un_immerse.cc
copy to milena/tests/world/k1/fill_0_1_faces_internal_border.cc
index 47e06e4..fbb9f73 100644
--- a/milena/tests/world/k1/un_immerse.cc
+++ b/milena/tests/world/k1/fill_0_1_faces_internal_border.cc
@@ -26,29 +26,34 @@
/// \file
#include <mln/core/image/image2d.hh>
-#include <mln/world/k1/un_immerse.hh>
#include <mln/make/box2d.hh>
#include <mln/data/compare.hh>
+#include <mln/world/k1/fill_0_1_faces_internal_border.hh>
int main()
{
using namespace mln;
- int refvals[2][2] = {
- {3, 3},
- {3, 3}
+ int refvals[5][5] = {
+ {1, 1, 1, 1, 1 },
+ {1, 2, 0, 2, 1 },
+ {1, 0, 0, 0, 1 },
+ {1, 2, 0, 2, 1 },
+ {1, 1, 1, 1, 1 }
};
- image2d<int> ref = make::image(refvals);
+ image2d<int> ref = make::image(refvals, point2d(-1, -1));
int vals[5][5] = {
- {1, 2, 1, 2, 1 },
- {2, 3, 2, 3, 2 },
- {1, 2, 1, 2, 1 },
- {2, 3, 2, 3, 2 },
- {1, 2, 1, 2, 1 }
+ {0, 0, 0, 0, 0 },
+ {0, 2, 0, 2, 0 },
+ {0, 0, 0, 0, 0 },
+ {0, 2, 0, 2, 0 },
+ {0, 0, 0, 0, 0 }
};
image2d<int> imak1 = make::image(vals, point2d(-1, -1));
- image2d<int> imak0 = world::k1::un_immerse(imak1);
- mln_assertion(imak0 == ref);
+ {
+ world::k1::fill_0_1_faces_internal_border(imak1, 1);
+ mln_assertion(ref == imak1);
+ }
}
--
1.7.2.5