* mln/world/kn/border/compute_1_faces.hh: New.
* mln/world/k1/fill_1_from_2_faces.hh,
* mln/world/kn/fill_1_from_2_faces.hh,
* mln/world/kn/fill_1_from_aux_2_faces.hh: Make use of
kn::border::compute_1_faces.
---
milena/ChangeLog | 11 +++
milena/mln/world/k1/fill_1_from_2_faces.hh | 3 +
.../{duplicate_2_faces.hh => compute_1_faces.hh} | 85 ++++++++------------
milena/mln/world/kn/fill_1_from_2_faces.hh | 3 +
milena/mln/world/kn/fill_1_from_aux_2_faces.hh | 3 +
5 files changed, 54 insertions(+), 51 deletions(-)
copy milena/mln/world/kn/border/{duplicate_2_faces.hh => compute_1_faces.hh} (57%)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index f93a95b..31adb4c 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,14 @@
+2012-10-29 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Add kn::border::compute_1_faces.
+
+ * mln/world/kn/border/compute_1_faces.hh: New.
+
+ * mln/world/k1/fill_1_from_2_faces.hh,
+ * mln/world/kn/fill_1_from_2_faces.hh,
+ * mln/world/kn/fill_1_from_aux_2_faces.hh: Make use of
+ kn::border::compute_1_faces.
+
2012-10-26 Guillaume Lazzara <z(a)lrde.epita.fr>
Various fixes.
diff --git a/milena/mln/world/k1/fill_1_from_2_faces.hh
b/milena/mln/world/k1/fill_1_from_2_faces.hh
index 3db133f..72922ec 100644
--- a/milena/mln/world/k1/fill_1_from_2_faces.hh
+++ b/milena/mln/world/k1/fill_1_from_2_faces.hh
@@ -33,6 +33,7 @@
# include <mln/core/alias/point2d.hh>
# include <mln/world/kn/is_1_face_vertical.hh>
# include <mln/world/kn/is_1_face_horizontal.hh>
+# include <mln/world/kn/border/compute_1_faces.hh>
namespace mln
{
@@ -90,6 +91,8 @@ namespace mln
I& inout = exact(inout_);
const F& f = exact(f_);
+ kn::border::compute_1_faces(inout, f);
+
mln_box(I) b = inout.domain();
mln_piter(I) p(b);
for_all(p)
diff --git a/milena/mln/world/kn/border/duplicate_2_faces.hh
b/milena/mln/world/kn/border/compute_1_faces.hh
similarity index 57%
copy from milena/mln/world/kn/border/duplicate_2_faces.hh
copy to milena/mln/world/kn/border/compute_1_faces.hh
index 2d1c89f..9788efc 100644
--- a/milena/mln/world/kn/border/duplicate_2_faces.hh
+++ b/milena/mln/world/kn/border/compute_1_faces.hh
@@ -27,11 +27,13 @@
///
/// \brief Duplicate 2 faces in KN 2D images borders.
-#ifndef MLN_WORLD_KN_BORDER_DUPLICATE_2_FACES_HH
-# define MLN_WORLD_KN_BORDER_DUPLICATE_2_FACES_HH
+#ifndef MLN_WORLD_KN_BORDER_COMPUTE_1_FACES_HH
+# define MLN_WORLD_KN_BORDER_COMPUTE_1_FACES_HH
# include <mln/core/concept/image.hh>
# include <mln/world/kn/is_2_face.hh>
+# include <mln/world/kn/is_1_face_horizontal.hh>
+# include <mln/world/kn/is_1_face_vertical.hh>
# include <mln/geom/min_row.hh>
# include <mln/geom/min_col.hh>
# include <mln/geom/max_row.hh>
@@ -50,84 +52,65 @@ namespace mln
namespace border
{
- /*! \brief Duplicate 2 faces in Kn 2D images borders.
+ /*! \brief Compute 1 faces in Kn 2D images borders.
\param[in,out] inout A 2D image immersed in KN.
+ \param[in,out] f A function computing 1-faces values from 2
+ 2-faces values.
*/
- template <typename I>
- void duplicate_2_faces(Image<I>& inout);
+ template <typename I, typename F>
+ void compute_1_faces(Image<I>& inout, const Function_vv2v<F>&
f);
# ifndef MLN_INCLUDE_ONLY
- template <typename I>
- void duplicate_2_faces(Image<I>& inout_)
+ template <typename I, typename F>
+ void compute_1_faces(Image<I>& inout_, const Function_vv2v<F>&
f_)
{
- trace::entering("mln::world::kn::duplicate_2_faces");
+ trace::entering("mln::world::kn::compute_1_faces");
mln_precondition(exact(inout_).is_valid());
- mln_precondition(exact(inout_).border() > 0);
+ mln_precondition(exact(inout_).border() >= 1);
I& inout = exact(inout_);
+ const F& f = exact(f_);
def::coord
- min_row_1 = geom::min_row(inout) + 1,
- max_row_1 = geom::max_row(inout) - 1,
- min_col_1 = geom::min_col(inout) + 1,
- max_col_1 = geom::max_col(inout) - 1;
-
- /* Fill horizontal border
-
- a b
- . - . - .
- | a | b |
- . - . - .
- a b
- */
+ min_row_1 = geom::min_row(inout) - 1,
+ max_row_1 = geom::max_row(inout) + 1,
+ min_col_1 = geom::min_col(inout) - 1,
+ max_col_1 = geom::max_col(inout) + 1;
+
+ // Fill horizontal border
for (def::coord col = min_col_1; col <= max_col_1; ++col)
{
- if (is_2_face(min_row_1, col))
+ std::cout << min_row_1 << "," << col << std::endl;
+ if (is_1_face_vertical(min_row_1, col))
{
// First row
- inout.at_(min_row_1 - 2, col) = inout.at_(min_row_1, col);
+ inout.at_(min_row_1, col) = f(inout.at_(min_row_1, col - 1),
+ inout.at_(min_row_1, col + 1));
// Last row
- inout.at_(max_row_1 + 2, col) = inout.at_(max_row_1, col);
+ inout.at_(max_row_1, col) = f(inout.at_(max_row_1, col - 1),
+ inout.at_(max_row_1, col + 1));
}
}
- /* Fill vertical border
-
-
- . - . - .
- a | a | b | b
- . - . - .
-
- */
+ // Fill vertical border
for (def::coord row = min_row_1; row <= max_row_1; ++row)
- if (is_2_face(row, min_col_1))
+ if (is_1_face_horizontal(row, min_col_1))
{
// First col
- inout.at_(row, min_col_1 - 2) = inout.at_(row, min_col_1);
+ inout.at_(row, min_col_1) = f(inout.at_(row - 1, min_col_1),
+ inout.at_(row + 1, min_col_1));
// Last col
- inout.at_(row, max_col_1 + 2) = inout.at_(row, max_col_1);
+ inout.at_(row, max_col_1) = f(inout.at_(row - 1, max_col_1),
+ inout.at_(row + 1, max_col_1));
}
- /* Handle the four corners
-
- a | | b
- - . - . - . -
- | a | b |
- - . - . - . -
- a | | b
- */
- inout.at_(min_row_1 - 2, min_col_1 - 2) = inout.at_(min_row_1, min_col_1);
- inout.at_(min_row_1 - 2, max_col_1 + 2) = inout.at_(min_row_1, max_col_1);
- inout.at_(max_row_1 + 2, min_col_1 - 2) = inout.at_(max_row_1, min_col_1);
- inout.at_(max_row_1 + 2, max_col_1 + 2) = inout.at_(max_row_1, max_col_1);
-
- trace::exiting("mln::world::kn::duplicate_2_faces");
+ trace::exiting("mln::world::kn::compute_1_faces");
}
@@ -141,4 +124,4 @@ namespace mln
} // end of namespace mln
-#endif // ! MLN_WORLD_KN_BORDER_DUPLICATE_2_FACES_HH
+#endif // ! MLN_WORLD_KN_BORDER_COMPUTE_1_FACES_HH
diff --git a/milena/mln/world/kn/fill_1_from_2_faces.hh
b/milena/mln/world/kn/fill_1_from_2_faces.hh
index 0c024b3..2177f48 100644
--- a/milena/mln/world/kn/fill_1_from_2_faces.hh
+++ b/milena/mln/world/kn/fill_1_from_2_faces.hh
@@ -33,6 +33,7 @@
# include <mln/core/alias/point2d.hh>
# include <mln/world/kn/is_1_face_vertical.hh>
# include <mln/world/kn/is_1_face_horizontal.hh>
+# include <mln/world/kn/border/compute_1_faces.hh>
namespace mln
{
@@ -124,6 +125,8 @@ namespace mln
I& inout = exact(inout_);
const F& f = exact(f_);
+ kn::border::compute_1_faces(inout, f);
+
mln_piter(I) p(inout.domain());
for_all(p)
if (kn::is_1_face_vertical(p))
diff --git a/milena/mln/world/kn/fill_1_from_aux_2_faces.hh
b/milena/mln/world/kn/fill_1_from_aux_2_faces.hh
index 987e3b7..820e78f 100644
--- a/milena/mln/world/kn/fill_1_from_aux_2_faces.hh
+++ b/milena/mln/world/kn/fill_1_from_aux_2_faces.hh
@@ -34,6 +34,7 @@
# include <mln/core/alias/point2d.hh>
# include <mln/world/kn/is_1_face_vertical.hh>
# include <mln/world/kn/is_1_face_horizontal.hh>
+# include <mln/world/kn/border/compute_1_faces.hh>
namespace mln
{
@@ -102,6 +103,8 @@ namespace mln
const J& aux = exact(aux_);
F& f = exact(f_);
+ kn::border::compute_1_faces(inout, f);
+
mln_piter(I) p(inout.domain());
for_all(p)
if (kn::is_1_face_vertical(p))
--
1.7.2.5