https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add extension::adjust_fill and elementary erosion.
* mln/debug/println.hh: Add trace.
* mln/border/resize.hh: Re-activate fast code.
* mln/border/adjust.hh: Handle the 0 case.
* mln/geom/delta.hh: New.
* mln/extension/adjust_fill.hh: New.
* mln/extension/all.hh: Update.
* mln/morpho/erosion.hh (todo): Remove; see below.
Use adjust_fill.
* mln/morpho/erosion.spe.hh: Likewise.
* mln/morpho/elementary: New directory.
* mln/morpho/elementary/like_ero_fun.hh: New.
* mln/morpho/elementary/like_ero_set.hh: New.
* mln/morpho/elementary/all.hh: New.
* mln/morpho/elementary/erosion.hh: New.
* tests/morpho/elementary: New directory.
* tests/morpho/elementary/erosion.cc: New.
mln/border/adjust.hh | 8 -
mln/border/resize.hh | 8 -
mln/debug/println.hh | 2
mln/extension/adjust_fill.hh | 134 ++++++++++++++++++++++
mln/extension/all.hh | 1
mln/extension/fill.hh | 1
mln/geom/delta.hh | 125 +++++++++++++++++++++
mln/morpho/elementary/all.hh | 53 ++++++++
mln/morpho/elementary/erosion.hh | 120 ++++++++++++++++++++
mln/morpho/elementary/like_ero_fun.hh | 201 ++++++++++++++++++++++++++++++++++
mln/morpho/elementary/like_ero_set.hh | 197 +++++++++++++++++++++++++++++++++
mln/morpho/erosion.hh | 8 -
mln/morpho/erosion.spe.hh | 38 ++----
tests/morpho/elementary/erosion.cc | 68 +++++++++++
14 files changed, 923 insertions(+), 41 deletions(-)
Index: tests/morpho/elementary/erosion.cc
--- tests/morpho/elementary/erosion.cc (revision 0)
+++ tests/morpho/elementary/erosion.cc (revision 0)
@@ -0,0 +1,68 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// 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.
+
+/*! \file tests/morpho/elementary/erosion.cc
+ *
+ * \brief Test on mln::morpho::elementary::erosion.
+ */
+
+#include <mln/core/image/image2d.hh>
+#include <mln/core/alias/neighb2d.hh>
+#include <mln/value/int_u8.hh>
+
+#include <mln/debug/iota.hh>
+#include <mln/debug/println.hh>
+
+#include <mln/morpho/elementary/erosion.hh>
+
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+
+// trace::quiet = false;
+
+ image2d<int_u8> ima(3, 3, 0);
+ debug::iota(ima);
+ debug::println(ima);
+ {
+ image2d<int_u8> ero = morpho::elementary::erosion(ima, c4());
+ mln_assertion(ero.border() == 1);
+ debug::println(ero);
+ }
+
+ image2d<bool> msk(3, 3, 0);
+ level::fill(msk, pw::value(ima) >= pw::cst(5));
+ debug::println(msk);
+ {
+ image2d<bool> ero = morpho::elementary::erosion(msk, c4());
+ mln_assertion(ero.border() == 1);
+ debug::println(ero);
+ }
+
+}
Index: mln/debug/println.hh
--- mln/debug/println.hh (revision 2711)
+++ mln/debug/println.hh (working copy)
@@ -81,8 +81,10 @@
void
println(const Image<I>& input)
{
+ trace::entering("debug::println");
impl::println(geom::bbox(exact(input).domain()),
exact(input));
+ trace::exiting("debug::println");
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/border/resize.hh
--- mln/border/resize.hh (revision 2711)
+++ mln/border/resize.hh (working copy)
@@ -92,11 +92,11 @@
mln_concrete(I) memo = clone(ima);
ima.resize_(thickness);
- // level::fill(ima, memo);
+ level::fill(ima, memo);
// level::paste(memo, ima);
- mln_piter(I) p(ima.domain());
- for_all(p)
- ima(p) = memo(p);
+// mln_piter(I) p(ima.domain());
+// for_all(p)
+// ima(p) = memo(p);
}
// ext_domain: /any/
Index: mln/border/adjust.hh
--- mln/border/adjust.hh (revision 2711)
+++ mln/border/adjust.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 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
@@ -66,9 +66,8 @@
{
trace::entering("border::adjust");
- //FIXME: fix this check
- //mlc_is(mln_trait_image_border(I),
- // trait::image::border::some)::check();
+ if (min_thickness != 0)
+ {
const I& ima = exact(ima_);
mln_precondition(ima.has_data());
@@ -76,6 +75,7 @@
border::resize(ima, min_thickness);
mln_postcondition(border::get(ima) >= min_thickness);
+ }
trace::exiting("border::adjust");
}
Index: mln/geom/delta.hh
--- mln/geom/delta.hh (revision 0)
+++ mln/geom/delta.hh (revision 0)
@@ -0,0 +1,125 @@
+// 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.
+
+#ifndef MLN_GEOM_DELTA_HH
+# define MLN_GEOM_DELTA_HH
+
+/*! \file mln/geom/delta.hh
+ *
+ * \todo Add doc.
+ */
+
+# include <mln/core/concept/window.hh>
+# include <mln/core/concept/weighted_window.hh>
+# include <mln/core/concept/neighborhood.hh>
+
+
+namespace mln
+{
+
+ namespace geom
+ {
+
+ /// Compute the delta of a window \p win.
+ template <typename W>
+ unsigned delta(const Window<W>& win);
+
+ /// Compute the delta of a weighted window \p wwin.
+ template <typename W>
+ unsigned delta(const Weighted_Window<W>& wwin);
+
+ /// Compute the delta of a neighborhood \p nbh.
+ template <typename N>
+ unsigned delta(const Neighborhood<N>& nbh);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace internal
+ {
+
+ template <typename W>
+ unsigned delta_dispatch(trait::window::support::any,
+ trait::window::definition::any,
+ const W& win)
+ {
+ return 0;
+ }
+
+ template <typename W>
+ unsigned delta_dispatch(trait::window::support::regular,
+ trait::window::definition::varying,
+ const W&)
+ {
+ return 0;
+ }
+
+ template <typename W>
+ unsigned delta_dispatch(trait::window::support::regular,
+ trait::window::definition::any, // So not varying.
+ const W& win)
+ {
+ return win.delta();
+ }
+
+ } // end of namespace mln::geom::internal
+
+
+ // Facades.
+
+ template <typename W>
+ unsigned delta(const Window<W>& win)
+ {
+ // mln_precondition(exact(win).is_valid());
+ return internal::delta_dispatch(mln_trait_window_support(W)(),
+ mln_trait_window_definition(W)(),
+ exact(win));
+ }
+
+ template <typename W>
+ unsigned delta(const Weighted_Window<W>& wwin)
+ {
+ // mln_precondition(exact(wwin).is_valid());
+ return delta(exact(wwin).win());
+ }
+
+ template <typename N>
+ unsigned delta(const Neighborhood<N>& nbh)
+ {
+ // mln_precondition(exact(nbh).is_valid());
+ return delta(exact(nbh).win());
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::geom
+
+} // end of namespace mln
+
+
+#endif // ! MLN_GEOM_DELTA_HH
Index: mln/morpho/erosion.spe.hh
--- mln/morpho/erosion.spe.hh (revision 2711)
+++ mln/morpho/erosion.spe.hh (working copy)
@@ -57,8 +57,6 @@
*
* \todo Warning: we should also have the "arbitrary" versions working
* on sets (not only on functions!)
- *
- * \todo Activate the FIXMEs (border::adjust).
*/
# ifndef MLN_INCLUDE_ONLY
@@ -104,8 +102,7 @@
const I& input = exact(input_);
const W& win = exact(win_);
- // FIXME: border::adjust(input, win.delta());
- extension::fill(input, mln_max(mln_value(I)));
+ extension::adjust_fill(input, win, mln_max(mln_value(I)));
O output;
initialize(output, input);
@@ -137,8 +134,7 @@
const I& input = exact(input_);
const W& win = exact(win_);
- // FIXME: border::adjust(input, win.delta());
- extension::fill(input, true);
+ extension::adjust_fill(input, win, true);
O output;
initialize(output, input);
@@ -170,8 +166,7 @@
const I& input = exact(input_);
const W& win = exact(win_);
- // FIXME: border::adjust(input, win.delta());
- extension::fill(input, true);
+ extension::adjust_fill(input, win, true);
O output;
output = clone(input);
@@ -201,8 +196,7 @@
const I& input = exact(input_);
const W& win = exact(win_);
- // FIXME: border::adjust(input, win.delta());
- extension::fill(input, true);
+ extension::adjust_fill(input, win, true);
O output;
output = clone(input);
@@ -404,8 +398,7 @@
void init()
{
- // FIXME: border::adjust(input, win.delta());
- extension::fill(input, mln_max(mln_value(I)));
+ extension::adjust_fill(input, win, mln_max(mln_value(I)));
initialize(output, input);
min.init();
p = input.domain().pmin() - dps[0];
@@ -562,8 +555,7 @@
void init()
{
- // FIXME: border::adjust(input, win.delta());
- extension::fill(input, mln_max(mln_value(I)));
+ extension::adjust_fill(input, win, mln_max(mln_value(I)));
initialize(output, input);
min.init();
p = input.domain().pmin() - dps[0];
@@ -674,8 +666,7 @@
void init()
{
- // FIXME: border::adjust(input, win.delta());
- extension::fill(input, accu);
+ extension::adjust_fill(input, win, accu);
initialize(output, input);
}
@@ -758,8 +749,7 @@
void init()
{
- // FIXME: border::adjust(input, win.delta());
- extension::fill(input, accu);
+ extension::adjust_fill(input, win, accu);
initialize(output, input);
}
@@ -845,8 +835,7 @@
void init()
{
- // FIXME: border::adjust(input, win.delta());
- extension::fill(input, mln_max(mln_value(I)));
+ extension::adjust_fill(input, win, mln_max(mln_value(I)));
initialize(output, input);
}
@@ -928,8 +917,7 @@
void init()
{
- // FIXME: border::adjust(input, win.delta());
- extension::fill(input, mln_max(mln_value(I)));
+ extension::adjust_fill(input, win, mln_max(mln_value(I)));
initialize(output, input);
}
@@ -1011,8 +999,7 @@
void init()
{
- // FIXME: border::adjust(input, win.delta());
- extension::fill(input, mln_max(mln_value(I)));
+ extension::adjust_fill(input, win, mln_max(mln_value(I)));
initialize(output, input);
}
@@ -1094,8 +1081,7 @@
void init()
{
- // FIXME: border::adjust(input, win.delta());
- extension::fill(input, mln_max(mln_value(I)));
+ extension::adjust_fill(input, win, mln_max(mln_value(I)));
initialize(output, input);
}
Index: mln/morpho/elementary/like_ero_fun.hh
--- mln/morpho/elementary/like_ero_fun.hh (revision 0)
+++ mln/morpho/elementary/like_ero_fun.hh (revision 0)
@@ -0,0 +1,201 @@
+// 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.
+
+#ifndef MLN_MORPHO_ELEMENTARY_LIKE_ERO_FUN_HH
+# define MLN_MORPHO_ELEMENTARY_LIKE_ERO_FUN_HH
+
+/// \file mln/morpho/elementary/like_ero_fun.hh
+
+# include <mln/morpho/includes.hh>
+
+
+namespace mln
+{
+
+ namespace morpho
+ {
+
+ namespace elementary
+ {
+
+ template <typename A, typename F,
+ typename I, typename N>
+ mln_concrete(I)
+ like_ero_fun(const Meta_Accumulator<A>&, const F& f,
+ const Image<I>& input, const Neighborhood<N>& nbh);
+
+
+ struct f_accu
+ {
+ template <typename V, typename A>
+ V operator()(const V& input_p, const A& a) const
+ {
+ return a;
+ }
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace impl
+ {
+
+ namespace generic
+ {
+
+ template <typename A, typename F,
+ typename I, typename N>
+ mln_concrete(I)
+ like_ero_fun(const Meta_Accumulator<A>&, const F& f,
+ const Image<I>& input_, const Neighborhood<N>& nbh_)
+ {
+ trace::entering("morpho::elementary::impl::generic::like_ero_fun");
+
+ const I& input = exact(input_);
+ const N& nbh = exact(nbh_);
+
+ mln_accu_with(A, mln_value(I)) a;
+ extension::adjust_fill(input, nbh, a);
+
+ mln_concrete(I) output;
+ initialize(output, input);
+
+ mln_piter(I) p(input.domain());
+ mln_niter(N) n(nbh, p);
+ for_all(p)
+ {
+ a.take_as_init(input(p));
+ for_all(n) if (input.has(n))
+ a.take(input(n));
+ output(p) = f(input(p), a);
+ }
+
+ trace::exiting("morpho::elementary::impl::generic::like_ero_fun");
+ return output;
+ }
+
+ } // end of namespace mln::morpho::elementary::impl::generic
+
+
+ template <typename A, typename F,
+ typename I, typename N>
+ mln_concrete(I)
+ like_ero_fun_fastest(const Meta_Accumulator<A>&, const F& f,
+ const Image<I>& input_, const Neighborhood<N>& nbh_)
+ {
+ trace::entering("morpho::elementary::impl::like_ero_fun_fastest");
+
+ const I& input = exact(input_);
+ const N& nbh = exact(nbh_);
+
+ mln_accu_with(A, mln_value(I)) a;
+ extension::adjust_fill(input, nbh, a);
+
+ mln_concrete(I) output;
+ initialize(output, input);
+
+ mln_pixter(const I) p_in(input);
+ mln_pixter(I) p_out(output);
+ mln_nixter(const I, N) n(p_in, nbh);
+ for_all_2(p_in, p_out)
+ {
+ a.take_as_init(p_in.val());
+ for_all(n)
+ a.take(n.val());
+ p_out.val() = f(p_in.val(), a);
+ }
+
+ trace::exiting("morpho::elementary::impl::like_ero_fun_fastest");
+ return output;
+ }
+
+ } // end of namespace mln::morpho::elementary::impl
+
+
+ namespace internal
+ {
+
+ template <typename A, typename F,
+ typename I, typename N>
+ mln_concrete(I)
+ like_ero_fun_dispatch(metal::false_,
+ const A& a, const F& f,
+ const I& input, const N& nbh)
+ {
+ return impl::generic::like_ero_fun(a, f, input, nbh);
+ }
+
+ template <typename A, typename F,
+ typename I, typename N>
+ mln_concrete(I)
+ like_ero_fun_dispatch(metal::true_,
+ const A& a, const F& f,
+ const I& input, const N& nbh)
+ {
+ return impl::like_ero_fun_fastest(a, f, input, nbh);
+ }
+
+ template <typename A, typename F,
+ typename I, typename N>
+ mln_concrete(I)
+ like_ero_fun_dispatch(const A& a, const F& f,
+ const I& input, const N& nbh)
+ {
+ typedef mlc_equal(mln_trait_image_speed(I),
+ trait::image::speed::fastest) I_fastest;
+ typedef mln_window(N) W;
+ typedef mln_is_simple_window(W) N_simple;
+
+ return like_ero_fun_dispatch(mlc_and(I_fastest, N_simple)(),
+ a, f, input, nbh);
+ }
+
+ } // end of namespace mln::morpho::elementary::internal
+
+
+ // Facade.
+
+ template <typename A, typename F,
+ typename I, typename N>
+ mln_concrete(I)
+ like_ero_fun(const Meta_Accumulator<A>& a, const F& f,
+ const Image<I>& input, const Neighborhood<N>& nbh)
+ {
+ return internal::like_ero_fun_dispatch(a, f,
+ exact(input), exact(nbh));
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::morpho::elementary
+
+ } // end of namespace mln::morpho
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MORPHO_ELEMENTARY_LIKE_ERO_FUN_HH
Index: mln/morpho/elementary/like_ero_set.hh
--- mln/morpho/elementary/like_ero_set.hh (revision 0)
+++ mln/morpho/elementary/like_ero_set.hh (revision 0)
@@ -0,0 +1,197 @@
+// 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.
+
+#ifndef MLN_MORPHO_ELEMENTARY_LIKE_ERO_SET_HH
+# define MLN_MORPHO_ELEMENTARY_LIKE_ERO_SET_HH
+
+/// \file mln/morpho/elementary/like_ero_set.hh
+
+# include <mln/morpho/includes.hh>
+
+
+namespace mln
+{
+
+ namespace morpho
+ {
+
+ namespace elementary
+ {
+
+ template <typename I, typename N>
+ mln_concrete(I)
+ like_ero_set(bool val[5],
+ const Image<I>& input, const Neighborhood<N>& nbh);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace impl
+ {
+
+ namespace generic
+ {
+
+ template <typename I, typename N>
+ mln_concrete(I)
+ like_ero_set(bool val[5],
+ const Image<I>& input_, const Neighborhood<N>& nbh_)
+ {
+ trace::entering("morpho::elementary::impl::generic::like_ero_set");
+
+ bool
+ ext_value = val[0],
+ do_clone = val[1],
+ on_input_p = val[2],
+ on_input_n = val[3],
+ output_p = val[4];
+
+ const I& input = exact(input_);
+ const N& nbh = exact(nbh_);
+
+ extension::adjust_fill(input, nbh, ext_value);
+
+ mln_concrete(I) output;
+ if (do_clone)
+ output = clone(input);
+ else
+ level::fill(output, false);
+
+ mln_piter(I) p(input.domain());
+ mln_niter(N) n(nbh, p);
+ for_all(p)
+ if (input(p) == on_input_p)
+ for_all(n)
+ if (input.has(n) && input(n) == on_input_n)
+ output(p) = output_p;
+
+ trace::exiting("morpho::elementary::impl::generic::like_ero_set");
+ return output;
+ }
+
+ } // end of namespace mln::morpho::elementary::impl::generic
+
+
+ template <typename I, typename N>
+ mln_concrete(I)
+ like_ero_set_fastest(bool val[5],
+ const Image<I>& input_, const Neighborhood<N>& nbh_)
+ {
+ trace::entering("morpho::elementary::impl::like_ero_set_fastest");
+
+ bool
+ ext_value = val[0],
+ do_clone = val[1],
+ on_input_p = val[2],
+ on_input_n = val[3],
+ output_p = val[4];
+
+ const I& input = exact(input_);
+ const N& nbh = exact(nbh_);
+
+ extension::adjust_fill(input, nbh, ext_value);
+
+ mln_concrete(I) output;
+ if (do_clone)
+ output = clone(input);
+ else
+ level::fill(output, false);
+
+ mln_pixter(const I) p_in(input);
+ mln_pixter(I) p_out(output);
+ mln_nixter(const I, N) n(p_in, nbh);
+ for_all_2(p_in, p_out)
+ if (p_in.val() == on_input_p)
+ for_all(n)
+ if (n.val() == on_input_n)
+ p_out.val() = output_p;
+
+ trace::exiting("morpho::elementary::impl::like_ero_set_fastest");
+ return output;
+ }
+
+ } // end of namespace mln::morpho::elementary::impl
+
+
+ namespace internal
+ {
+
+ template <typename I, typename N>
+ mln_concrete(I)
+ like_ero_set_dispatch(metal::false_,
+ bool val[5],
+ const I& input, const N& nbh)
+ {
+ return impl::generic::like_ero_set(val, input, nbh);
+ }
+
+ template <typename I, typename N>
+ mln_concrete(I)
+ like_ero_set_dispatch(metal::true_,
+ bool val[5],
+ const I& input, const N& nbh)
+ {
+ return impl::like_ero_set_fastest(val, input, nbh);
+ }
+
+ template <typename I, typename N>
+ mln_concrete(I)
+ like_ero_set_dispatch(bool val[5],
+ const I& input, const N& nbh)
+ {
+ typedef mlc_equal(mln_trait_image_speed(I),
+ trait::image::speed::fastest) I_fastest;
+ typedef mln_window(N) W;
+ typedef mln_is_simple_window(W) N_simple;
+
+ return like_ero_set_dispatch(mlc_and(I_fastest, N_simple)(),
+ val, input, nbh);
+ }
+
+ } // end of namespace mln::morpho::elementary::internal
+
+
+ // Facade.
+
+ template <typename I, typename N>
+ mln_concrete(I)
+ like_ero_set(bool val[5],
+ const Image<I>& input, const Neighborhood<N>& nbh)
+ {
+ return internal::like_ero_set_dispatch(val, exact(input), exact(nbh));
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::morpho::elementary
+
+ } // end of namespace mln::morpho
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MORPHO_ELEMENTARY_LIKE_ERO_SET_HH
Index: mln/morpho/elementary/all.hh
--- mln/morpho/elementary/all.hh (revision 0)
+++ mln/morpho/elementary/all.hh (revision 0)
@@ -0,0 +1,53 @@
+// 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.
+
+#ifndef MLN_MORPHO_ELEMENTARY_ALL_HH
+# define MLN_MORPHO_ELEMENTARY_ALL_HH
+
+/// \file mln/morpho/elementary/all.hh
+///
+/// File that includes all elementary mathematical morphology
+/// routines.
+
+
+namespace mln
+{
+ namespace morpho
+ {
+
+ /// Namespace of image processing routines of elementary
+ /// mathematical morphology.
+ namespace elementary {}
+
+ }
+}
+
+# include <mln/morpho/elementary/erosion.hh>
+
+
+
+#endif // ! MLN_MORPHO_ELEMENTARY_ALL_HH
Index: mln/morpho/elementary/erosion.hh
--- mln/morpho/elementary/erosion.hh (revision 0)
+++ mln/morpho/elementary/erosion.hh (revision 0)
@@ -0,0 +1,120 @@
+// 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.
+
+#ifndef MLN_MORPHO_ELEMENTARY_EROSION_HH
+# define MLN_MORPHO_ELEMENTARY_EROSION_HH
+
+/// \file mln/morpho/elementary/erosion.hh
+
+# include <mln/morpho/elementary/like_ero_fun.hh>
+# include <mln/morpho/elementary/like_ero_set.hh>
+
+
+namespace mln
+{
+
+ namespace morpho
+ {
+
+ namespace elementary
+ {
+
+
+ template <typename I, typename N>
+ mln_concrete(I)
+ erosion(const Image<I>& input, const Neighborhood<N>& nbh);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace internal
+ {
+
+ // Dispatch.
+
+ template <typename I, typename N>
+ mln_concrete(I)
+ erosion_dispatch(trait::image::kind::any,
+ const Image<I>& input, const Neighborhood<N>& nbh)
+ {
+ return like_ero_fun(accu::meta::min(), f_accu(), input, nbh);
+ }
+
+ template <typename I, typename N>
+ mln_concrete(I)
+ erosion_dispatch(trait::image::kind::logic,
+ const Image<I>& input, const Neighborhood<N>& nbh)
+ {
+ bool val[] =
+ {
+ 1, // ext_value
+ 1, // do_clone
+ 1, // on_input_p
+ 0, // on_input_n
+ 0, // output_p
+ };
+ return like_ero_set(val, input, nbh);
+ }
+
+ template <typename I, typename N>
+ mln_concrete(I)
+ erosion_dispatch(const Image<I>& input, const Neighborhood<N>& nbh)
+ {
+ return erosion_dispatch(mln_trait_image_kind(I)(),
+ input, nbh);
+ }
+
+ } // end of namespace mln::morpho::elementary::internal
+
+
+ // Facade.
+
+ template <typename I, typename N>
+ mln_concrete(I)
+ erosion(const Image<I>& input, const Neighborhood<N>& nbh)
+ {
+ trace::entering("morpho::elementary::erosion");
+
+ mln_precondition(exact(input).has_data());
+ // mln_precondition(exact(nbh).is_valid());
+
+ mln_concrete(I) output = internal::erosion_dispatch(input, nbh);
+
+ trace::exiting("morpho::elementary::erosion");
+ return output;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::morpho::elementary
+
+ } // end of namespace mln::morpho
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MORPHO_ELEMENTARY_EROSION_HH
Index: mln/morpho/erosion.hh
--- mln/morpho/erosion.hh (revision 2711)
+++ mln/morpho/erosion.hh (working copy)
@@ -30,8 +30,6 @@
/// \file mln/morpho/erosion.hh
/// \brief Morphological erosion.
-///
-/// \todo Activate the FIXMEs (border::adjust).
# include <mln/morpho/includes.hh>
@@ -72,8 +70,7 @@
const I& input = exact(input_);
const W& win = exact(win_);
- // FIXME: border::adjust(input, win.delta());
- extension::fill(input, mln_max(mln_value(I)));
+ extension::adjust_fill(input, win, mln_max(mln_value(I)));
mln_concrete(I) output;
initialize(output, input);
@@ -106,8 +103,7 @@
const I& input = exact(input_);
const W& win = exact(win_);
- // FIXME: border::adjust(input, win.delta());
- extension::fill(input, true);
+ extension::adjust_fill(input, win, true);
mln_concrete(I) output;
initialize(output, input);
Index: mln/extension/fill.hh
--- mln/extension/fill.hh (revision 2711)
+++ mln/extension/fill.hh (working copy)
@@ -63,7 +63,6 @@
void fill(const Image<I>& ima, const mln_value(I)& val);
-
# ifndef MLN_INCLUDE_ONLY
Index: mln/extension/all.hh
--- mln/extension/all.hh (revision 2711)
+++ mln/extension/all.hh (working copy)
@@ -46,6 +46,7 @@
# include <mln/extension/fill.hh>
+# include <mln/extension/adjust_fill.hh>
#endif // ! MLN_EXTENSION_ALL_HH
Index: mln/extension/adjust_fill.hh
--- mln/extension/adjust_fill.hh (revision 0)
+++ mln/extension/adjust_fill.hh (revision 0)
@@ -0,0 +1,134 @@
+// 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.
+
+#ifndef MLN_CORE_EXTENSION_ADJUST_FILL_HH
+# define MLN_CORE_EXTENSION_ADJUST_FILL_HH
+
+/*! \file mln/extension/adjust_fill.hh
+ *
+ * \brief Adjust then fill the domain extension.
+ *
+ * \todo Fix doc.
+ */
+
+# include <mln/border/adjust.hh>
+# include <mln/extension/fill.hh>
+# include <mln/geom/delta.hh>
+
+
+namespace mln
+{
+
+ namespace extension
+ {
+
+ /*! Fill the domain extension of image \p ima with the
+ * single value \p v.
+ *
+ * \param[in,out] ima The image whose domain extension is to be filled.
+ * \param[in] val The value to assign.
+ *
+ * \pre \p ima has to be initialized.
+ *
+ * \todo Optimize with memset if possible.
+ */
+ template <typename I, typename W>
+ void adjust_fill(const Image<I>& ima,
+ const Window<W>& win,
+ const mln_value(I)& val);
+
+ template <typename I, typename W>
+ void adjust_fill(const Image<I>& ima,
+ const Weighted_Window<W>& wwin,
+ const mln_value(I)& val);
+
+ template <typename I, typename N>
+ void adjust_fill(const Image<I>& ima,
+ const Neighborhood<N>& nbh,
+ const mln_value(I)& val);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace impl
+ {
+
+ template <typename I, typename W, typename V>
+ void do_adjust_fill(const I& ima,
+ const W& win_like,
+ const V& val)
+ {
+ mln_precondition(exact(ima).has_data());
+ // mln_precondition(exact(win_like).is_valid());
+
+ border::adjust(ima, geom::delta(win_like));
+ extension::fill(ima, val);
+ }
+
+ } // end of namespace mln::extension::impl
+
+
+ // Facades.
+
+ template <typename I, typename W>
+ void adjust_fill(const Image<I>& ima,
+ const Window<W>& win,
+ const mln_value(I)& val)
+ {
+ trace::entering("extension::adjust_fill");
+ impl::do_adjust_fill(ima, win, val);
+ trace::exiting("extension::adjust_fill");
+ }
+
+ template <typename I, typename W>
+ void adjust_fill(const Image<I>& ima,
+ const Weighted_Window<W>& wwin,
+ const mln_value(I)& val)
+ {
+ trace::entering("extension::adjust_fill");
+ impl::do_adjust_fill(ima, wwin, val);
+ trace::exiting("extension::adjust_fill");
+ }
+
+ template <typename I, typename N>
+ void adjust_fill(const Image<I>& ima,
+ const Neighborhood<N>& nbh,
+ const mln_value(I)& val)
+ {
+ trace::entering("extension::adjust_fill");
+ impl::do_adjust_fill(ima, nbh, val);
+ trace::exiting("extension::adjust_fill");
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::extension
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_EXTENSION_FILL_HH
URL: https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena/sandbox
ChangeLog:
2008-10-28 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
Add some bench tests on ocr preprocessing.
* garrigues/ocr/Makefile: New, compile an ocr with preprocess
and an other one without.
* garrigues/ocr/check.sh: New, script to bench ocr preprocessing.
* garrigues/ocr/ocr.cc: Rename as...
* garrigues/ocr/ocr_with_preprocess.cc: ...this.
* garrigues/ocr/ocr_without_preprocess.cc: New. version without
preprocess.
---
Makefile | 21 +++++++
check.sh | 29 ++++++++++
ocr_with_preprocess.cc | 130 ++++++++++++++++++++++++++++++++++++++++++++++
ocr_without_preprocess.cc | 98 ++++++++++++++++++++++++++++++++++
4 files changed, 278 insertions(+)
Index: branches/cleanup-2008/milena/sandbox/garrigues/ocr/ocr.cc (deleted)
===================================================================
Index: branches/cleanup-2008/milena/sandbox/garrigues/ocr/ocr_without_preprocess.cc
===================================================================
--- branches/cleanup-2008/milena/sandbox/garrigues/ocr/ocr_without_preprocess.cc (revision 0)
+++ branches/cleanup-2008/milena/sandbox/garrigues/ocr/ocr_without_preprocess.cc (revision 2710)
@@ -0,0 +1,98 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// 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 <iostream>
+
+#include <mln/core/image/image2d.hh>
+#include <mln/core/alias/window2d.hh>
+#include <mln/core/alias/neighb2d.hh>
+
+#include <mln/core/image/cast_image.hh>
+
+#include <mln/value/int_u8.hh>
+
+#include "resize.hh"
+#include "enlarge.hh"
+//#include "skeleton.hh"
+#include <mln/linear/gaussian.hh>
+
+#include <mln/trace/all.hh>
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+#include <mln/io/pbm/load.hh>
+#include <mln/io/pbm/save.hh>
+#include <mln/core/alias/w_window2d_float.hh>
+
+#include <mln/debug/println.hh>
+#include <mln/geom/chamfer.hh>
+#include <mln/make/win_chamfer.hh>
+#include <mln/labeling/regional_maxima.hh>
+#include <mln/morpho/dilation.hh>
+
+#include <tesseract/baseapi.h>
+
+// _COMPILATION_
+// g++ -DNDEBUG -O3 -I../../.. ocr.cc -L/usr/lib -ltesseract_full -lpthread
+
+
+// Call tesseract
+// lang: expected language
+template <typename T>
+char* tesseract(const char* lang, const mln::image2d<T>& input)
+{
+ TessBaseAPI::InitWithLanguage(NULL, NULL, lang, NULL, false, 0, NULL);
+ char* s = TessBaseAPI::TesseractRect(
+ (unsigned char*) input.buffer(),
+ sizeof (T),
+ input.ncols() * sizeof (T),
+ 0, 0,
+ input.ncols(),
+ input.nrows());
+ return s;
+}
+
+int main(int argc, char** argv)
+{
+ using namespace mln;
+ using value::int_u8;
+
+ image2d<bool> input;
+
+ if (argc < 2)
+ {
+ std::cerr << "Usage: " << argv[0] << " in.pbm" << std::endl;
+ return 1;
+ }
+
+ mln::border::thickness = 0;
+
+ io::pbm::load(input, argv[1]);
+
+ char* s = tesseract("fra", input);
+ std::cout << s;
+ free(s);
+}
Index: branches/cleanup-2008/milena/sandbox/garrigues/ocr/check.sh
===================================================================
--- branches/cleanup-2008/milena/sandbox/garrigues/ocr/check.sh (revision 0)
+++ branches/cleanup-2008/milena/sandbox/garrigues/ocr/check.sh (revision 2710)
@@ -0,0 +1,29 @@
+for i in input/*.pbm ; do
+ echo "==========================================="
+ echo "--------- $i"
+ echo "==========================================="
+
+ ref="$i.txt"
+ cat $ref
+ sed -e 's/\(.\)/\1\n/g' $ref > tmp/ref
+ total=`cat tmp/ref | wc -l `
+
+ ./ocr_without_preprocess $i tmp/`basename $i` > tmp/without
+ echo "_______________without preprocessing"
+ cat tmp/without
+ cat tmp/without | sed -e 's/\(.\)/\1\n/g' > tmp/without
+
+ ./ocr_with_preprocess $i tmp/`basename $i` > tmp/with
+ echo "_______________with preprocessing"
+ cat tmp/with
+ cat tmp/with | sed -e 's/\(.\)/\1\n/g' > tmp/with
+
+
+ d_without=`diff ./tmp/without tmp/ref | diffstat | grep insert | sed -r 's/.*, ([0-9]+) insertion.*/\1/g'`
+ echo "$(($d_without * 100 / $total))% missmatch without preprocessing"
+
+ ./ocr_with_preprocess $i tmp/`basename $i` | sed -e 's/\(.\)/\1\n/g' > tmp/with
+ d_with=`diff ./tmp/with tmp/ref | diffstat | grep insert | sed -r 's/.*, ([0-9]+) insertion.*/\1/g'`
+ echo "$(($d_with * 100 / $total))% missmatch with preprocessing"
+ echo ""
+done
Property changes on: branches/cleanup-2008/milena/sandbox/garrigues/ocr/check.sh
___________________________________________________________________
Name: svn:executable
+ *
Index: branches/cleanup-2008/milena/sandbox/garrigues/ocr/ocr_with_preprocess.cc
===================================================================
--- branches/cleanup-2008/milena/sandbox/garrigues/ocr/ocr_with_preprocess.cc (revision 0)
+++ branches/cleanup-2008/milena/sandbox/garrigues/ocr/ocr_with_preprocess.cc (revision 2710)
@@ -0,0 +1,130 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// 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 <iostream>
+
+#include <mln/core/image/image2d.hh>
+#include <mln/core/alias/window2d.hh>
+#include <mln/core/alias/neighb2d.hh>
+
+#include <mln/core/image/cast_image.hh>
+
+#include <mln/value/int_u8.hh>
+
+#include "resize.hh"
+#include "enlarge.hh"
+//#include "skeleton.hh"
+#include <mln/linear/gaussian.hh>
+
+#include <mln/trace/all.hh>
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+#include <mln/io/pbm/load.hh>
+#include <mln/io/pbm/save.hh>
+#include <mln/core/alias/w_window2d_float.hh>
+
+#include <mln/debug/println.hh>
+#include <mln/geom/chamfer.hh>
+#include <mln/make/win_chamfer.hh>
+#include <mln/labeling/regional_maxima.hh>
+#include <mln/morpho/dilation.hh>
+
+#include <tesseract/baseapi.h>
+
+// _COMPILATION_
+// g++ -DNDEBUG -O3 -I../../.. ocr.cc -L/usr/lib -ltesseract_full -lpthread
+
+
+// Call tesseract
+// lang: expected language
+template <typename T>
+char* tesseract(const char* lang, const mln::image2d<T>& input)
+{
+ TessBaseAPI::InitWithLanguage(NULL, NULL, lang, NULL, false, 0, NULL);
+ char* s = TessBaseAPI::TesseractRect(
+ (unsigned char*) input.buffer(),
+ sizeof (T),
+ input.ncols() * sizeof (T),
+ 0, 0,
+ input.ncols(),
+ input.nrows());
+ return s;
+}
+
+int main(int argc, char** argv)
+{
+ using namespace mln;
+ using value::int_u8;
+
+ image2d<bool> input;
+
+ if (argc < 2)
+ {
+ std::cerr << "Usage: " << argv[0] << " in.pbm out.pbm" << std::endl;
+ return 1;
+ }
+
+ mln::border::thickness = 0;
+
+ io::pbm::load(input, argv[1]);
+
+ // Resize
+ image2d<int_u8> output = enlarge(input, 1);
+
+ // TODO CLEANUP
+#if 0
+ // Blur.
+ output = linear::gaussian(output, 1);
+#endif
+
+#if 0
+ // Threshold
+ mln_piter_(image2d<unsigned>) p(output.domain());
+ for_all(p)
+ {
+ output(p) = output(p) > 127 ? 1 : 0;
+ }
+#endif
+
+#if 0
+ // Compute chamfer distance map.
+ const w_window2d_int& w_win = make::mk_chamfer_3x3_int<8, 0> ();
+ image2d<unsigned> out = geom::chamfer(output, w_win, 255);
+
+ for_all(p)
+ {
+ out(p) = out(p) > 10 ? 255 : 0;
+ }
+#endif
+
+ io::pgm::save(cast_image<int_u8>(output), argv[2]);
+
+ std::cout << "> with preprocessing." << std::endl;
+ char* s = tesseract("fra", output);
+ std::cout << s;
+ free(s);
+}
Index: branches/cleanup-2008/milena/sandbox/garrigues/ocr/Makefile
===================================================================
--- branches/cleanup-2008/milena/sandbox/garrigues/ocr/Makefile (revision 0)
+++ branches/cleanup-2008/milena/sandbox/garrigues/ocr/Makefile (revision 2710)
@@ -0,0 +1,21 @@
+CXXFLAGS=-I../../.. -I${HOME}/local/include
+LFLAGS=-L${HOME}/local/lib -ltesseract_full -lpthread
+
+all: ocr_without_preprocess ocr_with_preprocess
+
+ocr_without_preprocess: ocr_without_preprocess.cc
+ g++ -DNDEBUG -O3 ${CXXFLAGS} $< ${LFLAGS} -o $@
+
+ocr_with_preprocess: ocr_with_preprocess.cc
+ g++ -DNDEBUG -O3 ${CXXFLAGS} $< ${LFLAGS} -o $@
+clean:
+ rm -f *.o ocr_without_preprocess ocr_with_preprocess
+
+logs:
+ mkdir logs
+
+tmp:
+ mkdir tmp
+
+check: logs tmp ocr_without_preprocess ocr_with_preprocess
+ ./check.sh
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena/sandbox
Index: ChangeLog
from Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
INIM: Classif: Start working on max_tree version.
* classif/max_tree.hh: max_tree struct.
* classif/iccvg04.cc: minor fix.
* classif/display.hh: Put display here.
* classif/v2.cc: STart max_tree.
display.hh | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
iccvg04.cc | 30 -----------------------
max_tree.hh | 15 +++++++++++
v2.cc | 25 +++++++++----------
4 files changed, 104 insertions(+), 42 deletions(-)
Index: classif/max_tree.hh
--- classif/max_tree.hh (revision 2705)
+++ classif/max_tree.hh (working copy)
@@ -13,6 +13,7 @@
# include <mln/value/int_u8.hh>
# include <mln/io/pgm/load.hh>
# include <mln/core/site_set/p_array.hh>
+# include <mln/debug/println.hh>
using namespace mln;
@@ -83,6 +84,20 @@
zpar(p) = p;
}
+ void area()
+ {
+ image2d<value::int_u16> area(f.domain());
+ level::fill(area, 1);
+ mln_fwd_piter(S) p(s);
+ for_all(p)
+ {
+ if (parent(p) == p)
+ continue;
+ area(parent(p)) += area(p);
+ }
+ debug::println(area);
+ }
+
bool is_root(const point& p) const
{
return parent(p) == p;
Index: classif/iccvg04.cc
--- classif/iccvg04.cc (revision 2705)
+++ classif/iccvg04.cc (working copy)
@@ -36,6 +36,7 @@
#include <stdlib.h>
#include "proj.hh"
+#include "display.hh"
using namespace mln;
@@ -70,35 +71,6 @@
}
}
-template <typename I>
-void display(const I& ima, const char * dir)
-{
- mkdir(dir, 0777);
- chdir(dir);
-
- image2d< mln_value(I) > out(geom::nrows(ima), geom::ncols(ima));
-
- for (int s = 0; s < geom::nslis(ima); ++s)
- {
- // image2d< value::int_u8 > out(geom::nrows(ima), geom::ncols(ima));
- for (int r = 0; r < geom::nrows(ima); ++r)
- {
- for (int c = 0; c < geom::ncols(ima); ++c)
- {
- out(point2d(r, c)) = ima(point3d(s, r, c));
- }
- }
-
- std::ostringstream is;
- is << "out_" << s << ".pgm";
-
- io::pgm::save(out, is.str());
- }
-
- chdir("..");
-}
-
-
template <typename I, typename J, typename K>
void
classify_image(const I& ima, const J& histo, const K& ws, int nbasins, int f)
Index: classif/display.hh
--- classif/display.hh (revision 0)
+++ classif/display.hh (revision 0)
@@ -0,0 +1,76 @@
+// 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.
+
+#ifndef MLN__DISPLAY_HH
+# define MLN__DISPLAY_HH
+
+#include <mln/io/ppm/save.hh>
+#include <mln/geom/all.hh>
+#include <mln/value/all.hh>
+#include <mln/core/image/image3d.hh>
+
+#include <sys/stat.h>
+#include <sstream>
+#include <string.h>
+#include <stdlib.h>
+
+
+namespace mln
+{
+
+ template <typename I>
+ void display(const I& ima, const char * dir)
+ {
+ mkdir(dir, 0777);
+ chdir(dir);
+
+ image2d< mln_value(I) > out(geom::nrows(ima), geom::ncols(ima));
+
+ for (int s = 0; s < geom::nslis(ima); ++s)
+ {
+ // image2d< value::int_u8 > out(geom::nrows(ima), geom::ncols(ima));
+ for (int r = 0; r < geom::nrows(ima); ++r)
+ {
+ for (int c = 0; c < geom::ncols(ima); ++c)
+ {
+ out(point2d(r, c)) = ima(point3d(s, r, c));
+ }
+ }
+
+ std::ostringstream is;
+ is << "out_" << s << ".pgm";
+
+ io::pgm::save(out, is.str());
+ }
+
+ chdir("..");
+ }
+
+} // end of namespace mln
+
+#endif /* MLN__DISPLAY_HH */
+
Index: classif/v2.cc
--- classif/v2.cc (revision 2705)
+++ classif/v2.cc (working copy)
@@ -14,7 +14,9 @@
#include <mln/arith/revert.hh>
#include <mln/core/alias/neighb3d.hh>
-#include "min_tree.hh"
+#include "max_tree.hh"
+#include "proj.hh"
+#include "display.hh"
using namespace mln;
@@ -38,17 +40,11 @@
template <typename I, typename N>
unsigned
-compute_min_tree(const I& ima, const N& nbh)
+compute_max_tree(const I& ima, const J& histo, const N& nbh)
{
- min_tree_<I,N> run(ima, nbh);
+ max_tree_<I,N> run(ima, nbh);
- mln_piter(I) p(ima.domain());
- unsigned nnodes = 0;
- for_all(p)
- if (run.is_node(p))
- ++nnodes;
- return nnodes;
}
bool usage(int argc, char ** argv)
@@ -72,9 +68,12 @@
//make histo
image3d<unsigned> histo = fill_histo(ima,div_factor);
- //revert histo
- image3d<unsigned> rhisto = arith::revert(histo);
+ //proj
+ accu::mean<unsigned, unsigned, unsigned> mean;
+ image2d<unsigned> phisto = proj(histo, mean);
+
+ //debug::println(phisto);
- // Compute min_tree
- compute_min_tree(rhisto, c6());
+ // Compute max_tree
+ max_tree_<I,N> run(ima, nbh);
}