* mln/border/fill.hh (mln::border::impl::fill_size_1): Here.
Aesthetic changes.
* tests/border/fill_0.cc: New test.
* tests/border/Makefile.am (check_PROGRAMS): Add fill_0.
(fill_0_SOURCES): New.
---
milena/ChangeLog | 10 +++++
milena/mln/border/fill.hh | 31 ++++++++-------
milena/mln/core/box_runstart_piter.hh | 2 +
milena/tests/border/Makefile.am | 4 +-
.../sauvola.cc => milena/tests/border/fill_0.cc | 42 ++++++++++++--------
5 files changed, 57 insertions(+), 32 deletions(-)
copy scribo/tests/binarization/sauvola.cc => milena/tests/border/fill_0.cc (66%)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index e565b8b..544cc30 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,13 @@
+2011-10-04 Roland Levillain <roland(a)lrde.epita.fr>
+
+ Handle the case of filling an empty border.
+
+ * mln/border/fill.hh (mln::border::impl::fill_size_1): Here.
+ Aesthetic changes.
+ * tests/border/fill_0.cc: New test.
+ * tests/border/Makefile.am (check_PROGRAMS): Add fill_0.
+ (fill_0_SOURCES): New.
+
2011-09-15 Roland Levillain <roland(a)lrde.epita.fr>
Update Milena tests w.r.t. the new version of lena.pgm.
diff --git a/milena/mln/border/fill.hh b/milena/mln/border/fill.hh
index 6bc690e..5c04121 100644
--- a/milena/mln/border/fill.hh
+++ b/milena/mln/border/fill.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2011 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -95,16 +96,18 @@ namespace mln
unsigned st = 0;
for_all (pl)
- {
- unsigned end = ima.index_of_point (pl);
+ {
+ unsigned end = ima.index_of_point (pl);
+ if (st < end)
std::memset((void*)&opt::element(ima, st),
*(const int*)(&v),
end - st);
- st = end + len_r;
- }
- std::memset((void*)&opt::element(ima, st),
- *(const int*)(&v),
- opt::nelements(ima) - st);
+ st = end + len_r;
+ }
+ if (st < opt::nelements(ima))
+ std::memset((void*)&opt::element(ima, st),
+ *(const int*)(&v),
+ opt::nelements(ima) - st);
trace::exiting("border::impl::fill_size_1");
}
@@ -125,12 +128,12 @@ namespace mln
unsigned st = 0;
for_all (pl)
- {
- unsigned end = ima.index_of_point (pl);
- for (unsigned i = st; i < end; ++i)
- opt::element(ima, i) = v;
- st = end + len_r;
- }
+ {
+ unsigned end = ima.index_of_point (pl);
+ for (unsigned i = st; i < end; ++i)
+ opt::element(ima, i) = v;
+ st = end + len_r;
+ }
for (unsigned i = st; i < opt::nelements(ima); ++i)
opt::element(ima, i) = v;
diff --git a/milena/mln/core/box_runstart_piter.hh
b/milena/mln/core/box_runstart_piter.hh
index fafcc46..d031a2b 100644
--- a/milena/mln/core/box_runstart_piter.hh
+++ b/milena/mln/core/box_runstart_piter.hh
@@ -146,6 +146,8 @@ namespace mln
box_runstart_piter<P>::next_()
{
// Do we want this run for image in 3d?
+ /* FIXME: `dim - 2' is probably the wrong (= not generic) way to
+ express the manipulated dimension anyway. */
for (int c = dim - 2; c >= 0; --c)
{
if (p_[c] != s_->pmax()[c])
diff --git a/milena/tests/border/Makefile.am b/milena/tests/border/Makefile.am
index 80241ad..04052b6 100644
--- a/milena/tests/border/Makefile.am
+++ b/milena/tests/border/Makefile.am
@@ -1,4 +1,4 @@
-# Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+# Copyright (C) 2007, 2008, 2009, 2011 EPITA Research and Development
# Laboratory (LRDE).
#
# This file is part of Olena.
@@ -22,6 +22,7 @@ check_PROGRAMS = \
duplicate \
equalize \
fill \
+ fill_0 \
find \
get \
mirror \
@@ -43,6 +44,7 @@ adjust_SOURCES = adjust.cc
duplicate_SOURCES = duplicate.cc
equalize_SOURCES = equalize.cc
fill_SOURCES = fill.cc
+fill_0_SOURCES = fill_0.cc
find_SOURCES = find.cc
get_SOURCES = get.cc
mirror_SOURCES = mirror.cc
diff --git a/scribo/tests/binarization/sauvola.cc b/milena/tests/border/fill_0.cc
similarity index 66%
copy from scribo/tests/binarization/sauvola.cc
copy to milena/tests/border/fill_0.cc
index 33eb59f..62f664b 100644
--- a/scribo/tests/binarization/sauvola.cc
+++ b/milena/tests/border/fill_0.cc
@@ -24,29 +24,37 @@
// executable file might be covered by the GNU General Public License.
/// \file
+/// \brief Test filling an image with a border of 0.
#include <mln/core/image/image2d.hh>
-#include <mln/data/compare.hh>
#include <mln/value/int_u8.hh>
-#include <mln/io/pgm/load.hh>
-#include <mln/io/pbm/load.hh>
-#include <mln/io/pbm/save.hh>
+#include <mln/value/int_u16.hh>
-#include <scribo/binarization/sauvola.hh>
+#include <mln/debug/iota.hh>
+#include <mln/border/fill.hh>
-#include "tests/data.hh"
-
-int main()
+int
+main()
{
using namespace mln;
- image2d<value::int_u8> input;
- io::pgm::load(input, MILENA_IMG_DIR "/lena.pgm");
-
- image2d<bool> bin = scribo::binarization::sauvola(input, 101);
-
- image2d<bool> ref;
- io::pbm::load(ref, SCRIBO_TESTS_DIR "binarization/sauvola.ref.pbm");
-
- mln_assertion(bin == ref);
+ border::thickness = 0;
+
+ {
+ // Image with values of width 1 (sizeof(int_u8) == 1), the border
+ // of which is filled using mln::border::impl::fill_size_1().
+ using mln::value::int_u8;
+ image2d<int_u8> ima(3, 3);
+ debug::iota(ima);
+ border::fill(ima, 42);
+ }
+
+ {
+ // Image with values of width > 1 (sizeof(int_u16) == 2), the border
+ // of which is filled using mln::border::impl::fill_size_n().
+ using mln::value::int_u16;
+ image2d<int_u16> ima(3, 3);
+ debug::iota(ima);
+ border::fill(ima, 42);
+ }
}
--
1.7.2.5