last-svn-commit-499-g74fe464 Add a new test for primitive::link::merge_double_link.

* tests/img/pixels.pbm: New test image. * tests/Makefile.am (SUBDIRS): add primitive directory. * tests/primitive/Makefile.am, * tests/primitive/link/Makefile.am, * tests/primitive/link/merge_double_link.cc: New. --- scribo/ChangeLog | 12 +++++ scribo/tests/Makefile.am | 4 +- scribo/tests/img/pixels.pbm | 4 ++ scribo/tests/{toolchain => primitive}/Makefile.am | 3 +- .../tests/primitive/link}/Makefile.am | 8 +-- .../link/merge_double_link.cc} | 53 +++++++++++++++---- 6 files changed, 66 insertions(+), 18 deletions(-) create mode 100644 scribo/tests/img/pixels.pbm copy scribo/tests/{toolchain => primitive}/Makefile.am (98%) copy {milena/tests/subsampling => scribo/tests/primitive/link}/Makefile.am (86%) copy scribo/tests/{filter/objects_with_holes.cc => primitive/link/merge_double_link.cc} (55%) diff --git a/scribo/ChangeLog b/scribo/ChangeLog index 73fea45..7c0ab7c 100644 --- a/scribo/ChangeLog +++ b/scribo/ChangeLog @@ -1,3 +1,15 @@ +2010-10-25 Guillaume Lazzara <z@lrde.epita.fr> + + Add a new test for primitive::link::merge_double_link. + + * tests/img/pixels.pbm: New test image. + + * tests/Makefile.am (SUBDIRS): add primitive directory. + + * tests/primitive/Makefile.am, + * tests/primitive/link/Makefile.am, + * tests/primitive/link/merge_double_link.cc: New. + 2010-10-11 Guillaume Lazzara <z@lrde.epita.fr> Negate Sauvola's result. diff --git a/scribo/tests/Makefile.am b/scribo/tests/Makefile.am index a6ed969..d16453c 100644 --- a/scribo/tests/Makefile.am +++ b/scribo/tests/Makefile.am @@ -1,4 +1,5 @@ -# Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE). +# Copyright (C) 2009 2010 EPITA Research and Development Laboratory +# (LRDE). # # This file is part of Olena. # @@ -21,6 +22,7 @@ SUBDIRS = \ core \ filter \ preprocessing \ + primitive \ text \ toolchain \ unit_test diff --git a/scribo/tests/img/pixels.pbm b/scribo/tests/img/pixels.pbm new file mode 100644 index 0000000..e69f06d --- /dev/null +++ b/scribo/tests/img/pixels.pbm @@ -0,0 +1,4 @@ +P4 +# CREATOR: GIMP PNM Filter Version 1.1 +38 23 +ÿÿÿÿüÿÿÿÿüÿþ¿ÿüÿÿÿÿüÿþÿÿüÿÿÿÿüÿûÿÿüÿïÿÿüÿÿÿÿüÿÿÿÿüÿïÿÿüÿßÿÿüÿ×ÿÿüÿÿÿÿüÿÿÿÿüÿÿÿüÿoÿÿüÿïÿÿüÿÿÿÿüÿÿÿÿüÿÿÿÿüÿÿÿÿüÿÿÿÿü \ No newline at end of file diff --git a/scribo/tests/toolchain/Makefile.am b/scribo/tests/primitive/Makefile.am similarity index 98% copy from scribo/tests/toolchain/Makefile.am copy to scribo/tests/primitive/Makefile.am index 1e4a032..82c773a 100644 --- a/scribo/tests/toolchain/Makefile.am +++ b/scribo/tests/primitive/Makefile.am @@ -17,4 +17,5 @@ include $(top_srcdir)/scribo/tests/tests.mk SUBDIRS = \ - nepomuk + link + diff --git a/milena/tests/subsampling/Makefile.am b/scribo/tests/primitive/link/Makefile.am similarity index 86% copy from milena/tests/subsampling/Makefile.am copy to scribo/tests/primitive/link/Makefile.am index 7e859b4..a42f7f5 100644 --- a/milena/tests/subsampling/Makefile.am +++ b/scribo/tests/primitive/link/Makefile.am @@ -14,14 +14,12 @@ # You should have received a copy of the GNU General Public License # along with Olena. If not, see <http://www.gnu.org/licenses/>. -include $(top_srcdir)/milena/tests/tests.mk - +include $(top_srcdir)/scribo/tests/tests.mk check_PROGRAMS = \ - antialiased - + merge_double_link -antialiased_SOURCES = antialiased.cc +merge_double_link_SOURCES = merge_double_link.cc TESTS = $(check_PROGRAMS) diff --git a/scribo/tests/filter/objects_with_holes.cc b/scribo/tests/primitive/link/merge_double_link.cc similarity index 55% copy from scribo/tests/filter/objects_with_holes.cc copy to scribo/tests/primitive/link/merge_double_link.cc index c556513..ca3002b 100644 --- a/scribo/tests/filter/objects_with_holes.cc +++ b/scribo/tests/primitive/link/merge_double_link.cc @@ -1,5 +1,4 @@ -// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory -// (LRDE) +// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE) // // This file is part of Olena. // @@ -24,6 +23,8 @@ // 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/io/pbm/load.hh> @@ -34,29 +35,59 @@ #include <scribo/filter/objects_with_holes.hh> #include <scribo/primitive/extract/components.hh> +#include <scribo/primitive/link/with_single_left_link_dmax_ratio.hh> +#include <scribo/primitive/link/with_single_right_link_dmax_ratio.hh> +#include <scribo/primitive/link/merge_double_link.hh> +#include <scribo/primitive/link/internal/dmax_width_and_height.hh> #include "tests/data.hh" -int main(int argc, char *argv[]) + +int main() { using namespace mln; using namespace scribo; - std::string img = SCRIBO_IMG_DIR "/text_to_group_and_clean.pbm"; + std::string img = SCRIBO_IMG_DIR "/pixels.pbm"; + + unsigned ref_left[] = {0, 1, 1, 3, 4, 5, 6, 6, 8}; + unsigned ref_right[] = {0, 2, 2, 3, 4, 5, 6, 7, 8}; + unsigned ref_merged[] = {0, 1, 1, 3, 4, 5, 6, 7, 8}; + image2d<bool> input; io::pbm::load(input, img.c_str()); value::label_16 nlabels; - typedef component_set<image2d<value::label_16> > O; + typedef image2d<value::label_16> L; + typedef component_set<L> O; O comps = scribo::primitive::extract::components(input, c8(), nlabels); - O filtered_comps = scribo::filter::objects_with_holes(comps, 2, 1); - unsigned valid_comps = 0; - for_all_comps(c, filtered_comps) - if (filtered_comps(c).is_valid()) - ++valid_comps; + typedef primitive::link::internal::dmax_width_and_height dmax_fun_t; + + object_links<L> left_link + = primitive::link::with_single_left_link_dmax_ratio(comps, + dmax_fun_t(1), + anchor::MassCenter); + object_links<L> right_link + = primitive::link::with_single_right_link_dmax_ratio(comps, + dmax_fun_t(1), + anchor::MassCenter); + + // Validating left and right links. + object_links<L> + merged_links = primitive::link::merge_double_link(left_link, + right_link); + + + for_all_links(i, left_link) + mln_assertion(ref_left[i] == left_link(i)); + + for_all_links(i, right_link) + mln_assertion(ref_right[i] == right_link(i)); + + for_all_links(i, merged_links) + mln_assertion(ref_merged[i] == merged_links(i)); - mln_assertion(valid_comps == 8u); } -- 1.5.6.5
participants (1)
-
Guillaume Lazzara