LRE
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
List overview
Download
Olena-patches
March 2011
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
olena-patches@lrde.epita.fr
7 participants
277 discussions
Start a n
N
ew thread
last-svn-commit-783-g38639f4 Add new debug tools.
by Guillaume Lazzara
* scribo/src/debug/Makefile.am: New targets. * scribo/src/debug/show_separators.cc, * scribo/src/debug/show_stoppers.cc, * scribo/src/debug/show_text_lines.cc: New. --- scribo/ChangeLog | 10 ++ scribo/src/debug/Makefile.am | 12 ++- .../lines_pattern.cc => debug/show_separators.cc} | 74 +++++++++----- scribo/src/debug/show_stoppers.cc | 104 ++++++++++++++++++++ .../show_text_lines.cc} | 100 +++++++++++-------- 5 files changed, 225 insertions(+), 75 deletions(-) copy scribo/src/{primitive/extract/lines_pattern.cc => debug/show_separators.cc} (50%) create mode 100644 scribo/src/debug/show_stoppers.cc copy scribo/src/{text/pbm_lines_recognition.cc => debug/show_text_lines.cc} (52%) diff --git a/scribo/ChangeLog b/scribo/ChangeLog index 74c7a03..4a9dcbf 100644 --- a/scribo/ChangeLog +++ b/scribo/ChangeLog @@ -1,5 +1,15 @@ 2011-03-01 Guillaume Lazzara <z(a)lrde.epita.fr> + Add new debug tools. + + * scribo/src/debug/Makefile.am: New targets. + + * scribo/src/debug/show_separators.cc, + * scribo/src/debug/show_stoppers.cc, + * scribo/src/debug/show_text_lines.cc: New. + +2011-03-01 Guillaume Lazzara <z(a)lrde.epita.fr> + * scribo/text/extract_lines.hh: Update code. 2011-03-01 Guillaume Lazzara <z(a)lrde.epita.fr> diff --git a/scribo/src/debug/Makefile.am b/scribo/src/debug/Makefile.am index d203f5c..cdb1f30 100644 --- a/scribo/src/debug/Makefile.am +++ b/scribo/src/debug/Makefile.am @@ -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. # @@ -20,6 +20,7 @@ include $(top_srcdir)/scribo/scribo.mk noinst_PROGRAMS = \ show_info_x_height \ show_info_median_inter_characters \ + show_separators \ show_links_left_right_links_validation \ show_links_bbox_h_ratio \ show_links_bbox_overlap \ @@ -43,11 +44,14 @@ noinst_PROGRAMS = \ show_objects_large_small \ show_objects_small \ show_objects_thick \ - show_objects_thin + show_objects_thin \ + show_stoppers \ + show_text_lines show_info_x_height_SOURCES = show_info_x_height.cc show_info_median_inter_characters_SOURCES = show_info_median_inter_characters.cc +show_separators_SOURCES = show_separators.cc show_links_left_right_links_validation_SOURCES = show_links_left_right_links_validation.cc show_links_bbox_h_ratio_SOURCES = show_links_bbox_h_ratio.cc show_links_bbox_overlap_SOURCES = show_links_bbox_overlap.cc @@ -72,6 +76,8 @@ show_objects_large_small_SOURCES = show_objects_large_small.cc show_objects_small_SOURCES = show_objects_small.cc show_objects_thick_SOURCES = show_objects_thick.cc show_objects_thin_SOURCES = show_objects_thin.cc +show_stoppers_SOURCES = show_stoppers.cc +show_text_lines_SOURCES = show_text_lines.cc if HAVE_MAGICKXX diff --git a/scribo/src/primitive/extract/lines_pattern.cc b/scribo/src/debug/show_separators.cc similarity index 50% copy from scribo/src/primitive/extract/lines_pattern.cc copy to scribo/src/debug/show_separators.cc index cb56b36..ef80da6 100644 --- a/scribo/src/primitive/extract/lines_pattern.cc +++ b/scribo/src/debug/show_separators.cc @@ -1,5 +1,4 @@ -// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory -// (LRDE) +// Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE) // // This file is part of Olena. // @@ -14,33 +13,25 @@ // // 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. #include <mln/core/image/image2d.hh> +#include <mln/core/alias/box2d.hh> +#include <mln/core/alias/neighb2d.hh> #include <mln/io/pbm/all.hh> -#include <mln/pw/all.hh> -#include <mln/data/fill.hh> -#include <mln/core/image/dmorph/image_if.hh> +#include <mln/arith/plus.hh> +#include <mln/labeling/foreground.hh> #include <scribo/primitive/extract/lines_h_pattern.hh> #include <scribo/primitive/extract/lines_v_pattern.hh> #include <scribo/debug/usage.hh> +#include <scribo/debug/save_bboxes_image.hh> const char *args_desc[][2] = { - { "input.pbm", "A binary image." }, - { "length", " Minimum line length. (Common value : 51)" }, + { "length", " Minimum line length. (default: 101)" }, { "delta", " Distance between the object pixel and the background pixel" - "(Common value : 4)" }, + "(default: 4)" }, {0, 0} }; @@ -49,10 +40,10 @@ int main(int argc, char *argv[]) { using namespace mln; - if (argc != 5) + if (argc != 7 && argc != 5) return scribo::debug::usage(argv, - "Extract horizontal lines patterns", - "input.pbm length delta output.pbm", + "Extract horizontal and vertical lines patterns", + "input.pbm output.pbm input_wo_seps.pbm output.ppm length delta", args_desc); trace::entering("main"); @@ -60,19 +51,46 @@ int main(int argc, char *argv[]) image2d<bool> input; io::pbm::load(input, argv[1]); + // Set default option value + unsigned + length = 101, + delta = 4; + if (argc > 5) + { + length = atoi(argv[5]); + delta = atoi(argv[6]); + } + + util::timer t; + t.start(); + image2d<bool> - h_lines = scribo::primitive::extract::lines_h_pattern(input, - atoi(argv[2]), - atoi(argv[3])); + h_lines = scribo::primitive::extract::lines_h_pattern(input, length, delta); image2d<bool> - v_lines = scribo::primitive::extract::lines_v_pattern(input, - atoi(argv[2]), - atoi(argv[3])); + v_lines = scribo::primitive::extract::lines_v_pattern(input, length, delta); + + v_lines += h_lines; + + t.stop(); + std::cout << t << "s" << std::endl; + + // Save binary image. + io::pbm::save(v_lines, argv[2]); - data::fill((v_lines | pw::value(h_lines)).rw(), true); + // Save input without separators + { + image2d<bool> in_wo_seps = duplicate(input); + data::fill((in_wo_seps | pw::value(v_lines)).rw(), false); + io::pbm::save(in_wo_seps, argv[3]); + } - io::pbm::save(v_lines, argv[4]); + // Save bbox image + value::int_u8 nlabels; + 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); trace::exiting("main"); } diff --git a/scribo/src/debug/show_stoppers.cc b/scribo/src/debug/show_stoppers.cc new file mode 100644 index 0000000..a108da1 --- /dev/null +++ b/scribo/src/debug/show_stoppers.cc @@ -0,0 +1,104 @@ +// Copyright (C) 2011 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/
>. + +#include <mln/core/image/image2d.hh> +#include <mln/core/alias/box2d.hh> +#include <mln/core/alias/neighb2d.hh> +#include <mln/io/pbm/all.hh> +#include <mln/arith/plus.hh> +#include <mln/labeling/foreground.hh> + +#include <scribo/primitive/extract/lines_h_pattern.hh> +#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> + + +const char *args_desc[][2] = +{ + { "length", " Minimum line length. (default: 101)" }, + { "delta", " Distance between the object pixel and the background pixel" + "(default: 4)" }, + {0, 0} +}; + + +int main(int argc, char *argv[]) +{ + using namespace mln; + + if (argc != 7 && argc != 5) + return scribo::debug::usage(argv, + "Extract horizontal, vertical lines and stoppers", + "input.pbm output.pbm input_wo_seps.pbm output.ppm length delta", + args_desc); + + trace::entering("main"); + + image2d<bool> input; + io::pbm::load(input, argv[1]); + + // Set default option value + unsigned + length = 101, + delta = 4; + if (argc > 5) + { + length = atoi(argv[5]); + delta = atoi(argv[6]); + } + + util::timer t; + + t.start(); + image2d<bool> + 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 += h_lines; + + t.stop(); + + // Save input without separators + { + image2d<bool> in_wo_seps = duplicate(input); + data::fill((in_wo_seps | pw::value(v_lines)).rw(), false); + io::pbm::save(in_wo_seps, argv[3]); + } + + // Save bbox image + value::int_u8 nlabels; + 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); + + t.resume(); + + // Non visible separators + v_lines += scribo::primitive::extract::separators_nonvisible(input); + + t.stop(); + std::cout << t << "s" << std::endl; + + // Save binary image. + io::pbm::save(v_lines, argv[2]); + + trace::exiting("main"); +} diff --git a/scribo/src/text/pbm_lines_recognition.cc b/scribo/src/debug/show_text_lines.cc similarity index 52% copy from scribo/src/text/pbm_lines_recognition.cc copy to scribo/src/debug/show_text_lines.cc index 3451449..a031072 100644 --- a/scribo/src/text/pbm_lines_recognition.cc +++ b/scribo/src/debug/show_text_lines.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE) // // This file is part of Olena. // @@ -23,15 +23,15 @@ // exception does not however invalidate any other reasons why the // executable file might be covered by the GNU General Public License. -#ifdef HAVE_CONFIG_H -# include <config.h> -#endif - #include <iostream> #include <mln/core/image/image2d.hh> #include <mln/io/pbm/load.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 <scribo/text/recognition.hh> @@ -41,19 +41,15 @@ #include <scribo/core/object_links.hh> #include <scribo/core/object_groups.hh> -#include <scribo/text/merging.hh> -#include <scribo/primitive/extract/components.hh> -#include <scribo/primitive/link/with_single_left_link_dmax_ratio.hh> -#include <scribo/primitive/group/from_single_link.hh> +#include <scribo/text/extract_lines.hh> #include <scribo/io/text_boxes/save.hh> +#include <scribo/debug/save_bboxes_image.hh> + const char *args_desc[][2] = { - { "input.pbm", "A binary image. 'True' for objects, 'False'\ -for the background." }, - { "lang", "Must be set to \"eng\", \"fra\", \"deu\", \"spa\", \"ita\" (Default \"fra\")" }, {0, 0} }; @@ -64,10 +60,10 @@ int main(int argc, char* argv[]) using namespace scribo; using namespace mln; - if (argc != 2 && argc != 3 && argc != 4) + if (argc != 6) return scribo::debug::usage(argv, - "Text recognition", - "input.pbm [lang] [file]", + "Show text lines", + "input.pbm input_seps.pbm out.ppm out.pbm comps.pbm", args_desc); trace::entering("main"); @@ -75,37 +71,53 @@ int main(int argc, char* argv[]) image2d<bool> input; mln::io::pbm::load(input, argv[1]); - typedef image2d<value::int_u16> L; - value::int_u16 ncomps; - component_set<L> - comps = scribo::primitive::extract::components(input, c8(), ncomps); - std::cout << "ncomps = " << ncomps << std::endl; - - object_links<L> - links = scribo::primitive::link::with_single_left_link_dmax_ratio(comps, 2); - - object_groups<L> - groups = scribo::primitive::group::from_single_link(links); + image2d<bool> input_seps; + mln::io::pbm::load(input_seps, argv[2]); - line_set<L> lines(groups); - lines = text::merging(lines); + util::timer t; + t.start(); - std::string str = argv[2]; - const char *lang; - if (argc < 3 || (str != "eng" && str != "fra" - && str != "deu" && str != "spa" - && str != "ita")) - lang = "fra"; - else - lang = argv[2]; - - char *output = 0; - if (argc >= 4) - output = argv[3]; - - scribo::text::recognition(lines, lang); - - scribo::io::text_boxes::save(lines, output); + typedef image2d<value::int_u16> L; + line_set<L> lines = text::extract_lines(input, c8(), input_seps); + + t.stop(); + std::cout << t << "s" << std::endl; + + // 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[3]); + } + + // Binary image with line bboxes. + { + image2d<bool> output; + initialize(output, input); + data::fill(output, false); + for_all_lines(l, lines) + if (lines(l).is_textline()) + mln::draw::box_plain(output, lines(l).bbox(), true); + mln::io::pbm::save(output, argv[4]); + } + + { + image2d<bool> output; + initialize(output, input); + data::fill(output, false); + for_all_lines(l, lines) + if (lines(l).is_textline()) + { + const util::array<component_id_t>& comps = lines(l).components(); + const L& lbl = lines.components().labeled_image(); + for_all_elements(c, comps) + data::fill((output | lines.components()(comps(c)).bbox()).rw(), + ((input | lines.components()(comps(c)).bbox()) | (pw::value(lbl) == comps(c)))); + } + mln::io::pbm::save(output, argv[5]); + } trace::exiting("main"); } -- 1.5.6.5
13 years, 9 months
1
0
0
0
last-svn-commit-782-g08507d9 scribo/text/extract_lines.hh: Update code.
by Guillaume Lazzara
--- scribo/ChangeLog | 4 ++ scribo/scribo/text/extract_lines.hh | 68 ++++++++++++++++++++++------------ 2 files changed, 48 insertions(+), 24 deletions(-) diff --git a/scribo/ChangeLog b/scribo/ChangeLog index f740230..74c7a03 100644 --- a/scribo/ChangeLog +++ b/scribo/ChangeLog @@ -1,5 +1,9 @@ 2011-03-01 Guillaume Lazzara <z(a)lrde.epita.fr> + * scribo/text/extract_lines.hh: Update code. + +2011-03-01 Guillaume Lazzara <z(a)lrde.epita.fr> + Make use of mln::fun::v2v::rgb_to_luma. * scribo/toolchain/internal/text_in_doc_preprocess_functor.hh, diff --git a/scribo/scribo/text/extract_lines.hh b/scribo/scribo/text/extract_lines.hh index 1a25cc8..b81cb79 100644 --- a/scribo/scribo/text/extract_lines.hh +++ b/scribo/scribo/text/extract_lines.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. // @@ -33,13 +33,14 @@ # include <mln/core/concept/image.hh> -# include <mln/value/label_16.hh> +# include <mln/value/int_u16.hh> # include <scribo/core/line_set.hh> # include <scribo/primitive/extract/components.hh> # include <scribo/primitive/link/merge_double_link.hh> +# include <scribo/primitive/link/internal/dmax_width_and_height.hh> # include <scribo/primitive/link/with_single_left_link_dmax_ratio.hh> # include <scribo/primitive/link/with_single_right_link_dmax_ratio.hh> @@ -65,11 +66,18 @@ namespace scribo /*! ** \param[in] input A binary image. ** \param[in] nbh A neighborhood used for labeling. + ** \param[in] seps A binary image with separator information. ** ** \return A set of lines. */ template <typename I, typename N> - line_set<mln_ch_value(I,value::label_16)> + line_set<mln_ch_value(I,value::int_u16)> + extract_lines(const Image<I>& input_, const Neighborhood<N>& nbh_, + const mln_ch_value(I,bool)& separators); + + /// \overload + template <typename I, typename N> + line_set<mln_ch_value(I,value::int_u16)> extract_lines(const Image<I>& input, const Neighborhood<N>& nbh); @@ -77,8 +85,18 @@ namespace scribo template <typename I, typename N> - line_set<mln_ch_value(I,value::label_16)> - extract_lines(const Image<I>& input_, const Neighborhood<N>& nbh_) + line_set<mln_ch_value(I,value::int_u16)> + extract_lines(const Image<I>& input, const Neighborhood<N>& nbh) + { + mln_ch_value(I,bool) seps; + return extract_lines(input, nbh, seps); + } + + + template <typename I, typename N> + line_set<mln_ch_value(I,value::int_u16)> + extract_lines(const Image<I>& input_, const Neighborhood<N>& nbh_, + const mln_ch_value(I,bool)& separators) { trace::entering("scribo::text::extract_lines"); @@ -88,44 +106,46 @@ namespace scribo mln_precondition(input.is_valid()); mln_precondition(nbh.is_valid()); - typedef mln_ch_value(I,value::label_16) L; - /// Finding comps. - value::label_16 ncomps; + typedef mln_ch_value(I,value::int_u16) L; + value::int_u16 ncomps; component_set<L> - comps = scribo::primitive::extract::components(input, nbh, ncomps); + comps = scribo::primitive::extract::components(input, c8(), ncomps); /// First filtering. - component_set<L> filtered_comps - = scribo::filter::components_small(comps, 6); + comps = scribo::filter::components_small(comps, 3); + + /// Use separators. + if (exact(separators).is_valid()) + comps.add_separators(separators); /// Linking potential comps object_links<L> left_link - = primitive::link::with_single_left_link_dmax_ratio(filtered_comps); + = 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(filtered_comps); - + = primitive::link::with_single_right_link_dmax_ratio(comps, + primitive::link::internal::dmax_width_and_height(1), + anchor::MassCenter); // Validating left and right links. object_links<L> merged_links = primitive::link::merge_double_link(left_link, - right_link); + right_link); - // Remove links if bboxes have too different sizes. - object_links<L> hratio_filtered_links - = filter::object_links_bbox_h_ratio(merged_links, 2.0f); + object_links<L> hratio_filtered_links + = filter::object_links_bbox_h_ratio(merged_links, 2.5f); object_groups<L> groups = primitive::group::from_single_link(hratio_filtered_links); - - line_set<L> line = scribo::make::line_set(groups); - line = text::merging(line); - + line_set<L> lines(groups); + lines = text::merging(lines); trace::exiting("scribo::text::extract_lines"); - return line; + return lines; } # endif // ! MLN_INCLUDE_ONLY -- 1.5.6.5
13 years, 9 months
1
0
0
0
last-svn-commit-781-g300d0d7 Make use of mln::fun::v2v::rgb_to_luma.
by Guillaume Lazzara
* scribo/toolchain/internal/text_in_doc_preprocess_functor.hh, * src/binarization/ppm_sauvola.cc, * src/binarization/ppm_sauvola_ms.cc, * src/binarization/ppm_sauvola_ms_fg.cc, * src/binarization/ppm_sauvola_ms_split.cc, * src/binarization/sauvola.cc, * src/binarization/sauvola_debug.cc, * src/binarization/sauvola_ms.cc, * src/binarization/sauvola_ms_debug.cc, * src/binarization/sauvola_ms_fg.cc, * src/text_in_picture.cc, * src/text_in_picture_neg.cc, * src/text_recognition_in_picture.cc: Here. --- scribo/ChangeLog | 18 ++++++++++++++++++ .../internal/text_in_doc_preprocess_functor.hh | 7 ++++--- scribo/src/binarization/ppm_sauvola.cc | 9 +++++---- scribo/src/binarization/ppm_sauvola_ms.cc | 9 +++++---- scribo/src/binarization/ppm_sauvola_ms_fg.cc | 8 ++++---- scribo/src/binarization/ppm_sauvola_ms_split.cc | 5 ++--- scribo/src/binarization/sauvola.cc | 4 ++-- scribo/src/binarization/sauvola_debug.cc | 8 ++++---- scribo/src/binarization/sauvola_ms.cc | 9 +++++---- scribo/src/binarization/sauvola_ms_debug.cc | 9 +++++---- scribo/src/binarization/sauvola_ms_fg.cc | 8 ++++---- scribo/src/text_in_picture.cc | 7 ++++--- scribo/src/text_in_picture_neg.cc | 5 ++--- scribo/src/text_recognition_in_picture.cc | 9 +++++---- 14 files changed, 69 insertions(+), 46 deletions(-) diff --git a/scribo/ChangeLog b/scribo/ChangeLog index cf51ca8..f740230 100644 --- a/scribo/ChangeLog +++ b/scribo/ChangeLog @@ -1,5 +1,23 @@ 2011-03-01 Guillaume Lazzara <z(a)lrde.epita.fr> + Make use of mln::fun::v2v::rgb_to_luma. + + * scribo/toolchain/internal/text_in_doc_preprocess_functor.hh, + * src/binarization/ppm_sauvola.cc, + * src/binarization/ppm_sauvola_ms.cc, + * src/binarization/ppm_sauvola_ms_fg.cc, + * src/binarization/ppm_sauvola_ms_split.cc, + * src/binarization/sauvola.cc, + * src/binarization/sauvola_debug.cc, + * src/binarization/sauvola_ms.cc, + * src/binarization/sauvola_ms_debug.cc, + * src/binarization/sauvola_ms_fg.cc, + * src/text_in_picture.cc, + * src/text_in_picture_neg.cc, + * src/text_recognition_in_picture.cc: Here. + +2011-03-01 Guillaume Lazzara <z(a)lrde.epita.fr> + * scribo/io/xml/load.hh: New XML loader. 2011-03-01 Guillaume Lazzara <z(a)lrde.epita.fr> diff --git a/scribo/scribo/toolchain/internal/text_in_doc_preprocess_functor.hh b/scribo/scribo/toolchain/internal/text_in_doc_preprocess_functor.hh index 6a9506b..6c0dd5a 100644 --- a/scribo/scribo/toolchain/internal/text_in_doc_preprocess_functor.hh +++ b/scribo/scribo/toolchain/internal/text_in_doc_preprocess_functor.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. // @@ -29,7 +30,7 @@ #include <mln/core/concept/image.hh> #include <mln/data/transform.hh> #include <mln/data/convert.hh> -#include <mln/fun/v2v/rgb_to_int_u.hh> +#include <mln/fun/v2v/rgb_to_luma.hh> #include <mln/subsampling/antialiased.hh> #include <scribo/binarization/sauvola.hh> @@ -208,7 +209,7 @@ namespace scribo on_new_progress_label("Convert to gray-scale image"); image2d<value::int_u8> intensity_ima = mln::data::transform(input_rgb, - mln::fun::v2v::rgb_to_int_u<8>()); + mln::fun::v2v::rgb_to_luma<value::int_u8>()); on_progress(); diff --git a/scribo/src/binarization/ppm_sauvola.cc b/scribo/src/binarization/ppm_sauvola.cc index f0cd355..4732a02 100644 --- a/scribo/src/binarization/ppm_sauvola.cc +++ b/scribo/src/binarization/ppm_sauvola.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. // @@ -27,7 +27,7 @@ #include <mln/io/ppm/load.hh> #include <mln/io/pbm/save.hh> #include <mln/data/transform.hh> -#include <mln/fun/v2v/rgb_to_int_u.hh> +#include <mln/fun/v2v/rgb_to_luma.hh> #include <scribo/binarization/sauvola.hh> #include <scribo/debug/usage.hh> @@ -74,7 +74,8 @@ int main(int argc, char *argv[]) // Convert to Gray level image. image2d<value::int_u8> - input_gl = data::transform(input, mln::fun::v2v::rgb_to_int_u<8>()); + input_gl = data::transform(input, + mln::fun::v2v::rgb_to_luma<value::int_u8>()); // Binarize image2d<bool> out = scribo::binarization::sauvola(input_gl, w, k); diff --git a/scribo/src/binarization/ppm_sauvola_ms.cc b/scribo/src/binarization/ppm_sauvola_ms.cc index eb694c2..cff28f9 100644 --- a/scribo/src/binarization/ppm_sauvola_ms.cc +++ b/scribo/src/binarization/ppm_sauvola_ms.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. // @@ -29,7 +29,7 @@ #include <mln/io/ppm/load.hh> #include <mln/io/pbm/save.hh> #include <mln/data/transform.hh> -#include <mln/fun/v2v/rgb_to_int_u.hh> +#include <mln/fun/v2v/rgb_to_luma.hh> #include <scribo/binarization/sauvola_ms.hh> #include <scribo/debug/usage.hh> @@ -110,7 +110,8 @@ int main(int argc, char *argv[]) // Convert to Gray level image. image2d<value::int_u8> - input_1_gl = data::transform(input_1, mln::fun::v2v::rgb_to_int_u<8>()); + input_1_gl = data::transform(input_1, + mln::fun::v2v::rgb_to_luma<value::int_u8>()); // Binarize image2d<bool> diff --git a/scribo/src/binarization/ppm_sauvola_ms_fg.cc b/scribo/src/binarization/ppm_sauvola_ms_fg.cc index 20f237f..a17ce9f 100644 --- a/scribo/src/binarization/ppm_sauvola_ms_fg.cc +++ b/scribo/src/binarization/ppm_sauvola_ms_fg.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. // @@ -31,7 +31,7 @@ #include <mln/io/ppm/load.hh> #include <mln/io/pbm/save.hh> #include <mln/data/transform.hh> -#include <mln/fun/v2v/rgb_to_int_u.hh> +#include <mln/fun/v2v/rgb_to_luma.hh> #include <scribo/binarization/sauvola_ms.hh> #include <scribo/preprocessing/split_bg_fg.hh> @@ -122,7 +122,7 @@ int main(int argc, char *argv[]) // Convert to Gray level image. image2d<value::int_u8> - fg_gl = data::transform(fg, mln::fun::v2v::rgb_to_int_u<8>()); + fg_gl = data::transform(fg, mln::fun::v2v::rgb_to_luma<value::int_u8>()); // Binarize image2d<bool> diff --git a/scribo/src/binarization/ppm_sauvola_ms_split.cc b/scribo/src/binarization/ppm_sauvola_ms_split.cc index bb98b38..92a0817 100644 --- a/scribo/src/binarization/ppm_sauvola_ms_split.cc +++ b/scribo/src/binarization/ppm_sauvola_ms_split.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. // @@ -29,7 +29,6 @@ #include <mln/io/ppm/load.hh> #include <mln/io/pbm/save.hh> #include <mln/data/transform.hh> -#include <mln/fun/v2v/rgb_to_int_u.hh> #include <scribo/binarization/sauvola_ms_split.hh> #include <scribo/debug/usage.hh> diff --git a/scribo/src/binarization/sauvola.cc b/scribo/src/binarization/sauvola.cc index 0273071..e8047ab 100644 --- a/scribo/src/binarization/sauvola.cc +++ b/scribo/src/binarization/sauvola.cc @@ -29,7 +29,7 @@ #include <mln/io/magick/load.hh> #include <mln/io/pbm/save.hh> #include <mln/data/transform.hh> -#include <mln/fun/v2v/rgb_to_int_u.hh> +#include <mln/fun/v2v/rgb_to_luma.hh> #include <scribo/binarization/sauvola.hh> #include <scribo/debug/usage.hh> @@ -77,7 +77,7 @@ int main(int argc, char *argv[]) // Convert to Gray level image. image2d<value::int_u8> - input_1_gl = data::transform(input, mln::fun::v2v::rgb_to_int_u<8>()); + input_1_gl = data::transform(input, mln::fun::v2v::rgb_to_luma<value::int_u8>()); image2d<bool> out = scribo::binarization::sauvola(input_1_gl, w, k); diff --git a/scribo/src/binarization/sauvola_debug.cc b/scribo/src/binarization/sauvola_debug.cc index f723851..0c335a8 100644 --- a/scribo/src/binarization/sauvola_debug.cc +++ b/scribo/src/binarization/sauvola_debug.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. // @@ -32,7 +32,7 @@ #include <mln/data/convert.hh> #include <mln/data/saturate.hh> -#include <mln/fun/v2v/rgb_to_int_u.hh> +#include <mln/fun/v2v/rgb_to_luma.hh> #include <scribo/binarization/local_threshold.hh> #include <scribo/binarization/sauvola.hh> @@ -116,7 +116,7 @@ int main(int argc, char *argv[]) image2d<value::int_u8> gima = data::transform(input, - mln::fun::v2v::rgb_to_int_u<8>()); + mln::fun::v2v::rgb_to_luma<value::int_u8>()); image2d<bool> diff --git a/scribo/src/binarization/sauvola_ms.cc b/scribo/src/binarization/sauvola_ms.cc index 541b9e5..6d60ab4 100644 --- a/scribo/src/binarization/sauvola_ms.cc +++ b/scribo/src/binarization/sauvola_ms.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. // @@ -31,7 +31,7 @@ #include <mln/io/magick/load.hh> #include <mln/io/pbm/save.hh> #include <mln/data/transform.hh> -#include <mln/fun/v2v/rgb_to_int_u.hh> +#include <mln/fun/v2v/rgb_to_luma.hh> #include <scribo/binarization/sauvola_ms.hh> #include <scribo/debug/usage.hh> @@ -115,7 +115,8 @@ int main(int argc, char *argv[]) // Convert to Gray level image. image2d<value::int_u8> - input_1_gl = data::transform(input_1, mln::fun::v2v::rgb_to_int_u<8>()); + input_1_gl = data::transform(input_1, + mln::fun::v2v::rgb_to_luma<value::int_u8>()); // Binarize image2d<bool> diff --git a/scribo/src/binarization/sauvola_ms_debug.cc b/scribo/src/binarization/sauvola_ms_debug.cc index 6bf9837..70c1a9a 100644 --- a/scribo/src/binarization/sauvola_ms_debug.cc +++ b/scribo/src/binarization/sauvola_ms_debug.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. // @@ -29,7 +29,7 @@ #include <mln/io/magick/load.hh> #include <mln/io/pbm/save.hh> #include <mln/data/transform.hh> -#include <mln/fun/v2v/rgb_to_int_u.hh> +#include <mln/fun/v2v/rgb_to_luma.hh> #include <scribo/binarization/sauvola_ms.hh> #include <scribo/debug/usage.hh> @@ -124,7 +124,8 @@ int main(int argc, char *argv[]) // Convert to Gray level image. image2d<value::int_u8> - input_1_gl = data::transform(input_1, mln::fun::v2v::rgb_to_int_u<8>()); + input_1_gl = data::transform(input_1, + mln::fun::v2v::rgb_to_luma<value::int_u8>()); // Binarize. diff --git a/scribo/src/binarization/sauvola_ms_fg.cc b/scribo/src/binarization/sauvola_ms_fg.cc index 4227db4..7ff9321 100644 --- a/scribo/src/binarization/sauvola_ms_fg.cc +++ b/scribo/src/binarization/sauvola_ms_fg.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. // @@ -31,7 +31,7 @@ #include <mln/io/magick/load.hh> #include <mln/io/pbm/save.hh> #include <mln/data/transform.hh> -#include <mln/fun/v2v/rgb_to_int_u.hh> +#include <mln/fun/v2v/rgb_to_luma.hh> #include <scribo/binarization/sauvola_ms.hh> #include <scribo/preprocessing/split_bg_fg.hh> @@ -102,7 +102,7 @@ int main(int argc, char *argv[]) // Convert to Gray level image. image2d<value::int_u8> - fg_gl = data::transform(fg, mln::fun::v2v::rgb_to_int_u<8>()); + fg_gl = data::transform(fg, mln::fun::v2v::rgb_to_luma<value::int_u8>()); // Binarize image2d<bool> diff --git a/scribo/src/text_in_picture.cc b/scribo/src/text_in_picture.cc index e2f30de..77cf7b6 100644 --- a/scribo/src/text_in_picture.cc +++ b/scribo/src/text_in_picture.cc @@ -40,7 +40,7 @@ #include <mln/value/rgb8.hh> #include <mln/value/label_16.hh> -#include <mln/fun/v2v/rgb_to_int_u.hh> +#include <mln/fun/v2v/rgb_to_luma.hh> #include <mln/subsampling/antialiased.hh> @@ -236,7 +236,8 @@ int main(int argc, char* argv[]) std::cout << "** Using split_bg_fg" << std::endl; image2d<value::rgb8> fg = preprocessing::split_bg_fg(input_rgb, lambda, 32).second(); - intensity_ima = data::transform(fg, mln::fun::v2v::rgb_to_int_u<8>()); + intensity_ima = data::transform(fg, + mln::fun::v2v::rgb_to_luma<value::int_u8>()); t_ = timer_; std::cout << "Foreground extracted. " << t_ << std::endl; @@ -253,7 +254,7 @@ int main(int argc, char* argv[]) timer_.start(); std::cout << "** Using data::transform(intensity)" << std::endl; intensity_ima = data::transform(input_rgb, - mln::fun::v2v::rgb_to_int_u<8>()); + mln::fun::v2v::rgb_to_luma<value::int_u8>()); t_ = timer_; std::cout << "Intensity image " << t_ << std::endl; } diff --git a/scribo/src/text_in_picture_neg.cc b/scribo/src/text_in_picture_neg.cc index c1a4317..8d818e0 100644 --- a/scribo/src/text_in_picture_neg.cc +++ b/scribo/src/text_in_picture_neg.cc @@ -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. // @@ -48,8 +49,6 @@ #include <mln/value/rgb8.hh> #include <mln/value/label_16.hh> -#include <mln/fun/v2v/rgb_to_int_u.hh> - #include <mln/data/wrap.hh> #include <mln/draw/box.hh> diff --git a/scribo/src/text_recognition_in_picture.cc b/scribo/src/text_recognition_in_picture.cc index a5f93a7..8b76f48 100644 --- a/scribo/src/text_recognition_in_picture.cc +++ b/scribo/src/text_recognition_in_picture.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. // @@ -51,7 +51,7 @@ #include <mln/value/rgb8.hh> #include <mln/value/label_16.hh> -#include <mln/fun/v2v/rgb_to_int_u.hh> +#include <mln/fun/v2v/rgb_to_luma.hh> #include <mln/data/wrap.hh> @@ -253,7 +253,8 @@ int main(int argc, char* argv[]) // Extract foreground image2d<value::rgb8> fg = preprocessing::split_bg_fg(input_rgb, lambda, 32).second(); - intensity_ima = data::transform(fg, mln::fun::v2v::rgb_to_int_u<8>()); + intensity_ima = data::transform(fg, + mln::fun::v2v::rgb_to_luma<value::int_u8>()); // // Perform an initial rotation if needed. // // input_rgb = geom::rotate(input_rgb, -45, literal::black); -- 1.5.6.5
13 years, 9 months
1
0
0
0
last-svn-commit-780-gb37a853 mln/labeling/fill_holes.hh: Improve speed.
by Guillaume Lazzara
--- milena/ChangeLog | 4 ++++ milena/mln/labeling/fill_holes.hh | 17 +++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/milena/ChangeLog b/milena/ChangeLog index edefc8e..2eed916 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,5 +1,9 @@ 2011-03-01 Guillaume Lazzara <z(a)lrde.epita.fr> + * mln/labeling/fill_holes.hh: Improve speed. + +2011-03-01 Guillaume Lazzara <z(a)lrde.epita.fr> + * mln/fun/v2v/rgb_to_luma.hh: New function for grayscale conversion. diff --git a/milena/mln/labeling/fill_holes.hh b/milena/mln/labeling/fill_holes.hh index e76c489..5e487d9 100644 --- a/milena/mln/labeling/fill_holes.hh +++ b/milena/mln/labeling/fill_holes.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2007, 2008, 2009, 2011 EPITA Research and Development +// Laboratory (LRDE) // // This file is part of Olena. // @@ -33,6 +34,8 @@ # include <mln/labeling/background.hh> # include <mln/labeling/compute.hh> +# include <mln/data/transform.hh> + # include <mln/core/image/dmorph/image_if.hh> # include <mln/accu/math/count.hh> @@ -57,7 +60,7 @@ namespace mln /// \see mln::labeling::background /// template <typename I, typename N, typename L> - I + mln_concrete(I) fill_holes(const Image<I>& input, const Neighborhood<N>& nbh, L& nlabels); @@ -66,7 +69,7 @@ namespace mln template <typename I, typename N, typename L> inline - I + mln_concrete(I) fill_holes(const Image<I>& input, const Neighborhood<N>& nbh, L& nlabels) { @@ -77,10 +80,6 @@ namespace mln mln_precondition(exact(input).is_valid()); mln_precondition(exact(nbh).is_valid()); - mln_ch_value(I, bool) output; - initialize(output, input); - data::fill(output, false); - mln_ch_value(I, L) lbls = labeling::background(input, nbh, nlabels); accu::math::count<mln_value(I)> a_; @@ -99,7 +98,9 @@ namespace mln } } - data::fill((output | (pw::value(lbls) != bg_lbl)).rw(), true); + util::array<bool> bg_relbl(arr.nelements(), true); + bg_relbl(bg_lbl) = false; + mln_ch_value(I, bool) output = data::transform(lbls, bg_relbl); trace::exiting("labeling::fill_holes"); return output; -- 1.5.6.5
13 years, 9 months
1
0
0
0
last-svn-commit-779-g5127a7b mln/fun/v2v/rgb_to_luma.hh: New function for grayscale conversion.
by Guillaume Lazzara
--- milena/ChangeLog | 5 +++ .../achromatism.hh => mln/fun/v2v/rgb_to_luma.hh} | 32 ++++++++++++------- 2 files changed, 25 insertions(+), 12 deletions(-) copy milena/{sandbox/green/mln/fun/v2v/achromatism.hh => mln/fun/v2v/rgb_to_luma.hh} (67%) diff --git a/milena/ChangeLog b/milena/ChangeLog index c4bed2c..edefc8e 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,3 +1,8 @@ +2011-03-01 Guillaume Lazzara <z(a)lrde.epita.fr> + + * mln/fun/v2v/rgb_to_luma.hh: New function for grayscale + conversion. + 2011-02-17 Guillaume Lazzara <z(a)lrde.epita.fr> * mln/util/array.hh: Add last() method. diff --git a/milena/sandbox/green/mln/fun/v2v/achromatism.hh b/milena/mln/fun/v2v/rgb_to_luma.hh similarity index 67% copy from milena/sandbox/green/mln/fun/v2v/achromatism.hh copy to milena/mln/fun/v2v/rgb_to_luma.hh index 72b545c..304a798 100644 --- a/milena/sandbox/green/mln/fun/v2v/achromatism.hh +++ b/milena/mln/fun/v2v/rgb_to_luma.hh @@ -1,4 +1,4 @@ -// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE) // // This file is part of Olena. // @@ -23,10 +23,10 @@ // exception does not however invalidate any other reasons why the // executable file might be covered by the GNU General Public License. -#ifndef MLN_FUN_V2V_ACHROMATISM_HH -# define MLN_FUN_V2V_ACHROMATISM_HH +#ifndef MLN_FUN_V2V_RGB_TO_LUMA_HH +# define MLN_FUN_V2V_RGB_TO_LUMA_HH -# include <mln/value/rgb8.hh> +# include <mln/value/rgb.hh> namespace mln { @@ -37,22 +37,30 @@ namespace mln namespace v2v { - struct achromatism : public Function_v2v< achromatism > + template <typename T_luma> + struct rgb_to_luma : public Function_v2v< rgb_to_luma<T_luma> > { - typedef float result; + typedef T_luma result; + + template <typename T_rgb> + T_luma operator()(const T_rgb& rgb) const; - float operator()(const value::rgb8 rgb) const; }; + # ifndef MLN_INCLUDE_ONLY - float achromatism::operator()(const value::rgb8 rgb) const + template <typename T_luma> + template <typename T_rgb> + inline + T_luma + rgb_to_luma<T_luma>::operator()(const T_rgb& rgb) const { - return (math::abs(rgb.red() - rgb.green()) - + math::abs(rgb.red() - rgb.blue()) - + math::abs(rgb.green() - rgb.blue()))/3.0; + float luma = 0.299 * rgb.red() + 0.587 * rgb.green() + 0.114 * rgb.blue(); + return unsigned(luma + 0.49999); } + # endif // !MLN_INCLUDE_ONLY } // end of namespace fun::v2v @@ -61,4 +69,4 @@ namespace mln } // end of namespace mln -#endif // ! MLN_FUN_V2V_ACHROMATISM_HH +#endif // ! MLN_FUN_V2V_RGB_TO_LUMA_HH -- 1.5.6.5
13 years, 9 months
1
0
0
0
last-svn-commit-778-gb1fe7b8 scribo/io/xml/load.hh: New XML loader.
by Guillaume Lazzara
--- scribo/ChangeLog | 4 + scribo/scribo/io/xml/load.hh | 525 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 529 insertions(+), 0 deletions(-) create mode 100644 scribo/scribo/io/xml/load.hh diff --git a/scribo/ChangeLog b/scribo/ChangeLog index 6571137..cf51ca8 100644 --- a/scribo/ChangeLog +++ b/scribo/ChangeLog @@ -1,5 +1,9 @@ 2011-03-01 Guillaume Lazzara <z(a)lrde.epita.fr> + * scribo/io/xml/load.hh: New XML loader. + +2011-03-01 Guillaume Lazzara <z(a)lrde.epita.fr> + Make XML output more flexible. * scribo/core/component_info.hh, diff --git a/scribo/scribo/io/xml/load.hh b/scribo/scribo/io/xml/load.hh new file mode 100644 index 0000000..e0f4548 --- /dev/null +++ b/scribo/scribo/io/xml/load.hh @@ -0,0 +1,525 @@ +// Copyright (C) 2011 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. + +#ifndef SCRIBO_IO_XML_LOAD_HH +# define SCRIBO_IO_XML_LOAD_HH + +/// \file +/// +/// \brief Load document information from XML. + +# include <QtXml> + +# include <libgen.h> +# include <fstream> +# include <sstream> + +# include <map> + +# include <mln/core/image/image2d.hh> + +# include <mln/data/wrap.hh> +# include <mln/value/int_u8.hh> +# include <mln/io/pgm/save.hh> +# include <mln/io/pbm/save.hh> + +# include <scribo/core/document.hh> +# include <scribo/core/component_set.hh> +# include <scribo/core/line_set.hh> +# include <scribo/core/line_info.hh> + +# include <scribo/convert/from_base64.hh> + +namespace scribo +{ + + namespace io + { + + namespace xml + { + using namespace mln; + + /*! \brief Load document information from XML. + + We use a XML Schema part of the PAGE (Page Analysis and Ground + truth Elements) image representation framework. + + This schema was used in the Page Segmentation COMPetition + (PSCOMP) for ICDAR 2009. + + Its XSD file is located here: +
http://schema.primaresearch.org/PAGE/gts/pagecontent/2009-03-16/pagecontent…
+ + */ + template <typename L> + void + load(document<L>& doc, const std::string& input_name); + + +# ifndef MLN_INCLUDE_ONLY + + namespace internal + { + + + enum Mode + { + None, + ComponentSet, + ComponentInfo, + LabeledImage, + SeparatorsImage, + ObjectLinks, + ObjectGroups, + Point, + Link, + Group, + Line, + LineLinks, + LineLink, + TextData, + TextRegion, + CompIdList, + CompId, + Page + }; + + + struct ModeData + { + const char *name; + Mode mode; + }; + + + static const ModeData mode_data[] = { + { "component_set", ComponentSet }, + { "component_info", ComponentInfo }, + { "labeled_image", LabeledImage }, + { "separators_image", SeparatorsImage }, + { "object_links", ObjectLinks }, + { "object_groups", ObjectGroups }, + { "point", Point }, + { "link", Link }, + { "group", Group }, + { "line", Line }, + { "line_links", LineLinks }, + { "line_link", LineLink }, + { "text_data", TextData }, + { "text_region", TextRegion }, + { "compid_list", CompIdList }, + { "compid", CompId }, + { "page", Page }, + { 0, None } + }; + + + template <typename L> + class xml_handler : public QXmlDefaultHandler + { + + typedef mln_ch_value(L,bool) B; + + public: + xml_handler() : current_paragraph_id(1) { lines_data.append(line_info<L>()); } // line info id starts from 1. + + virtual + bool + startElement(const QString& /*namespaceURI*/, const QString& /*localName*/, + const QString& qName, const QXmlAttributes& atts ) + { + mode.push(find_mode(qName)); + + switch (mode.top()) + { + + // Component Set + case ComponentSet: + { + comp_set_data = new scribo::internal::component_set_data<L>(); + // qDebug() << qName << " - atts.value(\"nelements\").toInt() = " << atts.value("nelements").toInt();; + comp_set_data->soft_init(atts.value("nelements").toInt()); + } + break; + + + // Component Info + case ComponentInfo: + { + component_info info(atts.value("id").toInt(), + mln::make::box2d(atts.value("pmin_y").toInt(), + atts.value("pmin_x").toInt(), + atts.value("pmax_y").toInt(), + atts.value("pmax_x").toInt()), + mln::point2d(atts.value("mass_center_y").toInt(), + atts.value("mass_center_x").toInt()), + atts.value("card").toInt()); + + + info.update_tag(component::str2tag(atts.value("tag").toUtf8().constData())); + info.update_type(component::str2type(atts.value("type").toUtf8().constData())); + + comp_set_data->infos_.append(info); + } + break; + + + // Object links + case ObjectLinks: + { + // qDebug() << "object_links created"; + links = object_links<L>(components); + } + break; + + + // Object groups + case ObjectGroups: + { + // qDebug() << "object_groups created"; + groups = object_groups<L>(links); + } + break; + + + // Text data + case TextData: + { + // qDebug() << "TextData"; + + // Reserve space for line data. + lines_data.resize(atts.value("nlines").toInt() + 1); + // qDebug() << "line_set created"; + lines = line_set<L>(groups, lines_data); + llinks = line_links<L>(lines); + par_data = new scribo::internal::paragraph_set_data<L>(llinks, atts.value("nparagraphs").toInt()); + // std::cout << par_data->pars_.nelements() << " - " << llinks.nelements() << " - " << lines.nelements() << std::endl; + } + break; + + + // Text Region + case TextRegion: + { + // qDebug() << "TextRegion"; + + current_paragraph = paragraph_info<L>(llinks); + } + break; + + + // Line link + case LineLink: + { + llinks(atts.value("from").toInt()) = atts.value("to").toInt(); + } + break; + + + // Line + case Line: + { + current_line_id = atts.value("id").toInt(); + + line_data = new scribo::internal::line_info_data<L>(lines, mln::util::array<component_id_t>()); + + line_data->holder_ = lines; + line_data->text_ = atts.value("text").toUtf8().constData(); + + line_data->hidden_ = false; + line_data->tag_ = static_cast<line::Tag>(atts.value("tag").toInt()); + + line_data->baseline_ = atts.value("baseline").toInt(); + line_data->meanline_ = atts.value("meanline").toInt(); + line_data->x_height_ = atts.value("x_height").toInt(); + line_data->d_height_ = atts.value("d_height").toInt(); + line_data->a_height_ = atts.value("a_height").toInt(); + line_data->char_space_ = atts.value("kerning").toInt(); + line_data->char_width_ = atts.value("char_width").toInt(); + line_data->word_space_ = 0; + + line_data->reading_direction_ = line::LeftToRight; + line_data->type_ = line::str2type(atts.value("txt_text_type").toAscii().constData()); + line_data->reverse_video_ = (atts.value("txt_reverse_video") == "false" ? false : true); + line_data->orientation_ = 0; + line_data->reading_orientation_ = atts.value("txt_reading_orientation").toInt(); + line_data->indented_ = (atts.value("txt_indented") == "false" ? false : true); + + bbox.init(); + } + break; + + + // CompIdList + case CompIdList: + { + + } + break; + + + // CompId + case CompId: + { + line_data->components_.append(atts.value("value").toInt()); + } + break; + + + // Point + case Point: + { + point2d p(atts.value("y").toInt(), atts.value("x").toInt()); + bbox.take(p); + } + break; + + + // Labeled Image + case LabeledImage: + { + width = atts.value("width").toInt(); + height = atts.value("height").toInt(); + comp_set_data->ima_ = L(mln::make::box2d(height, width), 0); // No border + } + break; + + + // Separator Image + case SeparatorsImage: + { + width = atts.value("width").toInt(); + height = atts.value("height").toInt(); + comp_set_data->separators_ = B(mln::make::box2d(height, width), 0); // No border + } + break; + + + // Link + case Link: + { + links(atts.value("from").toInt()) = atts.value("to").toInt(); + } + break; + + + // Group + case Group: + { + groups(atts.value("object_id").toInt()) = atts.value("group_id").toInt(); + } + break; + + + // DEFAULT + default: + ; + } + + return true; + } + + + virtual + bool + endElement(const QString& /*namespaceURI*/, const QString& /*localName*/, const QString& /*qName*/) + { + switch(mode.top()) + { + // Component set + case ComponentSet: + { + // qDebug() << "Component set done"; + components = component_set<L>(comp_set_data); + } + break; + + // Line + case Line: + { + // qDebug() << "Line done"; + line_data->bbox_ = bbox; + lines_data(current_line_id) = line_info<L>(current_line_id, line_data); + lines_data(current_line_id).update_ebbox(); + + // Add this line to the current paragraph. + current_paragraph.add_line(lines_data(current_line_id)); + } + break; + + // TextRegion + case TextRegion: + { + // qDebug() << TextRegion; + par_data->pars_(current_paragraph_id++) = current_paragraph; + } + break; + + // Page + case Page: + { + // qDebug() << "Page done"; + lines.update_line_data_(lines_data); + parset = paragraph_set<L>(par_data); + } + break; + + // DEFAULT + default: + ; + + } + + mode.pop(); + return true; + } + + + + bool characters(const QString & ch) + { + switch (mode.top()) + { + case LabeledImage: + { + scribo::convert::from_base64(ch, comp_set_data->ima_); + } + break; + + case SeparatorsImage: + { + scribo::convert::from_base64(ch, comp_set_data->separators_); + } + break; + + default: + ; + } + + return true; + } + + +// private: // Methods + + Mode find_mode(const QString& qName) + { + for (int i = 0; mode_data[i].name; ++i) + if (mode_data[i].name == qName) + return mode_data[i].mode; + return None; + } + + +// private: // Attributes + + QStack<Mode> mode; + + // Shape + accu::shape::bbox<point2d> bbox; + + unsigned width; + unsigned height; + + // Components + mln::util::tracked_ptr<scribo::internal::component_set_data<L> > comp_set_data; + component_set<L> components; + + object_links<L> links; + object_groups<L> groups; + + // Lines + unsigned current_line_id; + scribo::internal::line_info_data<L> *line_data; + + line_links<L> llinks; + + unsigned current_paragraph_id; + paragraph_info<L> current_paragraph; + scribo::internal::paragraph_set_data<L> *par_data; + paragraph_set<L> parset; + + mln::util::array<line_info<L> > lines_data; + line_set<L> lines; + }; + + + + + + + + + + + template <typename L> + void + load_extended(document<L>& doc, + const std::string& output_name) + { + xml_handler<L> handler; + QXmlSimpleReader reader; + reader.setContentHandler(&handler); + + QFile file(output_name.c_str()); + if (!file.open(QFile::ReadOnly | QFile::Text)) + { + qDebug() << "Cannot read file"; + return; + } + + QXmlInputSource xmlInputSource(&file); + if (reader.parse(xmlInputSource)) + qDebug() << "Loaded successfuly"; + + doc.set_paragraphs(handler.parset); + } + + } // end of namespace scribo::io::xml::internal + + + // FACADE + + template <typename L> + void + load(document<L>& doc, + const std::string& output_name) + { + internal::load_extended(doc, output_name); + } + + +# endif // ! MLN_INCLUDE_ONLY + + } // end of namespace scribo::io::xml + + } // end of namespace scribo::io + +} // end of namespace scribo + + +#endif // ! SCRIBO_IO_XML_LOAD_HH + -- 1.5.6.5
13 years, 9 months
1
0
0
0
last-svn-commit-776-g37420bc Set component type during component extraction.
by Guillaume Lazzara
* scribo/core/component_info.hh, * scribo/core/component_set.hh, * scribo/core/document.hh, * scribo/core/tag/component.hh, * scribo/primitive/extract/components.hh, * scribo/primitive/identify.hh: Explicitly set component type to Separator when extracting separator components. --- scribo/ChangeLog | 12 ++++++ scribo/scribo/core/component_info.hh | 8 ++- scribo/scribo/core/component_set.hh | 50 ++++++++++++++++--------- scribo/scribo/core/document.hh | 6 ++- scribo/scribo/core/tag/component.hh | 20 ++++++--- scribo/scribo/primitive/extract/components.hh | 18 ++++++--- scribo/scribo/primitive/identify.hh | 2 +- 7 files changed, 79 insertions(+), 37 deletions(-) diff --git a/scribo/ChangeLog b/scribo/ChangeLog index 8b7ad7f..330338a 100644 --- a/scribo/ChangeLog +++ b/scribo/ChangeLog @@ -1,3 +1,15 @@ +2011-03-01 Guillaume Lazzara <z(a)lrde.epita.fr> + + Set component type during component extraction. + + * scribo/core/component_info.hh, + * scribo/core/component_set.hh, + * scribo/core/document.hh, + * scribo/core/tag/component.hh, + * scribo/primitive/extract/components.hh, + * scribo/primitive/identify.hh: Explicitly set component type to + Separator when extracting separator components. + 2011-02-17 Guillaume Lazzara <z(a)lrde.epita.fr> Add new tools in Scribo. diff --git a/scribo/scribo/core/component_info.hh b/scribo/scribo/core/component_info.hh index 1b03318..6fc73f8 100644 --- a/scribo/scribo/core/component_info.hh +++ b/scribo/scribo/core/component_info.hh @@ -53,7 +53,8 @@ namespace scribo component_info(const component_id_t& id, const mln::box2d& bbox, const mln::point2d& mass_center, - unsigned card); + unsigned card, + component::Type type = component::Undefined); component_id_t id() const; const mln::box2d& bbox() const; @@ -101,9 +102,10 @@ namespace scribo component_info::component_info(const component_id_t& id, const mln::box2d& bbox, const mln::point2d& mass_center, - unsigned card) + unsigned card, + component::Type type) : id_(id), bbox_(bbox), mass_center_(mass_center), card_(card), - tag_(component::None), type_(component::Undefined) + tag_(component::None), type_(type) { } diff --git a/scribo/scribo/core/component_set.hh b/scribo/scribo/core/component_set.hh index 7ddcf16..442e8d6 100644 --- a/scribo/scribo/core/component_set.hh +++ b/scribo/scribo/core/component_set.hh @@ -86,16 +86,20 @@ namespace scribo component_set_data(); component_set_data(const L& ima, const mln_value(L)& ncomps); component_set_data(const L& ima, const mln_value(L)& ncomps, - const mln::util::array<pair_accu_t>& attribs); + const mln::util::array<pair_accu_t>& attribs, + component::Type type = component::Undefined); component_set_data(const L& ima, const mln_value(L)& ncomps, - const mln::util::array<pair_data_t>& attribs); + const mln::util::array<pair_data_t>& attribs, + component::Type type = component::Undefined); component_set_data(const L& ima, const mln_value(L)& ncomps, const mln::util::array<scribo::component_info>& infos); - void fill_infos(const mln::util::array<pair_accu_t>& attribs); + void fill_infos(const mln::util::array<pair_accu_t>& attribs, + component::Type type = component::Undefined); - void fill_infos(const mln::util::array<pair_data_t>& attribs); + void fill_infos(const mln::util::array<pair_data_t>& attribs, + component::Type type = component::Undefined); // Useful while constructing incrementaly (XML loading). void soft_init(const mln_value(L) ncomps); @@ -141,10 +145,12 @@ namespace scribo /// Constructor from an image \p ima, the number of labels \p ncomps and /// attributes values (bounding box and mass center). component_set(const L& ima, const mln_value(L)& ncomps, - const mln::util::array<pair_accu_t>& attribs); + const mln::util::array<pair_accu_t>& attribs, + component::Type type = component::Undefined); component_set(const L& ima, const mln_value(L)& ncomps, - const mln::util::array<pair_data_t>& attribs); + const mln::util::array<pair_data_t>& attribs, + component::Type type = component::Undefined); /// @} /// Return the component count. @@ -284,26 +290,28 @@ namespace scribo inline component_set_data<L>::component_set_data(const L& ima, const mln_value(L)& ncomps, - const mln::util::array<pair_accu_t>& attribs) + const mln::util::array<pair_accu_t>& attribs, + component::Type type) : ima_(ima), ncomps_(ncomps) { initialize(separators_, ima); // FIXME: do we really want that? mln::data::fill(separators_, false); - fill_infos(attribs); + fill_infos(attribs, type); } template <typename L> inline component_set_data<L>::component_set_data(const L& ima, const mln_value(L)& ncomps, - const mln::util::array<pair_data_t>& attribs) + const mln::util::array<pair_data_t>& attribs, + component::Type type) : ima_(ima), ncomps_(ncomps) { initialize(separators_, ima); // FIXME: do we really want that? mln::data::fill(separators_, false); - fill_infos(attribs); + fill_infos(attribs, type); } template <typename L> @@ -321,7 +329,8 @@ namespace scribo template <typename L> inline void - component_set_data<L>::fill_infos(const mln::util::array<pair_accu_t>& attribs) + component_set_data<L>::fill_infos(const mln::util::array<pair_accu_t>& attribs, + component::Type type) { typedef mln_site(L) P; @@ -331,7 +340,8 @@ namespace scribo for_all_comp_data(i, attribs) { component_info info(i, attribs[i].first(), - attribs[i].second(), attribs[i].second_accu().nsites()); + attribs[i].second(), attribs[i].second_accu().nsites(), + type); infos_.append(info); } } @@ -339,7 +349,8 @@ namespace scribo template <typename L> inline void - component_set_data<L>::fill_infos(const mln::util::array<pair_data_t>& attribs) + component_set_data<L>::fill_infos(const mln::util::array<pair_data_t>& attribs, + component::Type type) { typedef mln_site(L) P; @@ -349,7 +360,8 @@ namespace scribo for_all_comp_data(i, attribs) { component_info info(i, attribs[i].first, - attribs[i].second.first, attribs[i].second.second); + attribs[i].second.first, attribs[i].second.second, + type); infos_.append(info); } } @@ -397,9 +409,10 @@ namespace scribo template <typename L> inline component_set<L>::component_set(const L& ima, const mln_value(L)& ncomps, - const mln::util::array<pair_accu_t>& attribs) + const mln::util::array<pair_accu_t>& attribs, + component::Type type) { - data_ = new internal::component_set_data<L>(ima, ncomps, attribs); + data_ = new internal::component_set_data<L>(ima, ncomps, attribs, type); } @@ -407,9 +420,10 @@ namespace scribo inline component_set<L>::component_set(const L& ima, const mln_value(L)& ncomps, - const mln::util::array<pair_data_t>& attribs) + const mln::util::array<pair_data_t>& attribs, + component::Type type) { - data_ = new internal::component_set_data<L>(ima, ncomps, attribs); + data_ = new internal::component_set_data<L>(ima, ncomps, attribs, type); } diff --git a/scribo/scribo/core/document.hh b/scribo/scribo/core/document.hh index e5ac825..ef0869e 100644 --- a/scribo/scribo/core/document.hh +++ b/scribo/scribo/core/document.hh @@ -297,7 +297,8 @@ namespace scribo mln_value(L) ncomps; whitespace_seps_comps_ = primitive::extract::components(whitespace_seps, - mln::c8(), ncomps); + mln::c8(), ncomps, + component::WhitespaceSeparator); } @@ -333,7 +334,8 @@ namespace scribo mln_value(L) ncomps; line_seps_comps_ = primitive::extract::components(line_seps, - mln::c8(), ncomps); + mln::c8(), ncomps, + component::LineSeparator); } diff --git a/scribo/scribo/core/tag/component.hh b/scribo/scribo/core/tag/component.hh index 10b86a6..7cd2ede 100644 --- a/scribo/scribo/core/tag/component.hh +++ b/scribo/scribo/core/tag/component.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. // @@ -55,7 +55,8 @@ namespace scribo { Undefined = 0, Character, - Separator, + LineSeparator, + WhitespaceSeparator, Noise, Punctuation, Image @@ -116,8 +117,11 @@ namespace scribo case Character: str = "Character"; break; - case Separator: - str = "Separator"; + case LineSeparator: + str = "LineSeparator"; + break; + case WhitespaceSeparator: + str = "WhitespaceSeparator"; break; case Noise: str = "Noise"; @@ -139,8 +143,10 @@ namespace scribo { if (str == "Character") return Character; - else if (str == "Separator") - return Separator; + else if (str == "LineSeparator") + return LineSeparator; + else if (str == "WhitespaceSeparator") + return WhitespaceSeparator; else if (str == "Noise") return Noise; else if (str == "Punctuation") diff --git a/scribo/scribo/primitive/extract/components.hh b/scribo/scribo/primitive/extract/components.hh index 4994d4b..849dd7b 100644 --- a/scribo/scribo/primitive/extract/components.hh +++ b/scribo/scribo/primitive/extract/components.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. // @@ -68,6 +69,7 @@ namespace scribo /// and background to 'false'. /// \param[in] nbh A neighborhood to be used for labeling. /// \param[in,out] ncomponents Will store the numbers of components found. + /// \param[in] type The default component type set to components. /// /// \return An image of labeled components. // @@ -75,7 +77,8 @@ namespace scribo inline component_set<mln_ch_value(I,V)> components(const Image<I>& input, - const Neighborhood<N>& nbh, V& ncomponents); + const Neighborhood<N>& nbh, V& ncomponents, + component::Type type = component::Undefined); # ifndef MLN_INCLUDE_ONLY @@ -88,7 +91,8 @@ namespace scribo inline void components_tests(const Image<I>& input, - const Neighborhood<N>& nbh, V& ncomponents) + const Neighborhood<N>& nbh, V& ncomponents, + component::Type type) { mlc_equal(mln_value(I),bool)::check(); // mlc_is_a(V, mln::value::Symbolic)::check(); @@ -97,6 +101,7 @@ namespace scribo (void) input; (void) nbh; (void) ncomponents; + (void) type; } @@ -107,11 +112,12 @@ namespace scribo inline component_set<mln_ch_value(I,V)> components(const Image<I>& input, - const Neighborhood<N>& nbh, V& ncomponents) + const Neighborhood<N>& nbh, V& ncomponents, + component::Type type = component::Undefined) { trace::entering("scribo::components"); - internal::components_tests(input, nbh, ncomponents); + internal::components_tests(input, nbh, ncomponents, type); typedef mln_ch_value(I,V) L; typedef mln::accu::shape::bbox<mln_site(L)> bbox_accu_t; @@ -129,7 +135,7 @@ namespace scribo pair_accu_t()); component_set<L> - output(results.first(), ncomponents, results.second().second()); + output(results.first(), ncomponents, results.second().second(), type); trace::exiting("scribo::components"); return output; diff --git a/scribo/scribo/primitive/identify.hh b/scribo/scribo/primitive/identify.hh index 81a7d16..1bed712 100644 --- a/scribo/scribo/primitive/identify.hh +++ b/scribo/scribo/primitive/identify.hh @@ -61,7 +61,7 @@ namespace scribo std::swap(min, max); if (max/min > 10) - output(c).update_type(component::Separator); + output(c).update_type(component::LineSeparator); } mln::trace::exiting("scribo::primitive::identify"); -- 1.5.6.5
13 years, 9 months
1
0
0
0
← Newer
1
...
25
26
27
28
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
Results per page:
10
25
50
100
200