
* tests/filter/Makefile.am: Add targets. * tests/filter/components_large.cc, * tests/filter/components_small.cc: New. * tests/filter/small_and_large_bboxes.cc: Remove. Depracted. --- scribo/ChangeLog | 11 ++++ scribo/tests/filter/Makefile.am | 9 ++- ...all_and_large_bboxes.cc => components_large.cc} | 49 +++++++++++++------- ...all_and_large_bboxes.cc => components_small.cc} | 48 +++++++++++++------ 4 files changed, 81 insertions(+), 36 deletions(-) copy scribo/tests/filter/{small_and_large_bboxes.cc => components_large.cc} (68%) rename scribo/tests/filter/{small_and_large_bboxes.cc => components_small.cc} (69%) diff --git a/scribo/ChangeLog b/scribo/ChangeLog index 54d8d47..5db7b16 100644 --- a/scribo/ChangeLog +++ b/scribo/ChangeLog @@ -1,5 +1,16 @@ 2010-10-26 Guillaume Lazzara <z@lrde.epita.fr> + Add tests for objects filtering routines. + + * tests/filter/Makefile.am: Add targets. + + * tests/filter/components_large.cc, + * tests/filter/components_small.cc: New. + + * tests/filter/small_and_large_bboxes.cc: Remove. Depracted. + +2010-10-26 Guillaume Lazzara <z@lrde.epita.fr> + Fix objects filtering routines. * scribo/filter/objects_large.hh: Add an overload. diff --git a/scribo/tests/filter/Makefile.am b/scribo/tests/filter/Makefile.am index b0659be..8064646 100644 --- a/scribo/tests/filter/Makefile.am +++ b/scribo/tests/filter/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. # @@ -18,10 +19,12 @@ include $(top_srcdir)/scribo/tests/tests.mk check_PROGRAMS = \ objects_with_holes \ - small_and_large_bboxes + components_small \ + components_large objects_with_holes_SOURCES = objects_with_holes.cc -small_and_large_bboxes_SOURCES = small_and_large_bboxes.cc +components_small_SOURCES = components_small.cc +components_large_SOURCES = components_large.cc TESTS = $(check_PROGRAMS) diff --git a/scribo/tests/filter/small_and_large_bboxes.cc b/scribo/tests/filter/components_large.cc similarity index 68% copy from scribo/tests/filter/small_and_large_bboxes.cc copy to scribo/tests/filter/components_large.cc index b3d7d5f..543b90d 100644 --- a/scribo/tests/filter/small_and_large_bboxes.cc +++ b/scribo/tests/filter/components_large.cc @@ -24,6 +24,8 @@ // exception does not however invalidate any other reasons why the // executable file might be covered by the GNU General Public License. +/// \file + #include <iostream> #include <mln/core/image/image2d.hh> @@ -36,7 +38,7 @@ #include <scribo/primitive/group/apply.hh> #include <scribo/primitive/link/with_single_left_link.hh> #include <scribo/primitive/group/from_single_link.hh> -#include <scribo/filter/objects_small.hh> +#include <scribo/filter/objects_large.hh> #include <scribo/make/debug_filename.hh> #include <scribo/debug/save_bboxes_image.hh> @@ -54,30 +56,43 @@ int main() image2d<bool> input; io::pbm::load(input, img.c_str()); - value::label_16 nbboxes; - typedef image2d<value::label_16> L; - component_set<L> - text = primitive::extract::components(input, c8(), nbboxes); + typedef value::label_16 V; + typedef image2d<V> L; + + { + V nbboxes; + component_set<L> + text = primitive::extract::components(input, c8(), nbboxes); + + object_links<L> links = primitive::link::with_single_left_link(text, 30); + + + mln_assertion(nbboxes == 12u); - object_links<L> links = primitive::link::with_single_left_link(text, 30); + object_groups<L> groups = primitive::group::from_single_link(links); + component_set<L> grouped_comps = primitive::group::apply(groups); - mln_assertion(nbboxes == 12u); + mln_assertion(grouped_comps.nelements() == 6u); - object_groups<L> groups = primitive::group::from_single_link(links); + component_set<L> + filtered_comps = scribo::filter::components_large(grouped_comps, 20); - component_set<L> grouped_comps = primitive::group::apply(groups); + unsigned valid_comps = 0; + for_all_comps(c, filtered_comps) + if (filtered_comps(c).is_valid()) + ++valid_comps; - mln_assertion(grouped_comps.nelements() == 6u); + mln_assertion(valid_comps == 4u); + } - component_set<L> - filtered_comps = scribo::filter::components_small(grouped_comps, 20); - unsigned valid_comps = 0; - for_all_comps(c, filtered_comps) - if (filtered_comps(c).is_valid()) - ++valid_comps; + { + V nlabels; + image2d<bool> output = scribo::filter::components_large(input, c8(), + nlabels, 20); - mln_assertion(valid_comps == 2u); + mln_assertion(nlabels == 4u); + } } diff --git a/scribo/tests/filter/small_and_large_bboxes.cc b/scribo/tests/filter/components_small.cc similarity index 69% rename from scribo/tests/filter/small_and_large_bboxes.cc rename to scribo/tests/filter/components_small.cc index b3d7d5f..d9b5325 100644 --- a/scribo/tests/filter/small_and_large_bboxes.cc +++ b/scribo/tests/filter/components_small.cc @@ -24,6 +24,8 @@ // exception does not however invalidate any other reasons why the // executable file might be covered by the GNU General Public License. +/// \file + #include <iostream> #include <mln/core/image/image2d.hh> @@ -44,6 +46,7 @@ #include "tests/data.hh" + int main() { using namespace scribo; @@ -54,30 +57,43 @@ int main() image2d<bool> input; io::pbm::load(input, img.c_str()); - value::label_16 nbboxes; - typedef image2d<value::label_16> L; - component_set<L> - text = primitive::extract::components(input, c8(), nbboxes); + typedef value::label_16 V; + typedef image2d<V> L; + + { + V nbboxes; + component_set<L> + text = primitive::extract::components(input, c8(), nbboxes); + + object_links<L> links = primitive::link::with_single_left_link(text, 30); + + + mln_assertion(nbboxes == 12u); - object_links<L> links = primitive::link::with_single_left_link(text, 30); + object_groups<L> groups = primitive::group::from_single_link(links); + component_set<L> grouped_comps = primitive::group::apply(groups); - mln_assertion(nbboxes == 12u); + mln_assertion(grouped_comps.nelements() == 6u); - object_groups<L> groups = primitive::group::from_single_link(links); + component_set<L> + filtered_comps = scribo::filter::components_small(grouped_comps, 20); - component_set<L> grouped_comps = primitive::group::apply(groups); + unsigned valid_comps = 0; + for_all_comps(c, filtered_comps) + if (filtered_comps(c).is_valid()) + ++valid_comps; - mln_assertion(grouped_comps.nelements() == 6u); + mln_assertion(valid_comps == 2u); + } - component_set<L> - filtered_comps = scribo::filter::components_small(grouped_comps, 20); - unsigned valid_comps = 0; - for_all_comps(c, filtered_comps) - if (filtered_comps(c).is_valid()) - ++valid_comps; + { + V nlabels; + image2d<bool> output = scribo::filter::components_small(input, c8(), + nlabels, 20); - mln_assertion(valid_comps == 2u); + mln_assertion(nlabels == 8u); + } } -- 1.5.6.5