* icdar/2009/hsc/lines_to_words.cc: Move some code...
* icdar/2009/hsc/get_line_images.hh: ... here. new routine.
---
milena/sandbox/ChangeLog | 7 +++
milena/sandbox/icdar/2009/hsc/get_line_images.hh | 62 ++++++++++++++++++++++
milena/sandbox/icdar/2009/hsc/lines_to_words.cc | 62 +++-------------------
3 files changed, 76 insertions(+), 55 deletions(-)
create mode 100644 milena/sandbox/icdar/2009/hsc/get_line_images.hh
diff --git a/milena/sandbox/ChangeLog b/milena/sandbox/ChangeLog
index 01e3f9b..c6a6156 100644
--- a/milena/sandbox/ChangeLog
+++ b/milena/sandbox/ChangeLog
@@ -1,3 +1,10 @@
+2009-04-07 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Update ICDAR code.
+
+ * icdar/2009/hsc/lines_to_words.cc: Move some code...
+ * icdar/2009/hsc/get_line_images.hh: ... here. new routine.
+
2009-04-07 Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Augment ICDAR-HSC.
diff --git a/milena/sandbox/icdar/2009/hsc/get_line_images.hh
b/milena/sandbox/icdar/2009/hsc/get_line_images.hh
new file mode 100644
index 0000000..07ae749
--- /dev/null
+++ b/milena/sandbox/icdar/2009/hsc/get_line_images.hh
@@ -0,0 +1,62 @@
+#ifndef GET_LINE_IMAGES_HH
+# define GET_LINE_IMAGES_HH
+
+#include <mln/core/concept/image.hh>
+#include <mln/core/site_set/box.hh>
+#include <mln/core/image/extended.hh>
+#include <mln/core/routine/duplicate.hh>
+#include <mln/core/routine/extend.hh>
+#include <mln/core/var.hh>
+
+#include <mln/data/fill.hh>
+
+#include <mln/accu/bbox.hh>
+
+#include <mln/geom/bbox.hh>
+
+#include <mln/labeling/compute.hh>
+
+#include <mln/util/array.hh>
+
+#include <mln/pw/all.hh>
+#include <mln/core/image/image_if.hh>
+
+
+namespace mln
+{
+
+ template <typename L>
+ util::array<mln_ch_value(L,bool)>
+ inline
+ get_line_images(const Image<L>& lines_, const mln_value(L)& nlines,
+ unsigned bbox_line_enlarge)
+ {
+ trace::entering("get_line_images");
+
+ const L& lines = exact(lines_);
+ mln_precondition(lines.is_valid());
+
+ util::array<box<mln_site(L)> >
+ bboxes = labeling::compute(accu::meta::bbox(), lines, nlines);
+
+ util::array<mln_ch_value(L,bool)> result;
+
+ for (unsigned i = 1; i < nlines; ++i)
+ {
+ typedef mln_ch_value(L,bool) line_t;
+ box<mln_site(L)> b = bboxes[i];
+ b.enlarge(bbox_line_enlarge);
+ line_t line(b);
+ data::fill(((line | bboxes[i]).rw() | (pw::value(lines) == i)).rw(), true);
+
+ result.append(line);
+ }
+
+ trace::exiting("get_line_images");
+ return result;
+ }
+
+
+} // end of namespace mln
+
+#endif // ! GET_LINE_IMAGES_HH
diff --git a/milena/sandbox/icdar/2009/hsc/lines_to_words.cc
b/milena/sandbox/icdar/2009/hsc/lines_to_words.cc
index cd4b1c3..5381d41 100644
--- a/milena/sandbox/icdar/2009/hsc/lines_to_words.cc
+++ b/milena/sandbox/icdar/2009/hsc/lines_to_words.cc
@@ -1,31 +1,16 @@
#include <mln/core/image/image2d.hh>
-#include <mln/core/alias/neighb2d.hh>
+
#include <mln/value/int_u8.hh>
-#include <mln/value/label_8.hh>
#include <mln/value/label_16.hh>
+
#include <mln/io/pgm/all.hh>
#include <mln/io/pbm/all.hh>
#include <mln/io/ppm/all.hh>
-#include <mln/accu/bbox.hh>
-#include <mln/labeling/compute.hh>
-#include <mln/pw/all.hh>
-#include <mln/core/image/image_if.hh>
-#include <mln/data/fill.hh>
-#include <mln/core/routine/extend.hh>
-#include <mln/transform/distance_geodesic.hh>
-#include <mln/win/disk2d.hh>
-#include <mln/morpho/watershed/flooding.hh>
-#include <mln/morpho/closing/structural.hh>
-#include <mln/transform/distance_geodesic.hh>
-#include <mln/core/image/extended.hh>
-#include <mln/core/var.hh>
+
#include <mln/level/convert.hh>
-#include <mln/level/compute.hh>
-#include <mln/accu/count_labels.hh>
#include <mln/labeling/relabel.hh>
-#include <mln/labeling/wrap.hh>
-#include <mln/core/routine/extend.hh>
-#include <mln/morpho/watershed/superpose.hh>
+
+#include "get_line_images.hh"
void usage(char* argv[])
{
@@ -56,43 +41,10 @@ int main(int argc, char *argv[])
io::pgm::load(lines_, argv[2]);
image2d<label_16> lines = level::convert(label_16(), lines_);
- unsigned delta = 10;
-
label_16 nlines;
labeling::relabel_inplace(lines, nlines);
+ util::array<image2d<bool> > result = get_line_images(lines, nlines, 10);
- std::cout << "nlines = " << nlines << std::endl;
- util::array<box2d> bboxes = labeling::compute(accu::meta::bbox(), lines,
nlines);
-
- std::cout << "BBoxes computed" << std::endl;
-
- for (unsigned i = 1; i < nlines; ++i)
- {
- std::cout << "* Processing line " << i << std::endl;
- typedef image2d<bool> line_t;
- line_t line = duplicate((pw::value(lines) == i) | (lines | bboxes[i]).domain());
-// io::pbm::save(line, "l2w_line.pbm");
-
- box2d b = geom::bbox(line);
- b.enlarge(delta);
-
- mln_VAR(line_ext, extended_to(extend(line,false),b));
-
-// io::pbm::save(line_ext, "l2w_line_ext.pbm");
-
- std::cout << " Distance geodesic" << std::endl;
- mln_VAR(line_dmap, transform::distance_geodesic(line_ext, c4(), mln_max(unsigned)));
-
- std::cout << " closing structural" << std::endl;
- mln_VAR(line_clo, morpho::closing::structural(line_dmap, win::disk2d(21)));
-
-
- std::cout << " Watershed" << std::endl;
- label_16 nwords;
- mln_VAR(wst, morpho::watershed::flooding(line_clo, c4(), nwords));
-
-// io::ppm::save(morpho::watershed::superpose(input | bboxes[i], wst),
"l2w_wst.ppm");
-// abort();
- }
+ io::pbm::save(result[2], argv[3]);
}
--
1.5.6.5
Show replies by date