* mln/core/internal/complex_window_base.hh: New.
---
milena/ChangeLog | 6 +
milena/mln/core/internal/complex_window_base.hh | 179 +++++++++++++++++++++++
2 files changed, 185 insertions(+), 0 deletions(-)
create mode 100644 milena/mln/core/internal/complex_window_base.hh
diff --git a/milena/ChangeLog b/milena/ChangeLog
index c439a18..aa0ac48 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,11 @@
2009-09-25 Roland Levillain <roland(a)lrde.epita.fr>
+ Introduce a base class for general complex windows.
+
+ * mln/core/internal/complex_window_base.hh: New.
+
+2009-09-25 Roland Levillain <roland(a)lrde.epita.fr>
+
Replace ad hoc code by Milena's in apps/graph-morpho.
* apps/graph-morpho/morpho.hh
diff --git a/milena/mln/core/internal/complex_window_base.hh b/milena/mln/core/internal/complex_window_base.hh
new file mode 100644
index 0000000..559c9de
--- /dev/null
+++ b/milena/mln/core/internal/complex_window_base.hh
@@ -0,0 +1,179 @@
+// Copyright (C) 2008, 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.
+
+#ifndef MLN_CORE_INTERNAL_COMPLEX_WINDOW_BASE_HH
+# define MLN_CORE_INTERNAL_COMPLEX_WINDOW_BASE_HH
+
+/// \file
+/// \brief Definition of a generic window of the face of a complex,
+/// based on a pair of (forward and backward) complex iterators.
+
+# include <mln/core/concept/window.hh>
+# include <mln/core/site_set/complex_psite.hh>
+# include <mln/core/image/complex_window_piter.hh>
+
+# include <mln/topo/centered_iter_adapter.hh>
+
+// FIXME: Factor with mln::internal::complex_neighborhood_base.
+
+
+namespace mln
+{
+ // Forward declarations.
+ template <typename I, typename G, typename W>
+ class complex_window_fwd_piter;
+ template <typename I, typename G, typename W>
+ class complex_window_bkd_piter;
+
+ namespace internal
+ {
+ template <unsigned D, typename G, typename F, typename B, typename E>
+ class complex_window_base;
+ }
+
+
+ namespace trait
+ {
+
+ template <unsigned D, typename G, typename F, typename B, typename E>
+ struct window_< mln::internal::complex_window_base<D, G, F, B, E> >
+ {
+ typedef trait::window::size::unknown size;
+ typedef trait::window::support::irregular support;
+ typedef trait::window::definition::varying definition;
+ };
+
+ } // end of namespace mln::trait
+
+
+ namespace internal
+ {
+ /** \brief Generic window centered on the face of a complex, based
+ on an pair of (forward and backward) complex iterators. The
+ center (site) is part of the window.
+
+ \tparam D The dimension of the complex.
+ \tparam G The type of the geometry functor of the complex.
+ \tparam F The underlying forward iterator type.
+ \tparam B The underlying backward iterator type.
+ \tparam E The exact type. */
+ template <unsigned D, typename G, typename F, typename B, typename E>
+ class complex_window_base : public Window<E>
+ {
+ public:
+ /// The associated complex iterators.
+ /// \{
+ typedef F complex_fwd_iter;
+ typedef B complex_bkd_iter;
+ /// \}
+
+ public:
+ /// Associated types.
+ /// \{
+ /// The type of psite corresponding to the window.
+ typedef complex_psite<D, G> psite;
+ /// The type of site corresponding to the window.
+ typedef mln_site(psite) site;
+
+ // FIXME: This is a dummy value.
+ typedef void dpsite;
+
+ /* FIXME: Ideally, the `is_centered' information should be
+ fetched from the iterators, but that's not an straighforward
+ task. */
+ complex_window_base(bool is_centered = false);
+
+ /// \brief Site_Iterator type to browse the psites of the window
+ /// w.r.t. the ordering of vertices.
+ typedef
+ complex_window_fwd_piter<complex_fwd_iter, G, E> fwd_qiter;
+
+ /// \brief Site_Iterator type to browse the psites of the window
+ /// w.r.t. the reverse ordering of vertices.
+ typedef
+ complex_window_bkd_piter<complex_bkd_iter, G, E> bkd_qiter;
+
+ /// The default qiter type.
+ typedef fwd_qiter qiter;
+ /// \}
+
+ public:
+ /// Services.
+ /// \{
+ /* FIXME: mln::morpho::dilation requires these method from models
+ of concept Window, but Window does not list them in its
+ requirements. Who's guilty: morpho::dilation or Window? */
+ /// Is this window empty? (Always returns \c false).
+ bool is_empty() const;
+ /// Is this window centered?
+ bool is_centered() const;
+
+ /// Return true by default.
+ bool is_valid() const;
+ /// \}
+
+ private:
+ bool is_centered_;
+ };
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <unsigned D, typename G, typename F, typename B, typename E>
+ complex_window_base<D, G, F, B, E>::complex_window_base(bool is_centered)
+ : is_centered_(is_centered)
+ {
+ }
+
+
+ template <unsigned D, typename G, typename F, typename B, typename E>
+ bool
+ complex_window_base<D, G, F, B, E>::is_empty() const
+ {
+ return false;
+ }
+
+ template <unsigned D, typename G, typename F, typename B, typename E>
+ bool
+ complex_window_base<D, G, F, B, E>::is_centered() const
+ {
+ return is_centered_;
+ }
+
+ template <unsigned D, typename G, typename F, typename B, typename E>
+ bool
+ complex_window_base<D, G, F, B, E>::is_valid() const
+ {
+ return true;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::internal
+
+} // end of namespace mln
+
+#endif // ! MLN_CORE_INTERNAL_COMPLEX_WINDOW_BASE_HH
--
1.6.3.1
* src/multi_scale/Makefile.am,
* src/multi_scale/find_lines.cc: New.
---
scribo/ChangeLog | 7 ++
scribo/src/multi_scale/Makefile.am | 26 +++++
scribo/src/multi_scale/find_lines.cc | 179 ++++++++++++++++++++++++++++++++++
3 files changed, 212 insertions(+), 0 deletions(-)
create mode 100644 scribo/src/multi_scale/Makefile.am
create mode 100644 scribo/src/multi_scale/find_lines.cc
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index ff13b41..85c59a7 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,5 +1,12 @@
2009-09-28 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+ Add a first draft of a multi-scale process.
+
+ * src/multi_scale/Makefile.am,
+ * src/multi_scale/find_lines.cc: New.
+
+2009-09-28 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
Cleanup scribo/src directory.
* src/text/Makefile.am,
diff --git a/scribo/src/multi_scale/Makefile.am b/scribo/src/multi_scale/Makefile.am
new file mode 100644
index 0000000..f3dfb42
--- /dev/null
+++ b/scribo/src/multi_scale/Makefile.am
@@ -0,0 +1,26 @@
+# 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/>.
+#
+
+## Process this file through Automake to create Makefile.in.
+
+include $(top_srcdir)/scribo/scribo.mk
+
+bin_PROGRAMS = \
+ find_lines
+
+find_lines_SOURCES = find_lines.cc
+
diff --git a/scribo/src/multi_scale/find_lines.cc b/scribo/src/multi_scale/find_lines.cc
new file mode 100644
index 0000000..f91c2da
--- /dev/null
+++ b/scribo/src/multi_scale/find_lines.cc
@@ -0,0 +1,179 @@
+// 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 <mln/core/alias/neighb2d.hh>
+#include <mln/core/image/image2d.hh>
+#include <mln/data/convert.hh>
+#include <mln/debug/superpose.hh>
+#include <mln/io/pbm/all.hh>
+#include <mln/io/ppm/save.hh>
+#include <mln/pw/all.hh>
+#include <mln/subsampling/subsampling.hh>
+#include <mln/value/label_16.hh>
+#include <mln/value/rgb8.hh>
+
+#include <mln/world/binary_2d/enlarge.hh>
+
+#include <scribo/debug/usage.hh>
+
+#include <scribo/core/object_image.hh>
+#include <scribo/primitive/extract/lines_h_pattern.hh>
+#include <scribo/primitive/extract/lines_v_pattern.hh>
+
+#include <scribo/filter/objects_h_thin.hh>
+#include <scribo/filter/objects_v_thin.hh>
+
+#include <sandbox/theo/Rd/sequential.hh>
+
+#include <mln/morpho/erosion.hh>
+
+const char *args_desc[][2] =
+{
+ { "input.pbm", "A binary image." },
+ { "length", " Minimum line length." },
+ {0, 0}
+};
+
+
+namespace mln
+{
+
+ template <typename I>
+ mln_concrete(I)
+ process(const I& input, const std::string& filename,
+ unsigned length, unsigned delta, unsigned ratio)
+ {
+ I hlines = scribo::primitive::extract::lines_h_pattern(input,
+ length,
+ delta);
+
+ value::label_16 nhlines;
+ hlines = scribo::filter::objects_v_thin(hlines, c8(),
+ nhlines, delta * ratio);
+
+// I vlines = scribo::primitive::extract::lines_v_pattern(input,
+// length,
+// delta);
+
+
+// value::label_16 nvlines;
+// vlines = scribo::filter::objects_h_thin(vlines, c8(),
+// nvlines, delta * ratio);
+
+// image2d<value::rgb8> out = debug::superpose(input, hlines, literal::red);
+// out = debug::superpose(out, vlines, literal::green);
+// io::ppm::save(out, filename);
+
+ return hlines;
+ }
+
+
+ template <typename I>
+ mln_concrete(I)
+ merge_results(const I& input,
+ const I& out, const I& out_sub2x, const I& out_sub4x)
+ {
+ mln_concrete(I) output;
+ initialize(output, input);
+
+
+
+ return output;
+ }
+
+
+} // end of namespace mln
+
+
+
+int main(int argc, char *argv[])
+{
+ using namespace mln;
+
+ if (argc != 4)
+ return scribo::debug::usage(argv,
+ "Extract discontinued horizontal and vertical lines (multi-scale version)",
+ "input.pbm length output.ppm",
+ args_desc,
+ "A color image. Horizontal lines are in red and vertical lines in green.");
+
+ trace::entering("main");
+
+ typedef image2d<bool> I;
+ dpoint2d none(0, 0);
+
+ I input;
+ io::pbm::load(input, argv[1]);
+
+
+ // 1/1
+ std::cout << "1/1" << std::endl;
+ I hlines = scribo::primitive::extract::lines_h_pattern(input,
+ atoi(argv[2]),
+ 3);
+
+
+
+// I vlines = scribo::primitive::extract::lines_v_pattern(input,
+// atoi(argv[2]),
+// 3);
+
+ image2d<value::rgb8> out = debug::superpose(input, hlines, literal::red);
+// out = debug::superpose(out, vlines, literal::green);
+ io::ppm::save(out, "out_1_1.ppm");
+
+// I out = process(input, "out_1_1.ppm", atoi(argv[2]), 3);
+
+
+
+ // 1/2
+ std::cout << "1/2" << std::endl;
+ I input_sub2x = mln::subsampling::subsampling(input, none, 2);
+ I out_sub2 = process(input_sub2x, "out_1_2.ppm", atoi(argv[2]), 3, 2);
+
+
+
+// // 1/4
+// std::cout << "1/4" << std::endl;
+// I input_sub4x = mln::subsampling::subsampling(input, none, 4);
+// I out_sub4 = process(input_sub4x, "out_1_4.ppm", atoi(argv[2]), 3, 4);
+
+
+// out_sub4 = world::binary_2d::enlarge(out_sub4, 2);
+ out_sub2 = world::binary_2d::enlarge(out_sub2, 1);
+
+// io::ppm::save(merge_results(input, out, out_sub2, out_sub4), argv[2]);
+
+ I tmp = morpho::Rd::sequential(hlines, input, c8());
+ io::pbm::save(tmp, "rd.pbm");
+ I tmp_sub2 = morpho::Rd::sequential(out_sub2, input, c8());
+ io::pbm::save(tmp_sub2, "rd_sub2.pbm");
+
+ out = debug::superpose(input, tmp_sub2, literal::red);
+ out = debug::superpose(out, tmp, literal::red);
+ io::ppm::save(out, "out.ppm");
+
+ trace::exiting("main");
+}
--
1.5.6.5