* preprocessing/all.hh,
* all.hh: fix includes.
* binarization/simple.hh: fix documentation and warnings.
* make/text.hh: add routine signature.
* preprocessing/unskew.hh: remove useless debug.
* scribo.mk: update path to milena directory.
* tests/preprocessing/unskew.cc: new test for unskew routine.
* tests/unit_test/unit-tests.mk: update unit test list.
* text/clean.hh: enlarge the image before cleaning it up.
---
scribo/ChangeLog | 21 ++++++++++++++
scribo/all.hh | 12 ++++----
scribo/binarization/simple.hh | 24 +++++-----------
scribo/make/text.hh | 19 +++++++++++--
scribo/preprocessing/all.hh | 4 +-
scribo/preprocessing/unskew.hh | 1 -
scribo/scribo.mk | 4 +-
scribo/tests/preprocessing/unskew.cc | 17 ++++++++++++
scribo/tests/unit_test/unit-tests.mk | 38 +++++++++++++++-----------
scribo/text/clean.hh | 49 +++++++++++++++++++++++++--------
10 files changed, 131 insertions(+), 58 deletions(-)
create mode 100644 scribo/tests/preprocessing/unskew.cc
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index 7b25394..4e49716 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,5 +1,26 @@
2009-05-28 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+ Small fixes in Scribo.
+
+ * preprocessing/all.hh,
+ * all.hh: fix includes.
+
+ * binarization/simple.hh: fix documentation and warnings.
+
+ * make/text.hh: add routine signature.
+
+ * preprocessing/unskew.hh: remove useless debug.
+
+ * scribo.mk: update path to milena directory.
+
+ * tests/preprocessing/unskew.cc: new test for unskew routine.
+
+ * tests/unit_test/unit-tests.mk: update unit test list.
+
+ * text/clean.hh: enlarge the image before cleaning it up.
+
+2009-05-28 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
Update samples in Scribo.
* src/Makefile.am,
diff --git a/scribo/all.hh b/scribo/all.hh
index 80c4bbf..d78e6a2 100644
--- a/scribo/all.hh
+++ b/scribo/all.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -39,14 +39,14 @@ namespace scribo
} // end of namespace scribo
+# include <scribo/core/all.hh>
+# include <scribo/debug/all.hh>
# include <scribo/draw/all.hh>
-# include <scribo/table/all.hh>
-# include <scribo/util/all.hh>
# include <scribo/filter/all.hh>
# include <scribo/make/all.hh>
+# include <scribo/preprocessing/all.hh>
+# include <scribo/table/all.hh>
# include <scribo/text/all.hh>
-# include <scribo/core/all.hh>
-# include <scribo/debug/all.hh>
-# include <scribo/deskew/all.hh>
+# include <scribo/util/all.hh>
#endif // ! SCRIBO_ALL_HH
diff --git a/scribo/binarization/simple.hh b/scribo/binarization/simple.hh
index 46953e9..36a5131 100644
--- a/scribo/binarization/simple.hh
+++ b/scribo/binarization/simple.hh
@@ -72,21 +72,13 @@ namespace scribo
/// Simple binarization of a gray-level document.
/*!
*
- * \param[in] input_ A binary image.
- * \param[in] nbh_ The neighborhood used for labeling image components.
- * \param[out] nlines The number of lines found.
- * \param[in] vwin Window used to extract the vertical lines in a morphological
- * opening
- * \param[in] hwin Window used to extract the horizontal lines in a morphological
- * opening
+ * \param[in] input_ A gray-level image.
*
- * \return pair of array of bounding boxes. The first array holds the
- * vertical lines bounding boxes and the second one the
- * horizontal lines bounding boxes.
+ * \result A Boolean image.
*/
template <typename I>
mln_ch_value(I, bool)
- simple(const Image<I>& input);
+ simple(const Image<I>& input_);
@@ -114,7 +106,7 @@ namespace scribo
unsigned nbasins;
mln_ch_value(I, unsigned) w = morpho::watershed::flooding(g, c4(), nbasins);
- h = histo::compute(input | (pw::value(w) == pw::cst(0)));
+ h = histo::compute(input | (pw::value(w) == pw::cst(0u)));
}
@@ -128,13 +120,13 @@ namespace scribo
convert::from_to(h, h_);
hs_ = linear::gaussian_1d(h_, sigma, 0);
l = labeling::regional_minima(hs_, c2(), n);
-
- if (n < 3)
+
+ if (n < 3u)
{
std::cerr << "This method has not worked properly!" <<
std::endl;
debug::histo(h, "tmp_h.txt");
-
+
std::ofstream file("tmp_hs.txt");
mln_piter(box1d) p(h_.domain());
for_all(p)
@@ -149,7 +141,7 @@ namespace scribo
c[0] = point1d(0); // Force a neutral value for the non-label value (0).
}
- int threshold;
+ unsigned threshold;
{
std::vector<int> v;
diff --git a/scribo/make/text.hh b/scribo/make/text.hh
index cac6356..406a77f 100644
--- a/scribo/make/text.hh
+++ b/scribo/make/text.hh
@@ -79,6 +79,20 @@ namespace scribo
V& nbboxes);
+ /// Construct a new util::text from another one.
+ ///
+ /// \param[in] text A text structure.
+ /// \param[in] f_ A function v2v or v2b. It will be used to regroup text
+ /// components.
+ ///
+ /// \return a new util::text.
+ //
+ template <typename L, typename F>
+ scribo::util::text<L>
+ text(const scribo::util::text<L>& text,
+ const Function<F>& f_);
+
+
# ifndef MLN_INCLUDE_ONLY
template <typename L>
@@ -123,9 +137,7 @@ namespace scribo
return make::text(cboxes, lbl, nbboxes);
}
- //FIXME: we want the following routine to construct a new util::text
- // from another one and a relabeling function. It avoids recomputing
- // the whole underlying data (mass centers, bboxes...)
+
template <typename L, typename F>
scribo::util::text<L>
text(const scribo::util::text<L>& text,
@@ -139,6 +151,7 @@ namespace scribo
mln_value(L) new_nbboxes;
mln::fun::i2v::array<mln_value(L)> fv2v
= mln::make::relabelfun(f, text.nbboxes(), new_nbboxes);
+
L lbl = labeling::relabel(text.label_image(), text.nbboxes(), fv2v);
mln::util::array< accu::bbox<mln_site(L)> >
tboxes(new_nbboxes.next());
diff --git a/scribo/preprocessing/all.hh b/scribo/preprocessing/all.hh
index 145d6f4..0218eaa 100644
--- a/scribo/preprocessing/all.hh
+++ b/scribo/preprocessing/all.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -43,6 +43,6 @@ namespace scribo
} // end of namespace scribo
-# include <scribo/preprocessing/hough.hh>
+# include <scribo/preprocessing/unskew.hh>
#endif // ! SCRIBO_PREPROCESSING_ALL_HH
diff --git a/scribo/preprocessing/unskew.hh b/scribo/preprocessing/unskew.hh
index bb71505..d092034 100644
--- a/scribo/preprocessing/unskew.hh
+++ b/scribo/preprocessing/unskew.hh
@@ -80,7 +80,6 @@ namespace scribo
point2d max_p = accu::compute(accu::max_site<image2d<float> >(),
hough_ima);
- std::cout << max_p.col() << std::endl;
double angle = 0;
int max_angle = max_p.col();
diff --git a/scribo/scribo.mk b/scribo/scribo.mk
index 866d51a..b32fe80 100644
--- a/scribo/scribo.mk
+++ b/scribo/scribo.mk
@@ -1,5 +1,5 @@
-include $(top_srcdir)/milena/tests/tests.mk
+#include $(top_srcdir)/milena/tests/tests.mk
# Add path to Scribo's headers
-AM_CPPFLAGS += -I$(top_srcdir)/ -I$(top_builddir)/
+AM_CPPFLAGS = -I$(top_srcdir)/ -I$(top_builddir)/ -I$(top_srcdir)/milena
-I$(top_builddir)/milena -DNDEBUG -O2
diff --git a/scribo/tests/preprocessing/unskew.cc b/scribo/tests/preprocessing/unskew.cc
new file mode 100644
index 0000000..c0291fe
--- /dev/null
+++ b/scribo/tests/preprocessing/unskew.cc
@@ -0,0 +1,17 @@
+#include <mln/core/image/image2d.hh>
+#include <mln/io/pbm/load.hh>
+#include <mln/io/pbm/save.hh>
+
+#include <scribo/preprocessing/unskew.hh>
+
+
+int main(int argc, char *argv[])
+{
+ (void) argc;
+ using namespace mln;
+
+ image2d<bool> ima;
+ io::pbm::load(ima, argv[1]);
+
+ io::pbm::save(scribo::preprocessing::unskew(ima), "tr.pbm");
+}
diff --git a/scribo/tests/unit_test/unit-tests.mk b/scribo/tests/unit_test/unit-tests.mk
index f7204da..761253b 100644
--- a/scribo/tests/unit_test/unit-tests.mk
+++ b/scribo/tests/unit_test/unit-tests.mk
@@ -5,36 +5,42 @@ scribo_all \
scribo_binarization_simple \
scribo_core_all \
scribo_core_central_sites \
-scribo_core_component_bboxes \
scribo_core_erase_bboxes \
scribo_core_macros \
+scribo_core_object_image \
scribo_debug_all \
scribo_debug_save_label_image \
scribo_debug_save_linked_textbboxes_image \
scribo_debug_save_table_image \
scribo_debug_save_textbboxes_image \
+scribo_debug_usage \
scribo_demat \
+scribo_demat_old \
scribo_draw_all \
scribo_draw_bounding_box_links \
scribo_draw_bounding_boxes \
+scribo_extract_lines_discontinued \
scribo_extract_primitive_canvas \
scribo_extract_primitive_cells \
scribo_extract_primitive_lines_discontinued \
scribo_extract_primitive_lines_h_discontinued \
+scribo_extract_primitive_lines_h_thick \
scribo_extract_primitive_lines_thick \
scribo_extract_primitive_lines_v_discontinued \
+scribo_extract_primitive_lines_v_thick \
scribo_extract_primitive_objects \
scribo_filter_all \
-scribo_filter_large_components \
-scribo_filter_small_components \
-scribo_filter_thick_bboxes \
-scribo_filter_thin_bboxes \
+scribo_filter_large_objects \
+scribo_filter_small_objects \
+scribo_filter_thick_objects \
+scribo_filter_thin_objects \
scribo_make_all \
scribo_make_debug_filename \
scribo_make_influence_zone_graph \
scribo_make_text \
scribo_preprocessing_all \
scribo_preprocessing_unskew \
+scribo_src_woot \
scribo_table_align_lines_horizontaly \
scribo_table_align_lines_verticaly \
scribo_table_all \
@@ -42,8 +48,6 @@ scribo_table_connect_horizontal_lines \
scribo_table_connect_vertical_lines \
scribo_table_erase \
scribo_table_extract \
-scribo_table_extract_lines_with_opening \
-scribo_table_extract_lines_with_rank \
scribo_table_internal_align_lines \
scribo_table_internal_all \
scribo_table_internal_connect_lines \
@@ -53,7 +57,6 @@ scribo_table_repair_horizontal_lines \
scribo_table_repair_vertical_lines \
scribo_text_all \
scribo_text_clean \
-scribo_text_extract_bboxes \
scribo_text_extract_lines \
scribo_text_grouping_all \
scribo_text_grouping_group_from_double_link \
@@ -82,36 +85,42 @@ scribo_all_SOURCES = scribo_all.cc
scribo_binarization_simple_SOURCES = scribo_binarization_simple.cc
scribo_core_all_SOURCES = scribo_core_all.cc
scribo_core_central_sites_SOURCES = scribo_core_central_sites.cc
-scribo_core_component_bboxes_SOURCES = scribo_core_component_bboxes.cc
scribo_core_erase_bboxes_SOURCES = scribo_core_erase_bboxes.cc
scribo_core_macros_SOURCES = scribo_core_macros.cc
+scribo_core_object_image_SOURCES = scribo_core_object_image.cc
scribo_debug_all_SOURCES = scribo_debug_all.cc
scribo_debug_save_label_image_SOURCES = scribo_debug_save_label_image.cc
scribo_debug_save_linked_textbboxes_image_SOURCES =
scribo_debug_save_linked_textbboxes_image.cc
scribo_debug_save_table_image_SOURCES = scribo_debug_save_table_image.cc
scribo_debug_save_textbboxes_image_SOURCES = scribo_debug_save_textbboxes_image.cc
+scribo_debug_usage_SOURCES = scribo_debug_usage.cc
scribo_demat_SOURCES = scribo_demat.cc
+scribo_demat_old_SOURCES = scribo_demat_old.cc
scribo_draw_all_SOURCES = scribo_draw_all.cc
scribo_draw_bounding_box_links_SOURCES = scribo_draw_bounding_box_links.cc
scribo_draw_bounding_boxes_SOURCES = scribo_draw_bounding_boxes.cc
+scribo_extract_lines_discontinued_SOURCES = scribo_extract_lines_discontinued.cc
scribo_extract_primitive_canvas_SOURCES = scribo_extract_primitive_canvas.cc
scribo_extract_primitive_cells_SOURCES = scribo_extract_primitive_cells.cc
scribo_extract_primitive_lines_discontinued_SOURCES =
scribo_extract_primitive_lines_discontinued.cc
scribo_extract_primitive_lines_h_discontinued_SOURCES =
scribo_extract_primitive_lines_h_discontinued.cc
+scribo_extract_primitive_lines_h_thick_SOURCES =
scribo_extract_primitive_lines_h_thick.cc
scribo_extract_primitive_lines_thick_SOURCES = scribo_extract_primitive_lines_thick.cc
scribo_extract_primitive_lines_v_discontinued_SOURCES =
scribo_extract_primitive_lines_v_discontinued.cc
+scribo_extract_primitive_lines_v_thick_SOURCES =
scribo_extract_primitive_lines_v_thick.cc
scribo_extract_primitive_objects_SOURCES = scribo_extract_primitive_objects.cc
scribo_filter_all_SOURCES = scribo_filter_all.cc
-scribo_filter_large_components_SOURCES = scribo_filter_large_components.cc
-scribo_filter_small_components_SOURCES = scribo_filter_small_components.cc
-scribo_filter_thick_bboxes_SOURCES = scribo_filter_thick_bboxes.cc
-scribo_filter_thin_bboxes_SOURCES = scribo_filter_thin_bboxes.cc
+scribo_filter_large_objects_SOURCES = scribo_filter_large_objects.cc
+scribo_filter_small_objects_SOURCES = scribo_filter_small_objects.cc
+scribo_filter_thick_objects_SOURCES = scribo_filter_thick_objects.cc
+scribo_filter_thin_objects_SOURCES = scribo_filter_thin_objects.cc
scribo_make_all_SOURCES = scribo_make_all.cc
scribo_make_debug_filename_SOURCES = scribo_make_debug_filename.cc
scribo_make_influence_zone_graph_SOURCES = scribo_make_influence_zone_graph.cc
scribo_make_text_SOURCES = scribo_make_text.cc
scribo_preprocessing_all_SOURCES = scribo_preprocessing_all.cc
scribo_preprocessing_unskew_SOURCES = scribo_preprocessing_unskew.cc
+scribo_src_woot_SOURCES = scribo_src_woot.cc
scribo_table_align_lines_horizontaly_SOURCES = scribo_table_align_lines_horizontaly.cc
scribo_table_align_lines_verticaly_SOURCES = scribo_table_align_lines_verticaly.cc
scribo_table_all_SOURCES = scribo_table_all.cc
@@ -119,8 +128,6 @@ scribo_table_connect_horizontal_lines_SOURCES =
scribo_table_connect_horizontal_
scribo_table_connect_vertical_lines_SOURCES = scribo_table_connect_vertical_lines.cc
scribo_table_erase_SOURCES = scribo_table_erase.cc
scribo_table_extract_SOURCES = scribo_table_extract.cc
-scribo_table_extract_lines_with_opening_SOURCES =
scribo_table_extract_lines_with_opening.cc
-scribo_table_extract_lines_with_rank_SOURCES = scribo_table_extract_lines_with_rank.cc
scribo_table_internal_align_lines_SOURCES = scribo_table_internal_align_lines.cc
scribo_table_internal_all_SOURCES = scribo_table_internal_all.cc
scribo_table_internal_connect_lines_SOURCES = scribo_table_internal_connect_lines.cc
@@ -130,7 +137,6 @@ scribo_table_repair_horizontal_lines_SOURCES =
scribo_table_repair_horizontal_li
scribo_table_repair_vertical_lines_SOURCES = scribo_table_repair_vertical_lines.cc
scribo_text_all_SOURCES = scribo_text_all.cc
scribo_text_clean_SOURCES = scribo_text_clean.cc
-scribo_text_extract_bboxes_SOURCES = scribo_text_extract_bboxes.cc
scribo_text_extract_lines_SOURCES = scribo_text_extract_lines.cc
scribo_text_grouping_all_SOURCES = scribo_text_grouping_all.cc
scribo_text_grouping_group_from_double_link_SOURCES =
scribo_text_grouping_group_from_double_link.cc
diff --git a/scribo/text/clean.hh b/scribo/text/clean.hh
index c8fa552..7a11329 100644
--- a/scribo/text/clean.hh
+++ b/scribo/text/clean.hh
@@ -34,14 +34,28 @@
/// Improve the quality of a text area.
# include <mln/core/concept/weighted_window.hh>
+# include <mln/core/routine/extend.hh>
+
# include <mln/morpho/skeleton_constrained.hh>
+
# include <mln/topo/skeleton/is_simple_point.hh>
# include <mln/topo/skeleton/crest.hh>
# include <mln/logical/not.hh>
-//# include <mln/debug/filename.hh>
-//# include <mln/io/pbm/save.hh>
+# include <mln/world/binary_2d/enlarge.hh>
+
+# include <mln/debug/filename.hh>
+# include <mln/io/pbm/save.hh>
+
+#include <mln/labeling/wrap.hh>
+#include <mln/win/octagon2d.hh>
+
+#include <mln/arith/revert.hh>
+
+
+#include <mln/linear/gaussian.hh>
+#include <mln/value/int_u8.hh>
namespace scribo
{
@@ -57,7 +71,7 @@ namespace scribo
# ifndef MLN_INCLUDE_ONLY
-// static int plop = 0;
+ static int plop = 0;
template <typename I, typename W>
mln_concrete(I)
@@ -72,30 +86,41 @@ namespace scribo
mln_precondition(input.is_valid());
mln_precondition(dmap_win.is_valid());
+ I input_large = world::binary_2d::enlarge(input, 2);
+
+// image2d<bool> blur = linear::gaussian(input_large, 2);
+// image2d<value::int_u8> blur =
linear::gaussian(level::convert(value::int_u8(), input_large), 2);
+// image2d<bool> blur =
level::transform(linear::gaussian(level::convert(value::int_u8(), input_large), 2),
fun::v2b::threshold<value::int_u8>(100));
+
mln_ch_value(I,unsigned)
- dmap = transform::distance_front(logical::not_(input), c8(),
+ dmap = transform::distance_front(logical::not_(input_large), c8(),
dmap_win,
mln_max(unsigned));
+// io::pgm::save(labeling::wrap(dmap), mln::debug::filename("dmap.pgm"));
- I constraint = topo::skeleton::crest(input, dmap, c8());
+// I skeleton = topo::skeleton::crest(input_large, dmap, c8());
+ I constraint = topo::skeleton::crest(input_large, dmap, c8());
mln_postcondition(constraint.is_valid());
+// io::pgm::save(labeling::wrap(constraint),
mln::debug::filename("constraint.pgm"));
+
I skeleton =
- morpho::skeleton_constrained(input, c8(),
+ morpho::skeleton_constrained(input_large, c8(),
topo::skeleton::is_simple_point<I,neighb2d>,
- extend(constraint, false), dmap);
+ extend(constraint, false), arith::revert(dmap));
- win::rectangle2d disk(3,3);
+ win::octagon2d disk(7);
I output = morpho::dilation(skeleton, disk);
-// if (plop < 10)
-// {
+// if (plop > 20 && plop < 50)
+ {
// io::pbm::save(input, mln::debug::filename("input.pbm"));
+// io::pbm::save(input_large,
mln::debug::filename("input_large_4x.pbm"));
// io::pbm::save(skeleton, mln::debug::filename("skeleton.pbm"));
// io::pbm::save(output, mln::debug::filename("dil_skel.pbm"));
-// ++plop;
-// }
+ }
+ ++plop;
trace::exiting("scribo::text::clean");
return output;
}
--
1.5.6.5