
* scribo/filter/object_links_bottom_aligned.hh, * scribo/filter/object_links_top_aligned.hh, * src/debug/show_links_bottom_aligned.cc, * src/debug/show_links_top_aligned.cc: Update call to linking routine. * scribo/filter/object_links_non_aligned_simple.hh: Copy data. * scribo/preprocessing/rotate_90.hh, * scribo/text/extract_lines.hh, * src/debug/show_stoppers.cc: Revamp. * scribo/primitive/extract/horizontal_separators.hh: Actually use horizontal routine. * scribo/primitive/extract/separators.hh: Adjust borders. * scribo/primitive/identify.hh: Disable for now. * scribo/primitive/link/with_single_right_link.hh: Add anchor argument. * scribo/primitive/link/with_single_right_link_top.hh: Rename arguments. * src/content_in_doc.cc: Add more usage information. * src/debug/show_links_center_aligned.cc: Update anchor value. * src/debug/show_text_lines.cc: Add XML output. * src/preprocessing/rotate.cc, * src/preprocessing/rotate_90.cc: Initialize ImageMagick. --- scribo/ChangeLog | 36 +++++++++++++++++ .../scribo/filter/object_links_bottom_aligned.hh | 8 ++-- .../filter/object_links_non_aligned_simple.hh | 3 +- scribo/scribo/filter/object_links_top_aligned.hh | 7 ++- scribo/scribo/preprocessing/rotate_90.hh | 25 +++++++----- .../primitive/extract/horizontal_separators.hh | 27 +++++++------ scribo/scribo/primitive/extract/separators.hh | 9 ++++- scribo/scribo/primitive/identify.hh | 30 +++++++------- .../primitive/link/with_single_right_link.hh | 16 +++++--- .../primitive/link/with_single_right_link_top.hh | 28 +++++++------- scribo/scribo/text/extract_lines.hh | 21 ++++++---- scribo/src/content_in_doc.cc | 3 +- scribo/src/debug/show_links_bottom_aligned.cc | 16 ++++--- scribo/src/debug/show_links_center_aligned.cc | 6 +- scribo/src/debug/show_links_top_aligned.cc | 18 ++++---- scribo/src/debug/show_stoppers.cc | 42 ++++++++++++++----- scribo/src/debug/show_text_lines.cc | 17 ++++++-- scribo/src/preprocessing/rotate.cc | 1 + scribo/src/preprocessing/rotate_90.cc | 1 + 19 files changed, 202 insertions(+), 112 deletions(-) diff --git a/scribo/ChangeLog b/scribo/ChangeLog index 5705c05..5ad1ca7 100644 --- a/scribo/ChangeLog +++ b/scribo/ChangeLog @@ -1,5 +1,41 @@ 2011-03-14 Guillaume Lazzara <z@lrde.epita.fr> + Various small fixes. + + * scribo/filter/object_links_bottom_aligned.hh, + * scribo/filter/object_links_top_aligned.hh, + * src/debug/show_links_bottom_aligned.cc, + * src/debug/show_links_top_aligned.cc: Update call to + linking routine. + + * scribo/filter/object_links_non_aligned_simple.hh: Copy data. + + * scribo/preprocessing/rotate_90.hh, + * scribo/text/extract_lines.hh, + * src/debug/show_stoppers.cc: Revamp. + + * scribo/primitive/extract/horizontal_separators.hh: Actually use + horizontal routine. + + * scribo/primitive/extract/separators.hh: Adjust borders. + + * scribo/primitive/identify.hh: Disable for now. + + * scribo/primitive/link/with_single_right_link.hh: Add anchor argument. + + * scribo/primitive/link/with_single_right_link_top.hh: Rename arguments. + + * src/content_in_doc.cc: Add more usage information. + + * src/debug/show_links_center_aligned.cc: Update anchor value. + + * src/debug/show_text_lines.cc: Add XML output. + + * src/preprocessing/rotate.cc, + * src/preprocessing/rotate_90.cc: Initialize ImageMagick. + +2011-03-14 Guillaume Lazzara <z@lrde.epita.fr> + Introduce a new component linking method. * scribo/primitive/link/internal/link_single_dmax_ratio_aligned_base.hh, diff --git a/scribo/scribo/filter/object_links_bottom_aligned.hh b/scribo/scribo/filter/object_links_bottom_aligned.hh index ba8ff31..2329f37 100644 --- a/scribo/scribo/filter/object_links_bottom_aligned.hh +++ b/scribo/scribo/filter/object_links_bottom_aligned.hh @@ -1,5 +1,5 @@ -// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory -// (LRDE) +// Copyright (C) 2009, 2010, 2011 EPITA Research and Development +// Laboratory (LRDE) // // This file is part of Olena. // @@ -38,7 +38,7 @@ # include <scribo/core/macros.hh> # include <scribo/core/object_links.hh> -# include <scribo/filter/object_links_non_aligned_simple.hh> +# include <scribo/filter/object_links_aligned.hh> namespace scribo { @@ -97,7 +97,7 @@ namespace scribo mln_precondition(links.is_valid()); object_links<L> - output = object_links_non_aligned_simple(links, anchor::Bottom, max_alpha); + output = object_links_aligned(links, max_alpha, anchor::Bottom); trace::exiting("scribo::filter::object_links_bottom_aligned"); return output; diff --git a/scribo/scribo/filter/object_links_non_aligned_simple.hh b/scribo/scribo/filter/object_links_non_aligned_simple.hh index 2381d88..5abf598 100644 --- a/scribo/scribo/filter/object_links_non_aligned_simple.hh +++ b/scribo/scribo/filter/object_links_non_aligned_simple.hh @@ -103,8 +103,7 @@ namespace scribo const component_set<L>& comps = links.components(); - object_links<L> output(links); - + object_links<L> output = links.duplicate(); float max_alpha_rad = (max_alpha / 180.0f) * math::pi; diff --git a/scribo/scribo/filter/object_links_top_aligned.hh b/scribo/scribo/filter/object_links_top_aligned.hh index 57e8d40..48598c6 100644 --- a/scribo/scribo/filter/object_links_top_aligned.hh +++ b/scribo/scribo/filter/object_links_top_aligned.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2009, 2011 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of Olena. // @@ -37,7 +38,7 @@ # include <scribo/core/macros.hh> # include <scribo/core/object_links.hh> -# include <scribo/filter/object_links_non_aligned_simple.hh> +# include <scribo/filter/object_links_aligned.hh> namespace scribo { @@ -96,7 +97,7 @@ namespace scribo mln_precondition(links.is_valid()); object_links<L> - output = object_links_non_aligned_simple(links, anchor::Top, max_alpha); + output = object_links_aligned(links, max_alpha, anchor::Top); trace::exiting("scribo::filter::object_links_top_aligned"); return output; diff --git a/scribo/scribo/preprocessing/rotate_90.hh b/scribo/scribo/preprocessing/rotate_90.hh index 96c0469..523b82f 100644 --- a/scribo/scribo/preprocessing/rotate_90.hh +++ b/scribo/scribo/preprocessing/rotate_90.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2010, 2011 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of Olena. // @@ -98,11 +99,13 @@ namespace scribo const mln_value(I)* in_ptr = input.buffer(); - unsigned in_ncols = geom::ncols(input) + 2 * input.border(); - unsigned in_nrows = geom::nrows(input) + 2 * input.border(); + unsigned + in_ncols = geom::ncols(input) + 2 * input.border(), + in_nrows = geom::nrows(input) + 2 * input.border(); - unsigned out_ncols = geom::ncols(output); - unsigned out_nrows = geom::nrows(output); + unsigned + out_ncols = geom::ncols(output) + 2 * input.border(), + out_nrows = geom::nrows(output) + 2 * input.border(); int out_next_offset, @@ -112,21 +115,21 @@ namespace scribo if (positive) // +90 deg { - dpoint2d dp(- out_nrows - 2 * output.border(), - 1); + dpoint2d dp(out_nrows, + 1); out_next_offset = output.delta_index(dp); - out_next_p_offset = output.delta_index(dpoint2d(+1, 0)); + out_next_p_offset = output.delta_index(dpoint2d(-1, 0)); - out_ptr += 2 * output.border() + out_ncols - 1; + out_ptr += output.delta_index(dpoint2d(out_nrows - 1, 0)); } else // -90 deg { - dpoint2d dp(out_nrows + 2 * output.border(), + 1); + dpoint2d dp(- out_nrows, - 1); out_next_offset = output.delta_index(dp); - out_next_p_offset = output.delta_index(dpoint2d(-1, 0)); + out_next_p_offset = output.delta_index(dpoint2d(+1, 0)); - out_ptr += output.delta_index(dpoint2d(out_nrows + 2 * output.border() - 1, 0)); + out_ptr += out_ncols - 1; } for (unsigned row = 0; row < in_nrows; ++row) diff --git a/scribo/scribo/primitive/extract/horizontal_separators.hh b/scribo/scribo/primitive/extract/horizontal_separators.hh index 9a6ea39..95db09e 100644 --- a/scribo/scribo/primitive/extract/horizontal_separators.hh +++ b/scribo/scribo/primitive/extract/horizontal_separators.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2010, 2011 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of Olena. // @@ -23,17 +24,17 @@ // exception does not however invalidate any other reasons why the // executable file might be covered by the GNU General Public License. -#ifndef SCRIBO_PRIMITIVE_EXTRACT_VERTICAL_SEPARATORS_HH -# define SCRIBO_PRIMITIVE_EXTRACT_VERTICAL_SEPARATORS_HH +#ifndef SCRIBO_PRIMITIVE_EXTRACT_HORIZONTAL_SEPARATORS_HH +# define SCRIBO_PRIMITIVE_EXTRACT_HORIZONTAL_SEPARATORS_HH /// \file /// -/// Extract vertical separators. +/// Extract horizontal separators. # include <mln/core/concept/image.hh> # include <mln/arith/plus.hh> -# include <scribo/primitive/extract/lines_v_pattern.hh> +# include <scribo/primitive/extract/lines_h_pattern.hh> namespace scribo @@ -47,7 +48,7 @@ namespace scribo using namespace mln; - /// \brief Extract vertical separators. + /// \brief Extract horizontal separators. /*! * * \param[in] input A binary image. @@ -59,7 +60,7 @@ namespace scribo */ template <typename I> mln_concrete(I) - vertical_separators(const Image<I>& input, unsigned line_length); + horizontal_separators(const Image<I>& input, unsigned line_length); @@ -68,19 +69,19 @@ namespace scribo template <typename I> mln_concrete(I) - vertical_separators(const Image<I>& input_, unsigned line_length) + horizontal_separators(const Image<I>& input_, unsigned line_length) { - trace::entering("scribo::primitive::extract::vertical_separators"); + trace::entering("scribo::primitive::extract::horizontal_separators"); const I& input = exact(input_); mlc_is(mln_value(I), bool)::check(); mln_precondition(input.is_valid()); mln_concrete(I) - vlines = extract::lines_v_pattern(input, line_length, 3); + hlines = extract::lines_h_pattern(input, line_length, 3); - trace::exiting("scribo::primitive::extract::vertical_separators"); - return vlines; + trace::exiting("scribo::primitive::extract::horizontal_separators"); + return hlines; } @@ -92,4 +93,4 @@ namespace scribo } // end of namespace scribo -#endif // ! SCRIBO_PRIMITIVE_EXTRACT_VERTICAL_SEPARATORS_HH +#endif // ! SCRIBO_PRIMITIVE_EXTRACT_HORIZONTAL_SEPARATORS_HH diff --git a/scribo/scribo/primitive/extract/separators.hh b/scribo/scribo/primitive/extract/separators.hh index 2ba22b4..316f806 100644 --- a/scribo/scribo/primitive/extract/separators.hh +++ b/scribo/scribo/primitive/extract/separators.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2010, 2011 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of Olena. // @@ -82,6 +83,12 @@ namespace scribo vlines = extract::lines_v_pattern(input, line_length, 3); hlines += vlines; + // FIXME: UGLY! We should not do that! + // Restore border size. + // Previous treatments may have changed it. + border::resize(hlines, border::thickness); + border::resize(input, border::thickness); + trace::exiting("scribo::primitive::extract::separators"); return hlines; } diff --git a/scribo/scribo/primitive/identify.hh b/scribo/scribo/primitive/identify.hh index 1bed712..6aa6ad3 100644 --- a/scribo/scribo/primitive/identify.hh +++ b/scribo/scribo/primitive/identify.hh @@ -28,7 +28,8 @@ /*! \brief try to determine the type of a component. -\fixme Add support for more component type (graphic, images, ...) +\fixme Write it and add support for component type (graphic, images, +...) */ # include <mln/trace/all.hh> @@ -48,24 +49,25 @@ namespace scribo mln_assertion(comps.is_valid()); - component_set<L> output = comps.duplicate(); + // component_set<L> output = comps.duplicate(); - for_all_comps(c, comps) - if (comps(c).is_valid()) - { - float - min = comps(c).bbox().height(), - max = comps(c).bbox().width(); + // for_all_comps(c, comps) + // if (comps(c).is_valid()) + // { + // float + // min = comps(c).bbox().height(), + // max = comps(c).bbox().width(); - if (comps(c).bbox().width() < comps(c).bbox().height()) - std::swap(min, max); + // if (comps(c).bbox().width() < comps(c).bbox().height()) + // std::swap(min, max); - if (max/min > 10) - output(c).update_type(component::LineSeparator); - } + // if (max/min > 10) + // output(c).update_type(component::LineSeparator); + // } mln::trace::exiting("scribo::primitive::identify"); - return output; + //return output; + return comps; } # ifndef MLN_INCLUDE_ONLY diff --git a/scribo/scribo/primitive/link/with_single_right_link.hh b/scribo/scribo/primitive/link/with_single_right_link.hh index e1abdcf..bc7942b 100644 --- a/scribo/scribo/primitive/link/with_single_right_link.hh +++ b/scribo/scribo/primitive/link/with_single_right_link.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2009, 2011 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of Olena. // @@ -28,7 +29,7 @@ /// \file /// -/// Link text objects with their right neighbor. +/// Link components with their right neighbor. # include <mln/core/concept/image.hh> @@ -71,7 +72,8 @@ namespace scribo inline object_links<L> with_single_right_link(const component_set<L>& components, - unsigned neighb_max_distance); + unsigned neighb_max_distance, + anchor::Type anchor = anchor::MassCenter); /// \overload @@ -123,7 +125,8 @@ namespace scribo inline object_links<L> with_single_right_link(const component_set<L>& components, - unsigned neighb_max_distance) + unsigned neighb_max_distance, + anchor::Type anchor = anchor::MassCenter) { trace::entering("scribo::primitive::link::with_single_right_link"); @@ -132,7 +135,7 @@ namespace scribo internal::single_right_functor<L> functor(components, neighb_max_distance); - object_links<L> output = compute(functor, anchor::MassCenter); + object_links<L> output = compute(functor, anchor); trace::exiting("scribo::primitive::link::with_single_right_link"); return output; @@ -144,7 +147,8 @@ namespace scribo object_links<L> with_single_right_link(const component_set<L>& components) { - return with_single_right_link(components, mln_max(unsigned)); + return with_single_right_link(components, mln_max(unsigned), + anchor::MassCenter); } diff --git a/scribo/scribo/primitive/link/with_single_right_link_top.hh b/scribo/scribo/primitive/link/with_single_right_link_top.hh index 6d26114..ada6650 100644 --- a/scribo/scribo/primitive/link/with_single_right_link_top.hh +++ b/scribo/scribo/primitive/link/with_single_right_link_top.hh @@ -1,5 +1,5 @@ -// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory -// (LRDE) +// Copyright (C) 2009, 2010, 2011 EPITA Research and Development +// Laboratory (LRDE) // // This file is part of Olena. // @@ -29,7 +29,7 @@ /// \file /// -/// Link text objects with their right neighbor. +/// Link components with their right neighbor. # include <mln/core/concept/image.hh> @@ -60,10 +60,10 @@ namespace scribo namespace link { - /// \brief Link objects with their right neighbor if exists. + /// \brief Link components with their right neighbor if exists. /// Lookup startup point is the object top center. /// - /// \param[in] objects An object image. + /// \param[in] components A component set. /// \param[in] The maximum distance allowed to seach a neighbor object. /// /// \return Object links data. @@ -71,7 +71,7 @@ namespace scribo template <typename L> inline object_links<L> - with_single_right_link_top(const component_set<L>& objects, + with_single_right_link_top(const component_set<L>& components, unsigned neighb_max_distance); @@ -80,7 +80,7 @@ namespace scribo template <typename L> inline object_links<L> - with_single_right_link_top(const component_set<L>& objects); + with_single_right_link_top(const component_set<L>& components); @@ -104,9 +104,9 @@ namespace scribo public: typedef mln_site(L) P; - single_right_top_functor(const component_set<L>& objects, + single_right_top_functor(const component_set<L>& components, unsigned dmax) - : super_(objects, dmax, anchor::Horizontal) + : super_(components, dmax, anchor::Horizontal) { } @@ -126,15 +126,15 @@ namespace scribo template <typename L> inline object_links<L> - with_single_right_link_top(const component_set<L>& objects, + with_single_right_link_top(const component_set<L>& components, unsigned neighb_max_distance) { trace::entering("scribo::primitive::link::with_single_right_link_top"); - mln_precondition(objects.is_valid()); + mln_precondition(components.is_valid()); internal::single_right_top_functor<L> - functor(objects, neighb_max_distance); + functor(components, neighb_max_distance); object_links<L> output = compute(functor, anchor::Top); @@ -146,9 +146,9 @@ namespace scribo template <typename L> inline object_links<L> - with_single_right_link_top(const component_set<L>& objects) + with_single_right_link_top(const component_set<L>& components) { - return with_single_right_link_top(objects, mln_max(unsigned)); + return with_single_right_link_top(components, mln_max(unsigned)); } diff --git a/scribo/scribo/text/extract_lines.hh b/scribo/scribo/text/extract_lines.hh index 9949d09..e69a249 100644 --- a/scribo/scribo/text/extract_lines.hh +++ b/scribo/scribo/text/extract_lines.hh @@ -120,14 +120,19 @@ namespace scribo comps.add_separators(separators); /// Linking potential comps - object_links<L> left_link - = primitive::link::with_single_left_link_dmax_ratio(comps, - primitive::link::internal::dmax_width_and_height(1), - anchor::MassCenter); - object_links<L> right_link - = primitive::link::with_single_right_link_dmax_ratio(comps, - primitive::link::internal::dmax_width_and_height(1), - anchor::MassCenter); + object_links<L> + left_link = primitive::link::with_single_left_link_dmax_ratio( + comps, + primitive::link::internal::dmax_width_and_height(1), +// primitive::link::internal::dmax_default(1), + anchor::MassCenter); + + object_links<L> + right_link = primitive::link::with_single_right_link_dmax_ratio( + comps, + primitive::link::internal::dmax_width_and_height(1), +// primitive::link::internal::dmax_default(1), + anchor::MassCenter); // Validating left and right links. object_links<L> diff --git a/scribo/src/content_in_doc.cc b/scribo/src/content_in_doc.cc index 81ec4fb..c879504 100644 --- a/scribo/src/content_in_doc.cc +++ b/scribo/src/content_in_doc.cc @@ -57,7 +57,8 @@ const char *args_desc[][2] = { "pmin_col", "Col index of the top left corner of the Region of interest." }, { "pmax_row", "Row index of the bottom right corner of the Region of interest." }, { "pmax_col", "Col index of the bottom right corner of the Region of interest." }, - { "language", "Language to be used for the text recognition. [eng|fra] (Default: eng)" }, + { "language", "Language to be used for the text recognition. [eng|fra] (Default: eng)." + "An empty language will disable OCR." }, { "find_lines", "Find vertical lines. (Default 1)" }, { "find_whitespaces", "Find whitespaces separators. (Default 1)" }, { "K", "Sauvola's binarization threshold parameter. (Default: 0.34)" }, diff --git a/scribo/src/debug/show_links_bottom_aligned.cc b/scribo/src/debug/show_links_bottom_aligned.cc index bf858dc..634551b 100644 --- a/scribo/src/debug/show_links_bottom_aligned.cc +++ b/scribo/src/debug/show_links_bottom_aligned.cc @@ -1,4 +1,5 @@ -// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2009, 2011 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of Olena. // @@ -40,8 +41,8 @@ #include <scribo/core/component_set.hh> #include <scribo/primitive/extract/components.hh> -#include <scribo/primitive/link/with_single_right_link_bottom.hh> -#include <scribo/filter/object_links_bottom_aligned.hh> +#include <scribo/primitive/link/with_single_right_link.hh> +#include <scribo/filter/object_links_aligned.hh> #include <scribo/debug/alignment_decision_image.hh> #include <scribo/debug/usage.hh> @@ -82,19 +83,20 @@ int main(int argc, char* argv[]) // Finding right links. object_links<L> right_links - = primitive::link::with_single_right_link_bottom(components, atoi(argv[2])); + = primitive::link::with_single_right_link(components, atoi(argv[2])); // Filtering. object_links<L> filtered_links - = filter::object_links_bottom_aligned(right_links, atof(argv[3])); + = filter::object_links_aligned(right_links, atof(argv[3]), + anchor::StrictBottomCenter); // Debug image. image2d<value::rgb8> decision_image = scribo::debug::alignment_decision_image(input, right_links, filtered_links, - scribo::debug::bottom, - atoi(argv[2])); + anchor::StrictBottomCenter); + io::ppm::save(decision_image, argv[4]); } diff --git a/scribo/src/debug/show_links_center_aligned.cc b/scribo/src/debug/show_links_center_aligned.cc index 727e7e9..9c358d9 100644 --- a/scribo/src/debug/show_links_center_aligned.cc +++ b/scribo/src/debug/show_links_center_aligned.cc @@ -1,5 +1,5 @@ -// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory -// (LRDE) +// Copyright (C) 2009, 2010, 2011 EPITA Research and Development +// Laboratory (LRDE) // // This file is part of Olena. // @@ -91,7 +91,7 @@ int main(int argc, char* argv[]) = scribo::debug::alignment_decision_image(input, right_links, filtered_links, - scribo::debug::center); + anchor::Center); io::ppm::save(decision_image, argv[3]); diff --git a/scribo/src/debug/show_links_top_aligned.cc b/scribo/src/debug/show_links_top_aligned.cc index 9efcb6d..5ffcb70 100644 --- a/scribo/src/debug/show_links_top_aligned.cc +++ b/scribo/src/debug/show_links_top_aligned.cc @@ -1,5 +1,5 @@ -// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory -// (LRDE) +// Copyright (C) 2009, 2010, 2011 EPITA Research and Development +// Laboratory (LRDE) // // This file is part of Olena. // @@ -39,10 +39,11 @@ #include <mln/io/ppm/save.hh> #include <scribo/primitive/extract/components.hh> -#include <scribo/primitive/link/with_single_right_link_top.hh> -#include <scribo/filter/object_links_top_aligned.hh> +#include <scribo/primitive/link/with_single_right_link.hh> +#include <scribo/filter/object_links_aligned.hh> #include <scribo/debug/alignment_decision_image.hh> +#include <scribo/debug/links_image.hh> #include <scribo/debug/usage.hh> @@ -82,20 +83,19 @@ int main(int argc, char* argv[]) // Finding right links. object_links<L> right_links - = primitive::link::with_single_right_link_top(components, atoi(argv[2])); + = primitive::link::with_single_right_link(components, atoi(argv[2])); // Filtering. object_links<L> filtered_links - = filter::object_links_top_aligned(right_links, atof(argv[3])); - + = filter::object_links_aligned(right_links, atof(argv[3]), + anchor::StrictTopCenter); // Debug image. image2d<value::rgb8> decision_image = scribo::debug::alignment_decision_image(input, right_links, filtered_links, - scribo::debug::top, - atoi(argv[2])); + anchor::StrictTopCenter); io::ppm::save(decision_image, argv[4]); } diff --git a/scribo/src/debug/show_stoppers.cc b/scribo/src/debug/show_stoppers.cc index a108da1..0e7fe0f 100644 --- a/scribo/src/debug/show_stoppers.cc +++ b/scribo/src/debug/show_stoppers.cc @@ -25,8 +25,11 @@ #include <scribo/primitive/extract/lines_v_pattern.hh> #include <scribo/primitive/extract/separators_nonvisible.hh> #include <scribo/debug/usage.hh> -#include <scribo/debug/save_bboxes_image.hh> +#include <scribo/debug/bboxes_image.hh> +#include <scribo/core/document.hh> +#include <scribo/core/def/lbl_type.hh> +#include <scribo/io/xml/save.hh> const char *args_desc[][2] = { @@ -41,10 +44,11 @@ int main(int argc, char *argv[]) { using namespace mln; - if (argc != 7 && argc != 5) + if (argc != 8 && argc != 6) return scribo::debug::usage(argv, "Extract horizontal, vertical lines and stoppers", - "input.pbm output.pbm input_wo_seps.pbm output.ppm length delta", + "input.pbm out_seps.pbm out_in_wo_seps.pbm " + "out_seps_bbox.ppm out_visible_seps.pbm length delta", args_desc); trace::entering("main"); @@ -56,20 +60,22 @@ int main(int argc, char *argv[]) unsigned length = 101, delta = 4; - if (argc > 5) + if (argc > 6) { - length = atoi(argv[5]); - delta = atoi(argv[6]); + length = atoi(argv[6]); + delta = atoi(argv[7]); } util::timer t; t.start(); image2d<bool> - h_lines = scribo::primitive::extract::lines_h_pattern(input, length, delta); + h_lines = scribo::primitive::extract::lines_h_pattern(input, length, + delta); image2d<bool> - v_lines = scribo::primitive::extract::lines_v_pattern(input, length, delta); + v_lines = scribo::primitive::extract::lines_v_pattern(input, length, + delta); v_lines += h_lines; @@ -87,18 +93,32 @@ int main(int argc, char *argv[]) image2d<value::int_u8> lbl = labeling::foreground(v_lines, c4(), nlabels); mln::util::array<box2d> bbox = labeling::compute(accu::shape::bbox<point2d>(), lbl, nlabels); - scribo::debug::save_bboxes_image(input, bbox, argv[4], literal::red); + io::ppm::save(scribo::debug::bboxes_image(input, bbox, literal::red), + argv[4]); + + // Save visible separators + mln::io::pbm::save(v_lines, argv[5]); t.resume(); // Non visible separators - v_lines += scribo::primitive::extract::separators_nonvisible(input); + image2d<bool> + nonvisible = scribo::primitive::extract::separators_nonvisible(input); t.stop(); std::cout << t << "s" << std::endl; + // // Saving stoppers data to XML + // typedef image2d<scribo::def::lbl_type> L; + // scribo::document<L> doc(argv[1]); + // doc.open(); + // doc.set_whitespace_separators(nonvisible); + // doc.set_line_separators(v_lines); + // scribo::io::xml::save(doc, argv[5], scribo::io::xml::Full); + // Save binary image. - io::pbm::save(v_lines, argv[2]); + v_lines += nonvisible; + mln::io::pbm::save(v_lines, argv[2]); trace::exiting("main"); } diff --git a/scribo/src/debug/show_text_lines.cc b/scribo/src/debug/show_text_lines.cc index d5a5c8f..1da0d66 100644 --- a/scribo/src/debug/show_text_lines.cc +++ b/scribo/src/debug/show_text_lines.cc @@ -32,20 +32,20 @@ #include <mln/pw/all.hh> #include <mln/core/image/dmorph/image_if.hh> #include <mln/data/convert.hh> +#include <mln/literal/colors.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/io/text_boxes/save.hh> - -#include <scribo/debug/save_bboxes_image.hh> +#include <scribo/io/xml/save.hh> const char *args_desc[][2] = @@ -60,10 +60,10 @@ int main(int argc, char* argv[]) using namespace scribo; using namespace mln; - if (argc != 6) + if (argc != 7) return scribo::debug::usage(argv, "Show text lines", - "input.pbm input_seps.pbm out.ppm out.pbm comps.pbm", + "input.pbm input_seps.pbm out_text_boxes.ppm out_text_boxes.pbm out_text_comps.pbm out_lines.xml", args_desc); trace::entering("main"); @@ -119,5 +119,12 @@ int main(int argc, char* argv[]) mln::io::pbm::save(output, argv[5]); } + // Saving stoppers data to XML + document<L> doc(argv[1]); + doc.open(); + doc.set_paragraphs(scribo::make::paragraph(lines)); + scribo::io::xml::save(doc, argv[6], scribo::io::xml::Full); + + trace::exiting("main"); } diff --git a/scribo/src/preprocessing/rotate.cc b/scribo/src/preprocessing/rotate.cc index 2910684..c0b599b 100644 --- a/scribo/src/preprocessing/rotate.cc +++ b/scribo/src/preprocessing/rotate.cc @@ -59,6 +59,7 @@ int main(int argc, char *argv[]) typedef image2d<value::rgb8> I; I ima; + Magick::InitializeMagick(0); io::magick::load(ima, argv[1]); image2d<value::rgb8> diff --git a/scribo/src/preprocessing/rotate_90.cc b/scribo/src/preprocessing/rotate_90.cc index c5e9536..23625a9 100644 --- a/scribo/src/preprocessing/rotate_90.cc +++ b/scribo/src/preprocessing/rotate_90.cc @@ -55,6 +55,7 @@ int main(int argc, char *argv[]) "input.* output.ppm <positive>", args_desc); + Magick::InitializeMagick(0); typedef image2d<value::rgb8> I; I ima; -- 1.5.6.5
participants (1)
-
Guillaume Lazzara