* mln/world/kn/internal/fill_primary_2_faces_from_input.hh:
Duplicate 2-faces values in border.
* tests/world/k1/fill_1_from_2_faces.cc,
* tests/world/kn/fill_1_from_2_faces.cc,
* tests/world/kn/fill_1_from_aux_2_faces.cc: Update tests.
---
milena/ChangeLog | 11 +++
.../kn/internal/fill_primary_2_faces_from_input.hh | 3 +
milena/tests/world/k1/fill_1_from_2_faces.cc | 82 ++++++++++---------
milena/tests/world/kn/fill_1_from_2_faces.cc | 59 +++++++--------
milena/tests/world/kn/fill_1_from_aux_2_faces.cc | 61 ++++++---------
5 files changed, 108 insertions(+), 108 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index e6c6d2e..6c1f276 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,16 @@
2012-10-26 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Handle border effects while computing 1-faces values.
+
+ * mln/world/kn/internal/fill_primary_2_faces_from_input.hh:
+ Duplicate 2-faces values in border.
+
+ * tests/world/k1/fill_1_from_2_faces.cc,
+ * tests/world/kn/fill_1_from_2_faces.cc,
+ * tests/world/kn/fill_1_from_aux_2_faces.cc: Update tests.
+
+2012-10-26 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Improve interface of hqueues.
* mln/util/hqueue.hh: Do not return queues directly.
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
index 04baddc..6a6e31e 100644
--- 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
@@ -33,6 +33,7 @@
# include <mln/world/kn/internal/immerse_point.hh>
# include <mln/world/kn/safe_cast.hh>
+# include <mln/world/kn/border/adjust_duplicate_2_faces.hh>
namespace mln
{
@@ -91,6 +92,8 @@ namespace mln
ima_kn(pout) = safe_cast_to<V>(ima(p));
}
+ kn::border::adjust_duplicate_2_faces(ima_kn, 1);
+
trace::exiting("mln::world::kn::internal::fill_primary_2_faces_from_input");
}
diff --git a/milena/tests/world/k1/fill_1_from_2_faces.cc
b/milena/tests/world/k1/fill_1_from_2_faces.cc
index 4045674..45f821e 100644
--- a/milena/tests/world/k1/fill_1_from_2_faces.cc
+++ b/milena/tests/world/k1/fill_1_from_2_faces.cc
@@ -26,28 +26,11 @@
/// \file
#include <mln/core/image/image2d.hh>
-#include <mln/make/box2d.hh>
#include <mln/data/compare.hh>
#include <mln/accu/math/sum.hh>
+#include <mln/fun/vv2v/sum.hh>
#include <mln/world/k1/fill_1_from_2_faces.hh>
-#include <mln/border/fill.hh>
-
-
-namespace mln
-{
-
- struct sum_t : Function_vv2v<sum_t>
- {
- typedef int result;
-
- int operator()(const int& v1, const int& v2) const
- {
- return v1 + v2;
- }
-
- };
-
-}
+#include <mln/world/kn/border/duplicate_2_faces.hh>
@@ -55,31 +38,52 @@ int main()
{
using namespace mln;
- int refvals[5][5] = {
- {1, 3, 1, 3, 1},
- {3, 3, 6, 3, 3},
- {1, 6, 1, 6, 1},
- {3, 3, 6, 3, 3},
- {1, 3, 1, 3, 1}
- };
- image2d<int> ref = make::image(refvals, point2d(-1, -1));
-
- int vals[5][5] = {
- {1, 0, 1, 0, 1 },
- {0, 3, 0, 3, 0 },
- {1, 0, 1, 0, 1 },
- {0, 3, 0, 3, 0 },
- {1, 0, 1, 0, 1 }
+ int vals[7][7] = {
+ {1, 0, 1, 0, 1, 0, 1 },
+ {0, 3, 0, 3, 0, 3, 0 },
+ {1, 0, 1, 0, 1, 0, 1 },
+ {0, 3, 0, 3, 0, 3, 0 },
+ {1, 0, 1, 0, 1, 0, 1 },
+ {0, 3, 0, 3, 0, 3, 0 },
+ {1, 0, 1, 0, 1, 0, 1 },
};
image2d<int> imakn = make::image(vals, point2d(-1, -1));
-
- /// Make sure the border is set to 0 to get deterministic results.
- border::fill(imakn, 0);
+ world::kn::border::duplicate_2_faces(imakn);
// Overload with function
{
- sum_t f;
- world::k1::fill_1_from_2_faces(imakn, f);
+ int refvals[7][7] = {
+ {1, 6, 1, 6, 1, 6, 1 },
+ {6, 3, 6, 3, 6, 3, 6 },
+ {1, 6, 1, 6, 1, 6, 1 },
+ {6, 3, 6, 3, 6, 3, 6 },
+ {1, 6, 1, 6, 1, 6, 1 },
+ {6, 3, 6, 3, 6, 3, 6 },
+ {1, 6, 1, 6, 1, 6, 1 },
+ };
+
+ image2d<int> ref = make::image(refvals, point2d(-1, -1));
+
+ world::k1::fill_1_from_2_faces(imakn, fun::vv2v::sum<int>());
+ mln_assertion(ref == imakn);
+ }
+
+ // Overload with accumulator
+ {
+ int refvals[7][7] = {
+ {1, 3, 1, 3, 1, 3, 1 },
+ {3, 3, 6, 3, 6, 3, 3 },
+ {1, 6, 1, 6, 1, 6, 1 },
+ {3, 3, 6, 3, 6, 3, 3 },
+ {1, 6, 1, 6, 1, 6, 1 },
+ {3, 3, 6, 3, 6, 3, 3 },
+ {1, 3, 1, 3, 1, 3, 1 },
+ };
+
+ image2d<int> ref = make::image(refvals, point2d(-1, -1));
+
+ accu::math::sum<int> accu;;
+ world::k1::fill_1_from_2_faces(imakn, accu);
mln_assertion(ref == imakn);
}
diff --git a/milena/tests/world/kn/fill_1_from_2_faces.cc
b/milena/tests/world/kn/fill_1_from_2_faces.cc
index bd14ace..dafb63c 100644
--- a/milena/tests/world/kn/fill_1_from_2_faces.cc
+++ b/milena/tests/world/kn/fill_1_from_2_faces.cc
@@ -29,41 +29,15 @@
#include <mln/make/box2d.hh>
#include <mln/data/compare.hh>
#include <mln/accu/math/sum.hh>
+#include <mln/fun/vv2v/sum.hh>
#include <mln/world/kn/fill_1_from_2_faces.hh>
-#include <mln/border/fill.hh>
-
-
-namespace mln
-{
-
- struct sum_t : Function_vv2v<sum_t>
- {
- typedef int result;
-
- int operator()(const int& v1, const int& v2) const
- {
- return v1 + v2;
- }
-
- };
-
-}
-
+#include <mln/world/kn/border/duplicate_2_faces.hh>
int main()
{
using namespace mln;
- int refvals[5][5] = {
- {1, 3, 1, 3, 1},
- {3, 3, 6, 3, 3},
- {1, 6, 1, 6, 1},
- {3, 3, 6, 3, 3},
- {1, 3, 1, 3, 1}
- };
- image2d<int> ref = make::image(refvals, point2d(-1, -1));
-
int vals[5][5] = {
{1, 0, 1, 0, 1 },
{0, 3, 0, 3, 0 },
@@ -72,16 +46,37 @@ int main()
{1, 0, 1, 0, 1 }
};
image2d<int> imakn = make::image(vals, point2d(-1, -1));
-
- /// Make sure the border is set to 0 to get deterministic results.
- border::fill(imakn, 0);
-
+ world::kn::border::duplicate_2_faces(imakn);
// Overload with accumulator
{
+ int refvals[5][5] = {
+ {1, 3, 1, 3, 1},
+ {3, 3, 6, 3, 3},
+ {1, 6, 1, 6, 1},
+ {3, 3, 6, 3, 3},
+ {1, 3, 1, 3, 1}
+ };
+ image2d<int> ref = make::image(refvals, point2d(-1, -1));
+
accu::math::sum<int> accu;
world::kn::fill_1_from_2_faces(imakn, accu);
mln_assertion(ref == imakn);
}
+ // Overload with Functions
+ {
+ int refvals[5][5] = {
+ {1, 6, 1, 6, 1},
+ {6, 3, 6, 3, 6},
+ {1, 6, 1, 6, 1},
+ {6, 3, 6, 3, 6},
+ {1, 6, 1, 6, 1}
+ };
+ image2d<int> ref = make::image(refvals, point2d(-1, -1));
+
+ world::kn::fill_1_from_2_faces(imakn, fun::vv2v::sum<int>());
+ mln_assertion(ref == imakn);
+ }
+
}
diff --git a/milena/tests/world/kn/fill_1_from_aux_2_faces.cc
b/milena/tests/world/kn/fill_1_from_aux_2_faces.cc
index 1475f75..20e1c2a 100644
--- a/milena/tests/world/kn/fill_1_from_aux_2_faces.cc
+++ b/milena/tests/world/kn/fill_1_from_aux_2_faces.cc
@@ -26,53 +26,25 @@
/// \file
#include <mln/core/image/image2d.hh>
-#include <mln/make/box2d.hh>
#include <mln/data/compare.hh>
#include <mln/accu/math/sum.hh>
+#include <mln/fun/vv2v/sum.hh>
#include <mln/world/kn/fill_1_from_aux_2_faces.hh>
-#include <mln/border/fill.hh>
-
-
-namespace mln
-{
-
- struct sum_t : Function_vv2v<sum_t>
- {
- typedef int result;
-
- int operator()(const int& v1, const int& v2) const
- {
- return v1 + v2;
- }
-
- };
-
-}
-
-
+#include <mln/world/kn/border/duplicate_2_faces.hh>
int main()
{
using namespace mln;
- int refvals[5][5] = {
- {1, 1, 1, 4, 1},
- {1, 3, 5, 3, 4},
- {1, 5, 1, 5, 1},
- {4, 3, 5, 3, 1},
- {1, 4, 1, 1, 1}
- };
- image2d<int> ref = make::image(refvals, point2d(-1, -1));
-
int auxvals[5][5] = {
{0, 0, 0, 0, 0 },
{0, 1, 0, 4, 0 },
{0, 0, 0, 0, 0 },
{0, 4, 0, 1, 0 },
- {0, 0, 0, 0, 1 }
+ {0, 0, 0, 0, 0 }
};
image2d<int> aux = make::image(auxvals, point2d(-1, -1));
-
+ world::kn::border::duplicate_2_faces(aux);
int vals[5][5] = {
{1, 0, 1, 0, 1 },
@@ -83,12 +55,17 @@ int main()
};
image2d<int> imakn = make::image(vals, point2d(-1, -1));
- /// Make sure the border is set to 0 to get deterministic results.
- border::fill(imakn, 0);
-
-
// Overload with accumulator
{
+ int refvals[5][5] = {
+ {1, 1, 1, 4, 1},
+ {1, 3, 5, 3, 4},
+ {1, 5, 1, 5, 1},
+ {4, 3, 5, 3, 1},
+ {1, 4, 1, 1, 1}
+ };
+ image2d<int> ref = make::image(refvals, point2d(-1, -1));
+
accu::math::sum<int> accu;
world::kn::fill_1_from_aux_2_faces(imakn, aux, accu);
mln_assertion(ref == imakn);
@@ -96,8 +73,18 @@ int main()
// Overload with function
{
- sum_t f;
+ int refvals[5][5] = {
+ {1, 2, 1, 8, 1},
+ {2, 3, 5, 3, 8},
+ {1, 5, 1, 5, 1},
+ {8, 3, 5, 3, 2},
+ {1, 8, 1, 2, 1}
+ };
+ image2d<int> ref = make::image(refvals, point2d(-1, -1));
+
+ fun::vv2v::sum<int> f;
world::kn::fill_1_from_aux_2_faces(imakn, aux, f);
+
mln_assertion(ref == imakn);
}
--
1.7.2.5