* src/debug/Makefile.am: Add new targets.
* src/debug/show_links_bbox_h_ratio.cc,
* src/debug/show_links_bbox_overlap.cc,
* src/debug/show_links_bottom_aligned.cc,
* src/debug/show_links_center_aligned.cc,
* src/debug/show_links_non_h_aligned.cc,
* src/debug/show_links_several_right.cc,
* src/debug/show_links_several_right_overlap.cc,
* src/debug/show_links_single_left.cc,
* src/debug/show_links_single_left_dmax_ratio.cc,
* src/debug/show_links_single_right.cc,
* src/debug/show_links_single_right_dmax_ratio.cc,
* src/debug/show_links_top_aligned.cc,
* src/debug/show_objects_large_small.cc,
* src/debug/show_objects_thick.cc: New debug tools.
* src/debug/show_objects_thin.cc: Write it.
---
scribo/ChangeLog | 23 ++++
scribo/src/debug/Makefile.am | 36 +++++-
..._single_right.cc => show_links_bbox_h_ratio.cc} | 57 +++------
...k_single_left.cc => show_links_bbox_overlap.cc} | 57 +++------
...ingle_right.cc => show_links_bottom_aligned.cc} | 59 +++-------
...ingle_right.cc => show_links_center_aligned.cc} | 56 +++------
...single_right.cc => show_links_non_h_aligned.cc} | 57 +++------
...single_right.cc => show_links_several_right.cc} | 38 ++-----
...ight.cc => show_links_several_right_overlap.cc} | 124 +++++++++++++------
...nk_single_left.cc => show_links_single_left.cc} | 117 +++++++++++++------
...eft.cc => show_links_single_left_dmax_ratio.cc} | 121 +++++++++++++-------
..._single_right.cc => show_links_single_right.cc} | 117 +++++++++++++------
...ht.cc => show_links_single_right_dmax_ratio.cc} | 121 +++++++++++++-------
...k_single_right.cc => show_links_top_aligned.cc} | 58 +++------
..._single_left.cc => show_objects_large_small.cc} | 69 ++++-------
...w_link_single_left.cc => show_objects_thick.cc} | 61 +++--------
scribo/src/debug/show_objects_thin.cc | 84 +++++++++++++
17 files changed, 703 insertions(+), 552 deletions(-)
copy scribo/src/debug/{show_link_single_right.cc => show_links_bbox_h_ratio.cc} (65%)
copy scribo/src/debug/{show_link_single_left.cc => show_links_bbox_overlap.cc} (65%)
copy scribo/src/debug/{show_link_single_right.cc => show_links_bottom_aligned.cc}
(64%)
copy scribo/src/debug/{show_link_single_right.cc => show_links_center_aligned.cc}
(65%)
copy scribo/src/debug/{show_link_single_right.cc => show_links_non_h_aligned.cc}
(65%)
copy scribo/src/debug/{show_link_single_right.cc => show_links_several_right.cc}
(76%)
copy scribo/src/debug/{show_link_single_right.cc =>
show_links_several_right_overlap.cc} (54%)
copy scribo/src/debug/{show_link_single_left.cc => show_links_single_left.cc} (57%)
copy scribo/src/debug/{show_link_single_left.cc =>
show_links_single_left_dmax_ratio.cc} (54%)
copy scribo/src/debug/{show_link_single_right.cc => show_links_single_right.cc} (57%)
copy scribo/src/debug/{show_link_single_right.cc =>
show_links_single_right_dmax_ratio.cc} (54%)
rename scribo/src/debug/{show_link_single_right.cc => show_links_top_aligned.cc}
(64%)
copy scribo/src/debug/{show_link_single_left.cc => show_objects_large_small.cc} (58%)
rename scribo/src/debug/{show_link_single_left.cc => show_objects_thick.cc} (59%)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index 2a3c71e..42d59dd 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,5 +1,28 @@
2009-11-03 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Add new debug tools.
+
+ * src/debug/Makefile.am: Add new targets.
+
+ * src/debug/show_links_bbox_h_ratio.cc,
+ * src/debug/show_links_bbox_overlap.cc,
+ * src/debug/show_links_bottom_aligned.cc,
+ * src/debug/show_links_center_aligned.cc,
+ * src/debug/show_links_non_h_aligned.cc,
+ * src/debug/show_links_several_right.cc,
+ * src/debug/show_links_several_right_overlap.cc,
+ * src/debug/show_links_single_left.cc,
+ * src/debug/show_links_single_left_dmax_ratio.cc,
+ * src/debug/show_links_single_right.cc,
+ * src/debug/show_links_single_right_dmax_ratio.cc,
+ * src/debug/show_links_top_aligned.cc,
+ * src/debug/show_objects_large_small.cc,
+ * src/debug/show_objects_thick.cc: New debug tools.
+
+ * src/debug/show_objects_thin.cc: Write it.
+
+2009-11-03 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Add new link filters.
* filter/internal/compute.hh: New routine to compute filter
diff --git a/scribo/src/debug/Makefile.am b/scribo/src/debug/Makefile.am
index 1d396a5..28839dc 100644
--- a/scribo/src/debug/Makefile.am
+++ b/scribo/src/debug/Makefile.am
@@ -20,17 +20,41 @@
include $(top_srcdir)/scribo/scribo.mk
bin_PROGRAMS = \
- show_objects_large \
show_left_right_links_validation \
- show_link_single_left \
- show_link_single_right \
+ show_links_bbox_h_ratio \
+ show_links_bbox_overlap \
+ show_links_bottom_aligned \
+ show_links_center_aligned \
+ show_links_non_h_aligned \
+ show_links_several_right \
+ show_links_several_right_overlap \
+ show_links_single_left \
+ show_links_single_left_dmax_ratio \
+ show_links_single_right \
+ show_links_single_right_dmax_ratio \
+ show_links_top_aligned \
+ show_objects_large \
+ show_objects_large_small \
show_objects_small \
+ show_objects_thick \
show_objects_thin
-show_objects_large_SOURCES = show_objects_large.cc
show_left_right_links_validation_SOURCES = show_left_right_links_validation.cc
-show_link_single_left_SOURCES = show_link_single_left.cc
-show_link_single_right_SOURCES = show_link_single_right.cc
+show_links_bbox_h_ratio_SOURCES = show_links_bbox_h_ratio.cc
+show_links_bbox_overlap_SOURCES = show_links_bbox_overlap.cc
+show_links_bottom_aligned_SOURCES = show_links_bottom_aligned.cc
+show_links_center_aligned_SOURCES = show_links_center_aligned.cc
+show_links_non_h_aligned_SOURCES = show_links_non_h_aligned.cc
+show_links_several_right_SOURCES = show_links_several_right.cc
+show_links_several_right_overlap_SOURCES = show_links_several_right_overlap.cc
+show_links_single_left_SOURCES = show_links_single_left.cc
+show_links_single_left_dmax_ratio_SOURCES = show_links_single_left_dmax_ratio.cc
+show_links_single_right_SOURCES = show_links_single_right.cc
+show_links_single_right_dmax_ratio_SOURCES = show_links_single_right_dmax_ratio.cc
+show_links_top_aligned_SOURCES = show_links_top_aligned.cc
+show_objects_large_SOURCES = show_objects_large.cc
+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
diff --git a/scribo/src/debug/show_link_single_right.cc
b/scribo/src/debug/show_links_bbox_h_ratio.cc
similarity index 65%
copy from scribo/src/debug/show_link_single_right.cc
copy to scribo/src/debug/show_links_bbox_h_ratio.cc
index 5f1001a..86841c6 100644
--- a/scribo/src/debug/show_link_single_right.cc
+++ b/scribo/src/debug/show_links_bbox_h_ratio.cc
@@ -39,10 +39,11 @@
#include <scribo/primitive/extract/objects.hh>
#include <scribo/primitive/link/with_single_right_link.hh>
+#include <scribo/primitive/link/with_single_left_link.hh>
+#include <scribo/filter/object_links_bbox_h_ratio.hh>
-#include <scribo/draw/bounding_boxes.hh>
-
-#include <scribo/debug/save_linked_bboxes_image.hh>
+#include <scribo/debug/decision_image.hh>
+#include <scribo/debug/links_decision_image.hh>
#include <scribo/debug/usage.hh>
@@ -50,7 +51,7 @@
const char *args_desc[][2] =
{
{ "input.pbm", "A binary image. True for objects and False for the
background." },
- { "max_nbh_dist", " Maximum distance for neighborhood search. (common
value : 30)" },
+ { "height_ratio", "Min height ratio between two bboxes. (common value :
2)" },
{0, 0}
};
@@ -63,8 +64,8 @@ int main(int argc, char* argv[])
if (argc != 4)
return scribo::debug::usage(argv,
- "Show sucessful/unsuccessful right links between components.",
- "input.pbm max_nbh_dist output.ppm",
+ "Show valid or invalid links according the bboxes height ratio.",
+ "input.pbm height_ratio output.ppm",
args_desc,
"A color image. Valid links are drawn in green, invalid ones in red.");
@@ -77,41 +78,21 @@ int main(int argc, char* argv[])
object_image(L) objects
= scribo::primitive::extract::objects(input, c8(), nbboxes);
- // Finding right links.
- object_links<L> right_link
- = primitive::link::with_single_right_link(objects, atoi(argv[2]));
-
-
- // Preparing output image.
- image2d<value::rgb8> output = data::convert(value::rgb8(), input);
- scribo::draw::bounding_boxes(output, objects, literal::blue);
-
-
- // Drawing links.
- mln::util::array<mln_result_(accu::center<mln_psite_(L)>)>
- mass_centers = labeling::compute(accu::meta::center(),
- objects, objects.nlabels());
-
- for_all_ncomponents(i, objects.nlabels())
- {
- unsigned midcol = (objects.bbox(i).pmax().col()
- - objects.bbox(i).pmin().col()) / 2;
- int dmax = midcol + atoi(argv[2]);
- mln_site_(L) c = mass_centers(i);
+ // Finding right links.
+ object_links<L> right_links
+ = primitive::link::with_single_right_link(objects);
- mln_site_(L) p = c + mln::right;
+ // Filtering.
+ object_links<L> hratio_filtered_links
+ = filter::object_links_bbox_h_ratio(objects, right_links, atof(argv[2]));
- while (is_invalid_link(objects, right_link, p, i, c, dmax))
- {
- if (right_link[i] != i)
- output(p) = literal::green;
- else
- output(p) = literal::red;
- ++p.col();
- }
- }
+ // Debug image.
+ image2d<value::rgb8> hratio_decision_image
+ = scribo::debug::links_decision_image(input,
+ right_links,
+ hratio_filtered_links);
+ io::ppm::save(hratio_decision_image, argv[3]);
- io::ppm::save(output, argv[3]);
}
diff --git a/scribo/src/debug/show_link_single_left.cc
b/scribo/src/debug/show_links_bbox_overlap.cc
similarity index 65%
copy from scribo/src/debug/show_link_single_left.cc
copy to scribo/src/debug/show_links_bbox_overlap.cc
index a8b42f2..eae1cd3 100644
--- a/scribo/src/debug/show_link_single_left.cc
+++ b/scribo/src/debug/show_links_bbox_overlap.cc
@@ -38,11 +38,12 @@
#include <mln/io/ppm/save.hh>
#include <scribo/primitive/extract/objects.hh>
+#include <scribo/primitive/link/with_single_right_link.hh>
#include <scribo/primitive/link/with_single_left_link.hh>
+#include <scribo/filter/object_links_bbox_overlap.hh>
-#include <scribo/draw/bounding_boxes.hh>
-
-#include <scribo/debug/save_linked_bboxes_image.hh>
+#include <scribo/debug/decision_image.hh>
+#include <scribo/debug/links_decision_image.hh>
#include <scribo/debug/usage.hh>
@@ -50,7 +51,7 @@
const char *args_desc[][2] =
{
{ "input.pbm", "A binary image. True for objects and False for the
background." },
- { "max_nbh_dist", " Maximum distance for neighborhood search. (common
value : 30)" },
+ { "ratio", "Maximum bounding boxes overlap ratio. (common value :
0.7)" },
{0, 0}
};
@@ -63,8 +64,8 @@ int main(int argc, char* argv[])
if (argc != 4)
return scribo::debug::usage(argv,
- "Show sucessful/unsuccessful left links between components.",
- "input.pbm max_nbh_dist output.ppm",
+ "Show valid or invalid links according the bboxes overlap.",
+ "input.pbm ratio output.ppm",
args_desc,
"A color image. Valid links are drawn in green, invalid ones in red.");
@@ -77,41 +78,21 @@ int main(int argc, char* argv[])
object_image(L) objects
= scribo::primitive::extract::objects(input, c8(), nbboxes);
- // Finding left links.
- object_links<L> left_link
- = primitive::link::with_single_left_link(objects, atoi(argv[2]));
-
-
-
- // Preparing output image.
- image2d<value::rgb8> output = data::convert(value::rgb8(), input);
- scribo::draw::bounding_boxes(output, objects, literal::blue);
-
-
- // Drawing links.
- mln::util::array<mln_result_(accu::center<mln_psite_(L)>)>
- mass_centers = labeling::compute(accu::meta::center(),
- objects, objects.nlabels());
- for_all_ncomponents(i, objects.nlabels())
- {
- unsigned midcol = (objects.bbox(i).pmax().col()
- - objects.bbox(i).pmin().col()) / 2;
- int dmax = midcol + atoi(argv[2]);
- mln_site_(L) c = mass_centers(i);
+ // Finding right links.
+ object_links<L> right_links
+ = primitive::link::with_single_right_link(objects);
- mln_site_(L) p = c + mln::left;
+ // Filtering.
+ object_links<L> hratio_filtered_links
+ = filter::object_links_bbox_overlap(objects, right_links, atof(argv[2]));
- while (is_invalid_link(objects, left_link, p, i, c, dmax))
- {
- if (left_link[i] != i)
- output(p) = literal::green;
- else
- output(p) = literal::red;
- --p.col();
- }
- }
+ // Debug image.
+ image2d<value::rgb8> hratio_decision_image
+ = scribo::debug::links_decision_image(input,
+ right_links,
+ hratio_filtered_links);
+ io::ppm::save(hratio_decision_image, argv[3]);
- io::ppm::save(output, argv[3]);
}
diff --git a/scribo/src/debug/show_link_single_right.cc
b/scribo/src/debug/show_links_bottom_aligned.cc
similarity index 64%
copy from scribo/src/debug/show_link_single_right.cc
copy to scribo/src/debug/show_links_bottom_aligned.cc
index 5f1001a..4751308 100644
--- a/scribo/src/debug/show_link_single_right.cc
+++ b/scribo/src/debug/show_links_bottom_aligned.cc
@@ -38,11 +38,10 @@
#include <mln/io/ppm/save.hh>
#include <scribo/primitive/extract/objects.hh>
-#include <scribo/primitive/link/with_single_right_link.hh>
+#include <scribo/primitive/link/with_single_right_link_bottom.hh>
+#include <scribo/filter/object_links_bottom_aligned.hh>
-#include <scribo/draw/bounding_boxes.hh>
-
-#include <scribo/debug/save_linked_bboxes_image.hh>
+#include <scribo/debug/alignment_decision_image.hh>
#include <scribo/debug/usage.hh>
@@ -50,7 +49,7 @@
const char *args_desc[][2] =
{
{ "input.pbm", "A binary image. True for objects and False for the
background." },
- { "max_nbh_dist", " Maximum distance for neighborhood search. (common
value : 30)" },
+ { "max_alpha", "Max angle between two object bottoms. (common value :
5)" },
{0, 0}
};
@@ -63,8 +62,8 @@ int main(int argc, char* argv[])
if (argc != 4)
return scribo::debug::usage(argv,
- "Show sucessful/unsuccessful right links between components.",
- "input.pbm max_nbh_dist output.ppm",
+ "Show valid or invalid links according the horizontal alignment (based on bottom
line).",
+ "input.pbm max_alpha output.ppm",
args_desc,
"A color image. Valid links are drawn in green, invalid ones in red.");
@@ -77,41 +76,21 @@ int main(int argc, char* argv[])
object_image(L) objects
= scribo::primitive::extract::objects(input, c8(), nbboxes);
- // Finding right links.
- object_links<L> right_link
- = primitive::link::with_single_right_link(objects, atoi(argv[2]));
-
-
-
- // Preparing output image.
- image2d<value::rgb8> output = data::convert(value::rgb8(), input);
- scribo::draw::bounding_boxes(output, objects, literal::blue);
+ // Finding right links.
+ object_links<L> right_links
+ = primitive::link::with_single_right_link_bottom(objects);
- // Drawing links.
- mln::util::array<mln_result_(accu::center<mln_psite_(L)>)>
- mass_centers = labeling::compute(accu::meta::center(),
- objects, objects.nlabels());
-
- for_all_ncomponents(i, objects.nlabels())
- {
- unsigned midcol = (objects.bbox(i).pmax().col()
- - objects.bbox(i).pmin().col()) / 2;
- int dmax = midcol + atoi(argv[2]);
- mln_site_(L) c = mass_centers(i);
-
- mln_site_(L) p = c + mln::right;
-
- while (is_invalid_link(objects, right_link, p, i, c, dmax))
- {
- if (right_link[i] != i)
- output(p) = literal::green;
- else
- output(p) = literal::red;
- ++p.col();
- }
+ // Filtering.
+ object_links<L> filtered_links
+ = filter::object_links_bottom_aligned(objects, right_links, atof(argv[2]));
- }
+ // Debug image.
+ image2d<value::rgb8> decision_image
+ = scribo::debug::alignment_decision_image(input,
+ right_links,
+ filtered_links,
+ scribo::debug::bottom);
+ io::ppm::save(decision_image, argv[3]);
- io::ppm::save(output, argv[3]);
}
diff --git a/scribo/src/debug/show_link_single_right.cc
b/scribo/src/debug/show_links_center_aligned.cc
similarity index 65%
copy from scribo/src/debug/show_link_single_right.cc
copy to scribo/src/debug/show_links_center_aligned.cc
index 5f1001a..dfcb775 100644
--- a/scribo/src/debug/show_link_single_right.cc
+++ b/scribo/src/debug/show_links_center_aligned.cc
@@ -39,10 +39,9 @@
#include <scribo/primitive/extract/objects.hh>
#include <scribo/primitive/link/with_single_right_link.hh>
+#include <scribo/filter/object_links_center_aligned.hh>
-#include <scribo/draw/bounding_boxes.hh>
-
-#include <scribo/debug/save_linked_bboxes_image.hh>
+#include <scribo/debug/alignment_decision_image.hh>
#include <scribo/debug/usage.hh>
@@ -50,7 +49,7 @@
const char *args_desc[][2] =
{
{ "input.pbm", "A binary image. True for objects and False for the
background." },
- { "max_nbh_dist", " Maximum distance for neighborhood search. (common
value : 30)" },
+ { "max_alpha", "Max angle between two object bottoms. (common value :
5)" },
{0, 0}
};
@@ -63,8 +62,8 @@ int main(int argc, char* argv[])
if (argc != 4)
return scribo::debug::usage(argv,
- "Show sucessful/unsuccessful right links between components.",
- "input.pbm max_nbh_dist output.ppm",
+ "Show valid or invalid links according the horizontal alignment (based on center
line).",
+ "input.pbm max_alpha output.ppm",
args_desc,
"A color image. Valid links are drawn in green, invalid ones in red.");
@@ -77,41 +76,22 @@ int main(int argc, char* argv[])
object_image(L) objects
= scribo::primitive::extract::objects(input, c8(), nbboxes);
- // Finding right links.
- object_links<L> right_link
- = primitive::link::with_single_right_link(objects, atoi(argv[2]));
-
-
- // Preparing output image.
- image2d<value::rgb8> output = data::convert(value::rgb8(), input);
- scribo::draw::bounding_boxes(output, objects, literal::blue);
-
-
- // Drawing links.
- mln::util::array<mln_result_(accu::center<mln_psite_(L)>)>
- mass_centers = labeling::compute(accu::meta::center(),
- objects, objects.nlabels());
-
- for_all_ncomponents(i, objects.nlabels())
- {
- unsigned midcol = (objects.bbox(i).pmax().col()
- - objects.bbox(i).pmin().col()) / 2;
- int dmax = midcol + atoi(argv[2]);
- mln_site_(L) c = mass_centers(i);
+ // Finding right links.
+ object_links<L> right_links
+ = primitive::link::with_single_right_link(objects);
- mln_site_(L) p = c + mln::right;
+ // Filtering.
+ object_links<L> filtered_links
+ = filter::object_links_center_aligned(objects, right_links, atof(argv[2]));
- while (is_invalid_link(objects, right_link, p, i, c, dmax))
- {
- if (right_link[i] != i)
- output(p) = literal::green;
- else
- output(p) = literal::red;
- ++p.col();
- }
+ // Debug image.
+ image2d<value::rgb8> decision_image
+ = scribo::debug::alignment_decision_image(input,
+ right_links,
+ filtered_links,
+ scribo::debug::center);
- }
+ io::ppm::save(decision_image, argv[3]);
- io::ppm::save(output, argv[3]);
}
diff --git a/scribo/src/debug/show_link_single_right.cc
b/scribo/src/debug/show_links_non_h_aligned.cc
similarity index 65%
copy from scribo/src/debug/show_link_single_right.cc
copy to scribo/src/debug/show_links_non_h_aligned.cc
index 5f1001a..04d3de5 100644
--- a/scribo/src/debug/show_link_single_right.cc
+++ b/scribo/src/debug/show_links_non_h_aligned.cc
@@ -39,10 +39,11 @@
#include <scribo/primitive/extract/objects.hh>
#include <scribo/primitive/link/with_single_right_link.hh>
+#include <scribo/primitive/link/with_single_left_link.hh>
+#include <scribo/filter/object_links_non_h_aligned.hh>
-#include <scribo/draw/bounding_boxes.hh>
-
-#include <scribo/debug/save_linked_bboxes_image.hh>
+#include <scribo/debug/decision_image.hh>
+#include <scribo/debug/links_decision_image.hh>
#include <scribo/debug/usage.hh>
@@ -50,7 +51,7 @@
const char *args_desc[][2] =
{
{ "input.pbm", "A binary image. True for objects and False for the
background." },
- { "max_nbh_dist", " Maximum distance for neighborhood search. (common
value : 30)" },
+ { "delta", "Max delta for horizontal alignment. (common value : 5)"
},
{0, 0}
};
@@ -63,8 +64,8 @@ int main(int argc, char* argv[])
if (argc != 4)
return scribo::debug::usage(argv,
- "Show sucessful/unsuccessful right links between components.",
- "input.pbm max_nbh_dist output.ppm",
+ "Show valid or invalid links according the horizontal alignment (based on top
and bottom lines).",
+ "input.pbm delta output.ppm",
args_desc,
"A color image. Valid links are drawn in green, invalid ones in red.");
@@ -77,41 +78,21 @@ int main(int argc, char* argv[])
object_image(L) objects
= scribo::primitive::extract::objects(input, c8(), nbboxes);
- // Finding right links.
- object_links<L> right_link
- = primitive::link::with_single_right_link(objects, atoi(argv[2]));
-
-
- // Preparing output image.
- image2d<value::rgb8> output = data::convert(value::rgb8(), input);
- scribo::draw::bounding_boxes(output, objects, literal::blue);
-
-
- // Drawing links.
- mln::util::array<mln_result_(accu::center<mln_psite_(L)>)>
- mass_centers = labeling::compute(accu::meta::center(),
- objects, objects.nlabels());
-
- for_all_ncomponents(i, objects.nlabels())
- {
- unsigned midcol = (objects.bbox(i).pmax().col()
- - objects.bbox(i).pmin().col()) / 2;
- int dmax = midcol + atoi(argv[2]);
- mln_site_(L) c = mass_centers(i);
+ // Finding right links.
+ object_links<L> right_links
+ = primitive::link::with_single_right_link(objects);
- mln_site_(L) p = c + mln::right;
+ // Filtering.
+ object_links<L> filtered_links
+ = filter::object_links_non_h_aligned(objects, right_links, atoi(argv[2]));
- while (is_invalid_link(objects, right_link, p, i, c, dmax))
- {
- if (right_link[i] != i)
- output(p) = literal::green;
- else
- output(p) = literal::red;
- ++p.col();
- }
- }
+ // Debug image.
+ image2d<value::rgb8> decision_image
+ = scribo::debug::links_decision_image(input,
+ right_links,
+ filtered_links);
+ io::ppm::save(decision_image, argv[3]);
- io::ppm::save(output, argv[3]);
}
diff --git a/scribo/src/debug/show_link_single_right.cc
b/scribo/src/debug/show_links_several_right.cc
similarity index 76%
copy from scribo/src/debug/show_link_single_right.cc
copy to scribo/src/debug/show_links_several_right.cc
index 5f1001a..05e4a74 100644
--- a/scribo/src/debug/show_link_single_right.cc
+++ b/scribo/src/debug/show_links_several_right.cc
@@ -38,11 +38,11 @@
#include <mln/io/ppm/save.hh>
#include <scribo/primitive/extract/objects.hh>
-#include <scribo/primitive/link/with_single_right_link.hh>
+#include <scribo/primitive/link/with_several_right_links.hh>
#include <scribo/draw/bounding_boxes.hh>
-#include <scribo/debug/save_linked_bboxes_image.hh>
+#include <scribo/debug/several_links_decision_image.hh>
#include <scribo/debug/usage.hh>
@@ -79,39 +79,17 @@ int main(int argc, char* argv[])
// Finding right links.
object_links<L> right_link
- = primitive::link::with_single_right_link(objects, atoi(argv[2]));
-
-
-
- // Preparing output image.
- image2d<value::rgb8> output = data::convert(value::rgb8(), input);
- scribo::draw::bounding_boxes(output, objects, literal::blue);
-
+ = primitive::link::with_several_right_links(objects, atoi(argv[2]));
// Drawing links.
mln::util::array<mln_result_(accu::center<mln_psite_(L)>)>
mass_centers = labeling::compute(accu::meta::center(),
objects, objects.nlabels());
- for_all_ncomponents(i, objects.nlabels())
- {
- unsigned midcol = (objects.bbox(i).pmax().col()
- - objects.bbox(i).pmin().col()) / 2;
- int dmax = midcol + atoi(argv[2]);
- mln_site_(L) c = mass_centers(i);
-
- mln_site_(L) p = c + mln::right;
-
- while (is_invalid_link(objects, right_link, p, i, c, dmax))
- {
- if (right_link[i] != i)
- output(p) = literal::green;
- else
- output(p) = literal::red;
- ++p.col();
- }
-
- }
+ image2d<value::rgb8> decision_image
+ = scribo::debug::several_links_decision_image(input,
+ right_link,
+ right_link);
- io::ppm::save(output, argv[3]);
+ io::ppm::save(decision_image, argv[3]);
}
diff --git a/scribo/src/debug/show_link_single_right.cc
b/scribo/src/debug/show_links_several_right_overlap.cc
similarity index 54%
copy from scribo/src/debug/show_link_single_right.cc
copy to scribo/src/debug/show_links_several_right_overlap.cc
index 5f1001a..6b2a66a 100644
--- a/scribo/src/debug/show_link_single_right.cc
+++ b/scribo/src/debug/show_links_several_right_overlap.cc
@@ -37,8 +37,12 @@
#include <mln/io/pbm/load.hh>
#include <mln/io/ppm/save.hh>
+#include <mln/draw/line.hh>
+
#include <scribo/primitive/extract/objects.hh>
-#include <scribo/primitive/link/with_single_right_link.hh>
+#include <scribo/primitive/link/internal/link_several_dmax_base.hh>
+#include <scribo/primitive/link/internal/anchors_3.hh>
+#include <scribo/primitive/link/compute_several.hh>
#include <scribo/draw/bounding_boxes.hh>
@@ -46,11 +50,83 @@
#include <scribo/debug/usage.hh>
+namespace scribo
+{
+
+ template <typename I, typename L>
+ struct several_right_overlap_debug_functor
+ : public primitive::link::internal::link_several_dmax_base<L,
several_right_overlap_debug_functor<I, L> >
+ {
+ typedef several_right_overlap_debug_functor<I, L> self_t;
+ typedef
+ primitive::link::internal::link_several_dmax_base<L, self_t> super_;
+
+ typedef
+ mln::util::array<mln::util::couple<unsigned, mln_site(L)>
+ potential_links_t;
+
+ public:
+ typedef mln_site(L) P;
+
+ several_right_overlap_debug_functor(const I& input,
+ const object_image(L)& objects,
+ float dmax)
+ : super_(objects, dmax, 3)
+ {
+ output_ = data::convert(value::rgb8(), input);
+ scribo::draw::bounding_boxes(output_, objects, literal::blue);
+ mln_postcondition(output_.is_valid());
+ }
+
+
+ void validate_link_(unsigned current_object,
+ const P& start_point,
+ const P& p,
+ unsigned anchor)
+ {
+ mln::draw::line(output_, start_point, p, literal::green);
+
+ super_::validate_link_(current_object, start_point, p, anchor);
+ }
+
+
+
+ void invalidate_link_(unsigned current_object,
+ const P& start_point,
+ const P& p,
+ unsigned anchor)
+ {
+ if (output_.domain().has(p))
+ mln::draw::line(output_, start_point, p, literal::red);
+ else
+ {
+ P tmp = p;
+ ++tmp.col();
+ mln::draw::line(output_, start_point, tmp, literal::red);
+ }
+
+ super_::invalidate_link_(current_object, start_point, p, anchor);
+ }
+
+
+
+ void compute_next_site_(P& p)
+ {
+ ++p.col();
+ }
+
+
+ image2d<value::rgb8> output_;
+ };
+
+
+}
+
const char *args_desc[][2] =
{
{ "input.pbm", "A binary image. True for objects and False for the
background." },
- { "max_nbh_dist", " Maximum distance for neighborhood search. (common
value : 30)" },
+ { "max_nbh_dist", "The maximum lookup distance. (common value :
30)" },
{0, 0}
};
@@ -68,7 +144,8 @@ int main(int argc, char* argv[])
args_desc,
"A color image. Valid links are drawn in green, invalid ones in red.");
- image2d<bool> input;
+ typedef image2d<bool> I;
+ I input;
io::pbm::load(input, argv[1]);
// Finding objects.
@@ -77,41 +154,10 @@ int main(int argc, char* argv[])
object_image(L) objects
= scribo::primitive::extract::objects(input, c8(), nbboxes);
- // Finding right links.
- object_links<L> right_link
- = primitive::link::with_single_right_link(objects, atoi(argv[2]));
-
-
-
- // Preparing output image.
- image2d<value::rgb8> output = data::convert(value::rgb8(), input);
- scribo::draw::bounding_boxes(output, objects, literal::blue);
-
-
- // Drawing links.
- mln::util::array<mln_result_(accu::center<mln_psite_(L)>)>
- mass_centers = labeling::compute(accu::meta::center(),
- objects, objects.nlabels());
-
- for_all_ncomponents(i, objects.nlabels())
- {
- unsigned midcol = (objects.bbox(i).pmax().col()
- - objects.bbox(i).pmin().col()) / 2;
- int dmax = midcol + atoi(argv[2]);
- mln_site_(L) c = mass_centers(i);
-
- mln_site_(L) p = c + mln::right;
-
- while (is_invalid_link(objects, right_link, p, i, c, dmax))
- {
- if (right_link[i] != i)
- output(p) = literal::green;
- else
- output(p) = literal::red;
- ++p.col();
- }
-
- }
+ // Write debug image.
+ several_right_overlap_debug_functor<I, L> functor(input,
+ objects, atof(argv[2]));
+ primitive::link::compute_several(functor);
- io::ppm::save(output, argv[3]);
+ io::ppm::save(functor.output_, argv[3]);
}
diff --git a/scribo/src/debug/show_link_single_left.cc
b/scribo/src/debug/show_links_single_left.cc
similarity index 57%
copy from scribo/src/debug/show_link_single_left.cc
copy to scribo/src/debug/show_links_single_left.cc
index a8b42f2..094ca85 100644
--- a/scribo/src/debug/show_link_single_left.cc
+++ b/scribo/src/debug/show_links_single_left.cc
@@ -37,8 +37,12 @@
#include <mln/io/pbm/load.hh>
#include <mln/io/ppm/save.hh>
+#include <mln/draw/line.hh>
+
#include <scribo/primitive/extract/objects.hh>
#include <scribo/primitive/link/with_single_left_link.hh>
+#include <scribo/primitive/link/internal/link_ms_dmax_base.hh>
+#include <scribo/primitive/link/compute.hh>
#include <scribo/draw/bounding_boxes.hh>
@@ -46,11 +50,79 @@
#include <scribo/debug/usage.hh>
+namespace scribo
+{
+
+ template <typename I, typename L>
+ struct single_left_link_debug_functor
+ : primitive::link::internal::link_ms_dmax_base<L,
+ single_left_link_debug_functor<I, L> >
+ {
+ typedef single_left_link_debug_functor<I, L> self_t;
+ typedef
+ primitive::link::internal::link_ms_dmax_base<L, self_t> super_;
+
+ public:
+ typedef mln_site(L) P;
+
+ single_left_link_debug_functor(const I& input,
+ const object_image(L)& objects,
+ float dmax)
+ : super_(objects, dmax)
+ {
+ output_ = data::convert(value::rgb8(), input);
+ scribo::draw::bounding_boxes(output_, objects, literal::blue);
+ mln_postcondition(output_.is_valid());
+ }
+
+ void validate_link_(unsigned current_object,
+ const P& start_point,
+ const P& p,
+ unsigned anchor)
+ {
+ mln::draw::line(output_, start_point, p, literal::green);
+
+ super_::validate_link_(current_object, start_point, p, anchor);
+ }
+
+
+
+ void invalidate_link_(unsigned current_object,
+ const P& start_point,
+ const P& p,
+ unsigned anchor)
+ {
+ if (output_.domain().has(p))
+ mln::draw::line(output_, start_point, p, literal::red);
+ else
+ {
+ P tmp = p;
+ ++tmp.col();
+ mln::draw::line(output_, start_point, tmp, literal::red);
+ }
+
+ super_::invalidate_link_(current_object, start_point, p, anchor);
+ }
+
+
+
+ void compute_next_site_(P& p)
+ {
+ --p.col();
+ }
+
+
+ image2d<value::rgb8> output_;
+ };
+
+
+}
+
const char *args_desc[][2] =
{
{ "input.pbm", "A binary image. True for objects and False for the
background." },
- { "max_nbh_dist", " Maximum distance for neighborhood search. (common
value : 30)" },
+ { "max_nbh_dist", "The maximum lookup distance. (common value :
30)" },
{0, 0}
};
@@ -68,7 +140,8 @@ int main(int argc, char* argv[])
args_desc,
"A color image. Valid links are drawn in green, invalid ones in red.");
- image2d<bool> input;
+ typedef image2d<bool> I;
+ I input;
io::pbm::load(input, argv[1]);
// Finding objects.
@@ -77,41 +150,9 @@ int main(int argc, char* argv[])
object_image(L) objects
= scribo::primitive::extract::objects(input, c8(), nbboxes);
- // Finding left links.
- object_links<L> left_link
- = primitive::link::with_single_left_link(objects, atoi(argv[2]));
-
-
-
- // Preparing output image.
- image2d<value::rgb8> output = data::convert(value::rgb8(), input);
- scribo::draw::bounding_boxes(output, objects, literal::blue);
-
-
- // Drawing links.
- mln::util::array<mln_result_(accu::center<mln_psite_(L)>)>
- mass_centers = labeling::compute(accu::meta::center(),
- objects, objects.nlabels());
-
- for_all_ncomponents(i, objects.nlabels())
- {
- unsigned midcol = (objects.bbox(i).pmax().col()
- - objects.bbox(i).pmin().col()) / 2;
- int dmax = midcol + atoi(argv[2]);
- mln_site_(L) c = mass_centers(i);
-
- mln_site_(L) p = c + mln::left;
-
- while (is_invalid_link(objects, left_link, p, i, c, dmax))
- {
- if (left_link[i] != i)
- output(p) = literal::green;
- else
- output(p) = literal::red;
- --p.col();
- }
-
- }
+ // Write debug image.
+ single_left_link_debug_functor<I, L> functor(input, objects, atof(argv[2]));
+ primitive::link::compute(functor);
- io::ppm::save(output, argv[3]);
+ io::ppm::save(functor.output_, argv[3]);
}
diff --git a/scribo/src/debug/show_link_single_left.cc
b/scribo/src/debug/show_links_single_left_dmax_ratio.cc
similarity index 54%
copy from scribo/src/debug/show_link_single_left.cc
copy to scribo/src/debug/show_links_single_left_dmax_ratio.cc
index a8b42f2..2ba0ace 100644
--- a/scribo/src/debug/show_link_single_left.cc
+++ b/scribo/src/debug/show_links_single_left_dmax_ratio.cc
@@ -37,8 +37,12 @@
#include <mln/io/pbm/load.hh>
#include <mln/io/ppm/save.hh>
+#include <mln/draw/line.hh>
+
#include <scribo/primitive/extract/objects.hh>
-#include <scribo/primitive/link/with_single_left_link.hh>
+#include <scribo/primitive/link/with_single_left_link_dmax_ratio.hh>
+#include <scribo/primitive/link/internal/link_ms_dmax_ratio_base.hh>
+#include <scribo/primitive/link/compute.hh>
#include <scribo/draw/bounding_boxes.hh>
@@ -46,11 +50,79 @@
#include <scribo/debug/usage.hh>
+namespace scribo
+{
+
+ template <typename I, typename L>
+ struct single_left_link_debug_functor
+ : primitive::link::internal::link_ms_dmax_ratio_base<L,
+ single_left_link_debug_functor<I, L> >
+ {
+ typedef single_left_link_debug_functor<I, L> self_t;
+ typedef
+ primitive::link::internal::link_ms_dmax_ratio_base<L, self_t> super_;
+
+ public:
+ typedef mln_site(L) P;
+
+ single_left_link_debug_functor(const I& input,
+ const object_image(L)& objects,
+ float dmax_ratio)
+ : super_(objects, dmax_ratio)
+ {
+ output_ = data::convert(value::rgb8(), input);
+ scribo::draw::bounding_boxes(output_, objects, literal::blue);
+ mln_postcondition(output_.is_valid());
+ }
+
+ void validate_link_(unsigned current_object,
+ const P& start_point,
+ const P& p,
+ unsigned anchor)
+ {
+ mln::draw::line(output_, start_point, p, literal::green);
+
+ super_::validate_link_(current_object, start_point, p, anchor);
+ }
+
+
+
+ void invalidate_link_(unsigned current_object,
+ const P& start_point,
+ const P& p,
+ unsigned anchor)
+ {
+ if (output_.domain().has(p))
+ mln::draw::line(output_, start_point, p, literal::red);
+ else
+ {
+ P tmp = p;
+ ++tmp.col();
+ mln::draw::line(output_, start_point, tmp, literal::red);
+ }
+
+ super_::invalidate_link_(current_object, start_point, p, anchor);
+ }
+
+
+
+ void compute_next_site_(P& p)
+ {
+ --p.col();
+ }
+
+
+ image2d<value::rgb8> output_;
+ };
+
+
+}
+
const char *args_desc[][2] =
{
{ "input.pbm", "A binary image. True for objects and False for the
background." },
- { "max_nbh_dist", " Maximum distance for neighborhood search. (common
value : 30)" },
+ { "max_nbh_dist_ratio", "Size ratio defining the maximum lookup
distance. (common value : 3)" },
{0, 0}
};
@@ -64,11 +136,12 @@ int main(int argc, char* argv[])
if (argc != 4)
return scribo::debug::usage(argv,
"Show sucessful/unsuccessful left links between components.",
- "input.pbm max_nbh_dist output.ppm",
+ "input.pbm max_nbh_dist_ratio output.ppm",
args_desc,
"A color image. Valid links are drawn in green, invalid ones in red.");
- image2d<bool> input;
+ typedef image2d<bool> I;
+ I input;
io::pbm::load(input, argv[1]);
// Finding objects.
@@ -77,41 +150,9 @@ int main(int argc, char* argv[])
object_image(L) objects
= scribo::primitive::extract::objects(input, c8(), nbboxes);
- // Finding left links.
- object_links<L> left_link
- = primitive::link::with_single_left_link(objects, atoi(argv[2]));
-
-
-
- // Preparing output image.
- image2d<value::rgb8> output = data::convert(value::rgb8(), input);
- scribo::draw::bounding_boxes(output, objects, literal::blue);
-
-
- // Drawing links.
- mln::util::array<mln_result_(accu::center<mln_psite_(L)>)>
- mass_centers = labeling::compute(accu::meta::center(),
- objects, objects.nlabels());
-
- for_all_ncomponents(i, objects.nlabels())
- {
- unsigned midcol = (objects.bbox(i).pmax().col()
- - objects.bbox(i).pmin().col()) / 2;
- int dmax = midcol + atoi(argv[2]);
- mln_site_(L) c = mass_centers(i);
-
- mln_site_(L) p = c + mln::left;
-
- while (is_invalid_link(objects, left_link, p, i, c, dmax))
- {
- if (left_link[i] != i)
- output(p) = literal::green;
- else
- output(p) = literal::red;
- --p.col();
- }
-
- }
+ // Write debug image.
+ single_left_link_debug_functor<I, L> functor(input, objects, atof(argv[2]));
+ primitive::link::compute(functor);
- io::ppm::save(output, argv[3]);
+ io::ppm::save(functor.output_, argv[3]);
}
diff --git a/scribo/src/debug/show_link_single_right.cc
b/scribo/src/debug/show_links_single_right.cc
similarity index 57%
copy from scribo/src/debug/show_link_single_right.cc
copy to scribo/src/debug/show_links_single_right.cc
index 5f1001a..c121cce 100644
--- a/scribo/src/debug/show_link_single_right.cc
+++ b/scribo/src/debug/show_links_single_right.cc
@@ -37,8 +37,12 @@
#include <mln/io/pbm/load.hh>
#include <mln/io/ppm/save.hh>
+#include <mln/draw/line.hh>
+
#include <scribo/primitive/extract/objects.hh>
#include <scribo/primitive/link/with_single_right_link.hh>
+#include <scribo/primitive/link/internal/link_ms_dmax_base.hh>
+#include <scribo/primitive/link/compute.hh>
#include <scribo/draw/bounding_boxes.hh>
@@ -46,11 +50,79 @@
#include <scribo/debug/usage.hh>
+namespace scribo
+{
+
+ template <typename I, typename L>
+ struct single_right_link_debug_functor
+ : primitive::link::internal::link_ms_dmax_base<L,
+ single_right_link_debug_functor<I, L> >
+ {
+ typedef single_right_link_debug_functor<I, L> self_t;
+ typedef
+ primitive::link::internal::link_ms_dmax_base<L, self_t> super_;
+
+ public:
+ typedef mln_site(L) P;
+
+ single_right_link_debug_functor(const I& input,
+ const object_image(L)& objects,
+ float dmax)
+ : super_(objects, dmax)
+ {
+ output_ = data::convert(value::rgb8(), input);
+ scribo::draw::bounding_boxes(output_, objects, literal::blue);
+ mln_postcondition(output_.is_valid());
+ }
+
+ void validate_link_(unsigned current_object,
+ const P& start_point,
+ const P& p,
+ unsigned anchor)
+ {
+ mln::draw::line(output_, start_point, p, literal::green);
+
+ super_::validate_link_(current_object, start_point, p, anchor);
+ }
+
+
+
+ void invalidate_link_(unsigned current_object,
+ const P& start_point,
+ const P& p,
+ unsigned anchor)
+ {
+ if (output_.domain().has(p))
+ mln::draw::line(output_, start_point, p, literal::red);
+ else
+ {
+ P tmp = p;
+ ++tmp.col();
+ mln::draw::line(output_, start_point, tmp, literal::red);
+ }
+
+ super_::invalidate_link_(current_object, start_point, p, anchor);
+ }
+
+
+
+ void compute_next_site_(P& p)
+ {
+ --p.col();
+ }
+
+
+ image2d<value::rgb8> output_;
+ };
+
+
+}
+
const char *args_desc[][2] =
{
{ "input.pbm", "A binary image. True for objects and False for the
background." },
- { "max_nbh_dist", " Maximum distance for neighborhood search. (common
value : 30)" },
+ { "max_nbh_dist", "The maximum lookup distance. (common value :
30)" },
{0, 0}
};
@@ -68,7 +140,8 @@ int main(int argc, char* argv[])
args_desc,
"A color image. Valid links are drawn in green, invalid ones in red.");
- image2d<bool> input;
+ typedef image2d<bool> I;
+ I input;
io::pbm::load(input, argv[1]);
// Finding objects.
@@ -77,41 +150,9 @@ int main(int argc, char* argv[])
object_image(L) objects
= scribo::primitive::extract::objects(input, c8(), nbboxes);
- // Finding right links.
- object_links<L> right_link
- = primitive::link::with_single_right_link(objects, atoi(argv[2]));
-
-
-
- // Preparing output image.
- image2d<value::rgb8> output = data::convert(value::rgb8(), input);
- scribo::draw::bounding_boxes(output, objects, literal::blue);
-
-
- // Drawing links.
- mln::util::array<mln_result_(accu::center<mln_psite_(L)>)>
- mass_centers = labeling::compute(accu::meta::center(),
- objects, objects.nlabels());
-
- for_all_ncomponents(i, objects.nlabels())
- {
- unsigned midcol = (objects.bbox(i).pmax().col()
- - objects.bbox(i).pmin().col()) / 2;
- int dmax = midcol + atoi(argv[2]);
- mln_site_(L) c = mass_centers(i);
-
- mln_site_(L) p = c + mln::right;
-
- while (is_invalid_link(objects, right_link, p, i, c, dmax))
- {
- if (right_link[i] != i)
- output(p) = literal::green;
- else
- output(p) = literal::red;
- ++p.col();
- }
-
- }
+ // Write debug image.
+ single_right_link_debug_functor<I, L> functor(input, objects, atof(argv[2]));
+ primitive::link::compute(functor);
- io::ppm::save(output, argv[3]);
+ io::ppm::save(functor.output_, argv[3]);
}
diff --git a/scribo/src/debug/show_link_single_right.cc
b/scribo/src/debug/show_links_single_right_dmax_ratio.cc
similarity index 54%
copy from scribo/src/debug/show_link_single_right.cc
copy to scribo/src/debug/show_links_single_right_dmax_ratio.cc
index 5f1001a..81415bc 100644
--- a/scribo/src/debug/show_link_single_right.cc
+++ b/scribo/src/debug/show_links_single_right_dmax_ratio.cc
@@ -37,8 +37,12 @@
#include <mln/io/pbm/load.hh>
#include <mln/io/ppm/save.hh>
+#include <mln/draw/line.hh>
+
#include <scribo/primitive/extract/objects.hh>
-#include <scribo/primitive/link/with_single_right_link.hh>
+#include <scribo/primitive/link/with_single_right_link_dmax_ratio.hh>
+#include <scribo/primitive/link/internal/link_ms_dmax_ratio_base.hh>
+#include <scribo/primitive/link/compute.hh>
#include <scribo/draw/bounding_boxes.hh>
@@ -46,11 +50,79 @@
#include <scribo/debug/usage.hh>
+namespace scribo
+{
+
+ template <typename I, typename L>
+ struct single_right_link_debug_functor
+ : primitive::link::internal::link_ms_dmax_ratio_base<L,
+ single_right_link_debug_functor<I, L> >
+ {
+ typedef single_right_link_debug_functor<I, L> self_t;
+ typedef
+ primitive::link::internal::link_ms_dmax_ratio_base<L, self_t> super_;
+
+ public:
+ typedef mln_site(L) P;
+
+ single_right_link_debug_functor(const I& input,
+ const object_image(L)& objects,
+ float dmax_ratio)
+ : super_(objects, dmax_ratio)
+ {
+ output_ = data::convert(value::rgb8(), input);
+ scribo::draw::bounding_boxes(output_, objects, literal::blue);
+ mln_postcondition(output_.is_valid());
+ }
+
+ void validate_link_(unsigned current_object,
+ const P& start_point,
+ const P& p,
+ unsigned anchor)
+ {
+ mln::draw::line(output_, start_point, p, literal::green);
+
+ super_::validate_link_(current_object, start_point, p, anchor);
+ }
+
+
+
+ void invalidate_link_(unsigned current_object,
+ const P& start_point,
+ const P& p,
+ unsigned anchor)
+ {
+ if (output_.domain().has(p))
+ mln::draw::line(output_, start_point, p, literal::red);
+ else
+ {
+ P tmp = p;
+ --tmp.col();
+ mln::draw::line(output_, start_point, tmp, literal::red);
+ }
+
+ super_::invalidate_link_(current_object, start_point, p, anchor);
+ }
+
+
+
+ void compute_next_site_(P& p)
+ {
+ ++p.col();
+ }
+
+
+ image2d<value::rgb8> output_;
+ };
+
+
+}
+
const char *args_desc[][2] =
{
{ "input.pbm", "A binary image. True for objects and False for the
background." },
- { "max_nbh_dist", " Maximum distance for neighborhood search. (common
value : 30)" },
+ { "max_nbh_dist_ratio", "Size ratio defining the maximum lookup
distance. (common value : 3)" },
{0, 0}
};
@@ -64,11 +136,12 @@ int main(int argc, char* argv[])
if (argc != 4)
return scribo::debug::usage(argv,
"Show sucessful/unsuccessful right links between components.",
- "input.pbm max_nbh_dist output.ppm",
+ "input.pbm max_nbh_dist_ratio output.ppm",
args_desc,
"A color image. Valid links are drawn in green, invalid ones in red.");
- image2d<bool> input;
+ typedef image2d<bool> I;
+ I input;
io::pbm::load(input, argv[1]);
// Finding objects.
@@ -77,41 +150,9 @@ int main(int argc, char* argv[])
object_image(L) objects
= scribo::primitive::extract::objects(input, c8(), nbboxes);
- // Finding right links.
- object_links<L> right_link
- = primitive::link::with_single_right_link(objects, atoi(argv[2]));
-
-
-
- // Preparing output image.
- image2d<value::rgb8> output = data::convert(value::rgb8(), input);
- scribo::draw::bounding_boxes(output, objects, literal::blue);
-
-
- // Drawing links.
- mln::util::array<mln_result_(accu::center<mln_psite_(L)>)>
- mass_centers = labeling::compute(accu::meta::center(),
- objects, objects.nlabels());
-
- for_all_ncomponents(i, objects.nlabels())
- {
- unsigned midcol = (objects.bbox(i).pmax().col()
- - objects.bbox(i).pmin().col()) / 2;
- int dmax = midcol + atoi(argv[2]);
- mln_site_(L) c = mass_centers(i);
-
- mln_site_(L) p = c + mln::right;
-
- while (is_invalid_link(objects, right_link, p, i, c, dmax))
- {
- if (right_link[i] != i)
- output(p) = literal::green;
- else
- output(p) = literal::red;
- ++p.col();
- }
-
- }
+ // Write debug image.
+ single_right_link_debug_functor<I, L> functor(input, objects, atof(argv[2]));
+ primitive::link::compute(functor);
- io::ppm::save(output, argv[3]);
+ io::ppm::save(functor.output_, argv[3]);
}
diff --git a/scribo/src/debug/show_link_single_right.cc
b/scribo/src/debug/show_links_top_aligned.cc
similarity index 64%
rename from scribo/src/debug/show_link_single_right.cc
rename to scribo/src/debug/show_links_top_aligned.cc
index 5f1001a..97b4a3b 100644
--- a/scribo/src/debug/show_link_single_right.cc
+++ b/scribo/src/debug/show_links_top_aligned.cc
@@ -38,11 +38,10 @@
#include <mln/io/ppm/save.hh>
#include <scribo/primitive/extract/objects.hh>
-#include <scribo/primitive/link/with_single_right_link.hh>
+#include <scribo/primitive/link/with_single_right_link_top.hh>
+#include <scribo/filter/object_links_top_aligned.hh>
-#include <scribo/draw/bounding_boxes.hh>
-
-#include <scribo/debug/save_linked_bboxes_image.hh>
+#include <scribo/debug/alignment_decision_image.hh>
#include <scribo/debug/usage.hh>
@@ -50,7 +49,7 @@
const char *args_desc[][2] =
{
{ "input.pbm", "A binary image. True for objects and False for the
background." },
- { "max_nbh_dist", " Maximum distance for neighborhood search. (common
value : 30)" },
+ { "max_alpha", "Max angle between two object tops. (common value :
5)" },
{0, 0}
};
@@ -63,8 +62,8 @@ int main(int argc, char* argv[])
if (argc != 4)
return scribo::debug::usage(argv,
- "Show sucessful/unsuccessful right links between components.",
- "input.pbm max_nbh_dist output.ppm",
+ "Show valid or invalid links according the horizontal alignment (based on top
line).",
+ "input.pbm max_alpha output.ppm",
args_desc,
"A color image. Valid links are drawn in green, invalid ones in red.");
@@ -77,41 +76,22 @@ int main(int argc, char* argv[])
object_image(L) objects
= scribo::primitive::extract::objects(input, c8(), nbboxes);
- // Finding right links.
- object_links<L> right_link
- = primitive::link::with_single_right_link(objects, atoi(argv[2]));
-
-
- // Preparing output image.
- image2d<value::rgb8> output = data::convert(value::rgb8(), input);
- scribo::draw::bounding_boxes(output, objects, literal::blue);
-
-
- // Drawing links.
- mln::util::array<mln_result_(accu::center<mln_psite_(L)>)>
- mass_centers = labeling::compute(accu::meta::center(),
- objects, objects.nlabels());
-
- for_all_ncomponents(i, objects.nlabels())
- {
- unsigned midcol = (objects.bbox(i).pmax().col()
- - objects.bbox(i).pmin().col()) / 2;
- int dmax = midcol + atoi(argv[2]);
- mln_site_(L) c = mass_centers(i);
+ // Finding right links.
+ object_links<L> right_links
+ = primitive::link::with_single_right_link_top(objects);
- mln_site_(L) p = c + mln::right;
+ // Filtering.
+ object_links<L> filtered_links
+ = filter::object_links_top_aligned(objects, right_links, atof(argv[2]));
- while (is_invalid_link(objects, right_link, p, i, c, dmax))
- {
- if (right_link[i] != i)
- output(p) = literal::green;
- else
- output(p) = literal::red;
- ++p.col();
- }
- }
+ // Debug image.
+ image2d<value::rgb8> decision_image
+ = scribo::debug::alignment_decision_image(input,
+ right_links,
+ filtered_links,
+ scribo::debug::top);
+ io::ppm::save(decision_image, argv[3]);
- io::ppm::save(output, argv[3]);
}
diff --git a/scribo/src/debug/show_link_single_left.cc
b/scribo/src/debug/show_objects_large_small.cc
similarity index 58%
copy from scribo/src/debug/show_link_single_left.cc
copy to scribo/src/debug/show_objects_large_small.cc
index a8b42f2..e72e5e1 100644
--- a/scribo/src/debug/show_link_single_left.cc
+++ b/scribo/src/debug/show_objects_large_small.cc
@@ -30,88 +30,71 @@
#include <mln/data/convert.hh>
-#include <mln/value/rgb8.hh>
#include <mln/value/label_16.hh>
+#include <mln/value/rgb8.hh>
#include <mln/literal/colors.hh>
#include <mln/io/pbm/load.hh>
#include <mln/io/ppm/save.hh>
#include <scribo/primitive/extract/objects.hh>
-#include <scribo/primitive/link/with_single_left_link.hh>
-
+#include <scribo/filter/objects_large.hh>
+#include <scribo/filter/objects_small.hh>
#include <scribo/draw/bounding_boxes.hh>
-
-#include <scribo/debug/save_linked_bboxes_image.hh>
#include <scribo/debug/usage.hh>
-
+#include <scribo/debug/save_object_diff.hh>
const char *args_desc[][2] =
{
{ "input.pbm", "A binary image. True for objects and False for the
background." },
- { "max_nbh_dist", " Maximum distance for neighborhood search. (common
value : 30)" },
+ { "min_card", " Minimum cardinality in a component." },
+ { "max_card", " Maximum cardinality in a component." },
{0, 0}
};
-int main(int argc, char* argv[])
+int main(int argc, char *argv[])
{
- using namespace scribo;
- using namespace scribo::primitive::internal;
using namespace mln;
- if (argc != 4)
+ if (argc != 5)
return scribo::debug::usage(argv,
- "Show sucessful/unsuccessful left links between components.",
- "input.pbm max_nbh_dist output.ppm",
+ "Show components not being too small nor too large.",
+ "input.pbm min_card max_card output.ppm",
args_desc,
- "A color image. Valid links are drawn in green, invalid ones in red.");
+ "A color image. Too small components are drawn in red, too large components in
orange and others in green.");
+
+ trace::entering("main");
image2d<bool> input;
io::pbm::load(input, argv[1]);
- // Finding objects.
value::label_16 nbboxes;
typedef image2d<value::label_16> L;
object_image(L) objects
= scribo::primitive::extract::objects(input, c8(), nbboxes);
- // Finding left links.
- object_links<L> left_link
- = primitive::link::with_single_left_link(objects, atoi(argv[2]));
-
+ object_image(L) filter(objects);
+ if (atoi(argv[2]) != 0)
+ filter = scribo::filter::objects_small(filter, atoi(argv[2]));
- // Preparing output image.
- image2d<value::rgb8> output = data::convert(value::rgb8(), input);
- scribo::draw::bounding_boxes(output, objects, literal::blue);
+ if (atoi(argv[3]) != 0)
+ filter = scribo::filter::objects_large(filter, atoi(argv[3]));
+ image2d<value::rgb8> output;
+ initialize(output, objects);
- // Drawing links.
- mln::util::array<mln_result_(accu::center<mln_psite_(L)>)>
- mass_centers = labeling::compute(accu::meta::center(),
- objects, objects.nlabels());
+ data::fill(output, literal::black);
- for_all_ncomponents(i, objects.nlabels())
- {
- unsigned midcol = (objects.bbox(i).pmax().col()
- - objects.bbox(i).pmin().col()) / 2;
- int dmax = midcol + atoi(argv[2]);
- mln_site_(L) c = mass_centers(i);
+ for_all_components(i, objects.bboxes())
+ data::fill(((output | objects.bbox(i)).rw() | (pw::value(objects) == i)).rw(),
literal::red);
- mln_site_(L) p = c + mln::left;
+ for_all_components(i, filter.bboxes())
+ data::fill(((output | filter.bbox(i)).rw() | (pw::value(filter) == i)).rw(),
literal::green);
- while (is_invalid_link(objects, left_link, p, i, c, dmax))
- {
- if (left_link[i] != i)
- output(p) = literal::green;
- else
- output(p) = literal::red;
- --p.col();
- }
- }
- io::ppm::save(output, argv[3]);
+ io::ppm::save(output, argv[4]);
}
diff --git a/scribo/src/debug/show_link_single_left.cc
b/scribo/src/debug/show_objects_thick.cc
similarity index 59%
rename from scribo/src/debug/show_link_single_left.cc
rename to scribo/src/debug/show_objects_thick.cc
index a8b42f2..4157ac3 100644
--- a/scribo/src/debug/show_link_single_left.cc
+++ b/scribo/src/debug/show_objects_thick.cc
@@ -30,88 +30,55 @@
#include <mln/data/convert.hh>
-#include <mln/value/rgb8.hh>
#include <mln/value/label_16.hh>
+#include <mln/value/rgb8.hh>
#include <mln/literal/colors.hh>
#include <mln/io/pbm/load.hh>
#include <mln/io/ppm/save.hh>
#include <scribo/primitive/extract/objects.hh>
-#include <scribo/primitive/link/with_single_left_link.hh>
-
+#include <scribo/filter/objects_thin.hh>
#include <scribo/draw/bounding_boxes.hh>
-
-#include <scribo/debug/save_linked_bboxes_image.hh>
#include <scribo/debug/usage.hh>
-
const char *args_desc[][2] =
{
- { "input.pbm", "A binary image. True for objects and False for the
background." },
- { "max_nbh_dist", " Maximum distance for neighborhood search. (common
value : 30)" },
+ { "input.pbm", " A binary image. True for objects and False for the
background." },
+ { "max_thickness", "Maximum bounding box thickness. (common value:
300)" },
{0, 0}
};
-int main(int argc, char* argv[])
+int main(int argc, char *argv[])
{
- using namespace scribo;
- using namespace scribo::primitive::internal;
using namespace mln;
if (argc != 4)
return scribo::debug::usage(argv,
- "Show sucessful/unsuccessful left links between components.",
- "input.pbm max_nbh_dist output.ppm",
+ "Show components being to thick.",
+ "input.pbm max_thickness output.ppm",
args_desc,
- "A color image. Valid links are drawn in green, invalid ones in red.");
+ "A color image. Too thick components have their bounding boxes drawn in
red.");
+
+ trace::entering("main");
image2d<bool> input;
io::pbm::load(input, argv[1]);
- // Finding objects.
value::label_16 nbboxes;
typedef image2d<value::label_16> L;
object_image(L) objects
= scribo::primitive::extract::objects(input, c8(), nbboxes);
- // Finding left links.
- object_links<L> left_link
- = primitive::link::with_single_left_link(objects, atoi(argv[2]));
-
-
- // Preparing output image.
image2d<value::rgb8> output = data::convert(value::rgb8(), input);
- scribo::draw::bounding_boxes(output, objects, literal::blue);
-
-
- // Drawing links.
- mln::util::array<mln_result_(accu::center<mln_psite_(L)>)>
- mass_centers = labeling::compute(accu::meta::center(),
- objects, objects.nlabels());
-
- for_all_ncomponents(i, objects.nlabels())
- {
- unsigned midcol = (objects.bbox(i).pmax().col()
- - objects.bbox(i).pmin().col()) / 2;
- int dmax = midcol + atoi(argv[2]);
- mln_site_(L) c = mass_centers(i);
-
- mln_site_(L) p = c + mln::left;
-
- while (is_invalid_link(objects, left_link, p, i, c, dmax))
- {
- if (left_link[i] != i)
- output(p) = literal::green;
- else
- output(p) = literal::red;
- --p.col();
- }
+ scribo::draw::bounding_boxes(output, objects, literal::red);
- }
+ object_image(L) filtered_objects
+ = scribo::filter::objects_thin(objects, atoi(argv[2]));
+ scribo::draw::bounding_boxes(output, filtered_objects, literal::green);
io::ppm::save(output, argv[3]);
}
diff --git a/scribo/src/debug/show_objects_thin.cc
b/scribo/src/debug/show_objects_thin.cc
index e69de29..4223fef 100644
--- a/scribo/src/debug/show_objects_thin.cc
+++ b/scribo/src/debug/show_objects_thin.cc
@@ -0,0 +1,84 @@
+// Copyright (C) 2009 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.
+
+#include <iostream>
+
+#include <mln/core/image/image2d.hh>
+#include <mln/core/alias/neighb2d.hh>
+
+#include <mln/data/convert.hh>
+
+#include <mln/value/label_16.hh>
+#include <mln/value/rgb8.hh>
+#include <mln/literal/colors.hh>
+
+#include <mln/io/pbm/load.hh>
+#include <mln/io/ppm/save.hh>
+
+#include <scribo/primitive/extract/objects.hh>
+#include <scribo/filter/objects_thin.hh>
+#include <scribo/draw/bounding_boxes.hh>
+#include <scribo/debug/usage.hh>
+
+
+const char *args_desc[][2] =
+{
+ { "input.pbm", " A binary image. True for objects and False for the
background." },
+ { "min_thickness", "Minimum bounding box thickness. (common value:
1)" },
+ {0, 0}
+};
+
+
+int main(int argc, char *argv[])
+{
+ using namespace mln;
+
+ if (argc != 4)
+ return scribo::debug::usage(argv,
+ "Show components being to thin.",
+ "input.pbm min_thickness output.ppm",
+ args_desc,
+ "A color image. Too thin components have their bounding boxes drawn in
red.");
+
+ trace::entering("main");
+
+ image2d<bool> input;
+ io::pbm::load(input, argv[1]);
+
+ value::label_16 nbboxes;
+ typedef image2d<value::label_16> L;
+ object_image(L) objects
+ = scribo::primitive::extract::objects(input, c8(), nbboxes);
+
+
+ image2d<value::rgb8> output = data::convert(value::rgb8(), input);
+ scribo::draw::bounding_boxes(output, objects, literal::red);
+
+ object_image(L) filtered_objects
+ = scribo::filter::objects_thin(objects, atoi(argv[2]));
+ scribo::draw::bounding_boxes(output, filtered_objects, literal::green);
+
+ io::ppm::save(output, argv[3]);
+}
--
1.5.6.5