URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
ChangeLog:
2009-03-13 Etienne FOLIO <folio(a)lrde.epita.fr>
Sandbox reorganization.
Moved again many old things...
* folio/dt/canvas_dt.hh: Remove.
* folio/dt/chamfer.hh: Remove.
* folio/dt/cp.hh: Remove.
* folio/dt/dmap.hh: Remove.
* folio/dt/path.hh: Remove.
* folio/dt/raw_cp_fast.hh: Remove.
* folio/dt/raw_cp_slow.hh: Remove.
* folio/dt/raw_dmap_fast.hh: Remove.
* folio/dt/raw_dmap_slow.hh: Remove.
* folio/dt/raw_path_fast.hh: Remove.
* folio/dt/raw_path_slow.hh: Remove.
* folio/dt: Remove.
* folio/dt_old/canevas_dt.hh: Remove.
* folio/dt_old/chamfer.cc: Remove.
* folio/dt_old/distance_front.cc: Remove.
* folio/dt_old/distance_front_new.hh: Remove.
* folio/dt_old/dt.cc: Remove.
* folio/dt_old/dt.hh: Remove.
* folio/dt_old/dt.spe.hh: Remove.
* folio/dt_old/naive.cc: Remove.
* folio/dt_old/psn.cc: Remove.
* folio/dt_old/psn_log.cc: Remove.
* folio/dt_old: Remove.
* folio/mln/dt/dt_old: New.
* folio/mln/dt: New.
---
canvas_dt.hh | 178 ++++++++++++++++++
chamfer.hh | 156 +++++++++++++++
cp.hh | 121 ++++++++++++
dmap.hh | 119 ++++++++++++
dt_old/canevas_dt.hh | 231 +++++++++++++++++++++++
dt_old/chamfer.cc | 206 +++++++++++++++++++++
dt_old/distance_front.cc | 88 +++++++++
dt_old/distance_front_new.hh | 420 +++++++++++++++++++++++++++++++++++++++++++
dt_old/dt.cc | 59 ++++++
dt_old/dt.hh | 101 ++++++++++
dt_old/dt.spe.hh | 123 ++++++++++++
dt_old/naive.cc | 142 ++++++++++++++
dt_old/psn.cc | 203 ++++++++++++++++++++
dt_old/psn_log.cc | 290 +++++++++++++++++++++++++++++
path.hh | 121 ++++++++++++
raw_cp_fast.hh | 173 +++++++++++++++++
raw_cp_slow.hh | 155 +++++++++++++++
raw_dmap_fast.hh | 164 ++++++++++++++++
raw_dmap_slow.hh | 149 +++++++++++++++
raw_path_fast.hh | 173 +++++++++++++++++
raw_path_slow.hh | 155 +++++++++++++++
21 files changed, 3527 insertions(+)
Index: trunk/milena/sandbox/folio/mln/dt/dmap.hh
===================================================================
--- trunk/milena/sandbox/folio/mln/dt/dmap.hh (revision 0)
+++ trunk/milena/sandbox/folio/mln/dt/dmap.hh (revision 3524)
@@ -0,0 +1,119 @@
+// Copyright (C) 2007 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_DT_DMAP_HH
+# define MLN_DT_DMAP_HH
+
+# include "canvas_dt.hh"
+
+namespace mln
+{
+
+ namespace dt
+ {
+
+ /*! Propagation using a single neighborhood (PSN).
+ *
+ * \param[in] input_ The input image.
+ * \param[in] nbh The chamfer window to use for distance calcul.
+ * \param[in] max Max value of the output image.
+ * \return A distance map.
+ *
+ * \pre \p img has to be initialized.
+ */
+ template<typename I, typename N>
+ mln_ch_value(I, unsigned)
+ dmap(const Image<I>& input_, const N& nbh, unsigned max);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace impl
+ {
+
+ // Generic functor.
+
+ template <typename I_, typename N_>
+ struct dmap_functor
+ {
+ typedef I_ I;
+ typedef N_ N;
+
+ const I& input;
+ const N& nbh;
+ unsigned max;
+
+ dmap_functor(const I& input, const N& nbh, unsigned max)
+ : input(input),
+ nbh(nbh),
+ max(max)
+ {}
+
+ void init()
+ {
+ }
+
+ void init_in_for(const mln_point(I)& p)
+ {
+ (void) p;
+ }
+
+ void run_in_for(const mln_point(I)& p, const mln_point(I)& n)
+ {
+ (void) p;
+ (void) n;
+ }
+ };
+
+ } // end of namespace mln::dt::impl
+
+
+ // Facade.
+
+ template<typename I, typename N>
+ inline
+ mln_ch_value(I, unsigned)
+ dmap(const Image<I>& input, const N& nbh, unsigned max)
+ {
+ trace::entering("dt::dmap");
+ mln_precondition(exact(input).is_valid());
+
+ typedef impl::dmap_functor<I, N> F;
+ F f(exact(input), nbh, max);
+ mln::canvas::dt<F> call(f);
+
+ trace::exiting("dt::dmap");
+ return call.distance;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::dt
+
+} // end of namespace mln
+
+#endif // ! MLN_DT_DMAP_HH
Index: trunk/milena/sandbox/folio/mln/dt/canvas_dt.hh
===================================================================
--- trunk/milena/sandbox/folio/mln/dt/canvas_dt.hh (revision 0)
+++ trunk/milena/sandbox/folio/mln/dt/canvas_dt.hh (revision 3524)
@@ -0,0 +1,178 @@
+// 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
+// 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_DT_CANVAS_HH
+# define MLN_DT_CANVAS_HH
+
+# include <vector>
+
+namespace mln
+{
+
+ namespace canvas
+ {
+
+ // General version.
+
+ template <typename F>
+ class dt
+ {
+ public:
+
+ // Ctor.
+ dt(F& f);
+
+ typedef typename F::I I;
+ typedef typename F::N N;
+ typedef mln_point(I) point;
+
+ mln_ch_value(I, unsigned) distance;
+
+ private:
+
+ // Functor.
+ F& f;
+
+ void init();
+ void run();
+
+ std::vector< std::vector<point> > bucket;
+ unsigned bucket_size;
+ unsigned mod;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ /*-------------.
+ | canvas::dt. |
+ `-------------*/
+
+ template <typename F>
+ dt<F>::dt(F& f)
+ : f(f),
+ bucket_size(0)
+ {
+ trace::entering("canvas::dt");
+
+ this->init();
+ this->run();
+
+ trace::exiting("canvas::dt");
+ }
+
+ template <typename F>
+ void
+ dt<F>::init()
+ {
+ // Preconditions.
+ mln_precondition(f.input.is_valid());
+
+ f.init(); //< f call.
+
+ initialize(distance, f.input);
+
+ // Mod determination.
+ mln::accu::max<unsigned> accu;
+ mln_fwd_piter(I) p(f.input.domain());
+ mln_qiter(N) n(f.nbh, p);
+ for_all(n)
+ accu.take(n.w());
+ mod = accu.to_result() + 1;
+
+ bucket.resize(mod);
+
+ // Initialization
+ for_all(p)
+ {
+ f.init_in_for(p); //< f call.
+ if (f.input(p))
+ {
+ distance(p) = literal::zero;
+ for_all(n)
+ if (f.input.has(n) && ! f.input(n))
+ {
+ bucket[0].push_back(p);
+ ++bucket_size;
+ break;
+ }
+ }
+ else
+ distance(p) = f.max;
+ }
+ }
+
+ template <typename F>
+ void
+ dt<F>::run()
+ {
+ point p;
+ mln_qiter(N) n(f.nbh, p);
+
+ for (unsigned d = 0; bucket_size != 0; ++d)
+ {
+ std::vector<point>& bucket_d = bucket[d % mod];
+ for (unsigned i = 0; i < bucket_d.size(); ++i)
+ {
+ p = bucket_d[i];
+
+ /* |00| |00| insert "a" in bucket 1 |00|
+ |ab| -> |12| -> insert "b" in bucket 1 -> |11| -> then in bucket 2.
+ when d = 2, "b" has already been processed when d = 1. */
+ if (distance(p) < d)
+ continue;
+
+ for_all(n)
+ if (distance.has(n) && distance(n) > d)
+ {
+ unsigned newDist = d + n.w();
+
+ if (newDist < distance(n))
+ {
+ f.run_in_for(p, n); //< f call.
+ distance(n) = newDist;
+ bucket[newDist % mod].push_back(n);
+ ++bucket_size;
+ }
+ }
+ }
+ bucket_size -= bucket_d.size();
+ bucket_d.clear();
+ }
+
+ } // end of method dt::run()
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+
+ } // end of namespace mln::canvas
+
+} // end of namespace mln
+
+
+#endif // ! MLN_DT_CANVAS_HH
Index: trunk/milena/sandbox/folio/mln/dt/cp.hh
===================================================================
--- trunk/milena/sandbox/folio/mln/dt/cp.hh (revision 0)
+++ trunk/milena/sandbox/folio/mln/dt/cp.hh (revision 3524)
@@ -0,0 +1,121 @@
+// Copyright (C) 2007 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_DT_CP_HH
+# define MLN_DT_CP_HH
+
+# include "canvas_dt.hh"
+
+namespace mln
+{
+
+ namespace dt
+ {
+
+ /*! Propagation using a single neighborhood (PSN).
+ *
+ * \param[in] input_ The input image.
+ * \param[in] nbh The chamfer window to use for distance calcul.
+ * \param[in] max Max value of the output image.
+ * \return A distance map.
+ *
+ * \pre \p img has to be initialized.
+ */
+ template<typename I, typename N>
+ mln_ch_value(I, mln_point(I))
+ cp(const Image<I>& input_, const N& nbh, unsigned max);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace impl
+ {
+
+ // Generic functor.
+
+ template <typename I_, typename N_>
+ struct cp_functor
+ {
+ typedef I_ I;
+ typedef N_ N;
+
+ const I& input;
+ const N& nbh;
+ unsigned max;
+
+ cp_functor(const I& input, const N& nbh, unsigned max)
+ : input(input),
+ nbh(nbh),
+ max(max)
+ {}
+
+ mln_ch_value(I, mln_point(I)) output;
+
+ void init()
+ {
+ initialize(output, input);
+ }
+
+ void init_in_for(const mln_point(I)& p)
+ {
+ output(p) = p;
+ }
+
+ void run_in_for(const mln_point(I)& p, const mln_point(I)& n)
+ {
+ output(n) = p;
+ }
+ };
+
+ } // end of namespace mln::dt::impl
+
+
+ // Facade.
+
+ template<typename I, typename N>
+ inline
+ mln_ch_value(I, mln_point(I))
+ cp(const Image<I>& input, const N& nbh, unsigned max)
+ {
+ trace::entering("dt::cp");
+ mln_precondition(exact(input).is_valid());
+
+ typedef impl::cp_functor<I, N> F;
+ F f(exact(input), nbh, max);
+ mln::canvas::dt<F> call(f);
+
+ trace::exiting("dt::cp");
+ return f.output;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::dt
+
+} // end of namespace mln
+
+#endif // ! MLN_DT_CP_HH
Index: trunk/milena/sandbox/folio/mln/dt/raw_path_fast.hh
===================================================================
--- trunk/milena/sandbox/folio/mln/dt/raw_path_fast.hh (revision 0)
+++ trunk/milena/sandbox/folio/mln/dt/raw_path_fast.hh (revision 3524)
@@ -0,0 +1,173 @@
+// Copyright (C) 2007 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_DT_RAW_PATH_FAST_HH
+# define MLN_DT_RAW_PATH_FAST_HH
+
+# include <queue>
+# include <map>
+# include <cmath>
+
+# include <mln/core/concept/image.hh>
+# include <mln/make/w_window.hh>
+# include <mln/core/concept/neighborhood.hh>
+# include <mln/literal/zero.hh>
+# include <mln/accu/max.hh>
+
+# include <iostream>
+
+namespace mln
+{
+
+ namespace dt
+ {
+
+ /*! Propagation using a single neighborhood (PSN).
+ *
+ * \param[in] input_ The input image.
+ * \param[in] nbh The chamfer window to use for distance calcul.
+ * \param[in] max Max value of the output image.
+ * \return A distance map.
+ *
+ * \pre \p img has to be initialized.
+ */
+ template<typename I, typename N>
+ mln_ch_value(I, mln_point(I))
+ raw_path_fast(const Image<I>& input_, const N& nbh, unsigned max);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ namespace impl
+ {
+ } // end of namespace mln::dt::impl
+
+
+
+ // Facade.
+
+ template<typename I, typename N>
+ inline
+ mln_ch_value(I, mln_point(I))
+ raw_path_fast(const Image<I>& input_, const N& nbh, unsigned max)
+ {
+ // Preconditions.
+ const I& input = exact(input_);
+ mln_precondition(input.is_valid());
+
+ // Types.
+ typedef mln_point(I) point;
+
+ // Initialization of distance.
+ mln_ch_value(I, unsigned) distance;
+ initialize(distance, input);
+
+ // Initialization of output.
+ mln_ch_value(I, mln_point(I)) output;
+ initialize(output, input);
+
+ // Mod determination.
+ mln_accu_with_(accu::max, unsigned) accu;
+ mln_fwd_piter(I) p(input.domain());
+ mln_qiter(N) n(nbh, p);
+ for_all(n)
+ accu.take(n.w());
+ unsigned mod = accu.to_result() + 1;
+
+ // Aux data.
+ std::vector< std::vector<point> > bucket(mod);
+ unsigned bucket_size = 0;
+
+ // Initialization.
+ {
+ for_all(p)
+ {
+ output(p) = p;
+ if (input(p))
+ {
+ distance(p) = literal::zero;
+ for_all(n)
+ if (input.has(n) && ! input(n))
+ {
+ bucket[0].push_back(p);
+ ++bucket_size;
+ break;
+ }
+ }
+ else
+ distance(p) = max;
+ }
+ }
+
+ // Propagation.
+ {
+ point p;
+ mln_qiter(N) n(nbh, p);
+
+ for (unsigned d = 0; bucket_size != 0; ++d)
+ {
+ std::vector<point>& bucket_d = bucket[d % mod];
+ for (unsigned i = 0; i < bucket_d.size(); ++i)
+ {
+ p = bucket_d[i];
+
+ // FIXME: Draw...
+ if (distance(p) < d)
+ // p has already been processed, having a distance less than d.
+ continue;
+
+ for_all(n)
+ if (distance.has(n) && distance(n) > d)
+ {
+ unsigned newDist = d + n.w();
+
+ if (newDist < distance(n))
+ {
+ output(n) = output(p);
+ distance(n) = newDist;
+ bucket[newDist % mod].push_back(n);
+ ++bucket_size;
+ }
+ }
+ }
+ bucket_size -= bucket_d.size();
+ bucket_d.clear();
+ }
+
+ } // end of propagation.
+
+ return output;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::dt
+
+} // end of namespace mln
+
+#endif // ! MLN_DT_RAW_PATH_FAST_HH
Index: trunk/milena/sandbox/folio/mln/dt/chamfer.hh
===================================================================
--- trunk/milena/sandbox/folio/mln/dt/chamfer.hh (revision 0)
+++ trunk/milena/sandbox/folio/mln/dt/chamfer.hh (revision 3524)
@@ -0,0 +1,156 @@
+// Copyright (C) 2007 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_DT_CHAMFER_HH
+# define MLN_DT_CHAMFER_HH
+
+# include <mln/core/concept/image.hh>
+# include <mln/make/w_window.hh>
+
+namespace mln
+{
+
+ namespace dt
+ {
+
+ /*! Distance tranform by chamfer application.
+ *
+ * \param[in] input_ The input image.
+ * \param[in] chamfer The chamfer window to use for distance calcul.
+ * \return A pair (distance map, nearest point map).
+ *
+ * \pre \p img has to be initialized.
+ */
+ template<typename I, typename T>
+ std::pair<mln_ch_value(I, T), mln_ch_value(I, mln_point(I))>
+ chamfer(const Image<I>& input_,
+ w_window<mln_dpoint(I), T> chamfer);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace impl
+ {
+
+ /*! Computes a pass of the chamfer DT algorithm.
+ *
+ * \param[in] p Iterator on the input image to use.
+ * \param[in] chamfer The chamfer window to use for distance calcul.
+ * \param[in] input The input image.
+ * \param[out] outputDistance The distance map updated.
+ * \param[out] outputnearest The nearest points map updated.
+ */
+ template<typename Q, typename I, typename T>
+ inline
+ void
+ chamfer_pass(const w_window<mln_dpoint(I), T> chamfer,
+ const I& input,
+ mln_ch_value(I, T)& outputDistance,
+ mln_ch_value(I, mln_point(I))& outputNearest)
+ {
+ typedef w_window<mln_dpoint(I), T> W;
+
+ Q p(input.domain());
+ mln_qiter(W) q(chamfer, p);
+ for_all(p)
+ {
+ std::pair<T, mln_point(I)> min(mln_max(T), p);
+
+ for_all(q)
+ if (input.has(q) && outputDistance(q) != mln_max(T))
+ {
+ T v = outputDistance(q) + q.w();
+
+ if (v < min.first)
+ {
+ min.first = v;
+ min.second = outputNearest(q);
+ }
+ }
+
+ if (min.first < outputDistance(p))
+ {
+ outputDistance(p) = min.first;
+ outputNearest(p) = min.second;
+ }
+ }
+ }
+
+ } // end of namespace mln::dt::impl
+
+
+
+ // Facade.
+
+ template<typename I, typename T>
+ inline
+ std::pair<mln_ch_value(I, T), mln_ch_value(I, mln_point(I))>
+ chamfer(const Image<I>& input_,
+ w_window<mln_dpoint(I), T> chamfer)
+ {
+ typedef w_window<mln_dpoint(I), T> W;
+
+ const I& input = exact(input_);
+ mln_precondition(input.is_valid());
+
+ mln_ch_value(I, T) outputDistance;
+ initialize(outputDistance, input);
+
+ mln_ch_value(I, mln_point(I)) outputNearest;
+ initialize(outputNearest, input);
+
+ // Initialization.
+ {
+ mln_fwd_piter(I) p(input.domain());
+ for_all(p)
+ {
+ outputDistance(p) = input(p) ? literal::zero : mln_max(T);
+ outputNearest(p) = p;
+ }
+ }
+
+ // First pass.
+ impl::chamfer_pass<mln_fwd_piter(I)>
+ (chamfer, input, outputDistance, outputNearest);
+
+ chamfer.sym();
+
+ // Second pass.
+ impl::chamfer_pass<mln_bkd_piter(I)>
+ (chamfer, input, outputDistance, outputNearest);
+
+ return std::pair<mln_ch_value(I, T), mln_ch_value(I, mln_point(I))>
+ (outputDistance, outputNearest);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::dt
+
+} // end of namespace mln
+
+#endif // ! MLN_DT_CHAMFER_HH
Index: trunk/milena/sandbox/folio/mln/dt/dt_old/psn.cc
===================================================================
--- trunk/milena/sandbox/folio/mln/dt/dt_old/psn.cc (revision 0)
+++ trunk/milena/sandbox/folio/mln/dt/dt_old/psn.cc (revision 3524)
@@ -0,0 +1,203 @@
+// Copyright (C) 2007 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_DT_CHAMFER_HH
+# define MLN_DT_CHAMFER_HH
+
+# include <queue>
+# include <map>
+# include <cmath>
+
+# include <mln/core/concept/image.hh>
+# include <mln/make/w_window.hh>
+# include <mln/core/concept/neighborhood.hh>
+# include <mln/literal/zero.hh>
+
+# include <iostream>
+
+namespace mln
+{
+
+ namespace dt
+ {
+
+ /*! Propagation using a single neighborhood (PSN).
+ *
+ * \param[in] input_ The input image.
+ * \param[in] nbh The chamfer window to use for distance calcul.
+ * \param[in] max Max value of the output image.
+ * \return A distance map.
+ *
+ * \pre \p img has to be initialized.
+ */
+ template<typename I, typename N>
+ mln_ch_value(I, unsigned)
+ psn(const Image<I>& input_, const N& nbh, unsigned max);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ namespace impl
+ {
+ } // end of namespace mln::dt::impl
+
+
+
+ // Facade.
+
+ template<typename I, typename N>
+ inline
+ mln_ch_value(I, unsigned)
+ psn(const Image<I>& input_, const N& nbh, unsigned max)
+ {
+ // Preconditions.
+ const I& input = exact(input_);
+ mln_precondition(input.is_valid());
+
+ // Types.
+ typedef mln_point(I) point;
+
+ // Initialization of output.
+ mln_ch_value(I, unsigned) output;
+ initialize(output, input);
+
+ // Initialization.
+ // {
+
+ std::map<unsigned, std::queue<point> > bucket;
+ unsigned bucket_size = 0;
+
+ mln_fwd_piter(I) p(input.domain());
+ for_all(p)
+ if (input(p))
+ {
+ output(p) = literal::zero;
+ bucket[0].push(p);
+ ++bucket_size;
+ }
+ else
+ output(p) = max;
+
+ unsigned d = 0;
+
+ // }
+
+ while (bucket_size != 0)
+ {
+ std::queue<point> bucket_d = bucket[d];
+ while (! bucket_d.empty())
+ {
+ point p = bucket_d.front();
+ bucket_d.pop();
+ --bucket_size;
+
+ if (output(p) == d)
+ {
+ mln_qiter(N) n(nbh, p);
+
+ for_all(n)
+ if (output.has(n))
+ {
+ unsigned newOut = output(p) + n.w();
+
+ if (newOut < output(n))
+ {
+ output(n) = newOut;
+ bucket[newOut].push(n);
+ ++bucket_size;
+ }
+ }
+ }
+ }
+ bucket.erase(d);
+ ++d;
+ }
+
+ return output;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::dt
+
+} // end of namespace mln
+
+#endif // ! MLN_DT_CHAMFER_HH
+
+#include <iostream>
+#include <mln/core/image/image2d.hh>
+#include <mln/debug/println.hh>
+#include <mln/make/win_chamfer.hh>
+#include <mln/data/fill.hh>
+#include <mln/core/alias/neighb2d.hh>
+
+#include <mln/io/pbm/load.hh>
+#include <mln/io/pgm/save.hh>
+#include <mln/level/stretch.hh>
+#include <mln/value/int_u8.hh>
+
+#include <mln/core/image/sub_image.hh>
+#include <mln/core/image/image_if.hh>
+#include <mln/pw/value.hh>
+
+int main()
+{
+ using namespace mln;
+
+ image2d<bool> ima(5,5);
+ bool vals[] = { 1, 0, 0, 1, 1,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 1, 0,
+ 0, 0, 0, 0, 0};
+ data::fill(ima, vals);
+
+ image2d<bool> msk(5,5);
+ bool rest[] = { 1, 0, 1, 1, 1,
+ 1, 0, 1, 1, 1,
+ 1, 1, 0, 0, 0,
+ 1, 1, 0, 1, 1,
+ 1, 1, 1, 1, 1};
+ data::fill(msk, rest);
+
+ int ws[] = { 2, 1, 2,
+ 1, 0, 1,
+ 2, 1, 2 };
+ image2d<unsigned> out;
+ out = dt::psn(ima | pw::value(msk), make::w_window2d(ws), 50);
+
+ debug::println(ima | pw::value(msk));
+ debug::println(out);
+
+// image2d<bool> ima = io::pbm::load("../../img/c01.pbm");
+
+// image2d<value::int_u8> out2(out.domain());
+// level::stretch(out, out2);
+
+// io::pgm::save(out2, "out.pgm");
+}
Index: trunk/milena/sandbox/folio/mln/dt/dt_old/canevas_dt.hh
===================================================================
--- trunk/milena/sandbox/folio/mln/dt/dt_old/canevas_dt.hh (revision 0)
+++ trunk/milena/sandbox/folio/mln/dt/dt_old/canevas_dt.hh (revision 3524)
@@ -0,0 +1,231 @@
+/*!
+ * \file canevas_dt.hh
+ * \author ornthalas <ornthalas(a)gmail.com>
+ */
+
+#ifndef CANEVAS_DT_HH
+# define CANEVAS_DT_HH
+
+# include <queue>
+# include <map>
+# include <mln/core/concept/image.hh>
+# include <mln/make/w_window.hh>
+# include <mln/literal/zero.hh>
+
+# include <mln/core/concept/neighborhood.hh>
+
+namespace mln
+{
+
+ namespace canvas
+ {
+
+ // General version.
+
+ template <typename F>
+ struct dt
+ {
+ // Functor.
+ F& f;
+
+ typedef typename F::I I;
+ typedef typename F::N N;
+ typedef typename F::L L;
+ typedef mln_psite(I) point;
+
+ mln_ch_value(I, L) output;
+
+ // Ctor.
+ dt(F& f);
+
+ void init();
+ void run();
+
+ std::map<unsigned, std::queue<point> > bucket;
+ unsigned bucket_size;
+
+ unsigned current_distance;
+ };
+
+ template <typename F>
+ struct dt_fastest
+ {
+ // Functor.
+ F& f;
+
+ typedef typename F::I I;
+ typedef typename F::N N;
+ typedef typename F::L L;
+ typedef mln_psite(I) point;
+
+ mln_ch_value(I, L) output;
+
+ // Ctor.
+ dt_fastest(F& f);
+
+ void init();
+ void run();
+
+ std::map<unsigned, std::queue<point> > bucket;
+ unsigned bucket_size;
+
+ unsigned current_distance;
+ };
+
+# ifndef MLN_INCLUDE_ONLY
+
+ /*-------------.
+ | canvas::dt. |
+ `-------------*/
+
+ template <typename F>
+ dt<F>::dt(F& f)
+ : f(f),
+ bucket_size(0),
+ current_distance(0)
+ {
+ trace::entering("canvas::dt");
+
+ this->init();
+ this->run();
+
+ trace::exiting("canvas::dt");
+ }
+
+ template <typename F>
+ void
+ dt<F>::init()
+ {
+ this->f.init();
+ initialize(this->output, this->f.input);
+
+ mln_fwd_piter(I) p(this->f.input.domain());
+ for_all(p)
+ if (this->f.input(p))
+ {
+ this->output(p) = literal::zero;
+ this->bucket[0].push(p);
+ ++this->bucket_size;
+ }
+ else
+ this->output(p) = this->max;
+ }
+
+ template <typename F>
+ void
+ dt<F>::run()
+ {
+ while (this->bucket_size != 0)
+ {
+ std::queue<point> bucket_d = this->bucket[this->current_distance];
+ while (! bucket_d.empty())
+ {
+ point p = bucket_d.front();
+ bucket_d.pop();
+ --bucket_size;
+
+ if (this->output(p) == this->current_distance)
+ {
+ mln_qiter(N) n(this->nbh, p);
+
+ for_all(n)
+ if (this->output.has(n))
+ {
+ unsigned new_out = this->output(p) + n.w();
+
+ if (new_out < this->output(n))
+ {
+ this->output(n) = new_out;
+ this->bucket[new_out].push(n);
+ ++this->bucket_size;
+ }
+ }
+ }
+ }
+ this->bucket.erase(this->current_distance);
+ ++this->current_distance;
+ }
+ }
+
+ /*---------------------.
+ | canvas::dt_fastest. |
+ `---------------------*/
+ template <typename F>
+ dt_fastest<F>::dt_fastest(F& f)
+ : f(f),
+ bucket_size(0),
+ current_distance(0)
+ {
+ trace::entering("canvas::dt");
+
+ this->init();
+ this->run();
+
+ trace::exiting("canvas::dt");
+ }
+
+ template <typename F>
+ void
+ dt_fastest<F>::init()
+ {
+ this->f.init();
+ initialize(this->output, this->f.input);
+
+ mln_fwd_piter(I) p(this->f.input.domain());
+ for_all(p)
+ if (this->f.input(p))
+ {
+ this->output(p) = literal::zero;
+ this->bucket[0].push(p);
+ ++this->bucket_size;
+ }
+ else
+ this->output(p) = this->max;
+ }
+
+ template <typename F>
+ void
+ dt_fastest<F>::run()
+ {
+ while (this->bucket_size != 0)
+ {
+ std::queue<point> bucket_d = this->bucket[this->current_distance];
+ while (! bucket_d.empty())
+ {
+ point p = bucket_d.front();
+ bucket_d.pop();
+ --bucket_size;
+
+ if (this->output(p) == this->current_distance)
+ {
+ mln_qiter(N) n(this->nbh, p);
+
+ for_all(n)
+ if (this->output.has(n))
+ {
+ unsigned new_out = this->output(p) + n.w();
+
+ if (new_out < this->output(n))
+ {
+ this->output(n) = new_out;
+ this->bucket[new_out].push(n);
+ ++this->bucket_size;
+ }
+ }
+ }
+ }
+ this->bucket.erase(this->current_distance);
+ ++this->current_distance;
+ }
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+
+ } // end of namespace mln::canvas
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CANVAS_DT_HH
Index: trunk/milena/sandbox/folio/mln/dt/dt_old/dt.hh
===================================================================
--- trunk/milena/sandbox/folio/mln/dt/dt_old/dt.hh (revision 0)
+++ trunk/milena/sandbox/folio/mln/dt/dt_old/dt.hh (revision 3524)
@@ -0,0 +1,101 @@
+/*!
+ * \file psn.cc
+ * \author ornthalas <ornthalas(a)gmail.com>
+ */
+
+#ifndef DT_HH
+# define DT_HH
+
+// The 'fastest' specialization is in:
+# include "dt.spe.hh"
+
+namespace mln
+{
+
+ namespace dt
+ {
+
+ template<typename I, typename N, typename L>
+ inline
+ mln_ch_value(I, L)
+ dt(const Image<I>& input_, const N& nbh, unsigned max);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace impl
+ {
+
+ // Generic functor.
+
+ template <typename I_, typename N_, typename L_>
+ struct dt_functor
+ {
+ typedef I_ I;
+ typedef N_ N;
+ typedef L_ L;
+
+ const I& input;
+ const N& nbh;
+ unsigned max;
+
+ dt_functor(const I_& input, const N_& nbh, const unsigned max)
+ : input(input),
+ nbh(nbh),
+ max(max)
+ {}
+
+ void init() {}
+ };
+
+
+ // Generic implementation.
+
+ namespace generic
+ {
+
+ template<typename I, typename N, typename L>
+ inline
+ mln_ch_value(I, L)
+ dt_(const Image<I>& input, const N& nbh, unsigned max)
+ {
+ trace::entering("dt::impl::generic::dt_");
+
+ typedef dt_functor<I, N, L> F;
+ F f(input, nbh, max);
+ canvas::dt<F> run(f);
+
+ trace::exiting("dt::impl::generic::dt_");
+ return run.output;
+ }
+
+ } // end of namespace mln::dt::impl::generic
+
+ } // end of namespace mln::dt::impl
+
+
+ // Facade.
+
+ template<typename I, typename N, typename L>
+ inline
+ mln_ch_value(I, L)
+ dt(const Image<I>& input, const N& nbh, unsigned max)
+ {
+ trace::entering("dt::dt");
+ mln_precondition(exact(input).is_valid());
+
+ mln_ch_value(I, L) output =
+ impl::dt_(mln_trait_image_speed(I)(),
+ exact(input), nbh, max);
+
+ trace::exiting("dt::dt");
+ return output;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::dt
+
+} // end of namespace mln
+
+#endif // !DT_HH
Index: trunk/milena/sandbox/folio/mln/dt/dt_old/psn_log.cc
===================================================================
--- trunk/milena/sandbox/folio/mln/dt/dt_old/psn_log.cc (revision 0)
+++ trunk/milena/sandbox/folio/mln/dt/dt_old/psn_log.cc (revision 3524)
@@ -0,0 +1,290 @@
+
+// Copyright (C) 2007 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_DT_CHAMFER_HH
+# define MLN_DT_CHAMFER_HH
+
+# include <vector>
+# include <queue>
+# include <map>
+# include <cmath>
+
+# include <mln/core/concept/image.hh>
+# include <mln/core/concept/neighborhood.hh>
+# include <mln/literal/zero.hh>
+
+#include <mln/core/image/image2d.hh>
+# include <mln/debug/println.hh>
+
+namespace mln
+{
+
+ namespace dt
+ {
+
+ /*! Propagation using a single neighborhood (PSN).
+ *
+ * \param[in] input_ The input image.
+ * \param[in] chamfer The chamfer window to use for distance calcul.
+ * \return A pair <distance map, closest point map>.
+ *
+ * \pre \p img has to be initialized.
+ */
+ template<typename I, typename N>
+ mln_ch_value(I, unsigned)
+ psn(const Image<I>& input_, const N& nbh);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ namespace impl
+ {
+
+ template <typename BP>
+ class compare
+ {
+ public:
+ bool
+ operator()(const BP& lhs, const BP& rhs) const
+ {
+ return lhs.second > rhs.second;
+ }
+ };
+
+ template <typename D>
+ unsigned
+ sq(const D& dp)
+ {
+ unsigned res = 0;
+
+ for (unsigned i = 0; i < D::dim; ++i)
+ res += std::abs(dp[i]); // FIXME: dp[i] * dp[i];
+
+ return res;
+ }
+
+ template <typename BP>
+ unsigned
+ size(const std::map<unsigned, std::queue<BP> >& bucket,
+ int d)
+ {
+ unsigned s = 0;
+ typename std::map<unsigned, std::queue<BP> >::const_iterator i;
+ for (i = bucket.begin(); i != bucket.end(); ++i)
+ if (i->first >= d)
+ s += i->second.size();
+ return s;
+ }
+
+ template <typename BP>
+ unsigned
+ size(const std::map<unsigned, std::queue<BP> >& bucket)
+ {
+ unsigned s = 0;
+ typename std::map<unsigned, std::queue<BP> >::const_iterator i;
+ for (i = bucket.begin(); i != bucket.end(); ++i)
+ s += i->second.size();
+ return s;
+ }
+
+ template <typename BP>
+ void
+ print(const std::map<unsigned, std::queue<BP> >& bucket)
+ {
+ typename std::map<unsigned, std::queue<BP> >::const_iterator i;
+ int d = -1;
+ for (i = bucket.begin(); i != bucket.end(); ++i)
+ {
+ if (i->first != d)
+ {
+ d = i->first;
+ std::cout << std::endl << d << ": ";
+ }
+ std::queue<BP> qu = i->second; // copy
+ std::vector<BP> v;
+ v.push_back(qu.front()); qu.pop();
+ typename std::vector<BP>::const_iterator j;
+ for (j = v.begin(); j != v.end(); ++j)
+ std::cout << j->first << " "; // point
+ }
+ std::cout << std::endl;
+ }
+
+ } // end of namespace mln::dt::impl
+
+
+
+ // Facade.
+
+ template<typename I, typename N>
+ inline
+ mln_ch_value(I, unsigned)
+ psn(const Image<I>& input_, const N& nbh)
+ {
+ const I& input = exact(input_);
+ mln_precondition(input.is_valid());
+
+ mln_ch_value(I, unsigned) D;
+ initialize(D, input);
+
+ static const unsigned M = 666; // FIXME
+
+ // Initialization.
+ typedef mln_point(I) point;
+ typedef mln_dpoint(I) dpoint;
+ typedef std::pair<point, dpoint> BP;
+
+ std::map<unsigned, std::queue<BP> > bucket;
+ unsigned bucket_size = 0;
+
+ mln_fwd_piter(I) p(input.domain());
+ for_all(p)
+ if (input(p))
+ {
+ D(p) = literal::zero;
+ bucket[0].push(BP(p, literal::zero));
+ ++bucket_size;
+ }
+ else
+ D(p) = M;
+
+ debug::println(input);
+ debug::println(D);
+ impl::print(bucket);
+
+ unsigned d = 0;
+
+ while (impl::size(bucket, d) != 0)
+ {
+
+ mln_invariant(impl::size(bucket) == bucket_size);
+
+ std::cout << "PROCESSING d = " << d << std::endl;
+
+ std::queue<BP>& bucket_d = bucket[d];
+
+ while (! bucket_d.empty())
+ {
+ point p = bucket_d.front().first;
+ dpoint dp = bucket_d.front().second;
+
+ bucket_d.pop();
+ --bucket_size;
+
+ std::cout << "pop " << p << " at D=" << D(p) << std::endl;
+
+ if (D(p) == d)
+ {
+ mln_niter(N) n_(nbh, p);
+
+ for_all(n_)
+ if (D.has(n_))
+ {
+ dpoint n = n_ - p;
+ unsigned newD = impl::sq(dp + n);
+
+ std::cout << " n=" << n_ << " at D=" << D(n_)
+ << " and newD=" << newD
+ << (newD < D(p + n) ? " push" : "")
+ << std::endl;
+
+ if (newD < D(p + n)) // p + n = p + n_ - p = n_
+ {
+ D(n_) = newD;
+ bucket[newD].push(BP(p + n, dp + n));
+ ++bucket_size;
+ }
+ }
+ }
+ }
+ ++d;
+ }
+
+ return D;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::dt
+
+} // end of namespace mln
+
+#endif // ! MLN_DT_CHAMFER_HH
+
+#include <iostream>
+#include <mln/debug/println.hh>
+#include <mln/make/win_chamfer.hh>
+#include <mln/data/fill.hh>
+#include <mln/core/alias/neighb2d.hh>
+
+#include <mln/io/pbm/load.hh>
+#include <mln/io/pgm/save.hh>
+#include <mln/level/stretch.hh>
+#include <mln/value/int_u8.hh>
+
+#include <mln/core/image/sub_image.hh>
+#include <mln/core/image/image_if.hh>
+#include <mln/pw/value.hh>
+
+int main()
+{
+ using namespace mln;
+
+// image2d<bool> ima(5,5);
+// bool vals[] = { 1, 1, 1, 0, 0,
+// 0, 0, 1, 0, 0,
+// 0, 0, 1, 0, 0,
+// 0, 0, 0, 0, 0,
+// 0, 0, 0, 0, 0 };
+
+ image2d<bool> ima(3,3);
+ bool vals[] = { 1, 0, 0,
+ 0, 0, 0,
+ 0, 0, 0};
+ data::fill(ima, vals);
+
+ image2d<bool> msk(3,3);
+ bool rest[] = { 1, 0, 1,
+ 1, 0, 1,
+ 1, 1, 1};
+ data::fill(msk, rest);
+
+ image2d<unsigned> out;
+ out = dt::psn(ima | pw::value(msk), c4());
+
+ debug::println(ima | pw::value(msk));
+ debug::println(out);
+
+// image2d<bool> ima = io::pbm::load("../../img/c01.pbm");
+
+// image2d<value::int_u8> out2(out.domain());
+// level::stretch(out, out2);
+
+// io::pgm::save(out2, "out.pgm");
+}
Index: trunk/milena/sandbox/folio/mln/dt/dt_old/distance_front.cc
===================================================================
--- trunk/milena/sandbox/folio/mln/dt/dt_old/distance_front.cc (revision 0)
+++ trunk/milena/sandbox/folio/mln/dt/dt_old/distance_front.cc (revision 3524)
@@ -0,0 +1,88 @@
+// Copyright (C) 2008, 2009 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/transform/distance_front.cc
+///
+/// Test on mln::transform::distance_front.
+
+#include <mln/core/var.hh>
+#include <mln/core/image/image2d.hh>
+#include <mln/core/alias/neighb2d.hh>
+#include <mln/make/w_window2d_int.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/data/fill.hh>
+#include <mln/debug/println.hh>
+#include <mln/opt/at.hh>
+#include <mln/level/compare.hh>
+
+#include <mln/transform/internal/distance_functor.hh>
+#include "distance_front_new.hh"
+
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+
+ typedef image2d<bool> I;
+
+ I input(9, 9);
+ data::fill(input, false);
+ opt::at(input, 4, 4) = true;
+
+
+ int_u8 dmax = 18;
+ mln_VAR(nbh, c4());
+
+ int ws[] = { 0, 9, 0, 9, 0,
+ 9, 6, 4, 6, 9,
+ 0, 4, 0, 4, 0,
+ 9, 6, 4, 6, 9,
+ 0, 9, 0, 9, 0 };
+ mln_VAR(w_win, make::w_window2d_int(ws));
+
+
+ transform::internal::distance_functor<I> f;
+ image2d<int_u8> ref, output;
+
+ ref = canvas::impl::generic::distance_front(input,
+ nbh,
+ w_win,
+ dmax,
+ f);
+ // debug::println("ref", ref);
+
+ output = canvas::impl::distance_front_fastest(input,
+ nbh,
+ w_win,
+ dmax,
+ f);
+ // debug::println("output", output);
+
+ mln_invariant(output == ref);
+}
Property changes on: trunk/milena/sandbox/folio/mln/dt/dt_old/distance_front.cc
___________________________________________________________________
Name: svn:mergeinfo
+
Index: trunk/milena/sandbox/folio/mln/dt/dt_old/naive.cc
===================================================================
--- trunk/milena/sandbox/folio/mln/dt/dt_old/naive.cc (revision 0)
+++ trunk/milena/sandbox/folio/mln/dt/dt_old/naive.cc (revision 3524)
@@ -0,0 +1,142 @@
+// Copyright (C) 2007, 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 TODO
+ *
+ * \brief Defines a function that creates a distance map corresponding to a
+ * given image.
+ */
+
+#ifndef MLN_DT_NAIVE_HH
+# define MLN_DT_NAIVE_HH
+
+# include <mln/core/concept/image.hh>
+# include <mln/core/concept/function.hh>
+# include <mln/literal/zero.hh>
+# include <mln/accu/min.hh>
+
+namespace mln
+{
+
+ namespace dt
+ {
+
+ /*! Calculates the distance map corresponding to a given image
+ *
+ * \param[in] input_ The binary reference image.
+ * \param[in] fun_ The function used for distance aclculus.
+ * \return New distance map image.
+ *
+ * \pre \p input_ has to be initialized.
+ *
+ * \fixme Use instead of R the result type of F::operator().
+ */
+ template <typename I, typename F>
+ inline
+ mln_ch_value(I, mln_result(F))
+ naive(const Image<I>& input_, const Function_v2v<F>& fun_);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ // Facade.
+
+ template <typename I, typename F>
+ inline
+ mln_ch_value(I, mln_result(F))
+ naive(const Image<I>& input_, const Function_v2v<F>& fun_)
+ {
+ const I& input = exact(input_);
+ const F& fun = exact(fun_);
+ mln_precondition(input.is_valid());
+
+ mln_ch_value(I, mln_result(F)) output;
+ initialize(output, input);
+
+ mln_piter(I) p(input.domain());
+ for_all(p)
+ {
+ if (input(p))
+ output(p) = literal::zero;
+ else
+ {
+ // p is in the background so the distance has to be computed.
+ accu::min_<mln_result(F)> min;
+ min.init();
+
+ mln_piter(I) q(input.domain());
+ for_all(q)
+ if (input(q))
+ {
+ // q is in the object.
+// metal::vec<2, int> vp = p.to_point(), vq = q.to_point();
+// min.take(fun_(vp, vq));
+ min.take(fun(p - q));
+ }
+ output(p) = min;
+ }
+ }
+
+ return output;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::dt
+
+} // end of namespace mln
+
+#endif // ! MLN_DT_NAIVE_HH
+
+#include <iostream>
+#include <mln/debug/println.hh>
+#include <mln/core/image/image2d.hh>
+#include <mln/data/fill.hh>
+#include <mln/fun/v2v/norm.hh>
+
+int main()
+{
+ using namespace mln;
+
+ {
+ image2d<bool> ima(5,5);
+ bool vals[] = { 1, 1, 1, 0, 0,
+ 0, 0, 1, 0, 0,
+ 0, 0, 1, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0 };
+
+ data::fill(ima, vals);
+ debug::println(ima);
+
+ typedef fun::v2v::l2_norm< algebra::vec<2,float>, float > L2;
+ image2d<float> out = dt::naive(ima, L2());
+
+ std::cerr << "Distance:" << std::endl;
+ debug::println(out);
+ }
+}
Index: trunk/milena/sandbox/folio/mln/dt/dt_old/chamfer.cc
===================================================================
--- trunk/milena/sandbox/folio/mln/dt/dt_old/chamfer.cc (revision 0)
+++ trunk/milena/sandbox/folio/mln/dt/dt_old/chamfer.cc (revision 3524)
@@ -0,0 +1,206 @@
+// Copyright (C) 2007 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_DT_CHAMFER_HH
+# define MLN_DT_CHAMFER_HH
+
+# include <mln/core/concept/image.hh>
+# include <mln/make/w_window.hh>
+
+namespace mln
+{
+
+ namespace dt
+ {
+
+ /*! Distance tranform by chamfer application.
+ *
+ * \param[in] input_ The input image.
+ * \param[in] chamfer The chamfer window to use for distance calcul.
+ * \return A pair (distance map, nearest point map).
+ *
+ * \pre \p img has to be initialized.
+ */
+ template<typename I, typename T>
+ std::pair<mln_ch_value(I, T), mln_ch_value(I, mln_point(I))>
+ chamfer(const Image<I>& input_,
+ w_window<mln_dpoint(I), T> chamfer);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace impl
+ {
+
+ /*! Computes a pass of the chamfer DT algorithm.
+ *
+ * \param[in] p Iterator on the input image to use.
+ * \param[in] chamfer The chamfer window to use for distance calcul.
+ * \param[in] input The input image.
+ * \param[out] outputDistance The distance map updated.
+ * \param[out] outputnearest The nearest points map updated.
+ */
+ template<typename Q, typename I, typename T>
+ inline
+ void
+ chamfer_pass(const w_window<mln_dpoint(I), T> chamfer,
+ const I& input,
+ mln_ch_value(I, T)& outputDistance,
+ mln_ch_value(I, mln_point(I))& outputNearest)
+ {
+ typedef w_window<mln_dpoint(I), T> W;
+
+ Q p(input.domain());
+ mln_qiter(W) q(chamfer, p);
+ for_all(p)
+ {
+ std::pair<T, mln_point(I)> min(mln_max(T), p);
+
+ for_all(q)
+ if (input.has(q) && outputDistance(q) != mln_max(T))
+ {
+ T v = outputDistance(q) + q.w();
+
+ if (v < min.first)
+ {
+ min.first = v;
+ min.second = outputNearest(q);
+ }
+ }
+
+ if (min.first < outputDistance(p))
+ {
+ outputDistance(p) = min.first;
+ outputNearest(p) = min.second;
+ }
+ }
+ }
+
+ } // end of namespace mln::dt::impl
+
+
+
+ // Facade.
+
+ template<typename I, typename T>
+ inline
+ std::pair<mln_ch_value(I, T), mln_ch_value(I, mln_point(I))>
+ chamfer(const Image<I>& input_,
+ w_window<mln_dpoint(I), T> chamfer)
+ {
+ typedef w_window<mln_dpoint(I), T> W;
+
+ const I& input = exact(input_);
+ mln_precondition(input.is_valid());
+
+ mln_ch_value(I, T) outputDistance;
+ initialize(outputDistance, input);
+
+ mln_ch_value(I, mln_point(I)) outputNearest;
+ initialize(outputNearest, input);
+
+ // Initialization.
+ {
+ mln_fwd_piter(I) p(input.domain());
+ for_all(p)
+ {
+ outputDistance(p) = input(p) ? literal::zero : mln_max(T);
+ outputNearest(p) = p;
+ }
+ }
+
+ // First pass.
+ impl::chamfer_pass<mln_fwd_piter(I)>
+ (chamfer, input, outputDistance, outputNearest);
+
+ chamfer.sym();
+
+ // Second pass.
+ impl::chamfer_pass<mln_bkd_piter(I)>
+ (chamfer, input, outputDistance, outputNearest);
+
+ return std::pair<mln_ch_value(I, T), mln_ch_value(I, mln_point(I))>
+ (outputDistance, outputNearest);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::dt
+
+} // end of namespace mln
+
+#endif // ! MLN_DT_CHAMFER_HH
+
+#include <iostream>
+#include <mln/core/image/image2d.hh>
+#include <mln/debug/println.hh>
+#include <mln/make/win_chamfer.hh>
+#include <mln/data/fill.hh>
+
+#include <mln/io/pbm/load.hh>
+#include <mln/io/pgm/save.hh>
+#include <mln/level/stretch.hh>
+#include <mln/value/int_u8.hh>
+
+int main()
+{
+ using namespace mln;
+
+ w_window2d_int chamfer = make::mk_chamfer_3x3_int<1, 2>();
+
+ {
+// image2d<bool> ima(5,5);
+// bool vals[] = { 1, 1, 1, 0, 0,
+// 0, 0, 1, 0, 0,
+// 0, 0, 1, 0, 0,
+// 0, 0, 0, 0, 0,
+// 0, 0, 0, 0, 0 };
+
+// data::fill(ima, vals);
+// debug::println(ima);
+
+// std::pair<image2d<int>, image2d<mln_point_(image2d<bool>)> > out;
+// for (int i = 0; i < 999; ++i)
+// out = dt::chamfer(ima, chamfer);
+
+// std::cerr << "Distance:" << std::endl;
+// debug::println(out.first);
+// std::cerr << "PPP:" << std::endl;
+// debug::println(out.second);
+
+ image2d<bool> ima = io::pbm::load("../../img/c01.pbm");
+
+ std::pair<image2d<int>, image2d<mln_point_(image2d<bool>)> > out;
+ out = dt::chamfer(ima, chamfer);
+
+ image2d<value::int_u8> out2(out.first.domain());
+ level::stretch(out.first, out2);
+
+ io::pgm::save(out2, "out.pgm");
+
+ }
+}
Index: trunk/milena/sandbox/folio/mln/dt/dt_old/distance_front_new.hh
===================================================================
--- trunk/milena/sandbox/folio/mln/dt/dt_old/distance_front_new.hh (revision 0)
+++ trunk/milena/sandbox/folio/mln/dt/dt_old/distance_front_new.hh (revision 3524)
@@ -0,0 +1,420 @@
+// 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.
+
+#ifndef MLN_CANVAS_DISTANCE_FRONT_HH
+# define MLN_CANVAS_DISTANCE_FRONT_HH
+
+/// \file mln/canvas/distance_front.hh
+///
+/// Discrete distance canvas by front propagation.
+
+# include <vector>
+# include <mln/core/concept/image.hh>
+# include <mln/core/concept/neighborhood.hh>
+# include <mln/core/concept/weighted_window.hh>
+# include <mln/data/fill.hh>
+# include <mln/accu/max.hh>
+# include <mln/extension/adjust_fill.hh>
+
+
+namespace mln
+{
+
+ namespace canvas
+ {
+
+ /// Discrete front distance canvas.
+ template <typename I,
+ typename N, typename W, typename D,
+ typename F>
+ mln_ch_value(I, D)
+ distance_front(const Image<I>& input,
+ const Neighborhood<N>& nbh, const Weighted_Window<W>& w_win, D max,
+ F& functor);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ // Tests.
+
+ namespace internal
+ {
+
+ template <typename I,
+ typename N, typename W, typename D,
+ typename F>
+ void
+ distance_front_tests(const Image<I>& input_,
+ const Neighborhood<N>& nbh_,
+ const Weighted_Window<W>& w_win_,
+ D max,
+ F& functor)
+ {
+ const I& input = exact(input_);
+ const N& nbh = exact(nbh_);
+ const W& w_win = exact(w_win_);
+
+ mln_precondition(input.is_valid());
+ mln_precondition(nbh.is_valid());
+
+ (void) input;
+ (void) nbh;
+ (void) max;
+ (void) functor;
+ }
+
+
+ } // of namespace mln::canvas::internal
+
+
+
+ // Implementations.
+
+ namespace impl
+ {
+
+ namespace generic
+ {
+
+ template <typename I,
+ typename N, typename W, typename D,
+ typename F>
+ mln_ch_value(I, D)
+ distance_front(const Image<I>& input_,
+ const Neighborhood<N>& nbh_,
+ const Weighted_Window<W>& w_win_,
+ D max,
+ F& functor)
+ {
+ trace::entering("canvas::impl::generic::distance_front");
+
+ const I& input = exact(input_);
+ const N& nbh = exact(nbh_);
+ const W& w_win = exact(w_win_);
+
+ mln_precondition(input.is_valid());
+ mln_precondition(w_win.is_valid());
+
+ typedef mln_site(I) P;
+ typedef std::vector<P> bucket_t;
+
+ // Distance map.
+ mln_ch_value(I, D) dmap;
+ initialize(dmap, input);
+ data::fill(dmap, max);
+
+ // Mod determination.
+ unsigned mod;
+ {
+ accu::max<unsigned> m;
+ for (unsigned i = 0; i < w_win.size(); ++i)
+ m.take(w_win.w(i));
+ mod = unsigned(m) + 1;
+ }
+
+ // Aux data.
+ std::vector<bucket_t> bucket(mod);
+ unsigned bucket_size = 0;
+
+ // Initialization.
+ {
+ functor.init(input); // <-- init
+ mln_piter(I) p(input.domain());
+ mln_niter(N) n(nbh, p);
+ for_all(p)
+ if (functor.inqueue_p_wrt_input_p(input(p))) // <-- inqueue_p_wrt_input_p
+ {
+ dmap(p) = 0;
+ for_all(n)
+ if (input.domain().has(n) &&
+ functor.inqueue_p_wrt_input_n(input(n))) // <-- inqueue_p_wrt_input_n
+ {
+ bucket[0].push_back(p);
+ ++bucket_size;
+ break;
+ }
+ }
+ } // end of Initialization.
+
+ // Propagation.
+ {
+ P p;
+ mln_qiter(W) q(w_win, p);
+ for (unsigned d = 0; bucket_size != 0; ++d)
+ {
+ bucket_t& bucket_d = bucket[d % mod];
+ for (unsigned i = 0; i < bucket_d.size(); ++i)
+ {
+ p = bucket_d[i];
+
+ if (dmap(p) == max)
+ {
+ // Saturation so stop.
+ bucket_size = bucket_d.size(); // So at end bucket_size == 0.
+ break;
+ }
+
+ if (dmap(p) < d)
+ // p has already been processed, having a distance less than d.
+ continue;
+
+ for_all(q)
+ if (dmap.domain().has(q) && dmap(q) > d)
+ {
+ unsigned d_ = d + q.w();
+ if (d_ < dmap(q))
+ {
+ dmap(q) = d_;
+ functor.process(p, q); // <- process
+ bucket[d_ % mod].push_back(q);
+ ++bucket_size;
+ }
+ }
+ }
+ bucket_size -= bucket_d.size();
+ bucket_d.clear();
+ }
+ } // end of Propagation.
+
+ trace::exiting("canvas::impl::generic::distance_front");
+ return dmap;
+ }
+
+ } // of namespace mln::canvas::impl::generic
+
+
+
+ // Fastest version.
+
+ template <typename I,
+ typename N, typename W, typename D,
+ typename F>
+ mln_ch_value(I, D)
+ distance_front_fastest(const Image<I>& input_,
+ const Neighborhood<N>& nbh_,
+ const Weighted_Window<W>& w_win_,
+ D max, F& functor)
+ {
+ trace::entering("canvas::impl::distance_front_fastest");
+
+ const I& input = exact(input_);
+ const N& nbh = exact(nbh_);
+ const W& w_win = exact(w_win_);
+
+ mln_precondition(input.is_valid());
+ mln_precondition(w_win.is_valid());
+
+ // Handling w_win.
+ extension::adjust(input, w_win);
+ const unsigned n_ws = w_win.size();
+ util::array<int> dp = offsets_wrt(input, w_win.win());
+ mln_invariant(dp.nelements() == n_ws);
+
+ // Distance map.
+ mln_ch_value(I, D) dmap;
+ initialize(dmap, input);
+ data::fill(dmap, max);
+
+ // Mod determination.
+ unsigned mod;
+ {
+ accu::max<unsigned> m;
+ for (unsigned i = 0; i < w_win.size(); ++i)
+ m.take(w_win.w(i));
+ mod = unsigned(m) + 1;
+ }
+
+ // Aux data.
+ typedef std::vector<unsigned> bucket_t;
+ std::vector<bucket_t> bucket(mod);
+ unsigned bucket_size = 0;
+
+ // Initialization.
+ {
+ functor.init_(input); // <-- init
+
+ // For the extension to be ignored:
+ extension::fill(input, true);
+ extension::fill(dmap, D(0));
+
+ mln_pixter(const I) p(input);
+ mln_nixter(const I, N) n(p, nbh);
+ for_all(p)
+ if (functor.inqueue_p_wrt_input_p_(p.val())) // <-- inqueue_p_wrt_input_p
+ {
+ dmap.element(p.offset()) = 0;
+ for_all(n)
+ if (functor.inqueue_p_wrt_input_n_(n.val())) // <-- inqueue_p_wrt_input_n
+ {
+ bucket[0].push_back(p.offset());
+ ++bucket_size;
+ break;
+ }
+ }
+ } // end of Initialization.
+
+ // Propagation.
+ {
+ unsigned p;
+
+ for (unsigned d = 0; bucket_size != 0; ++d)
+ {
+ bucket_t& bucket_d = bucket[d % mod];
+ for (unsigned i = 0; i < bucket_d.size(); ++i)
+ {
+ p = bucket_d[i];
+
+ if (dmap.element(p) == max)
+ {
+ // Saturation so stop.
+ bucket_size = bucket_d.size(); // So at end bucket_size == 0.
+ break;
+ }
+
+ if (dmap.element(p) < d)
+ // p has already been processed, having a distance less than d.
+ continue;
+
+ for (unsigned i = 0; i < n_ws; ++i)
+ {
+ unsigned q = p + dp[i];
+ if (dmap.element(q) > d)
+ {
+ unsigned d_ = d + w_win.w(i);
+ if (d_ < dmap.element(q))
+ {
+ dmap.element(q) = d_;
+ functor.process_(p, q); // <- process
+ bucket[d_ % mod].push_back(q);
+ ++bucket_size;
+ }
+ }
+ }
+ }
+ bucket_size -= bucket_d.size();
+ bucket_d.clear();
+ }
+ } // end of Propagation.
+
+ trace::exiting("canvas::impl::distance_front_fastest");
+ return dmap;
+ }
+
+
+ } // of namespace mln::canvas::impl
+
+
+
+ // Dispatch.
+
+ namespace internal
+ {
+
+ template <typename I,
+ typename N, typename W, typename D,
+ typename F>
+ inline
+ mln_ch_value(I, D)
+ distance_front_dispatch(metal::false_,
+ const Image<I>& input,
+ const Neighborhood<N>& nbh, const Weighted_Window<W>& w_win,
+ D max, F& functor)
+ {
+ return impl::generic::distance_front(input, nbh, max, w_win, functor);
+ }
+
+ template <typename I,
+ typename N, typename W, typename D,
+ typename F>
+ inline
+ mln_ch_value(I, D)
+ distance_front_dispatch(metal::true_,
+ const Image<I>& input,
+ const Neighborhood<N>& nbh, const Weighted_Window<W>& w_win,
+ D max, F& functor)
+ {
+ return impl::distance_front_fastest(input, nbh, w_win, max, functor);
+ // return impl::generic::distance_front(input, nbh, w_win, max, functor);
+ }
+
+ template <typename I,
+ typename N, typename W, typename D,
+ typename F>
+ inline
+ mln_ch_value(I, D)
+ distance_front_dispatch(const Image<I>& input,
+ const Neighborhood<N>& nbh, const Weighted_Window<W>& w_win,
+ D max, F& functor)
+ {
+ enum {
+ test = mlc_equal(mln_trait_image_speed(I),
+ trait::image::speed::fastest)::value
+ &&
+ mln_is_simple_neighborhood(N)::value
+ };
+ return distance_front_dispatch(metal::bool_<test>(),
+ input, nbh, w_win, max, functor);
+ }
+
+
+ } // of namespace mln::canvas::internal
+
+
+
+ // Facade.
+
+ template <typename I,
+ typename N, typename W, typename D,
+ typename F>
+ inline
+ mln_ch_value(I, D)
+ distance_front(const Image<I>& input,
+ const Neighborhood<N>& nbh, const Weighted_Window<W>& w_win,
+ D max, F& functor)
+ {
+ trace::entering("canvas::distance_front");
+
+ internal::distance_front_tests(input, nbh, w_win, max, functor);
+
+ mln_ch_value(I,D) output;
+ output = internal::distance_front_dispatch(input, nbh, w_win, max, functor);
+
+ trace::exiting("canvas::distance_front");
+ return output;
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::canvas
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CANVAS_DISTANCE_FRONT_HH
Index: trunk/milena/sandbox/folio/mln/dt/dt_old/dt.cc
===================================================================
--- trunk/milena/sandbox/folio/mln/dt/dt_old/dt.cc (revision 0)
+++ trunk/milena/sandbox/folio/mln/dt/dt_old/dt.cc (revision 3524)
@@ -0,0 +1,59 @@
+/*!
+ * \file dt.cc
+ * \author ornthalas <ornthalas(a)gmail.com>
+ */
+
+#include <iostream>
+#include <mln/core/image/image2d.hh>
+#include <mln/debug/println.hh>
+#include <mln/make/win_chamfer.hh>
+#include <mln/data/fill.hh>
+#include <mln/core/alias/neighb2d.hh>
+
+#include <mln/io/pbm/load.hh>
+#include <mln/io/pgm/save.hh>
+#include <mln/level/stretch.hh>
+#include <mln/value/int_u8.hh>
+
+#include <mln/core/image/sub_image.hh>
+#include <mln/core/image/image_if.hh>
+#include <mln/pw/value.hh>
+
+#include "dt.hh"
+
+int main()
+{
+ using namespace mln;
+
+ image2d<bool> ima(5,5);
+ bool vals[] = { 1, 0, 0, 1, 1,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 1, 0,
+ 0, 0, 0, 0, 0};
+ data::fill(ima, vals);
+
+ image2d<bool> msk(5,5);
+ bool rest[] = { 1, 0, 1, 1, 1,
+ 1, 0, 1, 1, 1,
+ 1, 1, 0, 0, 0,
+ 1, 1, 0, 1, 1,
+ 1, 1, 1, 1, 1};
+ data::fill(msk, rest);
+
+ int ws[] = { 2, 1, 2,
+ 1, 0, 1,
+ 2, 1, 2 };
+ image2d<unsigned> out;
+ out = dt::dt(ima | pw::value(msk), make::w_window2d(ws), 50);
+
+ debug::println(ima | pw::value(msk));
+ debug::println(out);
+
+// image2d<bool> ima = io::pbm::load("../../img/c01.pbm");
+
+// image2d<value::int_u8> out2(out.domain());
+// level::stretch(out, out2);
+
+// io::pgm::save(out2, "out.pgm");
+}
Index: trunk/milena/sandbox/folio/mln/dt/dt_old/dt.spe.hh
===================================================================
--- trunk/milena/sandbox/folio/mln/dt/dt_old/dt.spe.hh (revision 0)
+++ trunk/milena/sandbox/folio/mln/dt/dt_old/dt.spe.hh (revision 3524)
@@ -0,0 +1,123 @@
+/*!
+ * \file test_psn.spe.hh
+ * \author ornthalas <ornthalas(a)gmail.com>
+ */
+
+#ifndef DT_SPE_HH
+# define DT_SPE_HH
+
+# ifndef DT_HH
+# error "Forbidden inclusion of *.spe.hh"
+# endif // ! DT_HH
+
+# include "canevas_dt.hh"
+
+namespace mln
+{
+
+ namespace dt
+ {
+
+ template<typename I, typename N, typename L>
+ inline
+ mln_ch_value(I, L)
+ dt(const Image<I>& input_, const N& nbh, unsigned max);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace impl
+ {
+
+
+ // Fwd decl of the Generic version.
+
+ namespace generic
+ {
+
+ template<typename I, typename N, typename L>
+ inline
+ mln_ch_value(I, L)
+ dt_(const Image<I>& input_, const N& nbh, unsigned max);
+
+ } // end of namespace mln::dt::impl::generic
+
+
+ // Fastest functor.
+
+ template <typename I_, typename N_, typename L_>
+ struct dt_fasfunctor
+ {
+ typedef I_ I;
+ typedef N_ N;
+ typedef L_ L;
+
+ const I& input;
+ const N& nbh;
+ unsigned max;
+
+ dt_fasfunctor(const I_& input, const N_& nbh, const unsigned max)
+ : input(input),
+ nbh(nbh),
+ max(max)
+ {}
+
+ void init() {}
+ };
+
+
+ // Fastest implementation.
+
+ namespace fastest
+ {
+
+ template<typename I, typename N, typename L>
+ inline
+ mln_ch_value(I, L)
+ dt_(const I& input, const N& nbh, unsigned max)
+ {
+ trace::entering("dt::impl::dt_fas");
+
+ typedef dt_fasfunctor<I,N,L> F;
+ F f(input, nbh, max);
+ canvas::dt_fastest<F> run(f);
+
+ trace::exiting("dt::impl::dt_fas");
+ return run.output;
+ }
+
+ } // end of namespace mln::dt::impl::fastest
+
+
+ // Disjunction between "fastest" and "not fastest".
+
+ template<typename I, typename N, typename L>
+ inline
+ mln_ch_value(I, L)
+ dt_(trait::image::speed::any,
+ const I& input, const N& nbh, unsigned max)
+ {
+ return generic::dt_(input, nbh, max);
+ }
+
+ template<typename I, typename N, typename L>
+ inline
+ mln_ch_value(I, L)
+ dt_(trait::image::speed::fastest,
+ const I& input, const N& nbh, unsigned max)
+ {
+ return fastest::dt_(input, nbh, max);
+ }
+
+
+ } // end of namespace mln::dt::impl
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::dt
+
+} // end of namespace mln
+
+
+#endif // !DT_SPE_HH
Index: trunk/milena/sandbox/folio/mln/dt/raw_dmap_fast.hh
===================================================================
--- trunk/milena/sandbox/folio/mln/dt/raw_dmap_fast.hh (revision 0)
+++ trunk/milena/sandbox/folio/mln/dt/raw_dmap_fast.hh (revision 3524)
@@ -0,0 +1,164 @@
+// Copyright (C) 2007 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_DT_RAW_DMAP_FAST_HH
+# define MLN_DT_RAW_DMAP_FAST_HH
+
+# include <queue>
+# include <map>
+# include <cmath>
+
+# include <mln/core/concept/image.hh>
+# include <mln/make/w_window.hh>
+# include <mln/core/concept/neighborhood.hh>
+# include <mln/literal/zero.hh>
+
+# include <iostream>
+
+namespace mln
+{
+
+ namespace dt
+ {
+
+ /*! Propagation using a single neighborhood (PSN).
+ *
+ * \param[in] input_ The input image.
+ * \param[in] nbh The chamfer window to use for distance calcul.
+ * \param[in] max Max value of the distance image.
+ * \return A distance map.
+ *
+ * \pre \p img has to be initialized.
+ */
+ template<typename I, typename N>
+ mln_ch_value(I, unsigned)
+ raw_dmap_fast(const Image<I>& input_, const N& nbh, unsigned max);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ namespace impl
+ {
+ } // end of namespace mln::dt::impl
+
+
+
+ // Facade.
+
+ template<typename I, typename N>
+ inline
+ mln_ch_value(I, unsigned)
+ raw_dmap_fast(const Image<I>& input_, const N& nbh, unsigned max)
+ {
+ // Preconditions.
+ const I& input = exact(input_);
+ mln_precondition(input.is_valid());
+
+ // Types.
+ typedef mln_point(I) point;
+
+ // Initialization of distance.
+ mln_ch_value(I, unsigned) distance;
+ initialize(distance, input);
+
+ // Mod determination.
+ mln_accu_with_(accu::max, unsigned) accu;
+ mln_fwd_piter(I) p(input.domain());
+ mln_qiter(N) n(nbh, p);
+ for_all(n)
+ accu.take(n.w());
+ unsigned mod = accu.to_result() + 1;
+
+ // Aux data.
+ std::vector< std::vector<point> > bucket(mod);
+ unsigned bucket_size = 0;
+
+ // Initialization.
+ {
+ for_all(p)
+ if (input(p))
+ {
+ distance(p) = literal::zero;
+ for_all(n)
+ if (input.has(n) && ! input(n))
+ {
+ bucket[0].push_back(p);
+ ++bucket_size;
+ break;
+ }
+ }
+ else
+ distance(p) = max;
+ }
+
+ // Propagation.
+ {
+ point p;
+ mln_qiter(N) n(nbh, p);
+
+ for (unsigned d = 0; bucket_size != 0; ++d)
+ {
+ std::vector<point>& bucket_d = bucket[d % mod];
+ for (unsigned i = 0; i < bucket_d.size(); ++i)
+ {
+ p = bucket_d[i];
+
+ // FIXME: Draw...
+ if (distance(p) < d)
+ // p has already been processed, having a distance less than d.
+ continue;
+
+ for_all(n)
+ if (distance.has(n) && distance(n) > d)
+ {
+ unsigned newDist = d + n.w();
+
+ if (newDist < distance(n))
+ {
+ distance(n) = newDist;
+ bucket[newDist % mod].push_back(n);
+ ++bucket_size;
+ }
+ }
+ }
+ bucket_size -= bucket_d.size();
+ bucket_d.clear();
+ }
+
+ } // end of propagation.
+
+ return distance;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::dt
+
+} // end of namespace mln
+
+#endif // ! MLN_DT_RAW_DMAP_FAST_HH
Index: trunk/milena/sandbox/folio/mln/dt/raw_cp_fast.hh
===================================================================
--- trunk/milena/sandbox/folio/mln/dt/raw_cp_fast.hh (revision 0)
+++ trunk/milena/sandbox/folio/mln/dt/raw_cp_fast.hh (revision 3524)
@@ -0,0 +1,173 @@
+// Copyright (C) 2007 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_DT_RAW_CP_FAST_HH
+# define MLN_DT_RAW_CP_FAST_HH
+
+# include <queue>
+# include <map>
+# include <cmath>
+
+# include <mln/core/concept/image.hh>
+# include <mln/make/w_window.hh>
+# include <mln/core/concept/neighborhood.hh>
+# include <mln/literal/zero.hh>
+# include <mln/accu/max.hh>
+
+# include <iostream>
+
+namespace mln
+{
+
+ namespace dt
+ {
+
+ /*! Propagation using a single neighborhood (PSN).
+ *
+ * \param[in] input_ The input image.
+ * \param[in] nbh The chamfer window to use for distance calcul.
+ * \param[in] max Max value of the output image.
+ * \return A distance map.
+ *
+ * \pre \p img has to be initialcped.
+ */
+ template<typename I, typename N>
+ mln_ch_value(I, mln_point(I))
+ raw_cp_fast(const Image<I>& input_, const N& nbh, unsigned max);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ namespace impl
+ {
+ } // end of namespace mln::dt::impl
+
+
+
+ // Facade.
+
+ template<typename I, typename N>
+ inline
+ mln_ch_value(I, mln_point(I))
+ raw_cp_fast(const Image<I>& input_, const N& nbh, unsigned max)
+ {
+ // Preconditions.
+ const I& input = exact(input_);
+ mln_precondition(input.is_valid());
+
+ // Types.
+ typedef mln_point(I) point;
+
+ // Initialcpation of distance.
+ mln_ch_value(I, unsigned) distance;
+ initialize(distance, input);
+
+ // Initialcpation of output.
+ mln_ch_value(I, mln_point(I)) output;
+ initialize(output, input);
+
+ // Mod determination.
+ mln_accu_with_(accu::max, unsigned) accu;
+ mln_fwd_piter(I) p(input.domain());
+ mln_qiter(N) n(nbh, p);
+ for_all(n)
+ accu.take(n.w());
+ unsigned mod = accu.to_result() + 1;
+
+ // Aux data.
+ std::vector< std::vector<point> > bucket(mod);
+ unsigned bucket_size = 0;
+
+ // Initialcpation.
+ {
+ for_all(p)
+ {
+ output(p) = p;
+ if (input(p))
+ {
+ distance(p) = literal::zero;
+ for_all(n)
+ if (input.has(n) && ! input(n))
+ {
+ bucket[0].push_back(p);
+ ++bucket_size;
+ break;
+ }
+ }
+ else
+ distance(p) = max;
+ }
+ }
+
+ // Propagation.
+ {
+ point p;
+ mln_qiter(N) n(nbh, p);
+
+ for (unsigned d = 0; bucket_size != 0; ++d)
+ {
+ std::vector<point>& bucket_d = bucket[d % mod];
+ for (unsigned i = 0; i < bucket_d.size(); ++i)
+ {
+ p = bucket_d[i];
+
+ // FIXME: Draw...
+ if (distance(p) < d)
+ // p has already been processed, having a distance less than d.
+ continue;
+
+ for_all(n)
+ if (distance.has(n) && distance(n) > d)
+ {
+ unsigned newDist = d + n.w();
+
+ if (newDist < distance(n))
+ {
+ output(n) = p;
+ distance(n) = newDist;
+ bucket[newDist % mod].push_back(n);
+ ++bucket_size;
+ }
+ }
+ }
+ bucket_size -= bucket_d.size();
+ bucket_d.clear();
+ }
+
+ } // end of propagation.
+
+ return output;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::dt
+
+} // end of namespace mln
+
+#endif // ! MLN_DT_RAW_CP_FAST_HH
Index: trunk/milena/sandbox/folio/mln/dt/raw_path_slow.hh
===================================================================
--- trunk/milena/sandbox/folio/mln/dt/raw_path_slow.hh (revision 0)
+++ trunk/milena/sandbox/folio/mln/dt/raw_path_slow.hh (revision 3524)
@@ -0,0 +1,155 @@
+// Copyright (C) 2007 EPITA Research and Development unsignedaboratory
+//
+// This file is part of the Olena unsignedibrary. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public unsignedicense 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 unsignedicense for more details.
+//
+// You should have received a copy of the GNU General Public unsignedicense
+// 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
+// unsignedicense. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public unsignedicense.
+
+#ifndef MLN_DT_RAW_PATH_SLOW_HH
+# define MLN_DT_RAW_PATH_SLOW_HH
+
+# include <queue>
+# include <map>
+# include <cmath>
+
+# include <mln/core/concept/image.hh>
+# include <mln/make/w_window.hh>
+# include <mln/core/concept/neighborhood.hh>
+# include <mln/literal/zero.hh>
+
+# include <iostream>
+
+namespace mln
+{
+
+ namespace dt
+ {
+
+ /*! Propagation using a single neighborhood (PSN).
+ *
+ * \param[in] input_ The input image.
+ * \param[in] nbh The chamfer window to use for distance calcul.
+ * \param[in] max Max value of the output image.
+ * \return A distance map.
+ *
+ * \pre \p img has to be initialized.
+ */
+ template<typename I, typename N>
+ mln_ch_value(I, mln_point(I))
+ raw_path_slow(const Image<I>& input_, const N& nbh, unsigned max);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ namespace impl
+ {
+ } // end of namespace mln::dt::impl
+
+
+
+ // Facade.
+
+ template<typename I, typename N>
+ inline
+ mln_ch_value(I, mln_point(I))
+ raw_path_slow(const Image<I>& input_, const N& nbh, unsigned max)
+ {
+ // Preconditions.
+ const I& input = exact(input_);
+ mln_precondition(input.is_valid());
+
+ // Types.
+ typedef mln_point(I) point;
+
+ // Initialization of distance.
+ mln_ch_value(I, unsigned) distance;
+ initialize(distance, input);
+
+ // Initialization of output.
+ mln_ch_value(I, mln_point(I)) output;
+ initialize(output, input);
+
+ // Initialization.
+ // {
+
+ std::map< unsigned, std::queue<point> > bucket;
+ unsigned bucket_size = 0;
+
+ mln_fwd_piter(I) p(input.domain());
+ for_all(p)
+ {
+ output(p) = p;
+ if (input(p))
+ {
+ distance(p) = literal::zero;
+ bucket[0].push(p);
+ ++bucket_size;
+ }
+ else
+ distance(p) = max;
+ }
+
+ // }
+
+ for (unsigned d = 0; bucket_size != 0; ++d)
+ {
+ std::queue<point> bucket_d = bucket[d];
+ while (! bucket_d.empty())
+ {
+ point p = bucket_d.front();
+ bucket_d.pop();
+ --bucket_size;
+
+ if (distance(p) == d)
+ {
+ mln_qiter(N) n(nbh, p);
+
+ for_all(n)
+ if (distance.has(n))
+ {
+ unsigned newDist = d + n.w();
+
+ if (newDist < distance(n))
+ {
+ distance(n) = newDist;
+ output(n) = output(p);
+ bucket[newDist].push(n);
+ ++bucket_size;
+ }
+ }
+ }
+ }
+ bucket.erase(d);
+ }
+
+ return output;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::dt
+
+} // end of namespace mln
+
+#endif // ! MLN_DT_RAW_PATH_SLOW_HH
Index: trunk/milena/sandbox/folio/mln/dt/path.hh
===================================================================
--- trunk/milena/sandbox/folio/mln/dt/path.hh (revision 0)
+++ trunk/milena/sandbox/folio/mln/dt/path.hh (revision 3524)
@@ -0,0 +1,121 @@
+// Copyright (C) 2007 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_DT_PATH_HH
+# define MLN_DT_PATH_HH
+
+# include "canvas_dt.hh"
+
+namespace mln
+{
+
+ namespace dt
+ {
+
+ /*! Propagation using a single neighborhood (PSN).
+ *
+ * \param[in] input_ The input image.
+ * \param[in] nbh The chamfer window to use for distance calcul.
+ * \param[in] max Max value of the output image.
+ * \return A distance map.
+ *
+ * \pre \p img has to be initialized.
+ */
+ template<typename I, typename N>
+ mln_ch_value(I, mln_point(I))
+ path(const Image<I>& input_, const N& nbh, unsigned max);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace impl
+ {
+
+ // Generic functor.
+
+ template <typename I_, typename N_>
+ struct path_functor
+ {
+ typedef I_ I;
+ typedef N_ N;
+
+ const I& input;
+ const N& nbh;
+ unsigned max;
+
+ path_functor(const I& input, const N& nbh, unsigned max)
+ : input(input),
+ nbh(nbh),
+ max(max)
+ {}
+
+ mln_ch_value(I, mln_point(I)) output;
+
+ void init()
+ {
+ initialize(output, input);
+ }
+
+ void init_in_for(const mln_point(I)& p)
+ {
+ output(p) = p;
+ }
+
+ void run_in_for(const mln_point(I)& p, const mln_point(I)& n)
+ {
+ output(n) = output(p);
+ }
+ };
+
+ } // end of namespace mln::dt::impl
+
+
+ // Facade.
+
+ template<typename I, typename N>
+ inline
+ mln_ch_value(I, mln_point(I))
+ path(const Image<I>& input, const N& nbh, unsigned max)
+ {
+ trace::entering("dt::path");
+ mln_precondition(exact(input).is_valid());
+
+ typedef impl::path_functor<I, N> F;
+ F f(exact(input), nbh, max);
+ mln::canvas::dt<F> call(f);
+
+ trace::exiting("dt::path");
+ return f.output;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::dt
+
+} // end of namespace mln
+
+#endif // ! MLN_DT_PATH_HH
Index: trunk/milena/sandbox/folio/mln/dt/raw_dmap_slow.hh
===================================================================
--- trunk/milena/sandbox/folio/mln/dt/raw_dmap_slow.hh (revision 0)
+++ trunk/milena/sandbox/folio/mln/dt/raw_dmap_slow.hh (revision 3524)
@@ -0,0 +1,149 @@
+// Copyright (C) 2007 EPITA Research and Development unsignedaboratory
+//
+// This file is part of the Olena unsignedibrary. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public unsignedicense 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 unsignedicense for more details.
+//
+// You should have received a copy of the GNU General Public unsignedicense
+// 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
+// unsignedicense. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public unsignedicense.
+
+#ifndef MLN_DT_RAW_DMAP_SLOW_HH
+# define MLN_DT_RAW_DMAP_SLOW_HH
+
+# include <queue>
+# include <map>
+# include <cmath>
+
+# include <mln/core/concept/image.hh>
+# include <mln/make/w_window.hh>
+# include <mln/core/concept/neighborhood.hh>
+# include <mln/literal/zero.hh>
+
+# include <iostream>
+
+namespace mln
+{
+
+ namespace dt
+ {
+
+ /*! Propagation using a single neighborhood (PSN).
+ *
+ * \param[in] input_ The input image.
+ * \param[in] nbh The chamfer window to use for distance calcul.
+ * \param[in] max Max value of the output image.
+ * \return A distance map.
+ *
+ * \pre \p img has to be initialized.
+ */
+ template<typename I, typename N>
+ mln_ch_value(I, unsigned)
+ raw_dmap_slow(const Image<I>& input_, const N& nbh, unsigned max);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ namespace impl
+ {
+ } // end of namespace mln::dt::impl
+
+
+
+ // Facade.
+
+ template<typename I, typename N>
+ inline
+ mln_ch_value(I, unsigned)
+ raw_dmap_slow(const Image<I>& input_, const N& nbh, unsigned max)
+ {
+ // Preconditions.
+ const I& input = exact(input_);
+ mln_precondition(input.is_valid());
+
+ // Types.
+ typedef mln_point(I) point;
+
+ // Initialization of distance.
+ mln_ch_value(I, unsigned) distance;
+ initialize(distance, input);
+
+ // Initialization.
+ // {
+
+ std::map< unsigned, std::queue<point> > bucket;
+ unsigned bucket_size = 0;
+
+ mln_fwd_piter(I) p(input.domain());
+ for_all(p)
+ {
+ if (input(p))
+ {
+ distance(p) = literal::zero;
+ bucket[0].push(p);
+ ++bucket_size;
+ }
+ else
+ distance(p) = max;
+ }
+
+ // }
+
+ for (unsigned d = 0; bucket_size != 0; ++d)
+ {
+ std::queue<point> bucket_d = bucket[d];
+ while (! bucket_d.empty())
+ {
+ point p = bucket_d.front();
+ bucket_d.pop();
+ --bucket_size;
+
+ if (distance(p) == d)
+ {
+ mln_qiter(N) n(nbh, p);
+
+ for_all(n)
+ if (distance.has(n))
+ {
+ unsigned newDist = d + n.w();
+
+ if (newDist < distance(n))
+ {
+ distance(n) = newDist;
+ bucket[newDist].push(n);
+ ++bucket_size;
+ }
+ }
+ }
+ }
+ bucket.erase(d);
+ }
+
+ return distance;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::dt
+
+} // end of namespace mln
+
+#endif // ! MLN_DT_RAW_DMAP_SLOW_HH
Index: trunk/milena/sandbox/folio/mln/dt/raw_cp_slow.hh
===================================================================
--- trunk/milena/sandbox/folio/mln/dt/raw_cp_slow.hh (revision 0)
+++ trunk/milena/sandbox/folio/mln/dt/raw_cp_slow.hh (revision 3524)
@@ -0,0 +1,155 @@
+// Copyright (C) 2007 EPITA Research and Development unsignedaboratory
+//
+// This file is part of the Olena unsignedibrary. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public unsignedicense 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 unsignedicense for more details.
+//
+// You should have received a copy of the GNU General Public unsignedicense
+// 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
+// unsignedicense. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public unsignedicense.
+
+#ifndef MLN_DT_RAW_CP_SLOW_HH
+# define MLN_DT_RAW_CP_SLOW_HH
+
+# include <queue>
+# include <map>
+# include <cmath>
+
+# include <mln/core/concept/image.hh>
+# include <mln/make/w_window.hh>
+# include <mln/core/concept/neighborhood.hh>
+# include <mln/literal/zero.hh>
+
+# include <iostream>
+
+namespace mln
+{
+
+ namespace dt
+ {
+
+ /*! Propagation using a single neighborhood (PSN).
+ *
+ * \param[in] input_ The input image.
+ * \param[in] nbh The chamfer window to use for distance calcul.
+ * \param[in] max Max value of the output image.
+ * \return A distance map.
+ *
+ * \pre \p img has to be initialcped.
+ */
+ template<typename I, typename N>
+ mln_ch_value(I, mln_point(I))
+ raw_cp_slow(const Image<I>& input_, const N& nbh, unsigned max);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ namespace impl
+ {
+ } // end of namespace mln::dt::impl
+
+
+
+ // Facade.
+
+ template<typename I, typename N>
+ inline
+ mln_ch_value(I, mln_point(I))
+ raw_cp_slow(const Image<I>& input_, const N& nbh, unsigned max)
+ {
+ // Preconditions.
+ const I& input = exact(input_);
+ mln_precondition(input.is_valid());
+
+ // Types.
+ typedef mln_point(I) point;
+
+ // Initialcpation of distance.
+ mln_ch_value(I, unsigned) distance;
+ initialize(distance, input);
+
+ // Initialcpation of output.
+ mln_ch_value(I, mln_point(I)) output;
+ initialize(output, input);
+
+ // Initialcpation.
+ // {
+
+ std::map< unsigned, std::queue<point> > bucket;
+ unsigned bucket_size = 0;
+
+ mln_fwd_piter(I) p(input.domain());
+ for_all(p)
+ {
+ output(p) = p;
+ if (input(p))
+ {
+ distance(p) = literal::zero;
+ bucket[0].push(p);
+ ++bucket_size;
+ }
+ else
+ distance(p) = max;
+ }
+
+ // }
+
+ for (unsigned d = 0; bucket_size != 0; ++d)
+ {
+ std::queue<point> bucket_d = bucket[d];
+ while (! bucket_d.empty())
+ {
+ point p = bucket_d.front();
+ bucket_d.pop();
+ --bucket_size;
+
+ if (distance(p) == d)
+ {
+ mln_qiter(N) n(nbh, p);
+
+ for_all(n)
+ if (distance.has(n))
+ {
+ unsigned newDist = d + n.w();
+
+ if (newDist < distance(n))
+ {
+ distance(n) = newDist;
+ output(n) = p;
+ bucket[newDist].push(n);
+ ++bucket_size;
+ }
+ }
+ }
+ }
+ bucket.erase(d);
+ }
+
+ return output;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::dt
+
+} // end of namespace mln
+
+#endif // ! MLN_DT_RAW_CP_SLOW_HH
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add an identity site iterator adaptor.
* mln/core/internal/piter_identity.hh: New.
* mln/core/internal/site_iterator_base.hh (todo): Remove; done.
* mln/core/internal/site_set_iterator_base.hh (pset): New.
Upgrade file doc style.
piter_identity.hh | 88 ++++++++++++++++++++++++++++++++++++++++++++++
site_iterator_base.hh | 8 +---
site_set_iterator_base.hh | 29 ++++++++-------
3 files changed, 106 insertions(+), 19 deletions(-)
Index: mln/core/internal/piter_identity.hh
--- mln/core/internal/piter_identity.hh (revision 0)
+++ mln/core/internal/piter_identity.hh (revision 0)
@@ -0,0 +1,88 @@
+// Copyright (C) 2009 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.
+
+#ifndef MLN_CORE_INTERNAL_PITER_IDENTITY_HH
+# define MLN_CORE_INTERNAL_PITER_IDENTITY_HH
+
+/// \file mln/core/internal/piter_identity.hh
+///
+/// \brief Definition of site iterator identity adaptors.
+
+# include <mln/core/internal/piter_adaptor.hh>
+
+
+namespace mln
+{
+
+ namespace internal
+ {
+
+ /// A base class for site iterator identity adaptors.
+ ///
+ /// Parameter \c Pi is the type of the site iterator adaptee;
+ /// parameter E is the exact type.
+ ///
+ template <typename Pi, typename E>
+ class piter_identity_ : public piter_adaptor_< Pi, // Adaptee.
+ mln_pset(Pi), // Site set.
+ E > // Exact type.
+ {
+ typedef piter_adaptor_< Pi, mln_pset(Pi), E > super_;
+
+ protected:
+
+ /// Constructor without argument.
+ piter_identity_();
+
+ /// Constructor from a point iterator \p piter.
+ piter_identity_(const Pi& piter);
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename Pi, typename E>
+ inline
+ piter_identity_<Pi,E>::piter_identity_()
+ {
+ }
+
+ template <typename Pi, typename E>
+ inline
+ piter_identity_<Pi,E>::piter_identity_(const Pi& pi)
+ : super_(pi)
+ {
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::internal
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_INTERNAL_PITER_IDENTITY_HH
Index: mln/core/internal/site_iterator_base.hh
--- mln/core/internal/site_iterator_base.hh (revision 3521)
+++ mln/core/internal/site_iterator_base.hh (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2008, 2009 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
@@ -31,17 +32,12 @@
/// \file mln/core/internal/site_iterator_base.hh
///
/// Base class to factor code for site iterator classes.
-///
-/// \todo Import tech doc from home.
# include <mln/core/concept/site_iterator.hh>
# include <mln/core/concept/pseudo_site.hh> // Use of if_possible::change_target.
-// FIXME: See todo.
-
-
namespace mln
{
Index: mln/core/internal/site_set_iterator_base.hh
--- mln/core/internal/site_set_iterator_base.hh (revision 3521)
+++ mln/core/internal/site_set_iterator_base.hh (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2008, 2009 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
@@ -28,11 +29,10 @@
#ifndef MLN_CORE_INTERNAL_SITE_SET_ITERATOR_BASE_HH
# define MLN_CORE_INTERNAL_SITE_SET_ITERATOR_BASE_HH
-/*! \file mln/core/internal/site_set_iterator_base.hh
- *
- * \brief Base class to factor code for iterator classes directly
- * working on site sets.
- */
+/// \file mln/core/internal/site_set_iterator_base.hh
+///
+/// \brief Base class to factor code for iterator classes directly
+/// working on site sets.
# include <mln/core/internal/site_iterator_base.hh>
@@ -43,18 +43,21 @@
namespace internal
{
- /*! A base class for site iterators.
- *
- * Parameter \c S is the targeted site set type.
- *
- * IMPORTANT: Sub-classes have to define start_, next_,
- * is_valid_ and invalidate_.
- */
+ /// A base class for iterators on site sets.
+ ///
+ /// Parameter \c S is the targeted site set type.
+ ///
+ /// IMPORTANT: Sub-classes have to define start_, next_,
+ /// is_valid_ and invalidate_.
+ //
template <typename S, typename E>
class site_set_iterator_base : public site_iterator_base<S, E>
{
public:
+ /// The associated site set type.
+ typedef S pset;
+
/// Give the site set that this iterator browses.
const S& site_set() const;
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
ChangeLog:
2009-03-12 Edwin Carlinet <carlinet(a)lrde.epita.fr>
Clean and fix bugs on component trees propagation.
* edwin/tree/accumulator/max.hh: Special max accumulator for iterator.
* edwin/tree/accumulator: New.
* edwin/tree/propagate.hh,
* edwin/tree/propagate_leaf.hh,
* edwin/tree/propagate_node.hh,
* edwin/tree/propagate_value.hh: Improve propagation methods
and make them cleaner.
* edwin/tree/propagation.cc: Test file.
* edwin/tree/routines.hh: Add methods for tree traversal.
---
Makefile | 7 -
accumulator/max.hh | 154 ++++++++++++++++++++++++++++++++
propagate.hh | 7 +
propagate_leaf.hh | 63 +++++++++++++
propagate_node.hh | 253 +++++++++++++++++++++++++++++++++++++++++++++++++++++
propagate_value.hh | 231 ++++++++++++++++++++++++++++++++++++++++++++++++
propagation.cc | 118 ++++++++++++++++++++++++
routines.hh | 19 +++
8 files changed, 847 insertions(+), 5 deletions(-)
Index: trunk/milena/sandbox/edwin/tree/accumulator/max.hh
===================================================================
--- trunk/milena/sandbox/edwin/tree/accumulator/max.hh (revision 0)
+++ trunk/milena/sandbox/edwin/tree/accumulator/max.hh (revision 3518)
@@ -0,0 +1,154 @@
+// Copyright (C) 2007, 2008, 2009 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.
+
+#ifndef MLN_MORPHO_TREE_ACCUMULATOR_MAX_HH_
+# define MLN_MORPHO_TREE_ACCUMULATOR_MAX_HH_
+
+/// \file mln/morpho/tree/accumulator/max.hh
+///
+/// Define an accumulator that returns iterator matching the max node value.
+
+
+# include <mln/core/concept/image.hh>
+# include <mln/accu/internal/base.hh>
+
+namespace mln {
+ namespace morpho {
+ namespace tree{
+ namespace accumulator {
+
+ template <typename T, typename I>
+ class max : public mln::accu::internal::base< mln_bkd_piter(T::nodes_t), max<T, I> >
+ {
+ typedef mln::accu::internal::base< unsigned, max<T, I> > super_;
+
+ public:
+ typedef mln_bkd_piter(T::nodes_t) argument;
+
+ /// Constructor
+ max(const Image<I>& f);
+
+ /// Manipulators.
+ /// \{
+ void init();
+
+ void take(const argument& it);
+ void take(const max<T, I>& other);
+
+ void take_as_init(const argument& it);
+ /// \}
+
+ /// Get the value of the accumulator.
+ mln_bkd_piter(T::nodes_t) to_result() const;
+
+ /// Check whether the accumulator is able to give a result.
+ bool is_valid() const;
+
+ private:
+ const I& f_;
+ mln_bkd_piter(T::nodes_t) max_;
+ };
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename T, typename I>
+ inline
+ max<T, I>::max(const Image<I>& f) :
+ f_ (exact(f))
+ {
+ }
+
+ template <typename T, typename I>
+ inline
+ void
+ max<T, I>::init()
+ {
+ }
+
+ template <typename T, typename I>
+ inline
+ void
+ max<T, I>::take(const argument& it)
+ {
+ mln_invariant(it.is_valid());
+
+ if (!is_valid())
+ {
+ take_as_init(it);
+ return;
+ }
+
+ if (f_(it) > f_(max_))
+ max_ = it;
+ }
+
+ template <typename T, typename I>
+ inline
+ void
+ max<T, I>::take(const max<T, I>& other)
+ {
+ mln_invariant(other.is_valid());
+
+ if (f_(other.max_) > f_(max_))
+ max_ = other.max_;
+ }
+
+ template <typename T, typename I>
+ inline
+ void
+ max<T, I>::take_as_init(const argument& it)
+ {
+ mln_invariant(it.is_valid());
+ max_ = it;
+ }
+
+ template <typename T, typename I>
+ inline
+ mln_bkd_piter(T::nodes_t)
+ max<T, I>::to_result() const
+ {
+ return max_;
+ }
+
+ template <typename T, typename I>
+ inline
+ bool
+ max<T, I>::is_valid() const
+ {
+ return max_.is_valid();
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::morpho::tree::accumulator
+ } // end of namespace mln::morpho::tree
+ } // end of namespace mln::morpho
+} // end of namespace mln
+
+#endif /* ! MLN_MORPHO_TREE_ACCUMULATOR_MAX_HH_ */
Index: trunk/milena/sandbox/edwin/tree/propagate.hh
===================================================================
--- trunk/milena/sandbox/edwin/tree/propagate.hh (revision 3517)
+++ trunk/milena/sandbox/edwin/tree/propagate.hh (revision 3518)
@@ -1,4 +1,4 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2008, 2009 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
@@ -55,8 +55,11 @@
}
}
- namespace binary {
+
+
+
+ /// Dans le cas des images binaires...
/// Propagate a tagged node's value to its subbranches.
template <typename T, typename A>
void
Index: trunk/milena/sandbox/edwin/tree/propagate_node.hh
===================================================================
--- trunk/milena/sandbox/edwin/tree/propagate_node.hh (revision 0)
+++ trunk/milena/sandbox/edwin/tree/propagate_node.hh (revision 3518)
@@ -0,0 +1,253 @@
+// Copyright (C) 2007, 2008, 2009 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.
+
+#ifndef MLN_MORPHO_TREE_PROPAGATE_NODE_HH_
+# define MLN_MORPHO_TREE_PROPAGATE_NODE_HH_
+
+#include <mln/morpho/tree/data.hh>
+#include <mln/core/site_set/p_array.hh>
+
+/// \file mln/morpho/tree/propagate_node.hh
+///
+/// Functions to propagate node in the tree.
+
+namespace mln {
+ namespace morpho {
+ namespace tree {
+
+
+ /**
+ ** Propagate a value to a node and its descendants.
+ **
+ ** @param n Forward iterator related to the node.
+ ** @param t Reference to components tree.
+ ** @param a_ Reference to image.
+ ** @param v Value to propagate. Default is a_(n).
+ */
+ template <typename T, typename A>
+ void
+ propagate_node_to_descendants(mln_bkd_piter(T::nodes_t)& n,
+ const T& t,
+ Image<A>& a_,
+ mln_value(A) v);
+
+ /**
+ ** Propagate the value of a node to its descendants.
+ **
+ ** @param n Forward iterator related to the node.
+ ** @param t Reference to components tree.
+ ** @param a_ Reference to image.
+ */
+ template <typename T, typename A>
+ void
+ propagate_node_to_descendants(mln_bkd_piter(T::nodes_t)& n,
+ const T& t,
+ Image<A>& a_);
+
+
+ /**
+ ** Propagate a value to a node and its descendants.
+ **
+ ** @param n The root of subtree which value propagates in.
+ ** @param t The reference to components tree.
+ ** @param a_ The reference to image.
+ ** @param v The value to propagate. Default is a_(n).
+ */
+ template <typename T, typename A>
+ void
+ propagate_node_to_descendants(mln_psite(A) n,
+ const T& t,
+ Image<A>& a_,
+ mln_value(A) v);
+
+ /**
+ ** Propagate the node's value to its descendants.
+ **
+ ** @param n The root of subtree which value propagates in.
+ ** @param t The reference to components tree.
+ ** @param a_ The reference to image.
+ */
+ template <typename T, typename A>
+ void
+ propagate_node_to_descendants(mln_psite(A)& n,
+ const T& t,
+ Image<A>& a_);
+
+ /**
+ ** Propagate a value from a node to its ancestors.
+ **
+ ** @param n Forward iterator related to the node.
+ ** @param t Reference to components tree.
+ ** @param a_ Reference to image.
+ ** @param v Value to propagate.
+ */
+ template <typename T, typename A>
+ void
+ propagate_node_to_ancestors(mln_psite(A) n,
+ const T& t,
+ Image<A>& a_,
+ mln_value(A) v);
+
+ /**
+ ** Propagate the node's value to its ancestors.
+ **
+ ** @param n Forward iterator related to the node.
+ ** @param t Reference to components tree.
+ ** @param a_ Reference to image.
+ */
+ template <typename T, typename A>
+ void
+ propagate_node_to_ancestors(mln_psite(A) n,
+ const T& t,
+ Image<A>& a_);
+
+
+
+
+
+
+ /* Descendants propagation */
+
+ template <typename T, typename A>
+ void
+ propagate_node_to_descendants(mln_bkd_piter(T::nodes_t)& n,
+ const T& t,
+ Image<A>& a_,
+ mln_value(A) v)
+ {
+ A& a = exact(a_);
+ mln_precondition(a.is_valid());
+ mln_precondition(a.domain() == t.f().domain());
+ mln_precondition(n.is_valid());
+ mln_precondition(t.is_a_node(n));
+
+ mln_ch_value(A, bool) ancestors;
+ initialize(ancestors, a);
+ data::fill(ancestors, false);
+ ancestors(n) = true;
+
+ mln_bkd_piter(T::nodes_t) it(n);
+ for (it.next(); it.is_valid(); it.next())
+ {
+ if (ancestors(t.parent(it)))
+ {
+ ancestors(it) = true;
+ a(it) = v;
+ }
+ }
+ }
+
+ template <typename T, typename A>
+ inline
+ void
+ propagate_node_to_descendants(mln_bkd_piter(T::nodes_t)& n,
+ const T& t,
+ Image<A>& a_)
+ {
+ A& a = exact(a_);
+ propagate_node_to_descendants(n, t, a, a(n));
+ }
+
+ template <typename T, typename A>
+ void
+ propagate_node_to_descendants(mln_psite(A) n,
+ const T& t,
+ Image<A>& a_,
+ mln_value(A) v)
+ {
+ A& a = exact(a_);
+ mln_precondition(a.is_valid());
+ mln_precondition(a.domain() == t.f().domain());
+ mln_precondition(a.domain().has(n));
+
+
+ if (!t.is_a_node(n)) // Get the representant.
+ n = t.parent(n);
+
+ mln_bkd_piter(T::nodes_t) it = find_bkd(t.nodes(), n);
+ propagate_node_to_descendants(it, t, a, v);
+ }
+
+ template <typename T, typename A>
+ inline
+ void
+ propagate_node_to_descendants(mln_psite(A) n,
+ const T& t,
+ Image<A>& a_)
+
+ {
+ A& a = exact(a_);
+ propagate_node_to_descendants(n, t, a, a(n));
+ }
+
+
+ /* Ancestors propagation */
+
+ template <typename T, typename A>
+ void
+ propagate_node_to_ancestors(mln_psite(A) n,
+ const T& t,
+ Image<A>& a_,
+ mln_value(A) v)
+ {
+ A& a = exact(a_);
+ mln_precondition(a.is_valid());
+ mln_precondition(a.domain() == t.f().domain());
+ mln_precondition(a.domain().has(n));
+
+ if (!t.is_a_node(n))
+ n = t.parent(n);
+ mln_assertion(t.is_a_node(n));
+
+ if (t.is_root(n))
+ return;
+
+ do {
+ n = t.parent(n);
+ a(n) = v;
+ } while (!t.is_root(n));
+
+ }
+
+ template <typename T, typename A>
+ inline
+ void
+ propagate_node_to_ancestors(mln_psite(A) n,
+ const T& t,
+ Image<A>& a_)
+ {
+ A& a = exact(a_);
+ propagate_node_to_ancestors(n, t, a, a(n));
+ }
+
+
+ } // end of namespace mln::morpho::tree
+ } // end of namespace mln::morpho
+} // end of namespace mln
+
+#endif /* !MLN_MORPHO_TREE_PROPAGATE_NODE_HH_ */
Index: trunk/milena/sandbox/edwin/tree/routines.hh
===================================================================
--- trunk/milena/sandbox/edwin/tree/routines.hh (revision 3517)
+++ trunk/milena/sandbox/edwin/tree/routines.hh (revision 3518)
@@ -37,6 +37,22 @@
namespace morpho {
namespace tree {
+
+ template <typename T,
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// FIXME: it bugs; need a stack/queue
template <typename I, typename T>
util::array< mln_psite(I) >
@@ -65,6 +81,9 @@
return fnodes;
}
+ template <typename T,
+
+
}
}
}
Index: trunk/milena/sandbox/edwin/tree/propagate_leaf.hh
===================================================================
--- trunk/milena/sandbox/edwin/tree/propagate_leaf.hh (revision 0)
+++ trunk/milena/sandbox/edwin/tree/propagate_leaf.hh (revision 3518)
@@ -0,0 +1,63 @@
+// Copyright (C) 2007, 2008, 2009 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.
+
+#ifndef MLN_MORPHO_TREE_PROPAGATE_LEAF_HH_
+# define MLN_MORPHO_TREE_PROPAGATE_LEAF_HH_
+
+
+/// \file mln/morpho/tree/propagate_leaf.hh
+///
+/// Functions to propagate the leaf value in the tree.
+
+namespace mln {
+ namespace morpho {
+ namespace tree {
+
+ template <typename T, typename A>
+ void
+ propagate_leaf_to_ancestors(mln_value(A) v,
+ const T& t,
+ Image<A>& a_)
+ {
+ A& a = exact(a_);
+
+ mln_fwd_piter(T::leaves_t) l(t.leaves());
+ for_all(l)
+ a(t.parent(l)) = 0;
+
+ mln_fwd_piter(T::nodes_t) n(t.nodes());
+ for_all(n)
+ {
+ mln_assertion(t.is_a_node(t.parent(n)));
+ a(t.parent(n)) = a(t.parent(n)) || a(n);
+ }
+ }
+ } // end of namespace mln::morpho::tree
+ } // end of namespace mln::morpho
+} // end of namespace mln
+#endif /* !MLN_MORPHO_TREE_PROPAGATE_LEAF_HH_ */
Index: trunk/milena/sandbox/edwin/tree/propagation.cc
===================================================================
--- trunk/milena/sandbox/edwin/tree/propagation.cc (revision 0)
+++ trunk/milena/sandbox/edwin/tree/propagation.cc (revision 3518)
@@ -0,0 +1,118 @@
+#include <iostream>
+
+#include <mln/core/image/image2d.hh>
+#include <mln/core/alias/neighb2d.hh>
+#include <mln/core/alias/point2d.hh>
+#include <mln/core/routine/duplicate.hh>
+
+#include <mln/value/int_u8.hh>
+#include <mln/io/pgm/load.hh>
+
+
+#include <mln/level/sort_psites.hh>
+#include <mln/morpho/tree/data.hh>
+
+
+#include <../../theo/color/change_attributes.hh>
+#include "propagate_node.hh"
+#include "propagate_value.hh"
+#include "run.hh"
+#include "accumulator/max.hh"
+
+void usage(char** argv)
+{
+ std::cerr << "usage: " << argv[0] << " input" << std::endl;
+ abort();
+}
+
+void dsp(const char* str)
+{
+ std::cout << "*********************" << std::endl
+ << "** " << str << std::endl
+ << "*********************" << std::endl;
+}
+
+int main(int argc, char* argv[])
+{
+ using namespace mln;
+ using value::int_u8;
+
+ if (argc < 2)
+ usage(argv);
+
+
+ typedef image2d<int_u8> I;
+ I input, dup;
+
+
+ io::pgm::load(input, argv[1]);
+
+
+ typedef p_array< mln_site_(I) > S;
+ typedef morpho::tree::data<I,S> tree_t;
+ S sorted_sites = level::sort_psites_decreasing(input);
+ tree_t tree(input, sorted_sites, c4());
+
+ dsp("Input:");
+ display_tree_attributes(tree, input);
+
+ dup = duplicate(input);
+ morpho::tree::propagate_node_to_ancestors(point2d(1, 4), tree, dup, 0);
+ dsp("Propagate node to ancestors : (point2d(1, 4), tree, dup, 0)");
+ display_tree_attributes(tree, dup);
+
+ dup = duplicate(input);
+ morpho::tree::propagate_node_to_ancestors(point2d(1, 4), tree, dup);
+ dsp("Propagate node to ancestors : (point2d(1, 4), tree, dup)");
+ display_tree_attributes(tree, dup);
+
+ dup = duplicate(input);
+ morpho::tree::propagate_node_to_descendants(point2d(0, 2), tree, dup, 0);
+ dsp("Propagate node to descendants : (point2d(0, 2), tree, dup, 0)");
+ display_tree_attributes(tree, dup);
+
+ dup = duplicate(input);
+ morpho::tree::propagate_node_to_descendants(point2d(0, 2), tree, dup);
+ dsp("Propagate node to descendants : (point2d(0, 2), tree, dup)");
+ display_tree_attributes(tree, dup);
+
+ dup = duplicate(input);
+ morpho::tree::propagate_value_to_ancestors(117, tree, dup, 0);
+ dsp("Propagate value to ancestors : (117, tree, dup, 0)");
+ display_tree_attributes(tree, dup);
+
+ dup = duplicate(input);
+ morpho::tree::propagate_value_to_ancestors(117, tree, dup);
+ dsp("Propagate value to ancestors : (117, tree, dup)");
+ display_tree_attributes(tree, dup);
+
+ dup = duplicate(input);
+ morpho::tree::propagate_value_to_descendants(117, tree, dup, 0);
+ dsp("Propagate value to descendants : (117, tree, dup, 0)");
+ display_tree_attributes(tree, dup);
+
+ dup = duplicate(input);
+ morpho::tree::propagate_value_to_descendants(117, tree, dup);
+ dsp("Propagate value to descendants : (117, tree, dup)");
+ display_tree_attributes(tree, dup);
+
+
+
+ dup = duplicate(input);
+
+ typedef morpho::tree::accumulator::max<tree_t, I> A;
+ A accu(dup);
+ morpho::tree::run_bkd(tree, accu);
+
+ mln_bkd_piter_(tree_t::nodes_t) it_max = accu.to_result();
+ morpho::tree::propagate_node_to_descendants(it_max, tree, dup, 69);
+ dsp("Propagate value to descendants : (it_max, tree, dup, 69)");
+ display_tree_attributes(tree, dup);
+
+
+
+
+}
+
+
+
Index: trunk/milena/sandbox/edwin/tree/propagate_value.hh
===================================================================
--- trunk/milena/sandbox/edwin/tree/propagate_value.hh (revision 0)
+++ trunk/milena/sandbox/edwin/tree/propagate_value.hh (revision 3518)
@@ -0,0 +1,231 @@
+// Copyright (C) 2007, 2008, 2009 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.
+
+#ifndef MLN_MORPHO_TREE_PROPAGATE_VALUE_HH_
+# define MLN_MORPHO_TREE_PROPAGATE_VALUE_HH_
+
+
+/// \file mln/morpho/tree/propagate_value.hh
+///
+/// Functions to propagate a value in the tree.
+
+namespace mln {
+ namespace morpho {
+ namespace tree {
+
+ /**
+ ** Propagate the value \p v2 from node \p n having the value \p v
+ ** to its ancestors.
+ **
+ ** @param v Value that node must have to be propagated.
+ ** @param t Reference to components tree.
+ ** @param a_ Reference to image.
+ ** @param v2 Value to propagate (\p v by default).
+ */
+ template <typename T, typename A>
+ void
+ propagate_value_to_ancestors(mln_value(A) v,
+ const T& t,
+ Image<A>& a_,
+ mln_value(A) v2);
+
+ /**
+ ** Propagate the value \p v2 from node \p n having the value \p v
+ ** to its descendants.
+ **
+ ** @param v Value that node must have to be propagated.
+ ** @param t Reference to components tree.
+ ** @param a_ Reference to image.
+ ** @param v2 Value to propagate (\p v by default).
+ */
+ template <typename T, typename A>
+ void
+ propagate_value_to_descendants(mln_value(A) v,
+ const T& t,
+ Image<A>& a_,
+ mln_value(A) v2);
+
+
+
+
+
+
+
+
+
+ namespace internal
+ {
+ template <typename T, typename A>
+ bool check_propagate_ancestors(const T& t, const A& a, mln_value(A) v)
+ {
+ mln_fwd_piter(T::nodes_t) n(t.nodes());
+ for_all(n)
+ if (a(n) == v && a(t.parent(n)) != v)
+ return false;
+ return true;
+ }
+
+ template <typename T, typename A>
+ bool check_propagate_descendants(const T& t, const A& a, mln_value(A) v)
+ {
+ mln_fwd_piter(T::nodes_t) n(t.nodes());
+ for_all(n)
+ if (a(n) != v && a(t.parent(n)) == v)
+ return false;
+ return true;
+ }
+
+ } // end of namespace mln::morpho::tree::internal
+
+ template <typename T, typename A>
+ void
+ propagate_value_to_ancestors(mln_value(A) v,
+ const T& t,
+ Image<A>& a_,
+ mln_value(A) v2)
+ {
+ if (v == v2)
+ {
+ propagate_value_to_ancestors(v, t, a_);
+ return;
+ }
+
+ A& a = exact(a_);
+ mln_precondition(a.is_valid());
+ mln_precondition(a.domain() == t.f().domain());
+
+ mln_ch_value(A, bool) deja_vu;
+ initialize(deja_vu, a);
+ data::fill(deja_vu, false);
+
+ mln_fwd_piter(T::nodes_t) n(t.nodes());
+ for_all(n)
+ {
+ if (a(n) == v || deja_vu(n))
+ {
+ mln_assertion(t.is_a_node(t.parent(n)));
+ a(t.parent(n)) = v2;
+ deja_vu(t.parent(n)) = true;
+ }
+ }
+
+ mln_postcondition(internal::check_propagate_ancestors(t, a, v2));
+ }
+
+
+ template <typename T, typename A>
+ void
+ propagate_value_to_ancestors(mln_value(A) v,
+ const T& t,
+ Image<A>& a_)
+ {
+ A& a = exact(a_);
+ mln_precondition(a.is_valid());
+ mln_precondition(a.domain() == t.f().domain());
+
+ mln_fwd_piter(T::nodes_t) n(t.nodes());
+ for_all(n)
+ {
+ if (a(n) == v)
+ {
+ mln_assertion(t.is_a_node(t.parent(n)));
+ a(t.parent(n)) = v;
+ }
+ }
+
+ mln_postcondition(internal::check_propagate_ancestors(t, a, v));
+ }
+
+
+ template <typename T, typename A>
+ void
+ propagate_value_to_descendants(mln_value(A) v,
+ const T& t,
+ Image<A>& a_,
+ mln_value(A) v2)
+ {
+ if (v == v2)
+ {
+ propagate_value_to_descendants(v, t, a_);
+ return;
+ }
+
+ A& a = exact(a_);
+ mln_precondition(a.is_valid());
+ mln_precondition(a.domain() == t.f().domain());
+
+ mln_ch_value(A, bool) deja_vu;
+ initialize(deja_vu, a);
+ data::fill(deja_vu, false);
+
+ mln_bkd_piter(T::nodes_t) n(t.nodes());
+ for_all(n)
+ {
+ if (a(n) == v)
+ {
+ mln_assertion(t.is_a_node(t.parent(n)));
+ deja_vu(n) = true;
+ }
+ else if (deja_vu(t.parent(n)))
+ {
+ mln_assertion(t.is_a_node(t.parent(n)));
+ a(n) = v2;
+ deja_vu(n) = true;
+ }
+ }
+ mln_postcondition(internal::check_propagate_descendants(t, a, v2));
+ }
+
+ template <typename T, typename A>
+ void
+ propagate_value_to_descendants(mln_value(A) v,
+ const T& t,
+ Image<A>& a_)
+ {
+ A& a = exact(a_);
+ mln_precondition(a.is_valid());
+ mln_precondition(a.domain() == t.f().domain());
+
+ mln_bkd_piter(T::nodes_t) n(t.nodes());
+ for_all(n)
+ {
+ if (a(t.parent(n)) == v)
+ {
+ mln_assertion(t.is_a_node(t.parent(n)));
+ a(n) = v;
+ }
+ }
+ mln_postcondition(internal::check_propagate_descendants(t, a, v));
+ }
+
+
+ } // end of namespace mln::morpho::tree
+ } // end of namespace mln::morpho
+} // end of namespace mln
+
+#endif /* !MLN_MORPHO_TREE_PROPAGATE_VALUE_HH_ */
Index: trunk/milena/sandbox/edwin/tree/Makefile
===================================================================
--- trunk/milena/sandbox/edwin/tree/Makefile (revision 3517)
+++ trunk/milena/sandbox/edwin/tree/Makefile (revision 3518)
@@ -1,5 +1,5 @@
-TARGET=tree
-SRC=tree.cc
+TARGET=propagation
+SRC=propagation.cc
OBJS=${SRC:.cc=.o}
OLENADIR=$(MLN_DIR)/..
@@ -7,7 +7,8 @@
CXXFLAGS=-I$(MILENADIR) -I./
-CXXFLAGS += -DNDEBUG -O1
+CXXFLAGS += -g -ggdb
+#CXXFLAGS += -DNDEBUG -O1
CXX=g++
LD=g++
* Makefile.am: add new rule "tools".
* doc/examples/Makefile.am,
* doc/Makefile.am: rename rule data to examples.
* doc/ref_guide/ref_guide.tex: remove useless chapters.
* doc/tutorial/tutorial.tex: write two new chapters.
---
milena/ChangeLog | 13 +
milena/Makefile.am | 15 +-
milena/doc/Makefile.am | 12 +-
milena/doc/examples/Makefile.am | 2 +-
milena/doc/ref_guide/ref_guide.tex | 18 +-
milena/doc/tutorial/tutorial.tex | 718 ++++++++++++++++++++++++++++++++++--
6 files changed, 728 insertions(+), 50 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 8f4a879..db4cab5 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,16 @@
+2009-03-12 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
+ Improve tutorial and documentation.
+
+ * Makefile.am: add new rule "tools".
+
+ * doc/examples/Makefile.am,
+ * doc/Makefile.am: rename rule data to examples.
+
+ * doc/ref_guide/ref_guide.tex: remove useless chapters.
+
+ * doc/tutorial/tutorial.tex: write two new chapters.
+
2009-03-11 Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Fix missing update in labeling extrema.
diff --git a/milena/Makefile.am b/milena/Makefile.am
index 593fbf9..b394cf2 100644
--- a/milena/Makefile.am
+++ b/milena/Makefile.am
@@ -4,17 +4,20 @@
SUBDIRS = \
doc \
mesh \
- tests \
- tools
+ tests
# apps
-.PHONY: doc tutorial
+.PHONY: doc tutorial tools
+
doc:
$(MAKE) -C doc doc
tutorial:
$(MAKE) -C doc tutorial
+tools:
+ $(MAKE) -C tools all
+
.PHONY: regen-dist
regen-dist: $(srcdir)/headers.mk
# FIXME: Change generate_dist_headers.sh so that the action looks like this:
@@ -54,4 +57,8 @@ img/tiny.ppm \
img/toto.pbm
EXTRA_DIST += \
-generate_dist_headers.sh
+generate_dist_headers.sh\
+tools \
+tools/area_flooding.cc \
+tools/seed2tiling.cc
+
diff --git a/milena/doc/Makefile.am b/milena/doc/Makefile.am
index ad25545..14da88f 100644
--- a/milena/doc/Makefile.am
+++ b/milena/doc/Makefile.am
@@ -6,9 +6,9 @@ SUBDIRS = tutorial white_paper
DOXYGEN = doxygen
-.PHONY: doc user-doc complete-doc html-complete html-user tutorial white-paper regen-dist
+.PHONY: doc user-doc complete-doc html-complete html-user tutorial white-paper regen-dist examples
-doc: user-doc
+doc: user-doc tutorial white_paper ref-guide
complete-doc: html-complete
@@ -20,10 +20,10 @@ html-complete: Doxyfile tuto-html ref-guide-html
html-user: Doxyfile tuto-html ref-guide-html
$(DOXYGEN) Doxyfile_user
-tuto-html: data fig-convert
+tuto-html: examples fig-convert
$(MAKE) -C tutorial tuto-html
-tutorial: data fig-convert
+tutorial: examples fig-convert
$(MAKE) -C tutorial tutorial
white-paper:
@@ -36,8 +36,8 @@ ref-guide-html:
$(MAKE) -C ref_guide ref-guide-html
-data:
- make -C examples data
+examples:
+ make -C examples examples
fix-refdata:
make -C examples fix-refdata
diff --git a/milena/doc/examples/Makefile.am b/milena/doc/examples/Makefile.am
index 74f68f1..c343312 100644
--- a/milena/doc/examples/Makefile.am
+++ b/milena/doc/examples/Makefile.am
@@ -108,7 +108,7 @@ run-samples: all
done
-data: run-samples diff-data split-samples split-outputs
+examples: run-samples diff-data split-samples split-outputs
diff-data:
diff --git a/milena/doc/ref_guide/ref_guide.tex b/milena/doc/ref_guide/ref_guide.tex
index 4df8efa..28bc543 100644
--- a/milena/doc/ref_guide/ref_guide.tex
+++ b/milena/doc/ref_guide/ref_guide.tex
@@ -1119,9 +1119,9 @@ Voir les vset => attendre que ca soit ameliore?
\clearpage
\newpage
%Ugly workaround to avoid missing chapter references in doxygen.
-\begin{htmlonly}
-\doxychapter{1}{}
-\end{htmlonly}
+%\begin{htmlonly}
+%\doxychapter{1}{}
+%\end{htmlonly}
\doxychapter{winneigh}{Structural elements: Window and neighborhood}
In Olena, there are both the window and neighborhood concept. A window can be
@@ -1923,9 +1923,9 @@ site set.
\newpage
\clearpage
%Ugly workaround to avoid missing chapter references in doxygen.
-\begin{htmlonly}
-\doxychapter{2}{}
-\end{htmlonly}
+%\begin{htmlonly}
+%\doxychapter{2}{}
+%\end{htmlonly}
\doxychapter{graphandima}{Graphes and images}
FIXME: REWRITE
@@ -2186,9 +2186,9 @@ mln\_edge\_nbh\_edge\_iter(G) & G : graph type & Iterator on the edges adjacen
\newpage
\clearpage
%Ugly workaround to avoid missing chapter references in doxygen.
-\begin{htmlonly}
-\doxychapter{2}{}
-\end{htmlonly}
+%\begin{htmlonly}
+%\doxychapter{2}{}
+%\end{htmlonly}
\doxychapter{debugtools}{Debugging tools}
FIXME write it
diff --git a/milena/doc/tutorial/tutorial.tex b/milena/doc/tutorial/tutorial.tex
index 87949d9..903ac14 100644
--- a/milena/doc/tutorial/tutorial.tex
+++ b/milena/doc/tutorial/tutorial.tex
@@ -305,6 +305,15 @@ $$
\end{latexonly}
}
+\newcommand{\path}[1]{
+\textit{#1}
+}
+
+\newcommand{\dir}[1]{
+\textbf{\textit{#1}}
+}
+
+
\begin{document}
% Doxygen use only - Generate the left menu.
@@ -344,21 +353,684 @@ A copy of the license is provided in the file COPYING.DOC.
%\begin{htmlonly}
%====================================
-\doxychapter{tuto0}{Step 0: Foreword}
+\doxychapter{tuto1}{Welcome}
-- image2d
-- typical use case
+Welcome to Milena's tutorial.
-\begin{htmlonly}
- \begin{center}%
- \hspace{1cm} Go to \doxyref{tuto1}~ \longrightarrow%
- \end{center}%
-\end{htmlonly}
+
+%**************************
+\doxysection{tuto1howotlearn}{How to learn Milena}
+
+Milena is only a subpart of Olena but tends to be a large system too.
+Therefore it is not possible to present all the functionalities in a
+tutorial.
+
+
+Milena targets several audiences: \textit{end users}, \textit{designers} and
+\textit{providers}. \textit{End users} want to apply and assemble algorithms
+to solve image processing, pattern recognition or computer vision problems,
+\textit{designers} build new algorithms and \textit{providers} are interested
+in developping their own data structures and extend an existing library.
+
+
+Whatever the kind of user you are, the key to learning how to use Milena is to
+become familiar with its palette of objects and the way of combining them.
+
+As an \textit{end user}, you may start with this simple tutorial and the Quick
+tour (FIXME: ref). They describe and illustrate the key features of the library.
+\textit{End users} getting familiar with Milena and \textit{designers}, should
+take a look at the Quick Reference Guide (FIXME: ref!).
+It is a more detailed explanations of the library's features.
+
+\textit{end users} and \textit{designers} may be also interested by all the
+examples provided with the documentation and the tutorial. The source code is
+available in \path{milena/doc/examples} (FIXME: ref) and is usually pointed
+out and commented by the documentation.
+
+Taking a look at the test suite is also a good idea. The tests usually focus on
+a single functionality and handle several use cases which may overlap your needs.
+The test suite is located at \path{milena/tests} (FIXME: ref?).
+
+Still not enough information? More information about all the functions is
+available in the User HTML documentation (FIXME:ref).
+It mainly targets \textit{designers} and \texit{providers}.
+The latter may also be interested by the Developer HTML documentation
+(FIXME:ref).
+
+
+
+%**************************
+\doxysection{tuto1obtainingthelib}{Obtaining the library}
+
+There are two ways of getting Milena on the web:
+\begin{itemize}
+ \item Download a tarball/package from the website,
+ \item Checkout the SVN repository.
+\end{itemize}
+
+Downloading a package or a tarball is the best choice for a new user. Except
+for nightly builds which are packages generated every night from the SVN repository,
+packages and tarballs contain only a released version of Milena. It guaranties a
+certain quality: no building issues, no bugs (ok, maybe some...), \ldots
+
+This tutorial is based on the latest released version of Milena. Therefore,
+if you decide to use the SVN version, you may notice different behaviors or results
+compared to what it is described in this document.
+
+Using the SVN version implies some drawbacks: the code might crash, not
+compile or produce incorrect results.
+Besides, The SVN version is always up to date and you may find new functionalities,
+bug fixes and new syntax improvements.
+This version targets users familiar with build systems and compilation issues.
+We strongly advise you to not use it for production use.
+
+
+
+%**************************
+\doxysection{tuto1downloading}{Downloading the library}
+
+
+
+%download page.
+
+%--------------------------
+\subdoxysection{tuto1downloadingsvn}{Downloading from SVN}
+
+First, be sure that SVN is already installed on your system.
+Open a terminal and type:
+
+\begin{verbatim}
+\$ svn --version --quiet
+1.4.6
+\end{verbatim}
+
+You should see your version of SVN installed. If you read 'Command not found'
+then you need to install SVN.
+
+Usually, systems providing packages reference SVN's package as 'subversion'.
+
+Once you have SVN installed, go to the directory where you woudl like to
+download Olena and create a new directory.
+
+\begin{verbatim}
+\$ cd $HOME
+\$ mkdir olena
+\$ cd olena
+\end{verbatim}
+
+Then 'checkout' (download) the repository with the following command.
+
+\begin{verbatim}
+\$ svn co https://svn.lrde.epita.fr/svn/oln/trunk
+\end{verbatim}
+
+Enter the 'trunk' directory.
+
+\begin{verbatim}
+\$ cd trunk
+\end{verbatim}
+
+You are now ready to configure the directory and install Milena as described
+in section \ref{tuto2}.
+We invite you to take a look at the description of the directory structure
+(\ref{tuto1dirstruct}.
+If you encounter any issues in the installation process or if you have any
+question, do not forget to join the mailing lists (\ref{tuto1mailinglists}
+and/or use the other documentations ressources (\ref{tuto1ressources}).
+
+
+
+
+
+%--------------------------
+\subdoxysection{tuto1downloadingpackages}{Downloading packaged releases}
+
+%details.
+
+Milena's packages can be downloaded from:
+
+\begin{centerize}
+\begin{verbatim}
+http://www.lrde.epita.fr/Olena/Download
+\end{verbatim}
+\end{centerize}
+
+On this page you will find the latest and past releases.
+Currently, we provide only '.tar.gz' and 'tar.bz2' archives.
+
+Once download, you just need to uncompress the archive.
+
+For the '.tar.gz' archive:
+\begin{verbatim}
+$ tar zxvf olena-1.0.tar.gz
+\end{verbatim}
+
+For the '.tar.bz2' archive:
+\begin{verbatim}
+$ tar jxvf olena-1.0.tar.bz2
+\end{verbatim}
+
+Then, enter the new created directory:
+\begin{verbatim}
+$ cd olena-1.0
+\end{verbatim}
+
+
+You are now ready to configure the directory and install Milena as described
+in section \ref{tuto2}.
+We invite you to take a look at the description of the directory structure
+(\ref{tuto1dirstruct}.
+If you encounter any issues in the installation process or if you have any
+question, do not forget to join the mailing lists (\ref{tuto1mailinglists}
+and/or use the other documentations ressources (\ref{tuto1ressources}).
+
+
+
+%**************************
+\doxysection{tuto1mailinglists}{Join the mailing lists}
+
+Regardless your use of Olena, we strongly advise you to join our mailing lists.
+This is the best way to keep up to date about new releases, bug
+notifications/fixes and future updates.
+This is also a good opportunity to tell us what you would like to find in
+Milena and what could be improved.
+
+Currently four mailing-lists are available:
+
+\begin{tabular}{l l}
+\textbf{Olena} & Discussion about the project Olena \\
+\textbf{Olena-bugs} & Bugs from Olena projects \\
+\textbf{Olena-core} & Internal list for the Olena project \\
+\textbf{Olena-patches} & patches for the Olena project \\
+\end{tabular}
+
+You can subscribe to these mailing lists at the following adress:
+
+\begin{center}
+\begin{verbatim}
+https://www.lrde.epita.fr/mailman/listinfo/
+\end{verbatim}
+\end{center}
+
+Just click on the name of the mailing list you want to subscribe to and fill
+out the form.
+
+
+
+%**************************
+\doxysection{tuto1dirstruct}{Directory structure}
+
+Milena's directory is composed of several subdirectories. In order to help
+you finding what you need, you will find a description of all these
+subdirectories.
+
+
+List of \path{milena}'s subdirectories:
+\begin{itemize}
+
+\dir{apps} --- A full example of a 3D mesh visualization tool. It
+ uses milena.
+
+\dir{doc} --- THE directory you must know. Contains all the
+ documentation material.
+
+\dir{img} --- A set of common test images. They are used in the
+ test suite. Feel free to use it in your programs.
+
+\dir{mesh} --- A set of 3D meshes. They can be used with the full
+ example located in \path{milena/apps}.
+
+\dir{mln} --- The core of the libray. Contains all the library headers.
+
+\dir{tests} --- The test suite. Is it subdivided in sub directories.
+ The directory hierarchy respects \path{milena/mln}'s.
+
+\dir{tools} --- Small tools written with milena. They can be used as examples.
+
+\end{itemize}
+
+
+
+List of \path{mln}'s subdirectories:
+\begin{itemize}
+ \item \dir{accu} --- Set of Accumulators.
+ \item \dir{algebra} --- Algebraic structures like vectors or matrices.
+ \item \dir{arith} --- Arithmetical operators.
+ \item \dir{binarization} --- Routines to binarize an image.
+ \item \dir{border} --- Image border related routines.
+ \item \dir{canvas} --- Generic canvas. They define generic ways of browsing
+ an image, compute data, \dots.
+ \item \dir{convert} --- Automatic conversion mechanism.
+ \item \dir{core} --- Core of the library. Here you can find the image types,
+ the site set types and basic concepts.
+ \item \dir{data} --- Routine that modify image data.
+ \item \dir{debug} --- Debug related routines.
+ \item \dir{display} --- Display images on the screen.
+ \item \dir{draw} --- Draw geometric objects in an image.
+ \item \dir{essential} --- Set of essential headers for 1,2,3-D manipulations.
+ \item \dir{estim} --- Compute data on image values.
+ \item \dir{extension} --- Image extension manipulation.
+ \item \dir{extract} --- FIXME: extract will be removed and replaced by thru().
+ \item \dir{fun} --- Set of functions applying on sites, values, \ldots
+ \item \dir{geom} --- Functions related to image geometry.
+ \item \dir{graph} --- Graph related routines.
+ \item \dir{histo} --- Histogram related functions.
+ \item \dir{io} --- I/O related routines.
+ \item \dir{labeling} --- Labeling related routines.
+ \item \dir{level} --- Point-wise operators on levels.
+ \item \dir{linear} --- Linear operators.
+ \item \dir{literal} --- Generic image values such as zero, black, white \ldots
+ \item \dir{logical} --- Logical operators.
+ \item \dir{make} --- Small routines to construct images, windows, \ldots
+ \item \dir{math} --- Mathematical functions.
+ \item \dir{metal} --- Metalic macros/structures. Static library helping
+ developing doing static tests.
+ \item \dir{morpho} --- Mathematical morphology.
+ \item \dir{norm} --- Norm computation
+ \item \dir{opt} --- Optional routines. Routines which may work on a
+ specific image type only.
+ \item \dir{pw} --- Point-wise image related routines.
+ \item \dir{registration} -- Registration related routine.
+ \item \dir{set} --- Set related routines.
+ \item \dir{subsampling} --- Subsampling related algorithms.
+ \item \dir{tag} --- Tag traits.
+ \item \dir{test} --- Definition of predicates.
+ \item \dir{topo} --- Complex related structures.
+ \item \dir{trace} --- Debug trace mechanism.
+ \item \dir{trait} --- Internal traits mechanism.
+ \item \dir{transform} --- Algorithms based on the level::transform.
+ \item \dir{util} --- Various utilitarian classes.
+ \item \dir{value} --- Set of value types which can be used in an image.
+ \item \dir{win} --- Set of various window kinds.
+\end{itemize}}
+
+
+The source code and the material of the documentation is available in \path{
+milena/doc}.
+List of \path{doc}'s subdirectories:
+\begin{itemize}
+\item \dir{examples} --- All the source code of the documentation examples.
+\item \dir{benchmark} --- Some benchmarks.
+\item \dir{tools} --- Small tools used for generating documentation /
+ building examples.
+
+\item \dir{tutorial} --- Tutorial sources.
+\item \dir{white\_paper} --- White paper sources.
+\item \dir{technical} --- Technical documentation. (DEPRECATED)
+\item \dir{ref\_guide} --- Reference guide sources.
+\item \dir{figures} --- Reference figures for documentation generation.
+\item \dir{outputs} --- Reference outputs for documentation examples.
+
+\end{itemize}
+
+
+
+
+%**************************
+\doxysection{tuto1ressources}{Documentation}
+
+This tutorial is not the only documentation of Milena. Other documents are available:
+
+\begin{itemize}
+ \item \dir{White paper} --- a small document of few pages presenting the key
+ features of the library. It intents to give a big picture of the library.
+
+ \item \dir{Quick tour} --- it aims giving an overview of Milena's possibilities.
+ It does not only give the concepts but illustrate them with small sample
+ codes.
+
+ \item \dir{Quick reference guide} --- Present in details all the main
+ functionalities of Milena.
+ Hints and full examples are also provided. The sample codes are commented
+ and each concept in the library is detailed. This is the reference document for any
+ \textit{end user} and \textit{algorithm designer}.
+
+ \item \dir{HTML user doc} --- The full documentation of the library. The full
+ API is described in details. Each part of the library is classified by
+ categories and the source code is directly accessible from the documentation.
+ This is the reference document for any \textit{algorithm designer} and/or
+ \textit{provider of data structures}.
+
+ \item \dir{Header files} --- Every object or algorithm is declared in a '.hh' file.
+ The documentation is provided as comments in these file.
+\end{itemize}
+
+
+%**************************
+\doxysection{tuto1ressources}{Community and Support}
+
+Even though Milena is currently developped by the LRDE in EPITA, we are open
+for new contributors.
+
+\begin{itemize}
+ \item If you are a user, please send us feedback about the library.
+ Did you find what you wanted? Do you miss something?
+
+ \item Please report bugs and defect in the API. Mailing lists are the best
+ way for reporting that.
+
+ \item Developers, if you write cool open source programs or algorithms with Milena,
+ send them to us. We may ship your code with Olena and/or add it to
+ our download page.
+
+ \item Educators, if you use Olena for your courses and you are ready to
+ share your materials, you can send it to us through our mailing-lists.
+
+ \item We are also interested in partnership or commercial use of Milena.
+ If you are interested, contact us directly (\ref{tuto1contacts}).
+
+\end{itemize}
+
+
+%**************************
+\doxysection{tuto1projectstatus}{Project status}
+
+If you want to stay tuned to Milena's development, the best way is probably
+the mailing-lists (\ref{tuto1mailinglists}).
+
+There are other ways to get to know what is the status of the project.
+
+\begin{itemize}
+\item Olena's trac --- \href{https://trac.lrde.org/olena} --- Here is the
+roadmap, the current open tickets/bugs/improvements which are taken in
+consideration. A source browser is also available.
+
+\item Olena's Buildfarm --- https://buildfarm.lrde.org/buildfarm/oln/ --- The
+official buildfarm. Every night and after each commit, tests are compiled and run.
+The buildfarm can show you whether it is safe to update your svn copy of Milena or not\ldots
+
+\item Test failures --- http://www.lrde.epita.fr/dload/olena/test-failures-daily.html
+--- Through this page, you can see exactly which tests do not compile or pass.
+This page is updated every night.
+
+
+
+%**************************
+\doxysection{tuto1ressources}{A brief history of Milena}
+
+The Olena project aims at building a scientific computation platform oriented
+towards image processing, image recognition, and artificial vision.
+This environment is composed of a high performance generic library (Milena),
+a set of tools for shell scripts, together with, in the more distant future,
+an interpreter (a la Octave, MatLab etc.) and a visual programming environment.
+
+The Olena project started in 2000 from a small prototype on 2-D images.
+From November 2001 to April 2004, this prototype evolved from version 0.1 to 0.10.
+More image types were supported and the level of genericity expected from the
+library was partially obtained. During these three years, the prototype was used
+to experiment with genericity and to try to meet our objectives.
+In February 2007, Olena 0.11 was released to conform modern C++ compilers.
+At that time, the code was not enough readable though and the compilation time
+was too long.
+
+Since June 2007 up to now, The library of the Olena platform is called Milena
+and the library has been rewritten. The programming paradigm has been
+simplified: the code is more readable and the compilation time is acceptable.
+The level of genericity still meets our objectives though.
+
+Milena is now getting ready for being considered as stable and distributable.
+The core of the library is getting frozen and we aim at enriching the library,
+its documentation and the related tools.
+
+
+%**************************
+\doxysection{tuto1contacts}{Contacts}
+
+If you want to reach us directly, you can contact one of the following people:
+
+\begin{itemize}
+ \item Thierry Geraud - Project Manager - thierry.geraud(a)lrde.epita.fr
+\end{itemize}
+
+
+
+
+
+
+%\begin{htmlonly}
%====================================
-\doxychapter{tuto1}{Step 1: Load and save images}
+\doxychapter{tuto2}{Installation}
+
+%pre-requis/compatibility
+This section describes the installation process of Milena.
+Do not forget that Milena is a library, not a program. Therefore, no program
+will be installed.
+
+Milena's examples and tests are compiled on the following platforms:
+\begin{itemize}
+ \item Apple Tiger Darwin 8, PowerPC, GCC 4.0.1
+ \item Apple Leopard Darwin 10.5, X86-64, GCC 4.0.1, 4.2
+ \item Linux, i486, GCC 3.3, 4.1, 4.2, 4.3
+ \item Linux, x86-64, GCC 4.1
+\end{itemize}
+
+We guaranty that Milena compiles on these platforms, e.g. Linux and Unix
+platforms. It may compiles on other platforms though but we have not tested.
+If you did, and you succeeded, please let us know in order to update this
+section.
+
+Milena is known NOT to work with GCC-2.95.
+
+
+Milena is actively developed under Unix systems. As a result, the build system
+is based on the Autotools.
+Autotools make sure that every dependencies are resolved before compiling
+or installing a program.
+
+Milena is different from usual libraries in a way that nothing needs to be
+compiled to use it. The library itself is composed of headers which must be
+included when you need them.
+Then, your application will be compiled with the parts of the library used in
+that program. That's all.
+
+So, why do we have a build system? It is useful for installing the library on
+your system, generating the doc and compiling the test suite and the examples.
+
+
+
+%**************************
+\doxysection{tuto2bootstrap}{Bootstrap (SVN Sources)}
+
+If you got the sources from a package/tarball, you can skip this section. Go
+to section \ref{tuto2configure}.
+
+If you downloaded the sources from the SVN repository, you must launch a
+script before configuring the build directory.
+
+Run the following:
+\begin{verbatim}
+$ cd /my/path/to/olena-1.0
+$ ./bootstrap
+\end{verbatim}
+
+Running 'bootstrap' can take a while. Some files are generated during this
+process.
+When it's done, you are ready to configure the build directory.
+
+
+
+%**************************
+\doxysection{tuto2configure}{Configure}
+
+First, make sure you are at the root directory of the milena source:
+
+\begin{verbatim}
+$ cd /my/path/to/olena-1.0
+\end{verbatim}
+
+First, create and enter a build directory:
+\begin{verbatim}
+$ mkdir build
+$ cd build
+\end{verbatim}
+
+We are now about to configure the build directory. This process will create
+the necessary files to compile documentation, examples and tools and prepare the
+installation.
+
+\textbf{Important Note}: the Install path prefix must be chosen at this step.
+By default, Milena will be installed in /usr/local but you may like to install
+it elsewhere. To do so, pass the option \textit{--prefix=/installation/path/prefix}
+to the configure script (see below). Replace '/installation/path/prefix' with the
+wanted installation path prefix.
+
+now, you can run:
+\begin{verbatim}
+$ ../configure
+\end{verbatim}
+OR
+\begin{verbatim}
+$ ../configure --prefix=/installation/path/prefix
+\end{verbatim}
+
+The configure script will perform various tests. If there is no dependency
+issues, the last lines shown before the prompt are:
+
+\begin{verbatim}
+config.status: creating config.h
+config.status: executing depfiles commands
+$
+\end{verbatim}
+
+The build directory is now configured, the library can be installed.
+
+
+
+%**************************
+\doxysection{tuto2install}{Install}
+
+First, be sure to be in the build directory. If you followed the previous
+steps, the build directory should be in the Milena sources root directory.
+
+\begin{verbatim}
+$ cd /my/path/to/olena-1.0/build
+\end{verbatim}
+
+If you did not change the default install path prefix, set to
+\path{/usr/local}, you will need to have administrator privileges to
+perform the installation. Then, you may type:
+\begin{verbatim}
+$ sudo make install
+\end{verbatim}
+
+Otherwise, if you set the install path prefix to a directory own by your
+user, simply type:
+\begin{verbatim}
+$ make install
+\end{verbatim}
+
+When the installation is finished, you are done. Milena is installed on your
+system. But maybe you would like to build the examples? This is described
+in the next section \ref{tuto2optionalcomp}.
+
+A description of the installation content is also available in section
+\ref{tuto2installcontent}.
+
+
+
+%**************************
+\doxysection{tuto2optionalcomp}{Optional compilation}
+
+The library itself does not need to be compiled, therefore installing
+Milena does not require compilation.
+
+Though, some examples and tools are provided with the library and must be
+compiled if you want to use them.
+
+\doxysubsection{tuto2examples}{Examples}
+
+Examples are part of the documentation. The sources are located in
+\path{milena/doc/examples}.
+
+To compile the examples simply run:
+\begin{verbatim}
+$ cd /my/path/to/olena-1.0/build/milena/doc/examples
+$ make
+\end{verbatim}
+
+These examples can produce outputs and images. May be you would like
+to run all the examples and take a look at the outputs? To do so, run:
+\begin{verbatim}
+$ cd /my/path/to/olena-1.0/build/milena/doc/examples
+$ make examples
+\end{verbatim}
+
+Text and image outputs will be respectively stored in
+\path{build/milena/doc/outputs} and \path{build/milena/doc/figures}.
+
+
+
+\doxysubsection{tuto2examples}{Tools}
+
+Few tools are provided with Milena. They can be considered as full program
+examples.
+
+Currently two tools are available:
+\begin{tabular}{l l}
+area\_flooding.cc & FIXME:description \\
+\hline
+seed2tiling.cc & FIXME:description \\
+\end{itemize}
+
+To build these tools, run:
+\begin{verbatim}
+$ cd /my/path/to/olena-1.0/build/milena/tools
+$ make
+\end{verbatim}
+
+
+\doxysubsection{tuto2examples}{Tests}
+
+The test suite used for Milena's development is shipped with the library.
+
+In order to build and run it, just do the following:
+\begin{verbatim}
+$ cd /my/path/to/olena-1.0/build/milena/tests
+$ make check
+\end{verbatim}
+
+Running the test suite is memory and CPU consumming and will take a while.
+
+
+%**************************
+\doxysection{tuto2installcontent}{Installation content}
+
+Once installed, Milena's files are located in the installed path prefix
+you passed to the configure script or in the default path /usr/local.
+
+In the installed path prefix, Milena's files are located in:
+
+\begin{itemize}
+ \item include/mln/ --- The library. All the headers are located here.
+ \item share/olena/images --- Mesh sample files which may be used with
+ example programs.
+\end{itemize}
+
+
+
+%\begin{htmlonly}
+%====================================
+\doxychapter{tuto3}{Getting started with Milena}
+
+** intent
+
+A very simple processing chain; the target is the end-user!
+
+OR (?)
+this chain plus a sample tiny generic algorithm
+
+** misc
+/!\ step by step...
+compilation time w.r.t compilation options (O1, DNDEBUG).
+
+
+
+
+%====================================
+\doxychapter{tuto4}{Step 4: Load and save images}
After this step you shoud know how to:
\begin{itemize}
@@ -392,12 +1064,12 @@ The supported file formats and their associated image value types are listed
in section \doxyref{imaio}.
\vspace{2cm}
-\tutotoc{tuto0}{tuto2}
+\tutotoc{tuto3}{tuto5}
%====================================
-\doxychapter{tuto2}{Step 2: Create your first image}
+\doxychapter{tuto5}{Step 5: Create your first image}
After this step you should know how to:
\begin{itemize}
@@ -440,12 +1112,12 @@ though. A more detailed description can be found in section
\vspace{2cm}
\begin{center}
- \tutotoc{tuto1}{tuto3}
+ \tutotoc{tuto4}{tuto6}
\end{center}
%====================================
-\doxychapter{tuto3}{Step 3: Read and write images}
+\doxychapter{tuto6}{Step 6: Read and write images}
After this step you should know how to:
\begin{itemize}
@@ -495,12 +1167,12 @@ the reference guide.
\vspace{2cm}
\begin{center}
- \tutotoc{tuto2}{tuto4}
+ \tutotoc{tuto5}{tuto7}
\end{center}
%====================================
-\doxychapter{tuto4}{Step 4: Regions of interest}
+\doxychapter{tuto7}{Step 7: Regions of interest}
After this step you should know how to:
\begin{itemize}
@@ -711,23 +1383,9 @@ value in \var{label} is equal to 16'.
\vspace{2cm}
\begin{center}
- \tutotoc{tuto3}{tuto5}
+ \tutotoc{tuto6}{tuto8}
\end{center}
-%====================================%
-%%Ugly workaround to avoid missing chapter references in doxygen.
-%\begin{htmlonly}
-% \doxychapter{1}{}
-% \doxychapter{tuto5}{Step 5: Conversion between image values}
-%\end{htmlonly}
-
-
-%====================================
-\doxychapter{tuto6}{Step 6: Using structural elements with algorithms}
-
-
-%====================================
-\doxychapter{tuto7}{Step 7: Handle graphes with an image}
%\end{htmlonly}
--
1.5.6.5