https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add front computation of distance and influence zone.
* mln/transform/internal: New directory.
* mln/transform/internal/all.hh: New.
* mln/transform/distance_geodesic.hh: Copy to...
* mln/transform/distance_front.hh: ...this new file.
Update.
* mln/transform/distance_geodesic.hh
(distance_functor): Move into...
* mln/transform/internal/distance_functor.hh: ...this new file.
Split decl and def.
* mln/transform/influence_zone_geodesic.hh
(iz_functor): Move into...
* mln/transform/internal/influence_zone_functor.hh: ...this new
file.
(iz_functor): Rename as...
(influence_zone_functor): ...this.
Split decl and def.
* mln/transform/distance.hh: Remove.
* mln/transform/influence_zone_front.hh: New.
* mln/transform/all.hh: Update.
* mln/canvas/distance_front.hh: New.
* mln/canvas/all.hh: Update.
* tests/transform/distance.cc: Copy to...
* tests/transform/influence_zone_front.cc: ...this new file.
(vals): Rename as...
(ws): ...this less ambiguous name.
Update.
* tests/transform/distance.cc: Rename as...
* tests/transform/distance_front.cc: ...this.
Update.
* tests/transform/Makefile.am: Update.
mln/canvas/all.hh | 17 +-
mln/canvas/distance_front.hh | 136 +++++++++--------------
mln/transform/all.hh | 3
mln/transform/distance_front.hh | 61 +++-------
mln/transform/distance_geodesic.hh | 30 -----
mln/transform/influence_zone_front.hh | 93 +++++++++++++++
mln/transform/influence_zone_geodesic.hh | 53 +++-----
mln/transform/internal/all.hh | 53 ++++++++
mln/transform/internal/distance_functor.hh | 101 +++++++++++++++++
mln/transform/internal/influence_zone_functor.hh | 105 +++++++++++++++++
tests/transform/Makefile.am | 6 -
tests/transform/distance_front.cc | 16 +-
tests/transform/influence_zone_front.cc | 29 ++--
13 files changed, 486 insertions(+), 217 deletions(-)
Index: tests/transform/influence_zone_front.cc
--- tests/transform/influence_zone_front.cc (revision 2983)
+++ tests/transform/influence_zone_front.cc (working copy)
@@ -25,19 +25,17 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/transform/distance.cc
- *
- * \brief Test on mln::transform::distance.
- */
+/// \file tests/transform/influence_zone_front.cc
+///
+/// Test on mln::transform::influence_zone_front.
#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/level/fill.hh>
#include <mln/debug/println.hh>
-#include <mln/transform/distance.hh>
+#include <mln/transform/influence_zone_front.hh>
int main()
@@ -45,17 +43,24 @@
using namespace mln;
using value::int_u8;
- image2d<bool> input(9, 9);
- level::fill(input, false);
- input.at(4, 4) = true;
+ int_u8 vals[] =
+ { 1, 1, 0, 0, 0, 0, 3,
+ 1, 1, 1, 0, 0, 0, 0,
+ 0, 1, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 2, 0,
+ 0, 0, 0, 0, 2, 2, 0,
+ 0, 0, 0, 0, 0, 0, 0 };
+ image2d<int_u8> input = make::image2d(vals);
- int vals[] = { 0, 9, 0, 9, 0,
+ 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 };
- image2d<int_u8> output = transform::distance(int_u8(), input,
- c4(), make::w_window2d_int(vals));
+ image2d<int_u8> output;
+ output = transform::influence_zone_front(input,
+ c4(), make::w_window2d_int(ws));
debug::println(output);
}
Property changes on: tests/transform/influence_zone_front.cc
___________________________________________________________________
Added: svn:mergeinfo
Index: tests/transform/distance_front.cc
--- tests/transform/distance_front.cc (revision 2981)
+++ tests/transform/distance_front.cc (working copy)
@@ -25,10 +25,9 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/transform/distance.cc
- *
- * \brief Test on mln::transform::distance.
- */
+/// \file tests/transform/distance_front.cc
+///
+/// Test on mln::transform::distance_front.
#include <mln/core/image/image2d.hh>
#include <mln/core/alias/neighb2d.hh>
@@ -37,7 +36,7 @@
#include <mln/level/fill.hh>
#include <mln/debug/println.hh>
-#include <mln/transform/distance.hh>
+#include <mln/transform/distance_front.hh>
int main()
@@ -49,13 +48,14 @@
level::fill(input, false);
input.at(4, 4) = true;
- int vals[] = { 0, 9, 0, 9, 0,
+ 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 };
- image2d<int_u8> output = transform::distance(int_u8(), input,
- c4(), make::w_window2d_int(vals));
+ image2d<int_u8> output = transform::distance_front(input,
+ c4(), make::w_window2d_int(ws),
+ int_u8(18));
debug::println(output);
}
Property changes on: tests/transform/distance_front.cc
___________________________________________________________________
Added: svn:mergeinfo
Index: tests/transform/Makefile.am
--- tests/transform/Makefile.am (revision 2984)
+++ tests/transform/Makefile.am (working copy)
@@ -3,12 +3,14 @@
include $(top_srcdir)/milena/tests/tests.mk
check_PROGRAMS = \
- distance \
+ distance_front \
distance_geodesic \
+ influence_zone_front \
influence_zone_geodesic
-distance_SOURCES = distance.cc
+distance_front_SOURCES = distance_front.cc
distance_geodesic_SOURCES = distance_geodesic.cc
+influence_zone_front_SOURCES = influence_zone_front.cc
influence_zone_geodesic_SOURCES = influence_zone_geodesic.cc
TESTS = $(check_PROGRAMS)
Index: mln/transform/distance_front.hh
--- mln/transform/distance_front.hh (revision 2981)
+++ mln/transform/distance_front.hh (working copy)
@@ -25,14 +25,15 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_TRANSFORM_DISTANCE_GEODESIC_HH
-# define MLN_TRANSFORM_DISTANCE_GEODESIC_HH
+#ifndef MLN_TRANSFORM_DISTANCE_FRONT_HH
+# define MLN_TRANSFORM_DISTANCE_FRONT_HH
-/// \file mln/transform/distance_geodesic.hh
+/// \file mln/transform/distance_front.hh
///
-/// Discrete geodesic distance transform.
+/// Discrete front distance transform.
-# include <mln/canvas/distance_geodesic.hh>
+# include <mln/canvas/distance_front.hh>
+# include <mln/transform/internal/distance_functor.hh>
@@ -42,58 +43,32 @@
namespace transform
{
- /// Discrete geodesic distance transform.
- template <typename I, typename N, typename D>
+ /// Discrete front distance transform.
+ template <typename I, typename N, typename W, typename D>
mln_ch_value(I, D)
- distance_geodesic(const Image<I>& input, const Neighborhood<N>& nbh, D max);
+ distance_front(const Image<I>& input,
+ const Neighborhood<N>& nbh, const Weighted_Window<W>& w_win, D max);
# ifndef MLN_INCLUDE_ONLY
-
- namespace internal
- {
-
- template <typename I>
- struct distance_functor
- {
- typedef mln_value(I) V;
- typedef mln_site(I) P;
-
- void init(const I&)
- {
- }
- bool inqueue_p_wrt_input_p(const V& input_p)
- {
- return input_p == true;
- }
- bool inqueue_p_wrt_input_n(const V& input_n)
- {
- return input_n == false;
- }
- void process(const P&, const P&)
- {
- }
- };
-
- } // end of namespace mln::transform::internal
-
-
- template <typename I, typename N, typename D>
+ template <typename I, typename N, typename W, typename D>
inline
mln_ch_value(I, D)
- distance_geodesic(const Image<I>& input, const Neighborhood<N>& nbh, D max)
+ distance_front(const Image<I>& input,
+ const Neighborhood<N>& nbh, const Weighted_Window<W>& w_win, D max)
{
- trace::entering("transform::distance_geodesic");
+ trace::entering("transform::distance_front");
mln_precondition(exact(input).has_data());
// mln_precondition(exact(nbh).is_valid());
+ // mln_precondition(exact(w_win).is_valid());
mln_ch_value(I, D) output;
internal::distance_functor<I> f;
- output = mln::canvas::distance_geodesic(input, nbh, max, f);
+ output = mln::canvas::distance_front(input, nbh, w_win, max, f);
- trace::exiting("transform::distance_geodesic");
+ trace::exiting("transform::distance_front");
return output;
}
@@ -104,4 +79,4 @@
} // end of namespace mln
-#endif // ! MLN_TRANSFORM_DISTANCE_GEODESIC_HH
+#endif // ! MLN_TRANSFORM_DISTANCE_FRONT_HH
Property changes on: mln/transform/distance_front.hh
___________________________________________________________________
Added: svn:mergeinfo
Index: mln/transform/influence_zone_geodesic.hh
--- mln/transform/influence_zone_geodesic.hh (revision 2984)
+++ mln/transform/influence_zone_geodesic.hh (working copy)
@@ -30,10 +30,10 @@
/// \file mln/transform/influence_zone_geodesic.hh
///
-/// Discrete geodesic distance transform.
+/// Geodesic influence zone transform.
# include <mln/canvas/distance_geodesic.hh>
-# include <mln/literal/zero.hh>
+# include <mln/transform/internal/influence_zone_functor.hh>
namespace mln
@@ -42,45 +42,21 @@
namespace transform
{
- /// Discrete geodesic distance transform.
+ /// Geodesic influence zone transform.
template <typename I, typename N, typename D>
mln_concrete(I)
- influence_zone_geodesic(const Image<I>& input, const Neighborhood<N>& nbh, D max);
+ influence_zone_geodesic(const Image<I>& input,
+ const Neighborhood<N>& nbh, D max);
-# ifndef MLN_INCLUDE_ONLY
-
- namespace internal
- {
-
- template <typename I>
- struct iz_functor
- {
- typedef mln_value(I) V;
- typedef mln_site(I) P;
-
- mln_concrete(I) output;
+ /// Geodesic influence zone transform.
+ template <typename I, typename N>
+ mln_concrete(I)
+ influence_zone_geodesic(const Image<I>& input, const Neighborhood<N>& nbh);
- void init(const I& input)
- {
- output = clone(input);
- }
- bool inqueue_p_wrt_input_p(const V& input_p)
- {
- return input_p != 0u;
- }
- bool inqueue_p_wrt_input_n(const V& input_n)
- {
- return input_n == 0u;
- }
- void process(const P& p, const P& n)
- {
- output(n) = output(p);
- }
- };
- } // end of namespace mln::transform::internal
+# ifndef MLN_INCLUDE_ONLY
template <typename I, typename N, typename D>
mln_concrete(I)
@@ -92,13 +68,20 @@
mln_precondition(exact(input).has_data());
// mln_precondition(exact(nbh).is_valid());
- internal::iz_functor<I> f;
+ internal::influence_zone_functor<I> f;
(void) mln::canvas::distance_geodesic(input, nbh, max, f);
trace::exiting("transform::influence_zone_geodesic");
return f.output;
}
+ template <typename I, typename N>
+ mln_concrete(I)
+ influence_zone_geodesic(const Image<I>& input, const Neighborhood<N>& nbh)
+ {
+ return influence_zone_geodesic(input, nbh, mln_max(unsigned));
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::transform
Index: mln/transform/all.hh
--- mln/transform/all.hh (revision 2984)
+++ mln/transform/all.hh (working copy)
@@ -42,8 +42,9 @@
} // end of namespace mln
-# include <mln/transform/distance.hh>
+# include <mln/transform/distance_front.hh>
# include <mln/transform/distance_geodesic.hh>
+# include <mln/transform/influence_zone_front.hh>
# include <mln/transform/influence_zone_geodesic.hh>
Index: mln/transform/influence_zone_front.hh
--- mln/transform/influence_zone_front.hh (revision 0)
+++ mln/transform/influence_zone_front.hh (revision 0)
@@ -0,0 +1,93 @@
+// 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_TRANSFORM_INFLUENCE_ZONE_FRONT_HH
+# define MLN_TRANSFORM_INFLUENCE_ZONE_FRONT_HH
+
+/// \file mln/transform/influence_zone_front.hh
+///
+/// Influence zone transform.
+
+# include <mln/canvas/distance_front.hh>
+# include <mln/transform/internal/influence_zone_functor.hh>
+
+
+namespace mln
+{
+
+ namespace transform
+ {
+
+ /// Influence zone transform.
+ template <typename I, typename N, typename W, typename D>
+ mln_concrete(I)
+ influence_zone_front(const Image<I>& input,
+ const Neighborhood<N>& nbh, const Weighted_Window<W>& w_win, D max);
+
+ /// Influence zone transform.
+ template <typename I, typename N, typename W>
+ mln_concrete(I)
+ influence_zone_front(const Image<I>& input,
+ const Neighborhood<N>& nbh, const Weighted_Window<W>& w_win);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I, typename N, typename W, typename D>
+ mln_concrete(I)
+ influence_zone_front(const Image<I>& input,
+ const Neighborhood<N>& nbh, const Weighted_Window<W>& w_win, D max)
+ {
+ trace::entering("transform::influence_zone_front");
+
+ mln_precondition(exact(input).has_data());
+ // mln_precondition(exact(nbh).is_valid());
+ // mln_precondition(exact(w_win).is_valid());
+
+ internal::influence_zone_functor<I> f;
+ (void) mln::canvas::distance_front(input, nbh, w_win, max, f);
+
+ trace::exiting("transform::influence_zone_front");
+ return f.output;
+ }
+
+ template <typename I, typename N, typename W>
+ mln_concrete(I)
+ influence_zone_front(const Image<I>& input,
+ const Neighborhood<N>& nbh, const Weighted_Window<W>& w_win)
+ {
+ return influence_zone_front(input, nbh, w_win, mln_max(unsigned));
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::transform
+
+} // end of namespace mln
+
+
+#endif // ! MLN_TRANSFORM_INFLUENCE_ZONE_FRONT_HH
Index: mln/transform/distance_geodesic.hh
--- mln/transform/distance_geodesic.hh (revision 2984)
+++ mln/transform/distance_geodesic.hh (working copy)
@@ -33,6 +33,7 @@
/// Discrete geodesic distance transform.
# include <mln/canvas/distance_geodesic.hh>
+# include <mln/transform/internal/distance_functor.hh>
@@ -50,35 +51,6 @@
# ifndef MLN_INCLUDE_ONLY
-
- namespace internal
- {
-
- template <typename I>
- struct distance_functor
- {
- typedef mln_value(I) V;
- typedef mln_site(I) P;
-
- void init(const I&)
- {
- }
- bool inqueue_p_wrt_input_p(const V& input_p)
- {
- return input_p == true;
- }
- bool inqueue_p_wrt_input_n(const V& input_n)
- {
- return input_n == false;
- }
- void process(const P&, const P&)
- {
- }
- };
-
- } // end of namespace mln::transform::internal
-
-
template <typename I, typename N, typename D>
inline
mln_ch_value(I, D)
Index: mln/transform/internal/influence_zone_functor.hh
--- mln/transform/internal/influence_zone_functor.hh (revision 0)
+++ mln/transform/internal/influence_zone_functor.hh (revision 0)
@@ -0,0 +1,105 @@
+// 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_TRANSFORM_INTERNAL_INFLUENCE_ZONE_FUNCTOR_HH
+# define MLN_TRANSFORM_INTERNAL_INFLUENCE_ZONE_FUNCTOR_HH
+
+/// \file mln/transform/internal/influence_zone_functor.hh
+///
+/// Influence zone functor.
+
+# include <mln/core/routine/clone.hh>
+
+
+
+namespace mln
+{
+
+ namespace transform
+ {
+
+ namespace internal
+ {
+
+ template <typename I>
+ struct influence_zone_functor
+ {
+ typedef mln_value(I) V;
+ typedef mln_site(I) P;
+
+ mln_concrete(I) output;
+
+ void init(const I& input);
+ bool inqueue_p_wrt_input_p(const V& input_p);
+ bool inqueue_p_wrt_input_n(const V& input_n);
+ void process(const P& p, const P& n);
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I>
+ inline
+ void
+ influence_zone_functor<I>::init(const I& input)
+ {
+ output = clone(input);
+ }
+
+ template <typename I>
+ inline
+ bool
+ influence_zone_functor<I>::inqueue_p_wrt_input_p(const V& input_p)
+ {
+ return input_p != 0u;
+ }
+
+ template <typename I>
+ inline
+ bool
+ influence_zone_functor<I>::inqueue_p_wrt_input_n(const V& input_n)
+ {
+ return input_n == 0u;
+ }
+
+ template <typename I>
+ inline
+ void influence_zone_functor<I>::process(const P& p, const P& n)
+ {
+ output(n) = output(p);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::transform::internal
+
+ } // end of namespace mln::transform
+
+} // end of namespace mln
+
+
+#endif // ! MLN_TRANSFORM_INTERNAL_INFLUENCE_ZONE_FUNCTOR_HH
Index: mln/transform/internal/all.hh
--- mln/transform/internal/all.hh (revision 0)
+++ mln/transform/internal/all.hh (revision 0)
@@ -0,0 +1,53 @@
+// 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_TRANSFORM_INTERNAL_ALL_HH
+# define MLN_TRANSFORM_INTERNAL_ALL_HH
+
+/// \file mln/transform/internal/all.hh
+///
+/// File that includes all internals of mln/transform.
+
+
+namespace mln
+{
+
+ namespace transform
+ {
+
+ namespace internal {}
+
+ } // end of namespace mln::transform
+
+} // end of namespace mln
+
+
+# include <mln/transform/internal/distance_functor.hh>
+# include <mln/transform/internal/influence_zone_functor.hh>
+
+
+#endif // ! MLN_TRANSFORM_INTERNAL_ALL_HH
Index: mln/transform/internal/distance_functor.hh
--- mln/transform/internal/distance_functor.hh (revision 0)
+++ mln/transform/internal/distance_functor.hh (revision 0)
@@ -0,0 +1,101 @@
+// 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_TRANSFORM_INTERNAL_DISTANCE_FUNCTOR_HH
+# define MLN_TRANSFORM_INTERNAL_DISTANCE_FUNCTOR_HH
+
+/// \file mln/transform/internal/distance_functor.hh
+///
+/// Distance functor.
+
+# include <mln/core/macros.hh>
+
+
+
+namespace mln
+{
+
+ namespace transform
+ {
+
+ namespace internal
+ {
+
+ template <typename I>
+ struct distance_functor
+ {
+ typedef mln_value(I) V;
+ typedef mln_site(I) P;
+
+ void init(const I&);
+ bool inqueue_p_wrt_input_p(const V& input_p);
+ bool inqueue_p_wrt_input_n(const V& input_n);
+ void process(const P&, const P&);
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I>
+ inline
+ void
+ distance_functor<I>::init(const I&)
+ {
+ }
+
+ template <typename I>
+ inline
+ bool
+ distance_functor<I>::inqueue_p_wrt_input_p(const V& input_p)
+ {
+ return input_p == true;
+ }
+
+ template <typename I>
+ inline
+ bool
+ distance_functor<I>::inqueue_p_wrt_input_n(const V& input_n)
+ {
+ return input_n == false;
+ }
+
+ template <typename I>
+ inline
+ void distance_functor<I>::process(const P&, const P&)
+ {
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::transform::internal
+
+ } // end of namespace mln::transform
+
+} // end of namespace mln
+
+
+#endif // ! MLN_TRANSFORM_INTERNAL_DISTANCE_FUNCTOR_HH
Index: mln/canvas/distance_front.hh
--- mln/canvas/distance_front.hh (revision 2981)
+++ mln/canvas/distance_front.hh (working copy)
@@ -25,14 +25,12 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_TRANSFORM_DISTANCE_HH
-# define MLN_TRANSFORM_DISTANCE_HH
+#ifndef MLN_CANVAS_DISTANCE_FRONT_HH
+# define MLN_CANVAS_DISTANCE_FRONT_HH
-/// \file mln/transform/distance.hh
+/// \file mln/canvas/distance_front.hh
///
-/// Discrete distance transform.
-///
-/// \todo Make a canvas out of it.
+/// Discrete distance canvas by front propagation.
# include <vector>
# include <mln/core/concept/image.hh>
@@ -42,78 +40,76 @@
# include <mln/accu/max.hh>
-
namespace mln
{
- namespace transform
+ namespace canvas
{
- /*! Discrete distance transform.
- *
- * FIXME: doc.
- */
- template <typename D, typename I, typename N, typename W>
+ /// Discrete distance canvas by front propagation.
+ template <typename I,
+ typename N, typename W, typename D,
+ typename F>
mln_ch_value(I, D)
- distance(D, const Image<I>& input,
- const Neighborhood<N>& nbh, const Weighted_Window<W>& w_win);
+ distance_front(const Image<I>& input,
+ const Neighborhood<N>& nbh, const Weighted_Window<W>& w_win, D max,
+ F& functor);
# ifndef MLN_INCLUDE_ONLY
- namespace impl
- {
-
- namespace generic
- {
- template <typename D, typename I, typename N, typename W>
+ template <typename I,
+ typename N, typename W, typename D,
+ typename F>
+ inline
mln_ch_value(I, D)
- distance(D, const Image<I>& input_,
- const Neighborhood<N>& nbh_, const Weighted_Window<W>& w_win_)
+ distance_front(const Image<I>& input_,
+ const Neighborhood<N>& nbh_, const Weighted_Window<W>& w_win_, D max,
+ F& functor)
{
- trace::entering("transform::impl::generic::distance");
+ trace::entering("canvas::distance_front");
const I& input = exact(input_);
const N& nbh = exact(nbh_);
const W& w_win = exact(w_win_);
mln_precondition(input.has_data());
-
- const D Max = mln_max(D);
+ // mln_precondition(w_win.is_valid());
typedef mln_site(I) P;
typedef std::vector<P> bucket_t;
- mln_ch_value(I, D) output;
- initialize(output, input);
- level::fill(output, Max);
+ // Distance map.
+ mln_ch_value(I, D) dmap;
+ initialize(dmap, input);
+ level::fill(dmap, max);
- // Modulus determination.
+ // Mod determination.
unsigned mod;
{
- mln::accu::max<unsigned> accu;
- P p;
- mln_qiter(W) q(w_win, p);
- for_all(q)
- accu.take(q.w());
- mod = accu.to_result() + 1;
+ accu::max<unsigned> m;
+ for (unsigned i = 0; i < w_win.size(); ++i)
+ m.take(w_win.w(i));
+ mod = unsigned(m) + 1;
}
- std::vector<bucket_t> bucket;
- bucket.resize(mod);
+ // 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 (input(p) == true)
+ if (functor.inqueue_p_wrt_input_p(input(p))) // <-- inqueue_p_wrt_input_p
{
- output(p) = literal::zero;
+ dmap(p) = 0;
for_all(n)
- if (input.domain().has(n) && input(n) == false)
+ 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;
@@ -126,30 +122,32 @@
{
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 (output(p) < d)
+
+ 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 (output.domain().has(q) && output(q) > d)
+ if (dmap.domain().has(q) && dmap(q) > d)
{
- if (unsigned(Max - q.w()) < d) // Saturation => Stop!
- {
- // trace::warning...
- trace::exiting("transform::impl::generic::distance");
- return output;
- }
unsigned d_ = d + q.w();
-
- if (d_ < output(q))
+ if (d_ < dmap(q))
{
- output(q) = d_;
+ dmap(q) = d_;
+ functor.process(p, q); // <- process
bucket[d_ % mod].push_back(q);
++bucket_size;
}
@@ -158,41 +156,17 @@
bucket_size -= bucket_d.size();
bucket_d.clear();
}
- }
-
- trace::exiting("transform::impl::generic::distance");
- return output;
+ trace::exiting("canvas::distance_front");
+ return dmap;
}
-
- } // end of namespace mln::transform::impl::generic
-
- } // end of namespace mln::transform::impl
-
-
- // Facade.
-
- template <typename D, typename I, typename N, typename W>
- inline
- mln_ch_value(I, D)
- distance(D, const Image<I>& input,
- const Neighborhood<N>& nbh, const Weighted_Window<W>& w_win)
- {
- trace::entering("transform::distance");
-
- // FIXME: tests.
- mln_ch_value(I, D) output = impl::generic::distance(D(), input,
- nbh, w_win);
-
- trace::exiting("transform::distance");
- return output;
}
# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace mln::transform
+ } // end of namespace mln::canvas
} // end of namespace mln
-#endif // ! MLN_TRANSFORM_DISTANCE_HH
+#endif // ! MLN_CANVAS_DISTANCE_FRONT_HH
Property changes on: mln/canvas/distance_front.hh
___________________________________________________________________
Added: svn:mergeinfo
Index: mln/canvas/all.hh
--- mln/canvas/all.hh (revision 2984)
+++ mln/canvas/all.hh (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// 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
@@ -28,10 +29,9 @@
#ifndef MLN_CANVAS_ALL_HH
# define MLN_CANVAS_ALL_HH
-/*! \file mln/canvas/all.hh
- *
- * \brief File that includes all canvas-related routines.
- */
+/// \file mln/canvas/all.hh
+///
+/// File that includes all canvas-related routines.
namespace mln
@@ -40,15 +40,20 @@
/// Namespace of canvas.
namespace canvas
{
+
/// Implementation namespace of canvas namespace.
namespace impl {}
- }
}
+}
+
# include <mln/canvas/browsing/all.hh>
# include <mln/canvas/morpho/all.hh>
# include <mln/canvas/chamfer.hh>
+# include <mln/canvas/distance_front.hh>
+# include <mln/canvas/distance_geodesic.hh>
# include <mln/canvas/labeling.hh>
+
#endif // ! MLN_CANVAS_ALL_HH
* doc/Doxyfile.in: add a missing example path.
* doc/tutorial/outputs/ima2d-decl-2-blobs.txt: remove since
generated.
* doc/tutorial/tutorial.tex: fix wrong includes.
---
milena/ChangeLog | 14 +++++++-
milena/doc/Doxyfile.in | 1 +
milena/doc/tutorial/outputs/ima2d-decl-2-blobs.txt | 7 ----
milena/doc/tutorial/tutorial.tex | 36 ++++++++++----------
4 files changed, 32 insertions(+), 26 deletions(-)
delete mode 100644 milena/doc/tutorial/outputs/ima2d-decl-2-blobs.txt
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 6913b27..8fa2f02 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,15 @@
+2008-12-02 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Fix tutorial generation.
+
+ * doc/Doxyfile.in: add a missing example path.
+
+ * doc/tutorial/outputs/ima2d-decl-2-blobs.txt: remove since
+ generated.
+
+ * doc/tutorial/tutorial.tex: fix wrong includes.
+
+
2008-12-01 Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Make doc examples tuto_one compile again.
@@ -52,7 +64,7 @@
Fix more tests.
* mln/accu/count_adjacent_vertices.hh: make it work with the
-new graph images.
+ new graph images.
* mln/accu/median_alt.hh: fix compilation issue.
diff --git a/milena/doc/Doxyfile.in b/milena/doc/Doxyfile.in
index e56c529..bc28c77 100644
--- a/milena/doc/Doxyfile.in
+++ b/milena/doc/Doxyfile.in
@@ -86,6 +86,7 @@ EXCLUDE_SYMLINKS = YES
EXCLUDE_PATTERNS = *spe.hh
EXCLUDE_SYMBOLS =
EXAMPLE_PATH = @top_srcdir@/milena/doc/tutorial/samples \
+ @top_builddir@/milena/doc/tutorial/samples \
@top_builddir@/milena/doc/tutorial/outputs \
@top_builddir@/milena/doc/tutorial/outputs/splitted \
@top_srcdir@/milena/doc/tutorial/outputs
diff --git a/milena/doc/tutorial/outputs/ima2d-decl-2-blobs.txt b/milena/doc/tutorial/outputs/ima2d-decl-2-blobs.txt
deleted file mode 100644
index b48c715..0000000
--- a/milena/doc/tutorial/outputs/ima2d-decl-2-blobs.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-0 1 1 0 0
-0 1 1 0 0
-0 0 0 0 0
-2 2 0 3 0
-2 0 3 3 3
-2 0 0 0 0
-
diff --git a/milena/doc/tutorial/tutorial.tex b/milena/doc/tutorial/tutorial.tex
index 49ef8a1..1c4bb16 100644
--- a/milena/doc/tutorial/tutorial.tex
+++ b/milena/doc/tutorial/tutorial.tex
@@ -94,9 +94,9 @@ showstringspaces=false,linewidth=14cm}
\backslash htmlonly%
}
-\newcommand{\doxyfigure}[2]{
+\newcommand{\doxyfigure}[3][1]{
\backslash endhtmlonly%
-\backslash image html #1.png%
+\backslash image html #2-#1.png%
\backslash htmlonly%
}
@@ -122,8 +122,8 @@ $$
\renewcommand{\doxyrawcode}[1]{\lstinputlisting[frame=single]{samples/#1.cc.raw}}
\renewcommand{\doxyoutput}[1]{\lstinputlisting[frame=single]{outputs/#1.txt}}
\renewcommand{\doxymoutput}[2][1]{\lstinputlisting[frame=single]{outputs/splitted/#2-#1.txt}}
-\renewcommand{\doxyfigure}[2]{%
-\pgfimage[width=#2]{figures/#1}%
+\renewcommand{\doxyfigure}[3][1]{%
+\pgfimage[width=#3]{figures/#2-#1}%
\label{#1}%
}
\renewenvironment{doxymath}
@@ -800,7 +800,7 @@ Output:
\bigskip
\begin{tabular}{c c}
-\doxyfigure{ima2d-rot-1}{3cm} & \doxyfigure{ima2d-rot-2}{3cm} \\
+\doxyfigure[1]{ima2d-rot}{3cm} & \doxyfigure[2]{ima2d-rot}{3cm} \\
\multicolumn{2}{c}{\var{ima1} and its border before rotation (left) and \var{ima2}
and its border after rotation (right).} \\
\end{tabular}
@@ -1053,7 +1053,7 @@ These predefined neighborhood can be passed directly to a function. The headers
located in \header{mln/core/alias/neigh*.hh}.
Use case example:
-\doxycode{ima2d-decl-2-blobs}
+\doxycode[2]{labeling-compute}
\doxysubsection{customse}{Custom structural elements}
@@ -1439,7 +1439,7 @@ Consider the following image:
Output: \\
\begin{center}
-\doxyfigure{labeling-compute-1}{3cm}
+\doxyfigure[1]{labeling-compute}{3cm}
\end{center}
Then label this image thanks to \code{labeling::blobs()}:
@@ -1448,7 +1448,7 @@ Then label this image thanks to \code{labeling::blobs()}:
Output: \\
\begin{center}
-\doxyfigure{labeling-compute-2}{3cm}
+\doxyfigure[2]{labeling-compute}{3cm}
\end{center}
Note that this routine returns the number of components in its third parameter.
@@ -1480,14 +1480,14 @@ Example:
Make a binary image:
\doxycode[1]{logical-not}
\begin{center}
-\doxyfigure{logical-not-1}{3cm}
+\doxyfigure[1]{logical-not}{3cm}
\end{center}
Return the result in a new image:
\doxycode[2]{logical-not}
\begin{center}
\begin{tabular}{c c}
-\doxyfigure{logical-not-1}{3cm} & \doxyfigure{logical-not-2}{3cm} \\
+\doxyfigure[1]{logical-not}{3cm} & \doxyfigure[2]{logical-not}{3cm} \\
\multicolumn{2}{c}{\var{ima} (left) and \var{ima_neg} (right) after having
called logical::not\_().} \\
\end{tabular}
@@ -1497,7 +1497,7 @@ Or, work in place:
\doxycode[3]{logical-not}
Then, \var{ima} looks like:
\begin{center}
-\doxyfigure{logical-not-3}{3cm}
+\doxyfigure[3]{logical-not}{3cm}
\end{center}
@@ -1590,7 +1590,7 @@ Consider the following image:
Then label this image thanks to \code{labeling::blobs()}:
\doxycode[2]{labeling-compute}
Output:
-\doxymoutput[1]{labeling-compute}
+\doxyfigure[2]{labeling-compute}{3cm}
Then, use \code{labeling::compute()} with the bbox accumulator:
\doxycode[3]{labeling-compute}
@@ -1603,7 +1603,7 @@ In this case, it returns an array of \type{box2d}.
set the background to 0, we will want to iterate from 1 to nlabels included.
\doxycode[4]{labeling-compute}
Output:
-\doxymoutput[2]{labeling-compute}
+\doxyoutput{labeling-compute}
\subsection{Routines based on accumulators and *::compute()}
@@ -1670,7 +1670,7 @@ following declaration:
\doxycode[1]{fill-part-image}
Output:
\begin{center}
-\doxyfigure{fill-subdomain-1}{3cm}
+\doxyfigure[1]{fill-subdomain}{3cm}
\end{center}
\doxysubsection{restrictsiteset}{Restrict an image with a site set}
@@ -1688,7 +1688,7 @@ First, find and label the components.
\doxycode[2]{fill-subdomain}
Output:
\begin{center}
-\doxyfigure{fill-subdomain-2}{3cm}
+\doxyfigure[2]{fill-subdomain}{3cm}
\end{center}
Then, restrict the image to the sites being part of component 2.
@@ -1696,7 +1696,7 @@ Then, restrict the image to the sites being part of component 2.
\var{lbl\_2} is a new image. \var{lbl\_2} looks like:
\begin{center}
-\doxyfigure{fill-subdomain-3}{3cm}
+\doxyfigure[3]{fill-subdomain}{3cm}
\end{center}
Finally, create a new color image, fill it with black and fill the sites part of
@@ -1704,7 +1704,7 @@ component 2 with red.
\doxycode[4]{fill-subdomain}
Output:
\begin{center}
-\doxyfigure{fill-subdomain-4}{3cm}
+\doxyfigure[4]{fill-subdomain}{3cm}
\end{center}
The previous example can be written more quickly:
@@ -1722,7 +1722,7 @@ Restrict the image with it:
Output:
\begin{center}
-\doxyfigure{fill-subimage-cfun-1}{3cm}
+\doxyfigure[1]{fill-subimage-cfun}{3cm}
\end{center}
%
\medskip
--
1.5.6.5