last-svn-commit-96-g4a19598 Small fixes in Scribo.

* binarization/sauvola_ms.hh: Fix compilation issues on MacOS X. * core/component_set.hh: Add labeled_image_() member. * debug/save_bboxes_image.hh: Add a missing include. * preprocessing/split_bg_fg.hh, * primitive/extract/components.hh: Fix namespace ambiguities. * src/text_in_article.cc: Rename as... * src/text_in_article_pbm.cc: ... this. * src/Makefile.am: Update source file names. --- scribo/ChangeLog | 18 +++++++++++++++ scribo/binarization/sauvola_ms.hh | 9 +++++-- scribo/core/component_set.hh | 16 +++++++++++++ scribo/debug/save_bboxes_image.hh | 1 + scribo/preprocessing/split_bg_fg.hh | 2 +- scribo/primitive/extract/components.hh | 7 +++-- scribo/src/Makefile.am | 8 +++--- .../{text_in_article.cc => text_in_article_pbm.cc} | 23 ++++++++++++------- 8 files changed, 64 insertions(+), 20 deletions(-) rename scribo/src/{text_in_article.cc => text_in_article_pbm.cc} (94%) diff --git a/scribo/ChangeLog b/scribo/ChangeLog index 9ce6390..40a5fb4 100644 --- a/scribo/ChangeLog +++ b/scribo/ChangeLog @@ -1,3 +1,21 @@ +2010-03-19 Guillaume Lazzara <z@lrde.epita.fr> + + Small fixes in Scribo. + + * binarization/sauvola_ms.hh: Fix compilation issues on MacOS X. + + * core/component_set.hh: Add labeled_image_() member. + + * debug/save_bboxes_image.hh: Add a missing include. + + * preprocessing/split_bg_fg.hh, + * primitive/extract/components.hh: Fix namespace ambiguities. + + * src/text_in_article.cc: Rename as... + * src/text_in_article_pbm.cc: ... this. + + * src/Makefile.am: Update source file names. + 2010-03-18 Guillaume Lazzara <z@lrde.epita.fr> Cleanup binarization tools. diff --git a/scribo/binarization/sauvola_ms.hh b/scribo/binarization/sauvola_ms.hh index ad77660..2717770 100644 --- a/scribo/binarization/sauvola_ms.hh +++ b/scribo/binarization/sauvola_ms.hh @@ -125,7 +125,8 @@ namespace scribo typedef image2d<int_u8> I; typedef point2d P; - unsigned ratio = std::pow(q, i - 2); // Ratio in comparison to e_2 + // Cast to float is needed on MacOS X. + unsigned ratio = std::pow(float(q), float(i - 2u)); // Ratio in comparison to e_2 unsigned w_local = w * ratio, @@ -832,7 +833,8 @@ namespace scribo // Highest scale -> no maximum component size. { int i = sub_ima.size() - 1; - unsigned ratio = std::pow(q, i - 2); // Ratio compared to e_2 + // Cast to float is needed on MacOS X. + unsigned ratio = std::pow(float(q), float(i - 2)); // Ratio compared to e_2 t_ima[i] = internal::compute_t_n_and_e_2(sub_ima[i], e_2, lambda_min_2 / ratio, mln_max(unsigned), @@ -845,7 +847,8 @@ namespace scribo { for (int i = sub_ima.size() - 2; i > 2; --i) { - unsigned ratio = std::pow(q, i - 2); // Ratio compared to e_2 + // Cast to float is needed on MacOS X. + unsigned ratio = std::pow(float(q), float(i - 2)); // Ratio compared to e_2 t_ima[i] = internal::compute_t_n_and_e_2(sub_ima[i], e_2, lambda_min_2 / ratio, lambda_max_2 / ratio, diff --git a/scribo/core/component_set.hh b/scribo/core/component_set.hh index 14cdc4c..ef7ae4e 100644 --- a/scribo/core/component_set.hh +++ b/scribo/core/component_set.hh @@ -191,6 +191,13 @@ namespace scribo /// Unique set Id. unsigned id_() const; + + /// Read/Write access to the underlying labeled image. + /// Careful! Write in this image at your own risks! It may lead to + /// non-synchronised related data. + // + L& labeled_image_(); + /// @} private: @@ -479,6 +486,15 @@ namespace scribo template <typename L> inline + L& + component_set<L>::labeled_image_() + { + return this->data_->ima_; + } + + + template <typename L> + inline bool component_set<L>::has_separators() const { diff --git a/scribo/debug/save_bboxes_image.hh b/scribo/debug/save_bboxes_image.hh index 60f2c8d..f2c34e8 100644 --- a/scribo/debug/save_bboxes_image.hh +++ b/scribo/debug/save_bboxes_image.hh @@ -36,6 +36,7 @@ # include <mln/util/array.hh> # include <mln/io/ppm/save.hh> +# include <scribo/core/line_set.hh> # include <scribo/draw/bounding_boxes.hh> diff --git a/scribo/preprocessing/split_bg_fg.hh b/scribo/preprocessing/split_bg_fg.hh index f64635b..1ad056a 100644 --- a/scribo/preprocessing/split_bg_fg.hh +++ b/scribo/preprocessing/split_bg_fg.hh @@ -326,7 +326,7 @@ namespace scribo image2d<value::rgb8> fg = internal::inverted_diff_abs(input, bg); trace::exiting("scribo::preprocessing::split_bg_fg"); - return make::couple(bg, fg); + return mln::make::couple(bg, fg); } diff --git a/scribo/primitive/extract/components.hh b/scribo/primitive/extract/components.hh index 3363331..aac54e6 100644 --- a/scribo/primitive/extract/components.hh +++ b/scribo/primitive/extract/components.hh @@ -42,6 +42,7 @@ # include <mln/labeling/compute.hh> # include <mln/util/array.hh> +# include <mln/util/couple.hh> # include <mln/extension/fill.hh> @@ -120,9 +121,9 @@ namespace scribo // Setting extension value. extension::fill(input, 0); - util::couple<L, - util::couple<util::array<mln_result(pair_accu_t)>, - util::array<pair_accu_t> > > + mln::util::couple<L, + mln::util::couple<mln::util::array<mln_result(pair_accu_t)>, + mln::util::array<pair_accu_t> > > results = labeling::blobs_and_compute(input, nbh, ncomponents, pair_accu_t()); diff --git a/scribo/src/Makefile.am b/scribo/src/Makefile.am index 60c60f7..e254689 100644 --- a/scribo/src/Makefile.am +++ b/scribo/src/Makefile.am @@ -72,16 +72,16 @@ if HAVE_TIFF -lpthread -lhpdf - bin_PROGRAMS += text_in_article - text_in_article_CPPFLAGS = $(AM_CPPFLAGS) \ + bin_PROGRAMS += text_in_article_pbm + text_in_article_pbm_CPPFLAGS = $(AM_CPPFLAGS) \ $(TESSERACT_CPPFLAGS) \ $(TIFF_CPPFLAGS) - text_in_article_LDFLAGS = $(AM_LDFLAGS) \ + text_in_article_pbm_LDFLAGS = $(AM_LDFLAGS) \ $(TESSERACT_LDFLAGS) \ $(TIFF_LDFLAGS) \ -lpthread # -lhpdf - text_in_article_SOURCES = text_in_article.cc + text_in_article_pbm_SOURCES = text_in_article_pbm.cc text_in_photo_ppm_fast_CPPFLAGS = $(AM_CPPFLAGS) \ diff --git a/scribo/src/text_in_article.cc b/scribo/src/text_in_article_pbm.cc similarity index 94% rename from scribo/src/text_in_article.cc rename to scribo/src/text_in_article_pbm.cc index 2e6b1a6..3f37529 100644 --- a/scribo/src/text_in_article.cc +++ b/scribo/src/text_in_article_pbm.cc @@ -80,6 +80,7 @@ const char *args_desc[][2] = { { "input.pbm", "A binary image. 'False' for object, 'True'\ for the background." }, + { "denoise", "1 enables denoising, 0 disables it. (enabled by default)" }, { "debug_dir", "Output directory for debug image" }, {0, 0} }; @@ -90,15 +91,15 @@ int main(int argc, char* argv[]) using namespace scribo; using namespace mln; - if (argc != 3 && argc != 4) + if (argc != 3 && argc != 4 && argc != 5) return scribo::debug::usage(argv, "Find text lines using left/right validation and display x-height in a binarized article.", - "input.pbm out.ppm <debug_dir>", + "input.pbm out.txt <denoise: 0|1> <debug_dir>", args_desc, - "A color image. The following colors are used : dark blue for object bboxes, orange for single object bboxes, purple for group bboxes and light blue for x-height."); + "Text output."); - if (argc == 4) - scribo::make::internal::debug_filename_prefix = argv[3]; + if (argc == 5) + scribo::make::internal::debug_filename_prefix = argv[4]; trace::entering("main"); @@ -131,8 +132,11 @@ int main(int argc, char* argv[]) // mln::io::pbm::save(input_cleaned, "input_no_separators.pbm"); // Denoise - std::cout << "Denoise..." << std::endl; - input_cleaned = preprocessing::denoise_fg(input_cleaned, c8(), 3); + if (argc > 3 && atoi(argv[3]) != 0) + { + std::cout << "Denoise..." << std::endl; + input_cleaned = preprocessing::denoise_fg(input_cleaned, c8(), 3); + } // mln::io::pbm::save(input_cleaned, "input_denoised.pbm"); @@ -273,13 +277,14 @@ int main(int argc, char* argv[]) scribo::make::debug_filename("step2_looks_like_a_text_line.ppm")); // Bboxes image. - scribo::debug::save_bboxes_image(input, lines, argv[2]); + scribo::debug::save_bboxes_image(input, lines, + scribo::make::debug_filename("step2_bboxes.ppm")); //===== END OF DEBUG ===== - scribo::text::recognition(lines, "fra", "out.txt"); + scribo::text::recognition(lines, "fra", argv[2]); // // Display median character space. -- 1.5.6.5
participants (1)
-
Guillaume Lazzara