* debug/decision_image.hh: Fix precondition.
* filter/object_links_bbox_h_ratio.hh,
* filter/objects_thick.hh,
* primitive/internal/have_link_valid.hh,
* primitive/internal/is_link_valid.hh: Fix doc.
* filter/object_links_bbox_ratio.hh: Fix doc and invert ratio.
* filter/object_links_bottom_aligned.hh: Fix doc and use a float
angle value.
* filter/object_links_non_aligned.hh: Use absolute values.
* filter/object_links_non_aligned_simple.hh: Add special cases.
* filter/object_links_non_h_aligned.hh: Fix call to an underlying
routine.
* filter/objects_small.hh,
* filter/objects_thin.hh,
* filter/objects_v_thin.hh,
* primitive/extract/lines_discontinued.hh,
* primitive/extract/lines_h_single.hh,
* primitive/extract/lines_h_thick_and_single.hh,
* primitive/extract/lines_thick.hh,
* primitive/extract/lines_v_discontinued.hh,
* primitive/extract/lines_v_single.hh,
* primitive/extract/lines_v_thick_and_single.hh,
* primitive/internal/is_invalid_link.hh,
* src/multi_scale/find_lines.cc,
* src/primitive/group/group_from_rag.cc,
* src/table/rebuild_opening.cc,
* src/table/rebuild_rank.cc,
* text/clean.hh: Avoid warnings.
* primitive/internal/find_left_link.hh,
* primitive/internal/find_right_link.hh,
* primitive/internal/update_link_array.hh: Make the routine return
a value.
* src/binarization/sauvola.cc,
* src/binarization/sauvola_pgm.cc: Fix call to Sauvola's algorithm.
* src/primitive/group/group_from_graph.cc,
* src/primitive/group/group_from_several_graph.cc: Change
arguments values while calling with_several_graphes.
---
scribo/debug/decision_image.hh | 2 +-
scribo/filter/object_links_bbox_h_ratio.hh | 14 ++--
scribo/filter/object_links_bbox_ratio.hh | 31 ++++----
scribo/filter/object_links_bottom_aligned.hh | 33 +++++----
scribo/filter/object_links_non_aligned.hh | 6 +-
scribo/filter/object_links_non_aligned_simple.hh | 73 ++++++++++++++-----
scribo/filter/object_links_non_h_aligned.hh | 6 +-
scribo/filter/objects_small.hh | 4 +-
scribo/filter/objects_thick.hh | 2 +-
scribo/filter/objects_thin.hh | 5 +-
scribo/filter/objects_v_thin.hh | 3 +-
scribo/primitive/extract/lines_discontinued.hh | 3 +
scribo/primitive/extract/lines_h_single.hh | 4 +-
.../primitive/extract/lines_h_thick_and_single.hh | 4 +
scribo/primitive/extract/lines_thick.hh | 3 +
scribo/primitive/extract/lines_v_discontinued.hh | 3 +
scribo/primitive/extract/lines_v_single.hh | 4 +-
.../primitive/extract/lines_v_thick_and_single.hh | 4 +
scribo/primitive/internal/find_left_link.hh | 16 +++--
scribo/primitive/internal/find_right_link.hh | 18 +++--
scribo/primitive/internal/have_link_valid.hh | 3 +-
scribo/primitive/internal/is_invalid_link.hh | 9 ++-
scribo/primitive/internal/is_link_valid.hh | 3 +-
scribo/primitive/internal/update_link_array.hh | 18 +++--
scribo/primitive/link/merge_double_link.hh | 2 +-
scribo/src/binarization/sauvola.cc | 5 +-
scribo/src/binarization/sauvola_pgm.cc | 12 ++--
scribo/src/multi_scale/find_lines.cc | 3 +-
scribo/src/primitive/group/group_from_graph.cc | 2 +-
scribo/src/primitive/group/group_from_rag.cc | 2 +-
.../primitive/group/group_from_several_graph.cc | 2 +-
scribo/src/table/rebuild_opening.cc | 2 +-
scribo/src/table/rebuild_rank.cc | 4 +-
scribo/text/clean.hh | 1 +
34 files changed, 199 insertions(+), 107 deletions(-)
diff --git a/scribo/debug/decision_image.hh b/scribo/debug/decision_image.hh
index 447d3b0..34401ba 100644
--- a/scribo/debug/decision_image.hh
+++ b/scribo/debug/decision_image.hh
@@ -104,7 +104,7 @@ namespace scribo
mln_precondition(groups.is_valid());
mln_precondition(filtered_groups.is_valid());
mln_precondition(groups.size() == filtered_groups.size());
- mln_precondition(groups.objects_id() != filtered_groups.objects_id());
+ mln_precondition(groups.objects_id_() != filtered_groups.objects_id_());
/// Fixme: check that objects has been computed from input.
image2d<value::rgb8>
diff --git a/scribo/filter/object_links_bbox_h_ratio.hh
b/scribo/filter/object_links_bbox_h_ratio.hh
index 6ced8e6..e030a86 100644
--- a/scribo/filter/object_links_bbox_h_ratio.hh
+++ b/scribo/filter/object_links_bbox_h_ratio.hh
@@ -28,8 +28,10 @@
/// \file
///
-/// Invalidate links between two objects with too different height or
-/// width.
+/// Invalidate links between two objects with too different height.
+///
+/// \todo rename to object_links_bbox_v_ratio (v for vertical) to be
+/// consistent with other routine names.
# include <mln/util/array.hh>
@@ -52,7 +54,7 @@ namespace scribo
\param[in] objects An object image.
\param[in] links Link objects information.
- \param[in] min_h_ratio The minimum height ratio of two linked
+ \param[in] max_h_ratio The maximum height ratio of two linked
bounding boxes.
\result A filtered object link information.
@@ -61,7 +63,7 @@ namespace scribo
object_links<L>
object_links_bbox_h_ratio(const object_image(L)& objects,
const object_links<L>& links,
- float min_h_ratio);
+ float max_h_ratio);
# ifndef MLN_INCLUDE_ONLY
@@ -71,7 +73,7 @@ namespace scribo
object_links<L>
object_links_bbox_h_ratio(const object_image(L)& objects,
const object_links<L>& links,
- float min_h_ratio)
+ float max_h_ratio)
{
trace::entering("scribo::filter::object_links_bbox_h_ratio");
@@ -79,7 +81,7 @@ namespace scribo
mln_precondition(links.is_valid());
object_links<L>
- output = object_links_bbox_ratio(objects, links, 0, min_h_ratio);
+ output = object_links_bbox_ratio(objects, links, 0, max_h_ratio);
trace::exiting("scribo::filter::object_links_bbox_h_ratio");
return output;
diff --git a/scribo/filter/object_links_bbox_ratio.hh
b/scribo/filter/object_links_bbox_ratio.hh
index 3cd0c7e..2d9e507 100644
--- a/scribo/filter/object_links_bbox_ratio.hh
+++ b/scribo/filter/object_links_bbox_ratio.hh
@@ -52,7 +52,7 @@ namespace scribo
\param[in] objects An object image.
\param[in] links Link objects information.
\param[in] dim The dimension to use to compare bbox length.
- \param[in] min_ratio The minimum length ratio of two linked
+ \param[in] max_ratio The maximum length ratio of two linked
bounding boxes.
\result A filtered object link information.
@@ -62,7 +62,7 @@ namespace scribo
object_links_bbox_ratio(const object_image(L)& objects,
const object_links<L>& links,
unsigned dim,
- float min_ratio);
+ float max_ratio);
# ifndef MLN_INCLUDE_ONLY
@@ -73,7 +73,7 @@ namespace scribo
object_links_bbox_ratio(const object_image(L)& objects,
const object_links<L>& links,
unsigned dim,
- float min_ratio)
+ float max_ratio)
{
trace::entering("scribo::filter::object_links_bbox_ratio");
@@ -82,18 +82,19 @@ namespace scribo
object_links<L> output(links);
for (unsigned i = 1; i < links.size(); ++i)
- {
- float
- lmin = objects.bbox(i).pmax()[dim] - objects.bbox(i).pmin()[dim],
- lmax = objects.bbox(links(i)).pmax()[dim]
- - objects.bbox(links(i)).pmin()[dim];
-
- if (lmin > lmax)
- std::swap(lmin, lmax);
-
- if (lmin / lmax < min_ratio)
- output(i) = i;
- }
+ if (links[i] != i)
+ {
+ float
+ lmin = objects.bbox(i).pmax()[dim] - objects.bbox(i).pmin()[dim],
+ lmax = objects.bbox(links(i)).pmax()[dim]
+ - objects.bbox(links(i)).pmin()[dim];
+
+ if (lmin > lmax)
+ std::swap(lmin, lmax);
+
+ if ((lmax/ lmin) > max_ratio)
+ output(i) = i;
+ }
trace::exiting("scribo::filter::object_links_bbox_ratio");
return output;
diff --git a/scribo/filter/object_links_bottom_aligned.hh
b/scribo/filter/object_links_bottom_aligned.hh
index 0846203..d950a6e 100644
--- a/scribo/filter/object_links_bottom_aligned.hh
+++ b/scribo/filter/object_links_bottom_aligned.hh
@@ -53,31 +53,37 @@ namespace scribo
\param[in] objects An object image.
\param[in] links Object links information.
- \param[in] dim Choose the dimension on which applying the
- filter.
- \param[in] max_delta Maximum delta.
+ \param[in] max_alpha Maximum angle value (degrees).
\verbatim
+
------
| |
------ | |
| | | |
| x------------x |
- | | | | v
- ------ ~ ~ ~ |~ ~ | ~ ~ ~
- object1 | | | => delta, must be < to max_delta
- ------ ~ ~ ~
- object2 ^
-
+ | | | |
+ ------~ ~ ~ ~| ~ ~| ~ ~
+ object1 ~ | | ^
+ ~ | | |
+ ~------ |
+ object2 | Alpha
+ ~ |
+ ~ |
+ ~ |
+ ~ v
+ ~
\endverbatim
+ The angle between the two bottoms must be lower than \p max_alpha.
+
*/
template <typename L>
object_links<L>
object_links_bottom_aligned(const object_image(L)& objects,
const object_links<L>& links,
- unsigned max_delta);
+ float max_alpha);
# ifndef MLN_INCLUDE_ONLY
@@ -87,7 +93,7 @@ namespace scribo
object_links<L>
object_links_bottom_aligned(const object_image(L)& objects,
const object_links<L>& links,
- unsigned max_delta)
+ float max_alpha)
{
trace::entering("scribo::filter::object_links_bottom_aligned");
@@ -96,8 +102,7 @@ namespace scribo
object_links<L>
output = object_links_non_aligned_simple(objects, links,
- 1, 1,
- max_delta);
+ 1, max_alpha);
trace::exiting("scribo::filter::object_links_bottom_aligned");
return output;
@@ -112,4 +117,4 @@ namespace scribo
} // end of namespace scribo
-#endif // ! SCRIBO_FILTER_OBJECT_LINKS_NON_ALIGNED_SIMPLE_HH
+#endif // ! SCRIBO_FILTER_OBJECT_LINKS_BOTTOM_ALIGNED_HH
diff --git a/scribo/filter/object_links_non_aligned.hh
b/scribo/filter/object_links_non_aligned.hh
index 5d7e99a..b81a0ab 100644
--- a/scribo/filter/object_links_non_aligned.hh
+++ b/scribo/filter/object_links_non_aligned.hh
@@ -31,6 +31,7 @@
/// Invalidate links between two non aligned objects.
+# include <mln/math/abs.hh>
# include <mln/util/array.hh>
# include <scribo/core/macros.hh>
@@ -115,9 +116,10 @@ namespace scribo
hmax = i;
}
- if ((bboxes[hmin].pmin()[dim] - (float)bboxes[hmax].pmin()[dim]) > max_delta
- || (bboxes[hmin].pmax()[dim] - (float) bboxes[hmax].pmax()[dim]) > max_delta)
+ if (static_cast<unsigned>(math::abs((bboxes[hmin].pmin()[dim] -
bboxes[hmax].pmin()[dim]))) > max_delta
+ || static_cast<unsigned>(math::abs((bboxes[hmin].pmax()[dim] -
bboxes[hmax].pmax()[dim]))) > max_delta)
output[i] = i;
+
}
trace::exiting("scribo::filter::object_links_non_aligned");
diff --git a/scribo/filter/object_links_non_aligned_simple.hh
b/scribo/filter/object_links_non_aligned_simple.hh
index e302fcf..032b4d0 100644
--- a/scribo/filter/object_links_non_aligned_simple.hh
+++ b/scribo/filter/object_links_non_aligned_simple.hh
@@ -32,6 +32,8 @@
# include <mln/util/array.hh>
+# include <mln/math/abs.hh>
+# include <mln/math/pi.hh>
# include <scribo/core/macros.hh>
# include <scribo/core/object_links.hh>
@@ -50,9 +52,7 @@ namespace scribo
\param[in] objects An object image.
\param[in] links Object links information.
- \param[in] dim Choose the dimension on which applying the
- filter.
- \param[in] max_delta Maximum delta.
+ \param[in] max_alpha Maximum angle value (degrees).
Exemple with dim == 1 and edge == 1 (bottom
@@ -65,22 +65,33 @@ namespace scribo
------ | |
| | | |
| x------------x |
- | | | | v
- ------ ~ ~ ~ |~ ~ | ~ ~ ~
- object1 | | | => delta, must be < to max_delta
- ------ ~ ~ ~
- object2 ^
-
+ | | | |
+ ------~ ~ ~ ~| ~ ~| ~ ~
+ object1 ~ | | ^
+ ~ | | |
+ ~------ |
+ object2 | Alpha
+ ~ |
+ ~ |
+ ~ |
+ ~ v
+ ~
\endverbatim
+ The angle between the two bottoms must be lower than \p alpha.
+
+ edge values :
+ 0 = top
+ 1 = bottom
+ 2 = center
+
*/
template <typename L>
object_links<L>
object_links_non_aligned_simple(const object_image(L)& objects,
const object_links<L>& links,
- unsigned dim,
unsigned edge,
- unsigned max_delta);
+ float max_alpha);
# ifndef MLN_INCLUDE_ONLY
@@ -90,9 +101,8 @@ namespace scribo
object_links<L>
object_links_non_aligned_simple(const object_image(L)& objects,
const object_links<L>& links,
- unsigned dim,
unsigned edge,
- unsigned max_delta)
+ float max_alpha)
{
trace::entering("scribo::filter::object_links_non_aligned_simple");
@@ -102,34 +112,59 @@ namespace scribo
typedef typename object_image(L)::bbox_t bbox_t;
const mln::util::array<bbox_t>& bboxes = objects.bboxes();
object_links<L> output(links);
- unsigned delta;
+ float dr, dc;
+ float max_alpha_rad = (max_alpha / 180.0f) * math::pi;
+
+ // Top
if (edge == 0)
{
for_all_components(i, objects.bboxes())
if (links[i] != i)
{
- delta = bboxes[i].pmin()[dim] - bboxes[i].pmin()[dim];
+ dr = math::abs(bboxes[i].pmin().row()
+ - bboxes[links[i]].pmin().row());
+ dc = math::abs(bboxes[i].center().col()
+ - bboxes[links[i]].center().col());
- if (delta > max_delta)
+ if (std::atan(dr / dc) > max_alpha_rad)
output[i] = i;
}
}
+ // Bottom
else if (edge == 1)
for_all_components(i, objects.bboxes())
{
if (links[i] != i)
{
- delta = bboxes[i].pmax()[dim] - bboxes[i].pmax()[dim];
+ dr = math::abs(bboxes[i].pmax().row()
+ - bboxes[links[i]].pmax().row());
+ dc = math::abs(bboxes[i].center().col()
+ - bboxes[links[i]].center().col());
+
+ if (std::atan(dr / dc) > max_alpha_rad)
+ output[i] = i;
+ }
+ }
+ // Center
+ else if (edge == 2)
+ for_all_components(i, objects.bboxes())
+ {
+ if (links[i] != i)
+ {
+ dr = math::abs(bboxes[i].center().row()
+ - bboxes[links[i]].center().row());
+ dc = math::abs(bboxes[i].center().col()
+ - bboxes[links[i]].center().col());
- if (delta > max_delta)
+ if (std::atan(dr / dc) > max_alpha_rad)
output[i] = i;
}
}
else
{
- trace::warning("Invalid edge value...");
+ trace::warning("Invalid edge value... Aborting computation.");
trace::exiting("scribo::filter::object_links_non_aligned_simple");
return output;
}
diff --git a/scribo/filter/object_links_non_h_aligned.hh
b/scribo/filter/object_links_non_h_aligned.hh
index cae84a9..8216316 100644
--- a/scribo/filter/object_links_non_h_aligned.hh
+++ b/scribo/filter/object_links_non_h_aligned.hh
@@ -76,7 +76,7 @@ namespace scribo
object_links<L>
object_links_non_h_aligned(const object_image(L)& objects,
const object_links<L>& links,
- float ratio);
+ float max_delta);
# ifndef MLN_INCLUDE_ONLY
@@ -85,14 +85,14 @@ namespace scribo
object_links<L>
object_links_non_h_aligned(const object_image(L)& objects,
const object_links<L>& links,
- float ratio)
+ float max_delta)
{
trace::entering("scribo::filter::object_links_non_h_aligned");
mln_precondition(objects.is_valid());
object_links<L>
- output = object_links_non_aligned(objects, links, 1, ratio);
+ output = object_links_non_aligned(objects, links, 0, max_delta);
trace::exiting("scribo::filter::object_links_non_h_aligned");
return output;
diff --git a/scribo/filter/objects_small.hh b/scribo/filter/objects_small.hh
index cb65136..d1a0cf3 100644
--- a/scribo/filter/objects_small.hh
+++ b/scribo/filter/objects_small.hh
@@ -34,6 +34,7 @@
# include <mln/core/concept/image.hh>
# include <mln/core/concept/neighborhood.hh>
# include <mln/core/concept/function.hh>
+# include <mln/core/image/dmorph/image_if.hh>
# include <mln/labeling/blobs.hh>
# include <mln/labeling/relabel.hh>
@@ -110,6 +111,7 @@ namespace scribo
mln_precondition(input.is_valid());
mln_precondition(nbh.is_valid());
+ (void) label_type;
V nlabels;
typedef mln_ch_value(I,V) lbl_t;
@@ -120,7 +122,7 @@ namespace scribo
lbl.relabel(fv2b);
mln_concrete(I) output = duplicate(input);
- data::fill((output | pw::value(lbl) == pw::cst(literal::zero)).rw(),
+ data::fill((output | (pw::value(lbl) == pw::cst(literal::zero))).rw(),
false);
trace::exiting("scribo::filter::objects_small");
diff --git a/scribo/filter/objects_thick.hh b/scribo/filter/objects_thick.hh
index 519bd8c..5fe884e 100644
--- a/scribo/filter/objects_thick.hh
+++ b/scribo/filter/objects_thick.hh
@@ -66,7 +66,7 @@ namespace scribo
unsigned max_thickness);
- /// Remove lines of text thicker or equal to \p max_thickness.
+ /// Remove objects thicker or equal to \p max_thickness.
///
/// \param[in] objects An object image.
/// \param[in] max_thickness The maximum thickness value.
diff --git a/scribo/filter/objects_thin.hh b/scribo/filter/objects_thin.hh
index 510a64f..e9c869b 100644
--- a/scribo/filter/objects_thin.hh
+++ b/scribo/filter/objects_thin.hh
@@ -32,6 +32,8 @@
# include <mln/core/concept/image.hh>
# include <mln/core/concept/neighborhood.hh>
+# include <mln/core/image/dmorph/image_if.hh>
+# include <mln/pw/all.hh>
# include <mln/util/array.hh>
@@ -140,6 +142,7 @@ namespace scribo
mln_precondition(input.is_valid());
mln_precondition(nbh.is_valid());
+ (void) label_type;
V nlabels;
typedef mln_ch_value(I,V) lbl_t;
@@ -151,7 +154,7 @@ namespace scribo
objects.relabel(fv2b);
mln_concrete(I) output = duplicate(input);
- data::fill((output | pw::value(objects) == pw::cst(literal::zero)).rw(),
+ data::fill((output | (pw::value(objects) == pw::cst(literal::zero))).rw(),
false);
trace::exiting("scribo::filter::objects_thin");
diff --git a/scribo/filter/objects_v_thin.hh b/scribo/filter/objects_v_thin.hh
index bcf6726..6564d30 100644
--- a/scribo/filter/objects_v_thin.hh
+++ b/scribo/filter/objects_v_thin.hh
@@ -137,6 +137,7 @@ namespace scribo
{
trace::entering("scribo::filter::objects_v_thin");
+ (void) label_type;
const I& input = exact(input_);
const N& nbh = exact(nbh_);
@@ -153,7 +154,7 @@ namespace scribo
objects.relabel(fv2b);
mln_concrete(I) output = duplicate(input);
- data::fill((output | pw::value(objects) == pw::cst(literal::zero)).rw(),
+ data::fill((output | (pw::value(objects) == pw::cst(literal::zero))).rw(),
false);
trace::exiting("scribo::filter::objects_v_thin");
diff --git a/scribo/primitive/extract/lines_discontinued.hh
b/scribo/primitive/extract/lines_discontinued.hh
index 8ced7e3..2ea7de6 100644
--- a/scribo/primitive/extract/lines_discontinued.hh
+++ b/scribo/primitive/extract/lines_discontinued.hh
@@ -98,6 +98,9 @@ namespace scribo
mln_precondition(exact(nbh).is_valid());
mln_precondition(exact(win).is_valid());
+ (void) input;
+ (void) nbh;
+ (void) win;
(void) nlines;
(void) rank_k;
}
diff --git a/scribo/primitive/extract/lines_h_single.hh
b/scribo/primitive/extract/lines_h_single.hh
index 9b6d7c4..4e9cb74 100644
--- a/scribo/primitive/extract/lines_h_single.hh
+++ b/scribo/primitive/extract/lines_h_single.hh
@@ -108,8 +108,8 @@ namespace scribo
is_line_h_single(const object_image(L)& objects,
float w_h_ratio, unsigned min_line_length)
- : objects_(objects),
- w_h_ratio_(w_h_ratio), min_line_length_(min_line_length)
+ : w_h_ratio_(w_h_ratio), min_line_length_(min_line_length),
+ objects_(objects)
{
}
diff --git a/scribo/primitive/extract/lines_h_thick_and_single.hh
b/scribo/primitive/extract/lines_h_thick_and_single.hh
index 969acf5..3b3185b 100644
--- a/scribo/primitive/extract/lines_h_thick_and_single.hh
+++ b/scribo/primitive/extract/lines_h_thick_and_single.hh
@@ -104,6 +104,10 @@ namespace scribo
mln_precondition(exact(input).is_valid());
mln_precondition(exact(nbh).is_valid());
+ (void) input;
+ (void) nbh;
+ (void) min_line_length;
+ (void) h_w_ratio;
(void) nlines;
}
diff --git a/scribo/primitive/extract/lines_thick.hh
b/scribo/primitive/extract/lines_thick.hh
index f54e9b0..230b63c 100644
--- a/scribo/primitive/extract/lines_thick.hh
+++ b/scribo/primitive/extract/lines_thick.hh
@@ -93,6 +93,9 @@ namespace scribo
mln_precondition(exact(nbh).is_valid());
mln_precondition(exact(win).is_valid());
+ (void) input;
+ (void) nbh;
+ (void) win;
(void) nlines;
}
diff --git a/scribo/primitive/extract/lines_v_discontinued.hh
b/scribo/primitive/extract/lines_v_discontinued.hh
index 8463111..8f64472 100644
--- a/scribo/primitive/extract/lines_v_discontinued.hh
+++ b/scribo/primitive/extract/lines_v_discontinued.hh
@@ -87,6 +87,9 @@ namespace scribo
mln_precondition(exact(nbh).is_valid());
mln_precondition(line_length % 2);
+ (void) input;
+ (void) nbh;
+ (void) line_length;
(void) nlines;
(void) rank_k;
}
diff --git a/scribo/primitive/extract/lines_v_single.hh
b/scribo/primitive/extract/lines_v_single.hh
index f700dd0..74391f6 100644
--- a/scribo/primitive/extract/lines_v_single.hh
+++ b/scribo/primitive/extract/lines_v_single.hh
@@ -107,8 +107,8 @@ namespace scribo
is_line_v_single(const object_image(L)& objects,
float h_w_ratio, unsigned min_line_length)
- : objects_(objects),
- h_w_ratio_(h_w_ratio), min_line_length_(min_line_length)
+ : h_w_ratio_(h_w_ratio), min_line_length_(min_line_length),
+ objects_(objects)
{
}
diff --git a/scribo/primitive/extract/lines_v_thick_and_single.hh
b/scribo/primitive/extract/lines_v_thick_and_single.hh
index 7ddd25f..eba25ab 100644
--- a/scribo/primitive/extract/lines_v_thick_and_single.hh
+++ b/scribo/primitive/extract/lines_v_thick_and_single.hh
@@ -103,6 +103,10 @@ namespace scribo
mln_precondition(exact(input).is_valid());
mln_precondition(exact(nbh).is_valid());
+ (void) input;
+ (void) nbh;
+ (void) min_line_length;
+ (void) h_w_ratio;
(void) nlines;
}
diff --git a/scribo/primitive/internal/find_left_link.hh
b/scribo/primitive/internal/find_left_link.hh
index 243ac99..4f30e36 100644
--- a/scribo/primitive/internal/find_left_link.hh
+++ b/scribo/primitive/internal/find_left_link.hh
@@ -29,12 +29,15 @@
/// \file
///
/// Find the left neighbor of a line of text if exists.
+///
+/// \todo To be deleted.
# include <mln/core/concept/image.hh>
# include <mln/math/abs.hh>
# include <mln/util/array.hh>
+# include <mln/util/couple.hh>
# include <scribo/core/object_image.hh>
# include <scribo/primitive/internal/update_link_array.hh>
@@ -61,22 +64,22 @@ namespace scribo
/// \param c The lookup start point.
//
template <typename L>
- void
+ mln::util::couple<bool, mln_site(L)>
find_left_link(const object_image(L)& objects,
mln::util::array<unsigned>& left_link,
unsigned current_comp,
- int dmax,
+ float dmax,
const mln_site(L)& c);
# ifndef MLN_INCLUDE_ONLY
template <typename L>
- void
+ mln::util::couple<bool, mln_site(L)>
find_left_link(const object_image(L)& objects,
mln::util::array<unsigned>& left_link,
unsigned current_comp,
- int dmax,
+ float dmax,
const mln_site(L)& c)
{
///FIXME: the following code is not generic...
@@ -87,7 +90,10 @@ namespace scribo
current_comp, c, dmax))
--p.col();
- update_link_array(objects, left_link, p, c, current_comp, dmax);
+ bool
+ b = update_link_array(objects, left_link, p, c, current_comp, dmax);
+
+ return mln::make::couple(b, p);
}
# endif // MLN_INCLUDE_ONLY
diff --git a/scribo/primitive/internal/find_right_link.hh
b/scribo/primitive/internal/find_right_link.hh
index 1964a6d..09e60f9 100644
--- a/scribo/primitive/internal/find_right_link.hh
+++ b/scribo/primitive/internal/find_right_link.hh
@@ -29,12 +29,15 @@
/// \file
///
/// Find the right neighbor of a line of text if exists.
+///
+/// \todo To be deleted.
# include <mln/core/concept/image.hh>
# include <mln/math/abs.hh>
# include <mln/util/array.hh>
+# include <mln/util/couple.hh>
# include <scribo/core/object_image.hh>
# include <scribo/primitive/internal/update_link_array.hh>
@@ -61,25 +64,25 @@ namespace scribo
/// \param c The lookup start point.
//
template <typename L>
- void
+ mln::util::couple<bool, mln_site(L)>
find_right_link(const object_image(L)& objects,
mln::util::array<unsigned>& right_link,
unsigned current_comp,
- int dmax,
+ float dmax,
const mln_site(L)& c);
# ifndef MLN_INCLUDE_ONLY
template <typename L>
- void
+ mln::util::couple<bool, mln_site(L)>
find_right_link(const object_image(L)& objects,
mln::util::array<unsigned>& right_link,
unsigned current_comp,
- int dmax,
+ float dmax,
const mln_site(L)& c)
{
- ///FIXME: the following code is not generic...
+ /// FIXME: the following code is not generic...
/// First site on the right of the central site
mln_site(L) p = c + mln::right;
@@ -87,7 +90,10 @@ namespace scribo
current_comp, c, dmax))
++p.col();
- update_link_array(objects, right_link, p, c, current_comp, dmax);
+ bool
+ b = update_link_array(objects, right_link, p, c, current_comp, dmax);
+
+ return mln::make::couple(b, p);
}
# endif // MLN_INCLUDE_ONLY
diff --git a/scribo/primitive/internal/have_link_valid.hh
b/scribo/primitive/internal/have_link_valid.hh
index 3425745..accf7ff 100644
--- a/scribo/primitive/internal/have_link_valid.hh
+++ b/scribo/primitive/internal/have_link_valid.hh
@@ -29,7 +29,8 @@
/// \file
///
/// Tells whether a component have at least one valid link
-
+///
+/// \todo To be deleted ?.
# include <mln/util/array.hh>
# include <mln/util/couple.hh>
diff --git a/scribo/primitive/internal/is_invalid_link.hh
b/scribo/primitive/internal/is_invalid_link.hh
index dbabe72..e6343fd 100644
--- a/scribo/primitive/internal/is_invalid_link.hh
+++ b/scribo/primitive/internal/is_invalid_link.hh
@@ -29,7 +29,8 @@
/// \file
///
/// Check whether an objects link is invalid or not.
-
+///
+/// \todo To be deleted.
# include <mln/math/abs.hh>
# include <mln/literal/zero.hh>
@@ -64,7 +65,7 @@ namespace scribo
const mln_site(L)& p,
unsigned current_comp,
const mln_site(L)& c,
- int dmax);
+ float dmax);
# ifndef MLN_INCLUDE_ONLY
@@ -76,13 +77,13 @@ namespace scribo
const mln_site(L)& p,
unsigned current_comp,
const mln_site(L)& c,
- int dmax)
+ float dmax)
{
return (objects.domain().has(p) // Not outside image domain
&& (objects(p) == literal::zero // Is the background
|| objects(p) == current_comp // Is the current component
|| link_array[objects(p)] == current_comp) // Creates a loop
- && math::abs(p.col() - c.col()) < dmax); // Not too far
+ && static_cast<float>(math::abs(p.col() - c.col())) < dmax); // Not
too far
}
# endif // ! MLN_INCLUDE_ONLY
diff --git a/scribo/primitive/internal/is_link_valid.hh
b/scribo/primitive/internal/is_link_valid.hh
index 69fe484..34c27b8 100644
--- a/scribo/primitive/internal/is_link_valid.hh
+++ b/scribo/primitive/internal/is_link_valid.hh
@@ -29,7 +29,8 @@
/// \file
///
/// Validate a link from two different links.
-
+///
+/// \todo To be deleted ?.
# include <mln/util/array.hh>
# include <mln/util/couple.hh>
diff --git a/scribo/primitive/internal/update_link_array.hh
b/scribo/primitive/internal/update_link_array.hh
index 5e30bb5..f7fdf44 100644
--- a/scribo/primitive/internal/update_link_array.hh
+++ b/scribo/primitive/internal/update_link_array.hh
@@ -30,7 +30,8 @@
///
/// Update a lookup table if a neighbor is found on the right of
/// the current bbox.
-
+///
+/// \todo To be deleted.
# include <mln/core/concept/image.hh>
# include <mln/util/array.hh>
@@ -58,21 +59,21 @@ namespace scribo
/// \param[in] c A site of \p lbl.
//
template <typename I>
- void
+ bool
update_link_array(const Image<I>& lbl,
mln::util::array<unsigned>& link_array,
const mln_site(I)& p, const mln_site(I)& c,
- unsigned i, int dmax);
+ unsigned i, float dmax);
# ifndef MLN_INCLUDE_ONLY
template <typename I>
inline
- void
+ bool
update_link_array(const Image<I>& lbl_,
mln::util::array<unsigned>& link_array,
const mln_site(I)& p, const mln_site(I)& c,
- unsigned i, int dmax)
+ unsigned i, float dmax)
{
const I& lbl = exact(lbl_);
@@ -82,9 +83,14 @@ namespace scribo
if (lbl.domain().has(p) // Not outside image domain
&& lbl(p) != literal::zero // Not the background
&& lbl(p) != i // Not the current component
- && (math::abs(p.col() - c.col())) < dmax // Not too far
+ && static_cast<float>((math::abs(p.col() - c.col()))) < dmax // Not
too far
&& link_array[lbl(p)] != i) // Not creating a loop
+ {
link_array[i] = lbl(p);
+ return true;
+ }
+
+ return false;
}
# endif // ! MLN_INCLUDE_ONLY
diff --git a/scribo/primitive/link/merge_double_link.hh
b/scribo/primitive/link/merge_double_link.hh
index 3181117..f826048 100644
--- a/scribo/primitive/link/merge_double_link.hh
+++ b/scribo/primitive/link/merge_double_link.hh
@@ -101,7 +101,7 @@ namespace scribo
for_all_ncomponents(i, objects.nlabels())
{
mln::util::couple<bool, unsigned>
- nbh = internal::is_link_valid(left_link, right_link, i);
+ nbh = primitive::internal::is_link_valid(left_link, right_link, i);
if (!nbh.first())
merge[i] = i;
}
diff --git a/scribo/src/binarization/sauvola.cc b/scribo/src/binarization/sauvola.cc
index 9b34597..28d3ae7 100644
--- a/scribo/src/binarization/sauvola.cc
+++ b/scribo/src/binarization/sauvola.cc
@@ -25,6 +25,7 @@
#include <mln/io/ppm/load.hh>
#include <mln/io/pbm/save.hh>
+#include <mln/value/rgb8.hh>
#include <scribo/binarization/sauvola.hh>
#include <scribo/debug/usage.hh>
@@ -52,9 +53,7 @@ int main(int argc, char *argv[])
image2d<rgb8> input;
io::ppm::load(input, argv[1]);
-
- io::pbm::save(scribo::binarization::sauvola(input),
- argv[2]);
+ io::pbm::save(scribo::binarization::sauvola(input), argv[2]);
trace::exiting("main");
diff --git a/scribo/src/binarization/sauvola_pgm.cc
b/scribo/src/binarization/sauvola_pgm.cc
index cac71e1..f05ed5f 100644
--- a/scribo/src/binarization/sauvola_pgm.cc
+++ b/scribo/src/binarization/sauvola_pgm.cc
@@ -29,9 +29,11 @@
#include <scribo/binarization/sauvola.hh>
#include <scribo/debug/usage.hh>
+
const char *args_desc[][2] =
{
{ "input.pgm", "A gray level image." },
+ { "w", "Window size." },
{0, 0}
};
@@ -41,20 +43,20 @@ int main(int argc, char *argv[])
using namespace mln;
using value::int_u8;
- if (argc != 3)
+ if (argc != 4)
return scribo::debug::usage(argv,
"Binarization of a gray level image based on Sauvola's algorithm.",
- "input.pgm output.pbm",
+ "input.pgm w output.pbm",
args_desc, "A binary image.");
trace::entering("main");
+ unsigned w = atoi(argv[2]);
+
image2d<int_u8> input;
io::pgm::load(input, argv[1]);
-
- io::pbm::save(scribo::binarization::sauvola(input),
- argv[2]);
+ io::pbm::save(scribo::binarization::sauvola(input, w), argv[3]);
trace::exiting("main");
diff --git a/scribo/src/multi_scale/find_lines.cc b/scribo/src/multi_scale/find_lines.cc
index f91c2da..c5a2f97 100644
--- a/scribo/src/multi_scale/find_lines.cc
+++ b/scribo/src/multi_scale/find_lines.cc
@@ -65,6 +65,8 @@ namespace mln
process(const I& input, const std::string& filename,
unsigned length, unsigned delta, unsigned ratio)
{
+ (void) filename;
+
I hlines = scribo::primitive::extract::lines_h_pattern(input,
length,
delta);
@@ -72,7 +74,6 @@ namespace mln
value::label_16 nhlines;
hlines = scribo::filter::objects_v_thin(hlines, c8(),
nhlines, delta * ratio);
-
// I vlines = scribo::primitive::extract::lines_v_pattern(input,
// length,
// delta);
diff --git a/scribo/src/primitive/group/group_from_graph.cc
b/scribo/src/primitive/group/group_from_graph.cc
index 8b99c1b..833c4d4 100644
--- a/scribo/src/primitive/group/group_from_graph.cc
+++ b/scribo/src/primitive/group/group_from_graph.cc
@@ -66,7 +66,7 @@ int main(int argc, char* argv[])
typedef object_image(L) text_t;
text_t text = primitive::extract::objects(input, c8(), nbboxes);
- mln::util::graph g = primitive::link::with_graph(text, 30);
+ mln::util::graph g = primitive::link::with_graph(text, 255);
std::cout << "BEFORE - nbboxes = " << nbboxes.next() <<
std::endl;
scribo::debug::save_linked_bboxes_image(input,
diff --git a/scribo/src/primitive/group/group_from_rag.cc
b/scribo/src/primitive/group/group_from_rag.cc
index e354d09..23827a9 100644
--- a/scribo/src/primitive/group/group_from_rag.cc
+++ b/scribo/src/primitive/group/group_from_rag.cc
@@ -90,7 +90,7 @@ namespace scribo
mln_precondition(lbl.is_valid());
util::array<mln_result(A)>
- values = labeling::compute(accu, lbl_, nlabels);
+ values = labeling::compute(accu, lbl, nlabels);
vertex_image<void, mln_result(A), G>
v_ima = mln::make::vertex_image(g, values);
diff --git a/scribo/src/primitive/group/group_from_several_graph.cc
b/scribo/src/primitive/group/group_from_several_graph.cc
index 946e80f..3bba3ab 100644
--- a/scribo/src/primitive/group/group_from_several_graph.cc
+++ b/scribo/src/primitive/group/group_from_several_graph.cc
@@ -73,7 +73,7 @@ int main(int argc, char* argv[])
typedef object_image(L) text_t;
text_t text = scribo::primitive::extract::objects(input, c8(), nbboxes);
- mln::util::graph g = primitive::link::with_several_graphes(text, 30);
+ mln::util::graph g = primitive::link::with_several_graphes(text, 128);
std::cout << "BEFORE - nbboxes = " << nbboxes.next() <<
std::endl;
scribo::debug::save_linked_bboxes_image(input,
diff --git a/scribo/src/table/rebuild_opening.cc b/scribo/src/table/rebuild_opening.cc
index a13a00f..60d43e0 100644
--- a/scribo/src/table/rebuild_opening.cc
+++ b/scribo/src/table/rebuild_opening.cc
@@ -88,7 +88,7 @@ int main(int argc, char* argv[])
io::pgm::save(tables, scribo::make::debug_filename("table_cells.pgm"));
image2d<value::rgb8> input_rgb = data::convert(value::rgb8(), input);
- data::fill((input_rgb | pw::value(tables) == pw::cst(0u)).rw(), literal::red);
+ data::fill((input_rgb | (pw::value(tables) == pw::cst(0u))).rw(), literal::red);
io::ppm::save(input_rgb,
scribo::make::debug_filename("table_superposed.ppm"));
image2d<bool> in_wo_tables = table::erase(input, hlines, vlines);
diff --git a/scribo/src/table/rebuild_rank.cc b/scribo/src/table/rebuild_rank.cc
index 1c6b921..b04dac9 100644
--- a/scribo/src/table/rebuild_rank.cc
+++ b/scribo/src/table/rebuild_rank.cc
@@ -92,7 +92,7 @@ int main(int argc, char* argv[])
value::label_8 bg = data::compute(accu::maj_h<value::label_8>(), tables);
image2d<value::rgb8> sup = data::convert(value::rgb8(), input);
- data::paste((table_color | pw::value(tables) != pw::cst(bg))
+ data::paste((table_color | (pw::value(tables) != pw::cst(bg)))
| (pw::value(sup) == pw::cst(literal::black)), sup);
io::ppm::save(sup, scribo::make::debug_filename("table_color_sup.ppm"));
@@ -101,7 +101,7 @@ int main(int argc, char* argv[])
io::pgm::save(tables, scribo::make::debug_filename("table_cells.pgm"));
image2d<value::rgb8> input_rgb = data::convert(value::rgb8(), input);
- data::fill((input_rgb | pw::value(tables) == pw::cst(0u)).rw(), literal::red);
+ data::fill((input_rgb | (pw::value(tables) == pw::cst(0u))).rw(), literal::red);
io::ppm::save(input_rgb,
scribo::make::debug_filename("table_superposed.ppm"));
image2d<bool> in_wo_tables = table::erase(input, hlines, vlines);
diff --git a/scribo/text/clean.hh b/scribo/text/clean.hh
index e934241..cd8657e 100644
--- a/scribo/text/clean.hh
+++ b/scribo/text/clean.hh
@@ -105,6 +105,7 @@ namespace scribo
mlc_equal(mln_value(I),bool)::check();
mln_precondition(input.is_valid());
mln_precondition(dmap_win.is_valid());
+ (void) dmap_win;
// Resize
--
1.5.6.5