---
milena/ChangeLog | 8 ++
.../sandbox/scribo/{remove_tables.cc => demat.hh} | 110 ++++++++++++--------
milena/sandbox/scribo/main.cc | 45 ++++++++
3 files changed, 119 insertions(+), 44 deletions(-)
rename milena/sandbox/scribo/{remove_tables.cc => demat.hh} (55%)
create mode 100644 milena/sandbox/scribo/main.cc
diff --git a/milena/ChangeLog b/milena/ChangeLog
index dc4af1c..15c868f 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,13 @@
2008-10-14 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Use labeling::compute for Scribo.
+ * milena/sandbox/scribo/remove_tables.hh: split in...
+ * milena/sandbox/scribo/demat.hh,
+ * milena/sandbox/scribo/main.cc: ...these two files.
+ Update the code in order to use labeling::compute.
+
+2008-10-14 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Fix labeling::compute return type.
* milena/mln/labeling/compute.hh: Fix many compilation errors
while taking directly the result type of an accumulator as a template
diff --git a/milena/sandbox/scribo/remove_tables.cc b/milena/sandbox/scribo/demat.hh
similarity index 55%
rename from milena/sandbox/scribo/remove_tables.cc
rename to milena/sandbox/scribo/demat.hh
index 0ee0528..bba9105 100644
--- a/milena/sandbox/scribo/remove_tables.cc
+++ b/milena/sandbox/scribo/demat.hh
@@ -25,10 +25,8 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file doc/examples/hit_or_miss.cc
- *
- * \brief Test on mln::morpho::hit_or_miss.
- */
+#ifndef DEMAT_HH_
+# define DEMAT_HH_
# include <mln/core/image/image2d.hh>
@@ -57,55 +55,79 @@
# include <mln/convert/to_fun.hh>
# include <mln/geom/bbox.hh>
-void clean_lines(mln::image2d<bool>& in,
- const mln::image2d<bool>& ima,
- unsigned bbox_larger)
-{
- using namespace mln;
- using value::int_u8;
+# include <mln/labeling/compute.hh>
+# include <mln/accu/bbox.hh>
- int_u8 nlabels;
- image2d<int_u8> lbl = labeling::blobs(ima, c4(), nlabels);
+namespace scribo
+{
- for (unsigned i = nlabels; i > 0; --i)
+ namespace internal
{
- level::paste(pw::cst(false)
- | geom::bbox(lbl | (pw::value(lbl) == pw::cst(i))),//.to_larger(bbox_larger),
- in);
- }
-}
-int main(int argc, char*argv[])
-{
- using namespace mln;
- using value::int_u8;
+ void filter_image(mln::image2d<bool>& ima,
+ const mln::image2d<bool>& filter,
+ unsigned bbox_larger)
+ {
+ using namespace mln;
+ using value::int_u8;
+
+ typedef image2d<int_u8> I;
+ typedef mln_accu_with_(accu::meta::bbox, mln_psite_(I)) A;
+ typedef p_array<mlc_unqualif_(A::result)> boxes_t;
+
+ int_u8 nlabels;
+ I lbl = labeling::blobs(filter, c4(), nlabels);
+
+ boxes_t boxes = labeling::compute(accu::meta::bbox(), lbl, nlabels);
+ mln_piter_(boxes_t) p(boxes);
+
+ for_all(p)
+ level::paste(pw::cst(false)
+ | p.to_site().to_larger(bbox_larger),
+ ima);
+ }
- if (argc < 2)
+ void remove_tables(mln::image2d<bool>& in, unsigned h, unsigned w, unsigned
n)
+ {
+ using namespace mln;
+
+ // Lignes verticales
+ win::rectangle2d vwin(h, w);
+ image2d<bool> vfilter = morpho::opening(in, vwin);
+ io::pbm::save(vfilter, "./table-vfilter.pbm");
+ filter_image(in, vfilter, n);
+
+ // Lignes horizontales
+ win::rectangle2d hwin(w, h);
+ image2d<bool> hfilter = morpho::opening(in, hwin);
+ io::pbm::save(hfilter, "./table-hfilter.pbm");
+ filter_image(in, hfilter, n);
+ }
+
+ } // end of namespace scribo::internal
+
+
+
+ // Facade
+ void demat(char *argv[])
{
- std::cout << argv[0] << " <image.pgm> <h>
<w>" << std::endl;
- return 1;
- }
+ using namespace mln;
+ using value::int_u8;
- image2d<bool> in;
- io::pbm::load(in, argv[1]);
+ //Useful debug variables
+ unsigned h = atoi(argv[2]);
+ unsigned w = atoi(argv[3]);
+ unsigned n = atoi(argv[4]);
- unsigned h = atoi(argv[2]);
- unsigned w = atoi(argv[3]);
- unsigned n = atoi(argv[4]);
+ //Load image
+ image2d<bool> in;
+ io::pbm::load(in, argv[1]);
- // Lignes verticales
- win::rectangle2d vwin(h, w);
- image2d<bool> vout = morpho::opening(in, vwin);
- io::pbm::save(vout, "./vout.pbm");
- clean_lines(in, vout, n);
+ internal::remove_tables(in, h, w, n);
- // Lignes horizontales
- win::rectangle2d hwin(w, h);
- image2d<bool> hout = morpho::opening(in, hwin);
- io::pbm::save(hout, "./hout.pbm");
- clean_lines(in, hout, n);
+ io::pbm::save(in, "./table-filtered.pbm");
+ }
- io::pbm::save(in, "./outt.pbm");
+} // end of namespace scribo
- return 0;
-}
+# endif // ! DEMAT_HH
diff --git a/milena/sandbox/scribo/main.cc b/milena/sandbox/scribo/main.cc
new file mode 100644
index 0000000..d49fee8
--- /dev/null
+++ b/milena/sandbox/scribo/main.cc
@@ -0,0 +1,45 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library 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 this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library 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 "demat.hh"
+
+int main(int argc, char*argv[])
+{
+ using namespace mln;
+ using value::int_u8;
+
+ if (argc < 2)
+ {
+ std::cout << argv[0] << " <image.pgm> <h> <w>
<bbox_larger>" << std::endl;
+ return 1;
+ }
+
+ scribo::demat(argv);
+
+ return 0;
+}
--
1.5.6.5