* tests/img/lines_discontinued.pbm,
* tests/primitive/extract/lines_discontinued.cc: New.
* tests/primitive/extract/Makefile.am: Add new target.
---
scribo/ChangeLog | 9 ++
scribo/tests/img/lines_discontinued.pbm | Bin 0 -> 5050 bytes
scribo/tests/primitive/extract/Makefile.am | 5 +-
.../tests/primitive/extract/lines_discontinued.cc | 91 ++++++++++++++++++++
4 files changed, 103 insertions(+), 2 deletions(-)
create mode 100644 scribo/tests/img/lines_discontinued.pbm
create mode 100644 scribo/tests/primitive/extract/lines_discontinued.cc
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index a1a9184..60c197c 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,5 +1,14 @@
2013-03-05 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Add a new test for lines_discontinued.
+
+ * tests/img/lines_discontinued.pbm,
+ * tests/primitive/extract/lines_discontinued.cc: New.
+
+ * tests/primitive/extract/Makefile.am: Add new target.
+
+2013-03-05 Guillaume Lazzara <z(a)lrde.epita.fr>
+
* scribo/primitive/extract/lines_discontinued.hh: Add a missing
call to exact().
diff --git a/scribo/tests/img/lines_discontinued.pbm
b/scribo/tests/img/lines_discontinued.pbm
new file mode 100644
index 0000000..799b2da
Binary files /dev/null and b/scribo/tests/img/lines_discontinued.pbm differ
diff --git a/scribo/tests/primitive/extract/Makefile.am
b/scribo/tests/primitive/extract/Makefile.am
index 2d8c094..36de362 100644
--- a/scribo/tests/primitive/extract/Makefile.am
+++ b/scribo/tests/primitive/extract/Makefile.am
@@ -20,9 +20,10 @@ EXTRA_DIST = \
alignment_1.ref.pbm \
alignment_2.ref.pbm \
alignment_3.ref.pbm \
- alignment_4.ref.pbm
+ alignment_4.ref.pbm \
+ lines_discontinued.pbm
-check_PROGRAMS =
+check_PROGRAMS = lines_discontinued
if HAVE_MAGICKXX
diff --git a/scribo/tests/primitive/extract/lines_discontinued.cc
b/scribo/tests/primitive/extract/lines_discontinued.cc
new file mode 100644
index 0000000..c8f4013
--- /dev/null
+++ b/scribo/tests/primitive/extract/lines_discontinued.cc
@@ -0,0 +1,91 @@
+// Copyright (C) 2013 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.
+
+// \file
+
+#include <mln/core/image/image2d.hh>
+#include <mln/core/alias/neighb2d.hh>
+#include <mln/win/hline2d.hh>
+#include <mln/io/pbm/load.hh>
+#include <mln/value/label_8.hh>
+#include <mln/make/box2d.hh>
+#include <scribo/primitive/extract/lines_discontinued.hh>
+
+#include "tests/data.hh"
+
+
+int main()
+{
+ using namespace mln;
+ using namespace scribo;
+
+ image2d<bool> input;
+ io::pbm::load(input, SCRIBO_IMG_DIR "/lines_discontinued.pbm");
+
+ typedef value::label_8 V;
+ typedef image2d<V> I;
+
+ // Horizontal
+ {
+ win::hline2d win(51);
+ V nlines;
+ component_set<I>
+ comps = primitive::extract::lines_discontinued(input, c4(), nlines,
+ win, 3);
+
+ mln_assertion(comps.nelements() == 2);
+
+ mln_assertion(comps(1).bbox() == make::box2d(21, 37, 24, 176));
+ mln_assertion(comps(1).mass_center() == point2d(23, 107));
+ mln_assertion(comps(1).card() == 560);
+
+ mln_assertion(comps(2).bbox() == make::box2d(94, 32, 97, 91));
+ mln_assertion(comps(2).mass_center() == point2d(96, 62));
+ mln_assertion(comps(2).card() == 240);
+ }
+
+ // Vertical
+ {
+ win::vline2d win(51);
+ V nlines;
+ component_set<I>
+ comps = primitive::extract::lines_discontinued(input, c4(), nlines,
+ win, 3);
+
+ mln_assertion(comps.nelements() == 3);
+
+ mln_assertion(comps(1).bbox() == make::box2d(8, 23, 186, 26));
+ mln_assertion(comps(1).mass_center() == point2d(97, 25));
+ mln_assertion(comps(1).card() == 716);
+
+ mln_assertion(comps(2).bbox() == make::box2d(42, 98, 162, 100));
+ mln_assertion(comps(2).mass_center() == point2d(102, 99));
+ mln_assertion(comps(2).card() == 363);
+
+ mln_assertion(comps(3).bbox() == make::box2d(57, 137, 173, 144));
+ mln_assertion(comps(3).mass_center() == point2d(115, 141));
+ mln_assertion(comps(3).card() == 936);
+ }
+}
--
1.7.2.5