last-svn-commit-502-gc24234a Update tests in Scribo.

* tests/binarization/global_threshold.cc, * tests/binarization/local_threshold.cc, * tests/primitive/link/merge_double_link.cc: Fix tests. * tests/core/Makefile.am: Add a new test. * tests/core/line_info.cc: New. * tests/filter/small_and_large_bboxes.cc: Remove useless arguments. * tests/img/pixels.pbm: Update. --- scribo/ChangeLog | 16 ++++++ scribo/tests/binarization/global_threshold.cc | 28 ++++++++++- scribo/tests/binarization/local_threshold.cc | 34 +++++++++++-- scribo/tests/core/Makefile.am | 4 +- .../line_info.cc} | 54 +++++++++++--------- scribo/tests/filter/small_and_large_bboxes.cc | 2 +- scribo/tests/img/pixels.pbm | 2 +- scribo/tests/primitive/link/merge_double_link.cc | 7 +-- 8 files changed, 110 insertions(+), 37 deletions(-) copy scribo/tests/{filter/small_and_large_bboxes.cc => core/line_info.cc} (56%) diff --git a/scribo/ChangeLog b/scribo/ChangeLog index 98c90d6..b4c122c 100644 --- a/scribo/ChangeLog +++ b/scribo/ChangeLog @@ -1,5 +1,21 @@ 2010-10-25 Guillaume Lazzara <z@lrde.epita.fr> + Update tests in Scribo. + + * tests/binarization/global_threshold.cc, + * tests/binarization/local_threshold.cc, + * tests/primitive/link/merge_double_link.cc: Fix tests. + + * tests/core/Makefile.am: Add a new test. + + * tests/core/line_info.cc: New. + + * tests/filter/small_and_large_bboxes.cc: Remove useless arguments. + + * tests/img/pixels.pbm: Update. + +2010-10-25 Guillaume Lazzara <z@lrde.epita.fr> + Small fixes in Scribo * scribo/core/line_info.hh: Fix invalid extended bboxes. diff --git a/scribo/tests/binarization/global_threshold.cc b/scribo/tests/binarization/global_threshold.cc index 9da29e3..e43a487 100644 --- a/scribo/tests/binarization/global_threshold.cc +++ b/scribo/tests/binarization/global_threshold.cc @@ -1,10 +1,36 @@ +// Copyright (C) 2010 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/make/image.hh> #include <mln/data/compare.hh> #include <scribo/binarization/global_threshold.hh> - int main(int argc, char *argv[]) { using namespace mln; diff --git a/scribo/tests/binarization/local_threshold.cc b/scribo/tests/binarization/local_threshold.cc index 8fb5045..5de4dfd 100644 --- a/scribo/tests/binarization/local_threshold.cc +++ b/scribo/tests/binarization/local_threshold.cc @@ -1,11 +1,37 @@ +// Copyright (C) 2010 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/make/image.hh> #include <mln/data/compare.hh> #include <scribo/binarization/local_threshold.hh> - -int main(int argc, char *argv[]) +int main() { using namespace mln; @@ -15,8 +41,8 @@ int main(int argc, char *argv[]) unsigned data_threshold[2][2] = { { 12, 13 }, { 14, 15 } }; - bool data_ref[2][2] = { { 1, 1 }, - { 0, 0 } }; + bool data_ref[2][2] = { { 1, 0 }, + { 1, 1 } }; image2d<unsigned> input = make::image(data); image2d<unsigned> threshold = make::image(data_threshold); diff --git a/scribo/tests/core/Makefile.am b/scribo/tests/core/Makefile.am index cf1c528..356cc31 100644 --- a/scribo/tests/core/Makefile.am +++ b/scribo/tests/core/Makefile.am @@ -20,6 +20,8 @@ include $(top_srcdir)/scribo/tests/tests.mk -check_PROGRAMS = +check_PROGRAMS = line_info + +line_info_SOURCES = line_info.cc TESTS = $(check_PROGRAMS) diff --git a/scribo/tests/filter/small_and_large_bboxes.cc b/scribo/tests/core/line_info.cc similarity index 56% copy from scribo/tests/filter/small_and_large_bboxes.cc copy to scribo/tests/core/line_info.cc index 20ddd12..cc0c575 100644 --- a/scribo/tests/filter/small_and_large_bboxes.cc +++ b/scribo/tests/core/line_info.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. // @@ -28,28 +27,32 @@ #include <mln/core/image/image2d.hh> #include <mln/core/alias/neighb2d.hh> -#include <mln/util/graph.hh> #include <mln/value/label_16.hh> #include <mln/io/pbm/load.hh> -#include <mln/literal/colors.hh> #include <scribo/primitive/extract/components.hh> -#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/make/debug_filename.hh> -#include <scribo/debug/save_bboxes_image.hh> -#include <scribo/debug/save_linked_bboxes_image.hh> +#include <scribo/core/line_set.hh> #include "tests/data.hh" -int main(int argc, char* argv[]) + +int main() { using namespace scribo; using namespace mln; - std::string img = SCRIBO_IMG_DIR "/text_to_group_and_clean.pbm"; + + int ref[][9] = { { 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + // baseline, meanline, ascent, descent, x_height, d_height, a_height, char_space, char_width + { 2, 2, 2, 2, 1, 0, 1, 1, 1 }, + { 4, 4, 4, 4, 1, 0, 1, 0, 1 }, + { 6, 6, 6, 6, 1, 0, 1, 0, 1 }, + { 7, 7, 7, 7, 1, 0, 1, 0, 1 }, + { 12, 12, 10, 12, 1, 0, 3, 0, 1 }, + { 17, 15, 15, 17, 3, 0, 3, 0, 4 } }; + + std::string img = SCRIBO_IMG_DIR "/pixels.pbm"; image2d<bool> input; io::pbm::load(input, img.c_str()); @@ -61,23 +64,24 @@ int main(int argc, char* argv[]) object_links<L> links = primitive::link::with_single_left_link(text, 30); - - mln_assertion(nbboxes == 12u); - object_groups<L> groups = primitive::group::from_single_link(links); - component_set<L> grouped_comps = primitive::group::apply(groups); + line_set<L> lines = scribo::line_set<L>(groups); - mln_assertion(grouped_comps.nelements() == 6u); - component_set<L> - filtered_comps = scribo::filter::components_small(grouped_comps, 20); + for_all_lines(l, lines) + { + mln_assertion(lines(l).baseline() == ref[l][0]); + mln_assertion(lines(l).meanline() == ref[l][1]); + mln_assertion(lines(l).ascent() == ref[l][2]); + mln_assertion(lines(l).descent() == ref[l][3]); + mln_assertion(lines(l).x_height() == unsigned(ref[l][4])); + mln_assertion(lines(l).d_height() == ref[l][5]); + mln_assertion(lines(l).a_height() == ref[l][6]); + mln_assertion(lines(l).char_space() == unsigned(ref[l][7])); + mln_assertion(lines(l).char_width() == unsigned(ref[l][8])); + } - unsigned valid_comps = 0; - for_all_comps(c, filtered_comps) - if (filtered_comps(c).is_valid()) - ++valid_comps; +} - mln_assertion(valid_comps == 2u); -} diff --git a/scribo/tests/filter/small_and_large_bboxes.cc b/scribo/tests/filter/small_and_large_bboxes.cc index 20ddd12..b3d7d5f 100644 --- a/scribo/tests/filter/small_and_large_bboxes.cc +++ b/scribo/tests/filter/small_and_large_bboxes.cc @@ -44,7 +44,7 @@ #include "tests/data.hh" -int main(int argc, char* argv[]) +int main() { using namespace scribo; using namespace mln; diff --git a/scribo/tests/img/pixels.pbm b/scribo/tests/img/pixels.pbm index e69f06d..6f72469 100644 --- a/scribo/tests/img/pixels.pbm +++ b/scribo/tests/img/pixels.pbm @@ -1,4 +1,4 @@ P4 # CREATOR: GIMP PNM Filter Version 1.1 38 23 -ÿÿÿÿüÿÿÿÿüÿþ¿ÿüÿÿÿÿüÿþÿÿüÿÿÿÿüÿûÿÿüÿïÿÿüÿÿÿÿüÿÿÿÿüÿïÿÿüÿßÿÿüÿ×ÿÿüÿÿÿÿüÿÿÿÿüÿÿÿüÿoÿÿüÿïÿÿüÿÿÿÿüÿÿÿÿüÿÿÿÿüÿÿÿÿüÿÿÿÿü \ No newline at end of file +ÿÿÿÿüÿÿÿÿüÿþ¯ÿüÿÿÿÿüÿþÿÿüÿÿÿÿüÿûÿÿüÿïÿÿüÿÿÿÿüÿÿÿÿüÿïÿÿüÿßÿÿüÿ×ÿÿüÿÿÿÿüÿÿÿÿüÿÿÿüÿoÿÿüÿïÿÿüÿÿÿÿüÿÿÿÿüÿÿÿÿüÿÿÿÿüÿÿÿÿü \ No newline at end of file diff --git a/scribo/tests/primitive/link/merge_double_link.cc b/scribo/tests/primitive/link/merge_double_link.cc index ca3002b..1b0674e 100644 --- a/scribo/tests/primitive/link/merge_double_link.cc +++ b/scribo/tests/primitive/link/merge_double_link.cc @@ -50,9 +50,9 @@ int main() 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}; + unsigned ref_left[] = {0, 1, 1, 2, 4, 5, 6, 7, 7, 9}; + unsigned ref_right[] = {0, 2, 3, 3, 4, 5, 6, 7, 8, 9}; + unsigned ref_merged[] = {0, 1, 1, 2, 4, 5, 6, 7, 8, 9}; image2d<bool> input; @@ -79,7 +79,6 @@ int main() 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)); -- 1.5.6.5
participants (1)
-
Guillaume Lazzara