URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2008-02-21 Etienne FOLIO <folio(a)lrde.epita.fr>
Chamfer DT algorithm.
* sandbox/folio/chamfer_dt.cc: Chamfer DT algorithm (with test).
* sandbox/folio/dmap.cc: Unsignificative modification.
---
chamfer_dt.cc | 116 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
dmap.cc | 1
2 files changed, 116 insertions(+), 1 deletion(-)
Index: trunk/milena/sandbox/folio/chamfer_dt.cc
===================================================================
--- trunk/milena/sandbox/folio/chamfer_dt.cc (revision 0)
+++ trunk/milena/sandbox/folio/chamfer_dt.cc (revision 1747)
@@ -0,0 +1,116 @@
+// 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.
+
+#include <iostream>
+
+#include <mln/core/image2d.hh>
+#include <mln/level/fill.hh>
+#include <mln/debug/println.hh>
+#include <mln/make/win_chamfer.hh>
+#include <mln/accu/min.hh>
+
+#ifndef CHAMFER_DT_HH
+# define CHAMFER_DT_HH
+
+namespace mln
+{
+ template<typename I>
+ inline
+ mln_ch_value(I, float)
+ chamfer_dt(const Image<I>& input_)
+ {
+ const I& input = exact(input_);
+ mln_precondition(input.has_data());
+
+ mln_ch_value(I, float) output;
+ initialize(output, input);
+
+ accu::min_<int> min;
+ w_window2d_int chamferTop = make::mk_chamfer_3x3_int<3, 4>();
+
+ // initialization
+ {
+ mln_fwd_piter(I) p(input.domain());
+ for_all(p)
+ output(p) = input(p) ? 0 : mln_max(int);
+ }
+
+ // First pass.
+ {
+ mln_fwd_piter(I) p(input.domain());
+ mln_qiter(w_window2d_int) q(chamferTop, p);
+ for_all(p)
+ {
+ min.init();
+ for_all(q)
+ if (input.has(q) && output(q) != mln_max(int))
+ min.take(output(q) + q.w());
+ if (output(p) != mln_max(int))
+ min.take(output(p));
+ output(p) = min.to_result();
+ }
+ }
+
+ // Second pass.
+ {
+ w_window2d_int chamferBottom = chamferTop.sym();
+ mln_bkd_piter(I) p(input.domain());
+ mln_qiter(w_window2d_int) q(chamferBottom, p);
+ for_all(p)
+ {
+ min.init();
+ for_all(q)
+ if (input.has(q) && output(q) != mln_max(int))
+ min.take(output(q) + q.w());
+ if (output(p) != mln_max(int))
+ min.take(output(p));
+ output(p) = min.to_result();
+ }
+ }
+
+ return output;
+ }
+}
+
+#endif /* ! CHAMFER_DT_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 };
+
+ level::fill(ima, vals);
+
+ debug::println(ima);
+ debug::println(chamfer_dt(ima));
+}
Index: trunk/milena/sandbox/folio/dmap.cc
===================================================================
--- trunk/milena/sandbox/folio/dmap.cc (revision 1746)
+++ trunk/milena/sandbox/folio/dmap.cc (revision 1747)
@@ -4,7 +4,6 @@
#include <mln/debug/println.hh>
#include <mln/accu/min.hh>
#include <mln/norm/l2.hh>
-// #include <mln/literal/zero.hh>
namespace mln
{
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Have graph_image<P,V> work with V = bool as well.
* mln/core/graph_image.hh
(graph_image<P,V>::lvalue, graph_image<P,V>::rvalue):
Redefine using std::vector's associated types `reference' and
`const_reference', so as to be able to form references on the
elements of the image when its value type is `bool'.
Use these associated types as return types for...
(graph_image<P,V>::operator()(const graph_psite<P>&))
(graph_image<P,V>::operator()(const graph_psite<P>&) const):
...these operators.
graph_image.hh | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
Index: mln/core/graph_image.hh
--- mln/core/graph_image.hh (revision 1745)
+++ mln/core/graph_image.hh (working copy)
@@ -104,10 +104,15 @@
typedef V value;
/// Return type of read-write access.
- typedef V& lvalue;
+ ///
+ /// We use the associated type \c reference instead of a plain
+ /// reference on th value type (\v V), because it's the only way
+ /// to safely form a reference on the element in the case of a
+ /// std::vector<bool>.
+ typedef typename std::vector<V>::reference lvalue;
/// Return type of read-only access.
- typedef const V& rvalue;
+ typedef typename std::vector<V>::const_reference rvalue;
/// Value set associated type.
typedef mln::value::set<value> vset;
@@ -127,10 +132,10 @@
void init_(const p_graph<P>& g, const std::vector<V>& val);
/// Read-only access of pixel value at point site \p p.
- const V& operator()(const graph_psite<P>& p) const;
+ rvalue operator()(const graph_psite<P>& p) const;
/// Read-write access of pixel value at point site \p p.
- V& operator()(const graph_psite<P>& p);
+ lvalue operator()(const graph_psite<P>& p);
/// Accessors.
/// \{
@@ -234,7 +239,7 @@
template <typename P, typename V>
inline
- const V&
+ typename graph_image<P, V>::rvalue
graph_image<P, V>::operator()(const graph_psite<P>& p) const
{
mln_precondition(&p.pg() == &this->data_->pg_);
@@ -244,7 +249,7 @@
template <typename P, typename V>
inline
- V&
+ typename graph_image<P, V>::lvalue
graph_image<P, V>::operator()(const graph_psite<P>& p)
{
mln_precondition(&p.pg() == &this->data_->pg_);
Git'll probably be useful for those cases... :P
URL : https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
===================================================================
--- ChangeLog (revision 1744)
+++ ChangeLog (revision 1745)
@@ -11,6 +11,7 @@
(line_graph_image<P,V>::operator()(const line_graph_psite<P>&))
(line_graph_image<P,V>::operator()(const line_graph_psite<P>&) const):
...these operators.
+ Suggested by Alexandre Duret-Lutz.
* mln/morpho/level_components.hh (morpho::level_components):
Remove the kludge: actually use an image of `bool' instead of an
image of `int' to tick the processed points.
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Have line_graph_image<P,V> work with V = bool.
* mln/core/line_graph_image.hh
(line_graph_image<P,V>::lvalue, line_graph_image<P,V>::rvalue):
Redefine using std::vector's associated types `reference' and
`const_reference', so as to be able to form references on the
elements of the image when its value type is `bool'.
Use these associated types as return types for...
(line_graph_image<P,V>::operator()(const line_graph_psite<P>&))
(line_graph_image<P,V>::operator()(const line_graph_psite<P>&) const):
...these operators.
* mln/morpho/level_components.hh (morpho::level_components):
Remove the kludge: actually use an image of `bool' instead of an
image of `int' to tick the processed points.
core/line_graph_image.hh | 17 +++++++++++------
morpho/level_components.hh | 12 +-----------
2 files changed, 12 insertions(+), 17 deletions(-)
Index: mln/core/line_graph_image.hh
--- mln/core/line_graph_image.hh (revision 1743)
+++ mln/core/line_graph_image.hh (working copy)
@@ -122,10 +122,15 @@
typedef V value;
/// Return type of read-write access.
- typedef V& lvalue;
+ ///
+ /// We use the associated type \c reference instead of a plain
+ /// reference on th value type (\v V), because it's the only way
+ /// to safely form a reference on the element in the case of a
+ /// std::vector<bool>.
+ typedef typename std::vector<V>::reference lvalue;
/// Return type of read-only access.
- typedef const V& rvalue;
+ typedef typename std::vector<V>::const_reference rvalue;
/// Value set associated type.
typedef mln::value::set<value> vset;
@@ -149,10 +154,10 @@
const std::vector<V>& edge_val);
/// Read-only access of pixel value at point site \p p.
- const V& operator()(const line_graph_psite<P>& p) const;
+ rvalue operator()(const line_graph_psite<P>& p) const;
/// Read-write access of pixel value at point site \p p.
- V& operator()(const line_graph_psite<P>& p);
+ lvalue operator()(const line_graph_psite<P>& p);
/// Accessors.
/// \{
@@ -271,7 +276,7 @@
template <typename P, typename V>
inline
- const V&
+ typename line_graph_image<P, V>::rvalue
line_graph_image<P, V>::operator()(const line_graph_psite<P>& p) const
{
mln_precondition(&p.plg() == &this->data_->plg_);
@@ -281,7 +286,7 @@
template <typename P, typename V>
inline
- V&
+ typename line_graph_image<P, V>::lvalue
line_graph_image<P, V>::operator()(const line_graph_psite<P>& p)
{
mln_precondition(&p.plg() == &this->data_->plg_);
Index: mln/morpho/level_components.hh
--- mln/morpho/level_components.hh (revision 1743)
+++ mln/morpho/level_components.hh (working copy)
@@ -99,17 +99,7 @@
const W& win = exact(win_);
mln_ch_value(I, DestValue) labels(input.domain());
- /* FIXME: Yet another KLUDGE, this time required by the
- specialization std::vector<bool>, which prevents forming
- (mutable) reference to any of its elements. This creates
- errors later with images using std::vector<bool> to store
- their data (e.g., line_graph_image<P, V>).
-
- Alas, we cannot prevent the compiler to use this
- specialization. Our workaround is simply... to use integers
- instead of booleans. */
-// mln_ch_value(I, bool) processed(input.domain());
- mln_ch_value(I, int) processed(input.domain());
+ mln_ch_value(I, bool) processed(input.domain());
level::fill (processed, false);
DestValue cur_label = mln_min(DestValue);
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Have `make all' behave as expected in tests/accu/.
* tests/accu/all.cc: Rename as...
* tests/accu/all_accus.cc: ...this, so that this test is not
confused with Make's `all' target.
Adjust.
Wrap long lines.
* tests/accu/Makefile.am: Adjust.
Makefile.am | 4 ++--
all_accus.cc | 12 +++++-------
2 files changed, 7 insertions(+), 9 deletions(-)
Index: tests/accu/Makefile.am
--- tests/accu/Makefile.am (revision 1741)
+++ tests/accu/Makefile.am (working copy)
@@ -3,7 +3,7 @@
include $(top_srcdir)/milena/tests/tests.mk
check_PROGRAMS = \
-all \
+ all_accus \
bbox \
compute \
count \
@@ -19,7 +19,7 @@
pair \
tuple
-all_SOURCES = all.cc
+all_accus_SOURCES = all_accus.cc
bbox_SOURCES = bbox.cc
compute_SOURCES = compute.cc
count_SOURCES = count.cc
Index: tests/accu/all_accus.cc
--- tests/accu/all_accus.cc (revision 1740)
+++ tests/accu/all_accus.cc (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,10 +25,8 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/accu/all.cc
- *
- * \brief Tests on all files in mln/accu.
- */
+/// \file tests/accu/all_accus.cc
+/// \brief Tests on all_accus files in mln/accu.
#include <mln/accu/all.hh>
#include <mln/core/point2d.hh>
@@ -40,7 +38,6 @@
using namespace mln;
using namespace mln::accu;
-
bbox<point2d> b;
count_<int> c;
histo< value::set<bool> > h;
@@ -48,7 +45,8 @@
mean_<int> me;
// median< value::set<bool> > med; // FIXME: bool has no min so workaround!
min_<int> mi;
- // min_h< value::set<bool> > mh; // OK: do not work since bool has no min/max :)
+ // min_h< value::set<bool> > mh; // OK: do not work since bool has
+ // no min/max :)
min_max_<int> mm;
nil n;
pair_< min_<int>, max_<int> > p;
https://svn.lrde.epita.fr/svn/oln/trunk
This should help our dear BuildBot to go a bit further (hopefully).
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Update the list of Makefiles to be configured.
* configure.ac: Configure milena/tests/fun/vv2v/Makefile.
configure.ac | 1 +
1 file changed, 1 insertion(+)
Index: configure.ac
--- configure.ac (revision 1740)
+++ configure.ac (working copy)
@@ -103,6 +103,7 @@
milena/tests/fun/p2b/Makefile
milena/tests/fun/p2v/Makefile
milena/tests/fun/v2v/Makefile
+ milena/tests/fun/vv2v/Makefile
milena/tests/fun/x2x/Makefile
milena/tests/geom/Makefile
milena/tests/histo/Makefile
On 19-02-2008, Roland Levillain <roland(a)lrde.epita.fr> wrote:
>
> Le 13 févr. 08 à 18:51, Michel Pellegrin a écrit :
>> Index: trunk/milena/sandbox/pellegrin/set/Makefile
>> ===================================================================
>> --- trunk/milena/sandbox/pellegrin/set/Makefile (revision 0)
>> +++ trunk/milena/sandbox/pellegrin/set/Makefile (revision 1721)
>
> You should have a look at how we write Makefiles.am in the
> subdirectories of tests/, and use that instead of hard-coded rules.
>
This is not a true Makefile, but more likely a text file in which
i wanted to put all the warnings and errors's command-line parameters
of gcc :O). (But it's also easier to type make than g++-4.2 .....
so i create a such ugly Makefile)
> Thanks for this first patch! Some of my remarks may be absolutely out-
> of-date (since you might have changed a lot of things in your
> following patches). In that case, just ignore them, of course.
>
Thank you for the corrections.
--
Michel PELLEGRIN