URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-10-04 Simon Nivault <simon.nivault(a)lrde.epita.fr>
Add generic line.
* mln/core/win/line.hh: New.
* mln/core/win/hline2d.hh,
* mln/core/win/vline2d.hh: Now inherit of line.
* tests/win_hline2d.cc: New.
---
mln/core/win/hline2d.hh | 125 +-------------------------------
mln/core/win/line.hh | 185 ++++++++++++++++++++++++++++++++++++++++++++++++
mln/core/win/vline2d.hh | 125 +-------------------------------
tests/win_hline2d.cc | 48 ++++++++++++
4 files changed, 247 insertions(+), 236 deletions(-)
Index: trunk/milena/tests/win_hline2d.cc
===================================================================
--- trunk/milena/tests/win_hline2d.cc (revision 0)
+++ trunk/milena/tests/win_hline2d.cc (revision 1245)
@@ -0,0 +1,48 @@
+// 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.
+
+/*! \file tests/win_diag2d.cc
+ *
+ * \brief Tests on mln::win::diag2d.
+ */
+
+#include <mln/core/win/hline2d.hh>
+
+#include <mln/convert/to_image.hh>
+
+#include <mln/debug/println.hh>
+
+int main()
+{
+ using namespace mln;
+
+ const unsigned l = 5;
+ win::hline2d hline(l);
+
+ debug::println(convert::to_image(hline));
+}
+
Index: trunk/milena/mln/core/win/vline2d.hh
===================================================================
--- trunk/milena/mln/core/win/vline2d.hh (revision 1244)
+++ trunk/milena/mln/core/win/vline2d.hh (revision 1245)
@@ -33,10 +33,8 @@
* \brief Definition of the mln::win::vline2d window.
*/
-# include <mln/core/concept/window.hh>
-# include <mln/core/internal/dpoints_base.hh>
-# include <mln/core/dpoint2d.hh>
-# include <mln/core/dpoints_piter.hh>
+# include <mln/core/win/line.hh>
+# include <mln/core/grids.hh>
namespace mln
@@ -56,123 +54,14 @@
* o \n
* is defined with length = 5.
*/
- struct vline2d : public Window< vline2d >,
- public internal::dpoints_base_< dpoint2d, vline2d >
+ struct vline2d : public line<grid::square, 0, vline2d>
{
- /// Point associated type.
- typedef point2d point;
-
- /// Dpoint associated type.
- typedef dpoint2d dpoint;
-
- /*! \brief Point_Iterator type to browse a vline such as: "for each row
- * (increasing), for each column (increasing)."
- */
- typedef dpoints_fwd_piter<dpoint2d> fwd_qiter;
-
- /*! \brief Point_Iterator type to browse a vline such as: "for each row
- * (decreasing), for each column (decreasing)."
- */
- typedef dpoints_bkd_piter<dpoint2d> bkd_qiter;
-
- /*! \brief Same as fwd_qiter.
- */
- typedef fwd_qiter qiter;
-
- /*! \brief Constructor.
- *
- * \param[in] length Length, thus height, of the vertical line.
- *
- * \pre \p length is odd.
- */
- vline2d(unsigned length);
-
- /*! \brief Test if the window is centered.
- *
- * \return True.
- */
- bool is_centered() const;
-
- /*! \brief Test if the window is symmetric.
- *
- * \return true.
- */
- bool is_symmetric() const;
-
- /*! \brief Give the vline length, that is, its height.
- */
- unsigned length() const;
-
- /*! \brief Give the maximum coordinate gap between the window
- * center and a window point.
- */
- unsigned delta() const;
-
- /// Apply a central symmetry to the target window.
- vline2d& sym();
-
- protected:
- unsigned length_;
- };
-
-
- /*! \brief Print a vertical 2D line window \p win into the output
- * stream \p ostr.
- *
- * \param[in,out] ostr An output stream.
- * \param[in] win A vertical 2D line window.
- *
- * \return The modified output stream \p ostr.
- *
- * \relates mln::win::vline2d
- */
- std::ostream& operator<<(std::ostream& ostr, const vline2d& win);
-
-
-
-# ifndef MLN_INCLUDE_ONLY
-
- vline2d::vline2d(unsigned length)
- : length_(length)
+ // Ctor.
+ vline2d(unsigned length)
+ : line<grid::square, 0, vline2d>(length)
{
- mln_precondition(length % 2 == 1);
- const int drow = length / 2;
- for (int row = - drow; row <= drow; ++row)
- insert(make::dpoint2d(row, 0));
}
-
- bool vline2d::is_centered() const
- {
- return true;
- }
-
- bool vline2d::is_symmetric() const
- {
- return true;
- }
-
- unsigned vline2d::length() const
- {
- return length_;
- }
-
- unsigned vline2d::delta() const
- {
- return length_ / 2;
- }
-
- vline2d& vline2d::sym()
- {
- return *this;
- }
-
- std::ostream& operator<<(std::ostream& ostr, const vline2d& win)
- {
- ostr << "[line2d: length=" << win.length() << ']';
- return ostr;
- }
-
-# endif // ! MLN_INCLUDE_ONLY
+ };
} // end of namespace mln::win
Index: trunk/milena/mln/core/win/hline2d.hh
===================================================================
--- trunk/milena/mln/core/win/hline2d.hh (revision 1244)
+++ trunk/milena/mln/core/win/hline2d.hh (revision 1245)
@@ -33,10 +33,8 @@
* \brief Definition of the mln::win::hline2d window.
*/
-# include <mln/core/concept/window.hh>
-# include <mln/core/internal/dpoints_base.hh>
-# include <mln/core/dpoint2d.hh>
-# include <mln/core/dpoints_piter.hh>
+# include <mln/core/win/line.hh>
+# include <mln/core/grids.hh>
namespace mln
@@ -54,123 +52,14 @@
* o o x o o \n
* is defined with length = 5.
*/
- struct hline2d : public Window< hline2d >,
- public internal::dpoints_base_< dpoint2d, hline2d >
+ struct hline2d : public line<grid::square, 1, hline2d>
{
- /// Point associated type.
- typedef point2d point;
-
- /// Dpoint associated type.
- typedef dpoint2d dpoint;
-
- /*! \brief Point_Iterator type to browse a hline such as: "for each row
- * (increasing), for each column (increasing)."
- */
- typedef dpoints_fwd_piter<dpoint2d> fwd_qiter;
-
- /*! \brief Point_Iterator type to browse a hline such as: "for each row
- * (decreasing), for each column (decreasing)."
- */
- typedef dpoints_bkd_piter<dpoint2d> bkd_qiter;
-
- /*! \brief Same as fwd_qiter.
- */
- typedef fwd_qiter qiter;
-
- /*! \brief Constructor.
- *
- * \param[in] length Length, thus width, of the horizontal line.
- *
- * \pre \p length is odd.
- */
- hline2d(unsigned length);
-
- /*! \brief Test if the window is centered.
- *
- * \return True.
- */
- bool is_centered() const;
-
- /*! \brief Test if the window is symmetric.
- *
- * \return true.
- */
- bool is_symmetric() const;
-
- /*! \brief Give the hline length, that is, its width.
- */
- unsigned length() const;
-
- /*! \brief Give the maximum coordinate gap between the window
- * center and a window point.
- */
- unsigned delta() const;
-
- /// Apply a central symmetry to the target window.
- hline2d& sym();
-
- protected:
- unsigned length_;
- };
-
-
- /*! \brief Print an horizontal 2D line window \p win into the output
- * stream \p ostr.
- *
- * \param[in,out] ostr An output stream.
- * \param[in] win An horizontal 2D line window.
- *
- * \return The modified output stream \p ostr.
- *
- * \relates mln::win::hline2d
- */
- std::ostream& operator<<(std::ostream& ostr, const hline2d& win);
-
-
-
-# ifndef MLN_INCLUDE_ONLY
-
- hline2d::hline2d(unsigned length)
- : length_(length)
+ // Ctor.
+ hline2d(unsigned length)
+ : line<grid::square, 1, hline2d>(length)
{
- mln_precondition(length % 2 == 1);
- const int dcol = length / 2;
- for (int col = - dcol; col <= dcol; ++col)
- insert(make::dpoint2d(0, col));
}
-
- bool hline2d::is_centered() const
- {
- return true;
- }
-
- bool hline2d::is_symmetric() const
- {
- return true;
- }
-
- unsigned hline2d::length() const
- {
- return length_;
- }
-
- unsigned hline2d::delta() const
- {
- return length_ / 2;
- }
-
- hline2d& hline2d::sym()
- {
- return *this;
- }
-
- std::ostream& operator<<(std::ostream& ostr, const hline2d& win)
- {
- ostr << "[line2d: length=" << win.length() << ']';
- return ostr;
- }
-
-# endif // ! MLN_INCLUDE_ONLY
+ };
} // end of namespace mln::win
Index: trunk/milena/mln/core/win/line.hh
===================================================================
--- trunk/milena/mln/core/win/line.hh (revision 0)
+++ trunk/milena/mln/core/win/line.hh (revision 1245)
@@ -0,0 +1,185 @@
+// 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_CORE_WIN_LINE_HH
+# define MLN_CORE_WIN_LINE_HH
+
+/*! \file mln/core/win/line.hh
+ *
+ * \brief Definition of the mln::win::line window.
+ */
+
+# include <mln/core/concept/window.hh>
+# include <mln/core/internal/dpoints_base.hh>
+# include <mln/core/dpoint.hh>
+# include <mln/core/dpoints_piter.hh>
+
+
+namespace mln
+{
+
+ namespace win
+ {
+
+ template <typename M, unsigned i, typename E>
+ struct line : public Window<E>,
+ public internal::dpoints_base_
+ <dpoint_
+ <M, int>, point_
+ <M, int> >
+ {
+ /// Point associated type.
+ typedef point_<M, int> point;
+
+ /// Dpoint associated type.
+ typedef dpoint_<M, int> dpoint;
+
+ /// Point_Iterator type to browse a line forward
+ typedef dpoints_fwd_piter<dpoint> fwd_qiter;
+
+ /// Point_Iterator type to browse a line backward
+ typedef dpoints_bkd_piter<dpoint> bkd_qiter;
+
+ /// Same as fwd_qiter
+ typedef fwd_qiter qiter;
+
+ /*! \brief Constructor.
+ *
+ * \param[in] length Length of the line.
+ *
+ * \pre \p length is odd.
+ */
+ line(unsigned length);
+
+ /*! \brief Test if the window is centered.
+ *
+ * \return True.
+ */
+ bool is_centered() const;
+
+ /*! \brief Test if the window is symmetric.
+ *
+ * \return true.
+ */
+ bool is_symmetric() const;
+
+ /*! \brief Give the hline length, that is, its width.
+ */
+ unsigned length() const;
+
+ /*! \brief Give the maximum coordinate gap between the window
+ * center and a window point.
+ */
+ unsigned delta() const;
+
+ /// Apply a central symmetry to the target window.
+ E& sym();
+
+ protected:
+ unsigned length_;
+ };
+
+
+ /*! \brief Print an line window \p win into the output
+ * stream \p ostr.
+ *
+ * \param[in,out] ostr An output stream.
+ * \param[in] win An line window.
+ *
+ * \return The modified output stream \p ostr.
+ *
+ * \relates mln::win::line
+ */
+ template <typename M, unsigned i, typename E>
+ std::ostream& operator<<(std::ostream& ostr, const line<M,i,E>& win);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ template <typename M, unsigned i, typename E>
+ line<M,i,E>::line(unsigned length)
+ : length_(length)
+ {
+ mln_precondition(i < M::dim);
+ mln_precondition(length % 2 == 1);
+ const int dcol = length / 2;
+ for (int col = - dcol; col <= dcol; ++col)
+ {
+ dpoint n;
+ n[i] = col;
+ insert(n);
+ }
+ }
+
+ template <typename M, unsigned i, typename E>
+ bool line<M,i,E>::is_centered() const
+ {
+ return true;
+ }
+
+ template <typename M, unsigned i, typename E>
+ bool line<M,i,E>::is_symmetric() const
+ {
+ return true;
+ }
+
+ template <typename M, unsigned i, typename E>
+ unsigned line<M,i,E>::length() const
+ {
+ return length_;
+ }
+
+ template <typename M, unsigned i, typename E>
+ unsigned line<M,i,E>::delta() const
+ {
+ return length_ / 2;
+ }
+
+ template <typename M, unsigned i, typename E>
+ E& line<M,i,E>::sym()
+ {
+ return exact(*this);
+ }
+
+ template <typename M, unsigned i, typename E>
+ std::ostream& operator<<(std::ostream& ostr, const line<M,i,E>& win)
+ {
+ ostr << "[line: length=" << win.length() << ']';
+ return ostr;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::win
+
+} // end of namespace mln
+
+
+
+#endif // ! MLN_CORE_WIN_LINE_HH
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-10-04 Simon Nivault <simon.nivault(a)lrde.epita.fr>
Add best canvas and make median_dir use it.
* mln/canvas/browsing/dir_ricard51.hh: New canvas.
* mln/canvas/browsing/directional.hh: Fix some names.
* mln/level/median.hh: Use new canvas.
* tests/level_median_dir.cc: New.
---
mln/canvas/browsing/dir_ricard51.hh | 173 ++++++++++++++++++++++++++++++++++++
mln/canvas/browsing/directional.hh | 8 -
mln/level/median.hh | 63 +++----------
tests/level_median_dir.cc | 55 +++++++++++
4 files changed, 248 insertions(+), 51 deletions(-)
Index: trunk/milena/tests/level_median_dir.cc
===================================================================
--- trunk/milena/tests/level_median_dir.cc (revision 0)
+++ trunk/milena/tests/level_median_dir.cc (revision 1239)
@@ -0,0 +1,55 @@
+// 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.
+
+/*! \file tests/level_median.cc
+ *
+ * \brief Test on mln::level::median.
+ */
+
+#include <mln/core/image2d_b.hh>
+
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+
+#include <mln/value/int_u8.hh>
+#include <mln/level/median.hh>
+
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+
+ border::thickness = 7;
+
+ image2d_b<int_u8>
+ lena = io::pgm::load("../img/lena.pgm"),
+ out(lena.domain());
+
+ level::median_dir(lena, 1, 15, out);
+ io::pgm::save(out, "out.pgm");
+}
Index: trunk/milena/mln/level/median.hh
===================================================================
--- trunk/milena/mln/level/median.hh (revision 1238)
+++ trunk/milena/mln/level/median.hh (revision 1239)
@@ -41,7 +41,7 @@
# include <mln/set/diff.hh>
# include <mln/canvas/browsing/snake_fwd.hh>
-# include <mln/canvas/browsing/directional.hh>
+# include <mln/canvas/browsing/dir_ricard51.hh>
# include <mln/accu/median.hh>
@@ -190,11 +190,6 @@
// aux data
mln_point(I) p;
- const mln_point(I)
- pmin, pmax;
- const mln_coord(I)
- pmin_dir, pmax_dir,
- pmin_dir_plus, pmax_dir_minus;
accu::median<mln_vset(I)> med;
// ctor
@@ -206,12 +201,6 @@
output(exact(output)),
// aux data
p(),
- pmin(input.domain().pmin()),
- pmax(input.domain().pmax()),
- pmin_dir(pmin[dir]),
- pmax_dir(pmax[dir]),
- pmin_dir_plus (pmin[dir] + length / 2),
- pmax_dir_minus(pmax[dir] - length / 2),
med(input.values())
{
}
@@ -220,55 +209,26 @@
{
}
- void next()
+ void init_line()
{
- mln_point(I)
- p = this->p,
- pt = p,
- pu = p;
-
- typedef mln_coord(I)& coord_ref;
- coord_ref
- ct = pt[dir],
- cu = pu[dir],
- p_dir = p[dir];
-
- // initialization (before first point of the row)
med.init();
- for (ct = pmin_dir; ct < pmin_dir_plus; ++ct)
- if (input.has(pt))
- med.take(input(pt));
+ }
- // left columns (just take new points)
- for (p_dir = pmin_dir; p_dir <= pmin_dir_plus; ++p_dir, ++ct)
+ void add_point(mln_point(I) pt)
{
- if (input.has(pt))
med.take(input(pt));
- if (output.has(p))
- output(p) = med.to_result();
}
- // middle columns (both take and untake)
- cu = pmin[dir];
- for (; p_dir <= pmax_dir_minus; ++cu, ++p_dir, ++ct)
+ void remove_point(mln_point(I) pu)
{
- if (input.has(pt))
- med.take(input(pt));
- if (input.has(pu))
med.untake(input(pu));
- if (output.has(p))
- output(p) = med.to_result();
}
- // right columns (now just untake old points)
- for (; p_dir <= pmax_dir; ++cu, ++p_dir)
+ void next()
{
- if (input.has(pu))
- med.untake(input(pu));
if (output.has(p))
output(p) = med.to_result();
}
- }
void final()
{
@@ -282,7 +242,7 @@
void median_dir_(const Image<I>& input, unsigned dir, unsigned length, O& output)
{
median_dir_t<I,O> f(exact(input), dir, length, output);
- canvas::browsing::directional(f);
+ canvas::browsing::dir_ricard51(f);
}
@@ -330,11 +290,20 @@
void median_dir(const Image<I>& input, unsigned dir, unsigned length,
Image<O>& output)
{
+ trace::entering("level::median_dir");
+
+ mlc_is(mln_trait_image_io(O), trait::io::write)::check();
+ mlc_is(mln_trait_image_support(I), trait::support::aligned)::check();
+ mlc_converts_to(mln_value(I), mln_value(O))::check();
+
mln_precondition(exact(output).domain() == exact(input).domain());
typedef mln_point(I) P;
mln_precondition(dir < P::dim);
mln_precondition(length % 2 == 1);
+
impl::median_dir_(exact(input), dir, length, exact(output));
+
+ trace::exiting("level::median_dir");
}
# endif // ! MLN_INCLUDE_ONLY
Index: trunk/milena/mln/canvas/browsing/dir_ricard51.hh
===================================================================
--- trunk/milena/mln/canvas/browsing/dir_ricard51.hh (revision 0)
+++ trunk/milena/mln/canvas/browsing/dir_ricard51.hh (revision 1239)
@@ -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_CANVAS_DIR_RICARD51_HH
+# define MLN_CANVAS_DIR_RICARD51_HH
+
+/*! \file mln/canvas/dir_ricard51.hh
+ *
+ * \brief Dir_Ricard51 browsing of an image.
+ */
+
+# include <mln/core/concept/browsing.hh>
+# include <mln/core/concept/image.hh>
+
+namespace mln
+{
+
+ namespace canvas
+ {
+
+ namespace browsing
+ {
+
+ /*! FIXME : DOC
+ * F shall features : \n
+ * { \n
+ * --- as types: \n
+ * I; \n
+ * --- as attributes: \n
+ * dim; \n
+ * dir; // and test dir < dim \n
+ * input; \n
+ * p; \n
+ * length; \n
+ * --- as methods: \n
+ * void init(); \n
+ * void init_line(); \n
+ * void add_point(p) \n
+ * void remove_point(p) \n
+ * void next(); \n
+ * void final(); \n
+ * } \n
+ *
+ */
+ struct dir_ricard51_t : public Browsing< dir_ricard51_t >
+ {
+ template <typename F>
+ void operator()(F& f) const;
+ }
+
+ dir_ricard51;
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename F>
+ void
+ dir_ricard51_t::operator()(F& f) const
+ {
+ mln_precondition(f.dir < f.dim);
+ typedef typename F::I I;
+
+ const mln_point(I)
+ pmin = f.input.domain().pmin(),
+ pmax = f.input.domain().pmax();
+
+ const mln_coord(I)
+ pmin_dir = pmin[f.dir],
+ pmax_dir = pmax[f.dir],
+ pmin_dir_plus_half_length = pmin_dir + f.length / 2,
+ pmax_dir_minus_half_length = pmax_dir - f.length / 2;
+
+ mln_point(I) pt, pu;
+
+ typedef mln_coord(I)& coord_ref;
+ coord_ref
+ ct = pt[f.dir],
+ cu = pu[f.dir],
+ p_dir = f.p[f.dir];
+
+ f.p = pmin;
+
+ f.init();
+
+ do
+ {
+ pt = f.p;
+ pu = f.p;
+
+ f.init_line();
+
+ // initialization (before first point of the line)
+ for (ct = pmin_dir; ct < pmin_dir_plus_half_length; ++ ct)
+ if (f.input.has(pt))
+ f.add_point(pt);
+
+ // left columns (just take new points)
+ for (p_dir = pmin_dir; p_dir <= pmin_dir_plus_half_length; ++p_dir, ++ct)
+ {
+ if (f.input.has(pt))
+ f.add_point(pt);
+ f.next();
+ }
+
+ // middle columns (both take and untake)
+ cu = pmin_dir;
+ for (; p_dir <= pmax_dir_minus_half_length; ++cu, ++p_dir, ++ct)
+ {
+ if (f.input.has(pt))
+ f.add_point(pt);
+ if (f.input.has(pu))
+ f.remove_point(pu);
+ f.next();
+ }
+
+ // right columns (now just untake old points)
+ for (; p_dir <= pmax_dir; ++cu, ++p_dir)
+ {
+ if (f.input.has(pu))
+ f.remove_point(pu);
+ f.next();
+ }
+
+ p_dir = pmin_dir;
+
+ for (int c = F::dim - 1; c >= 0; --c)
+ {
+ if (c == int(f.dir))
+ continue;
+ if (f.p[c] != pmax[c])
+ {
+ ++f.p[c];
+ break;
+ }
+ f.p[c] = pmin[c];
+ }
+ } while (f.p != pmin);
+
+ f.final();
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::canvas::browsing
+
+ } // end of namespace mln::canvas
+
+} // end of namespace mln
+
+#endif // ! MLN_CANVAS_DIR_RICARD51_HH
Index: trunk/milena/mln/canvas/browsing/directional.hh
===================================================================
--- trunk/milena/mln/canvas/browsing/directional.hh (revision 1238)
+++ trunk/milena/mln/canvas/browsing/directional.hh (revision 1239)
@@ -25,10 +25,10 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_CANVAS_DIRBROWSING_HH
-# define MLN_CANVAS_DIRBROWSING_HH
+#ifndef MLN_CANVAS_DIRECTIONAL_HH
+# define MLN_CANVAS_DIRECTIONAL_HH
-/*! \file mln/canvas/dirbrowsing.hh
+/*! \file mln/canvas/browsing/directional.hh
*
* \brief Directional browsing of an image.
*/
@@ -115,4 +115,4 @@
} // end of namespace mln
-#endif // ! MLN_CANVAS_DIRBROWSING_HH
+#endif // ! MLN_CANVAS_DIRECTIONAL_HH