last-svn-commit-880-g853ed71 Add new sample programs.

* src/debug/Makefile.am: New targets. * src/debug/show_groups_bboxes_filtered.cc, * src/debug/show_text_lines_wo_seps.cc: New. --- milena/ChangeLog | 9 ++++ scribo/src/debug/Makefile.am | 16 ++++++ ...ps_bboxes.cc => show_groups_bboxes_filtered.cc} | 38 +++++++++++---- ...er_characters.cc => show_text_lines_wo_seps.cc} | 51 ++++++++++--------- 4 files changed, 80 insertions(+), 34 deletions(-) copy scribo/src/debug/{show_groups_bboxes.cc => show_groups_bboxes_filtered.cc} (75%) copy scribo/src/debug/{show_info_median_inter_characters.cc => show_text_lines_wo_seps.cc} (67%) diff --git a/milena/ChangeLog b/milena/ChangeLog index 5523182..e8430cd 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,5 +1,14 @@ 2011-05-17 Guillaume Lazzara <z@lrde.epita.fr> + Add new sample programs. + + * src/debug/Makefile.am: New targets. + + * src/debug/show_groups_bboxes_filtered.cc, + * src/debug/show_text_lines_wo_seps.cc: New. + +2011-05-17 Guillaume Lazzara <z@lrde.epita.fr> + Fix precision issue with algebra::vec conversion. * mln/core/point.hh: Round float values. diff --git a/scribo/src/debug/Makefile.am b/scribo/src/debug/Makefile.am index be8bb78..35beaf2 100644 --- a/scribo/src/debug/Makefile.am +++ b/scribo/src/debug/Makefile.am @@ -20,6 +20,7 @@ include $(top_srcdir)/scribo/scribo.mk noinst_PROGRAMS = \ show_components_bboxes \ show_groups_bboxes \ + show_groups_bboxes_filtered \ show_info_x_height \ show_info_median_inter_characters \ show_lines_boldness \ @@ -53,6 +54,7 @@ noinst_PROGRAMS = \ show_components_bboxes_SOURCES = show_components_bboxes.cc show_groups_bboxes_SOURCES = show_groups_bboxes.cc +show_groups_bboxes_filtered_SOURCES = show_groups_bboxes_filtered.cc show_info_x_height_SOURCES = show_info_x_height.cc show_info_median_inter_characters_SOURCES = show_info_median_inter_characters.cc show_lines_boldness_SOURCES = show_lines_boldness.cc @@ -127,6 +129,20 @@ if HAVE_QT show_text_lines_LDADD = $(LDADD) \ $(QT_LIBS) + noinst_PROGRAMS += show_text_lines_wo_seps + show_text_lines_wo_seps_SOURCES = show_text_lines_wo_seps.cc + show_text_lines_wo_seps_CPPFLAGS = $(AM_CPPFLAGS) \ + $(MAGICKXX_CPPFLAGS) \ + $(QT_CPPFLAGS) -DHAVE_QT + show_text_lines_wo_seps_CXXFLAGS = $(AM_CXXFLAGS) \ + $(QT_CXXFLAGS) + show_text_lines_wo_seps_LDFLAGS = $(AM_LDFLAGS) \ + $(MAGICKXX_LDFLAGS) \ + $(QT_LDFLAGS) + show_text_lines_wo_seps_LDADD = $(LDADD) \ + $(QT_LIBS) + + noinst_PROGRAMS += show_stoppers show_stoppers_SOURCES = show_stoppers.cc diff --git a/scribo/src/debug/show_groups_bboxes.cc b/scribo/src/debug/show_groups_bboxes_filtered.cc similarity index 75% copy from scribo/src/debug/show_groups_bboxes.cc copy to scribo/src/debug/show_groups_bboxes_filtered.cc index c7457ad..93b0c84 100644 --- a/scribo/src/debug/show_groups_bboxes.cc +++ b/scribo/src/debug/show_groups_bboxes_filtered.cc @@ -31,6 +31,8 @@ #include <scribo/primitive/link/internal/dmax_width_and_height.hh> #include <scribo/filter/object_links_bbox_h_ratio.hh> +#include <scribo/filter/objects_v_thick.hh> +#include <scribo/filter/objects_small.hh> int main(int argc, char *argv[]) { @@ -38,10 +40,11 @@ int main(int argc, char *argv[]) using namespace scribo; using namespace scribo::primitive; - if (argc != 3 && argc != 4) + if (argc != 3 && argc != 4 && argc != 5 && argc != 6) { - std::cerr << "Usage : " << argv[0] << " input.pbm out.pbm [hratio = 2.5]" << std::endl; - std::cerr << "Group components and makes sure size ratio is correct." << std::endl; + std::cerr << "Usage : " << argv[0] << " input.pbm out.pbm [hratio = 2.5] [min_comp_area = 3] [max_comp_height = 300]" << std::endl; + std::cerr << "Remove small and large components. Group components and makes sure " + << " size ratio is correct." << std::endl; return 1; } @@ -56,6 +59,18 @@ int main(int argc, char *argv[]) components = scribo::primitive::extract::components(input, c8(), ncomponents); + int + min_comp_area = 3, + max_comp_height = 300; + + if (argc >= 5) + min_comp_area = atoi(argv[4]); + if (argc >= 6) + max_comp_height = atoi(argv[5]); + + components = scribo::filter::components_small(components, min_comp_area); + components = scribo::filter::objects_v_thick(components, max_comp_height); + object_links<L> left_link = primitive::link::with_single_left_link_dmax_ratio( @@ -80,6 +95,7 @@ int main(int argc, char *argv[]) if (argc == 4) hratio = atof(argv[3]); + object_links<L> hratio_filtered_links = filter::object_links_bbox_h_ratio(merged_links, hratio); @@ -89,13 +105,15 @@ int main(int argc, char *argv[]) line_set<L> lines(groups); - image2d<bool> output; - initialize(output, input); - data::fill(output, false); + { + image2d<bool> output; + initialize(output, input); + data::fill(output, false); - for_all_lines(l, lines) - if (lines(l).is_valid()) - mln::draw::box(output, lines(l).bbox(), true); + for_all_lines(l, lines) + if (lines(l).is_valid()) + mln::draw::box(output, lines(l).bbox(), true); - io::pbm::save(output, argv[2]); + io::pbm::save(output, argv[2]); + } } diff --git a/scribo/src/debug/show_info_median_inter_characters.cc b/scribo/src/debug/show_text_lines_wo_seps.cc similarity index 67% copy from scribo/src/debug/show_info_median_inter_characters.cc copy to scribo/src/debug/show_text_lines_wo_seps.cc index 2ba240e..98ef05e 100644 --- a/scribo/src/debug/show_info_median_inter_characters.cc +++ b/scribo/src/debug/show_text_lines_wo_seps.cc @@ -1,5 +1,4 @@ -// Copyright (C) 2009, 2010, 2011 EPITA Research and Development -// Laboratory (LRDE) +// Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE) // // This file is part of Olena. // @@ -24,37 +23,38 @@ // exception does not however invalidate any other reasons why the // executable file might be covered by the GNU General Public License. - -#include <libgen.h> #include <iostream> #include <mln/core/image/image2d.hh> -#include <mln/core/alias/neighb2d.hh> - #include <mln/io/pbm/load.hh> -#include <mln/io/ppm/save.hh> - -#include <mln/value/rgb8.hh> #include <mln/value/int_u16.hh> +#include <mln/draw/box_plain.hh> +#include <mln/pw/all.hh> +#include <mln/core/image/dmorph/image_if.hh> +#include <mln/data/convert.hh> +#include <mln/literal/colors.hh> -#include <mln/draw/box.hh> -#include <mln/draw/line.hh> +#include <scribo/text/recognition.hh> +#include <scribo/debug/usage.hh> + +#include <scribo/core/document.hh> +#include <scribo/core/component_set.hh> +#include <scribo/core/object_links.hh> +#include <scribo/core/object_groups.hh> #include <scribo/text/extract_lines.hh> -#include <scribo/debug/char_space_image.hh> -#include <scribo/debug/usage.hh> +#include <scribo/io/xml/save.hh> const char *args_desc[][2] = { - { "input.pbm", "A binary image. 'False' for objects, 'True'\ -for the background." }, {0, 0} }; + int main(int argc, char* argv[]) { using namespace scribo; @@ -62,23 +62,26 @@ int main(int argc, char* argv[]) if (argc != 3) return scribo::debug::usage(argv, - "Find text lines using left/right validation and display x-height in a binarized article.", - "input.pbm out.ppm", + "Show text lines", + "input.pbm output.ppm", args_desc); - trace::entering("main"); - image2d<bool> input; mln::io::pbm::load(input, argv[1]); typedef image2d<scribo::def::lbl_type> L; - - line_set<L> line = scribo::text::extract_lines(input, c8()); - - image2d<value::rgb8> output = scribo::debug::char_space_image(input, line); - mln::io::ppm::save(output, argv[2]); + line_set<L> lines = text::extract_lines(input, c8()); + + // Color image with line bboxes. + { + image2d<value::rgb8> output = data::convert(value::rgb8(), input); + for_all_lines(l, lines) + if (lines(l).is_textline()) + mln::draw::box(output, lines(l).bbox(), literal::red); + mln::io::ppm::save(output, argv[2]); + } trace::exiting("main"); } -- 1.5.6.5
participants (1)
-
Guillaume Lazzara