https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Update reconstruction algorithms in theo's sandbox.
* milena/mln/level/paste.hh: Fix warning.
* milena/sandbox/geraud/Rd/hybrid.hh,
* milena/sandbox/geraud/Rd/queue_based.hh,
* milena/sandbox/geraud/Rd/parallel.cc,
* milena/sandbox/geraud/Rd/union_find.hh,
* milena/sandbox/geraud/Rd/parallel.hh,
* milena/sandbox/geraud/Rd/sequential.cc,
* milena/sandbox/geraud/Rd/utils.hh,
* milena/sandbox/geraud/Rd/hybrid.cc,
* milena/sandbox/geraud/Rd/queue_based.cc,
* milena/sandbox/geraud/Rd/min.cc,
* milena/sandbox/geraud/Rd/sequential.hh,
* milena/sandbox/geraud/Rd/union_find.cc: Update.
mln/level/paste.hh | 2 +
sandbox/geraud/Rd/hybrid.cc | 20 ++++++++-------
sandbox/geraud/Rd/hybrid.hh | 24 +++++++------------
sandbox/geraud/Rd/min.cc | 4 +--
sandbox/geraud/Rd/parallel.cc | 23 ++++++++++--------
sandbox/geraud/Rd/parallel.hh | 20 ++++-----------
sandbox/geraud/Rd/queue_based.cc | 22 +++++++++--------
sandbox/geraud/Rd/queue_based.hh | 19 +++++----------
sandbox/geraud/Rd/sequential.cc | 23 ++++++++----------
sandbox/geraud/Rd/sequential.hh | 13 +---------
sandbox/geraud/Rd/union_find.cc | 22 +++++++++--------
sandbox/geraud/Rd/union_find.hh | 30 ++++++++---------------
sandbox/geraud/Rd/utils.hh | 49 +++++++++++++++++++--------------------
13 files changed, 123 insertions(+), 148 deletions(-)
Index: milena/mln/level/paste.hh
--- milena/mln/level/paste.hh (revision 2439)
+++ milena/mln/level/paste.hh (working copy)
@@ -84,6 +84,8 @@
mlc_converts_to(mln_value(I), mln_value(J))::check();
mln_precondition(exact(data).has_data());
mln_precondition(exact(data).domain() <= exact(destination).domain());
+ (void)data;
+ (void)destination;
}
} // end of namespace mln::level::internal
Index: milena/sandbox/geraud/Rd/hybrid.hh
--- milena/sandbox/geraud/Rd/hybrid.hh (revision 2439)
+++ milena/sandbox/geraud/Rd/hybrid.hh (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
@@ -46,17 +46,11 @@
I hybrid(const I& f, const I& g, const N& nbh,
bool echo = false)
{
- typedef mln_point(I) point;
+ typedef mln_site(I) point;
std::queue<point> q;
- f.name_it("f");
- g.name_it("g");
-
// initialisation
- I o(f.domain());
- o.name_it("o");
- level::paste(f, o);
- // WAS: I o = clone(f);
+ I o = clone(f);
unsigned n_init_pushs = 0, n_body_pushs = 0, n_pops = 0;
@@ -72,8 +66,10 @@
for_all(p)
{
o(p) = min( max_Nplus(o, p,nbh), g(p) );
- for_all(n) if (f.has(n) and n < p) // N+
- if (o(n) < o(p) and o(n) < g(n))
+ for_all(n)
+ if (f.has(n) &&
+ util::ord_strict(n.to_site(), p.to_site())) // N+
+ if (o(n) < o(p) && o(n) < g(n))
{
q.push(p);
++n_init_pushs;
@@ -92,7 +88,7 @@
q.pop();
++n_pops;
for_all(n) if (f.has(n))
- if (o(n) < o(p) and o(n) != g(n))
+ if (o(n) < o(p) && o(n) != g(n))
{
o(n) = min(o(p), g(n));
if (echo) std::cout << " push " << n;
@@ -103,13 +99,11 @@
if (echo) std::cout << std::endl;
}
-
+ if (echo)
std::cout << "n_init_pushs = " << n_init_pushs << std::endl
<< "n_body_pushs = " << n_body_pushs << std::endl
<< "n_pops = " << n_pops << std::endl;
- print_counts();
-
return o;
}
Index: milena/sandbox/geraud/Rd/queue_based.hh
--- milena/sandbox/geraud/Rd/queue_based.hh (revision 2439)
+++ milena/sandbox/geraud/Rd/queue_based.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research && 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
@@ -18,7 +18,7 @@
// 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
+// file, or you compile this file && 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
@@ -52,13 +52,9 @@
if (echo) std::cout << std::endl;
- f.name_it("f");
- g.name_it("g");
-
- typedef mln_point(I) point;
+ typedef mln_site(I) point;
std::queue<point> q;
I o;
- o.name_it("o");
unsigned n_init_pushs = 0, n_body_pushs = 0, n_pops = 0;
@@ -71,8 +67,8 @@
mln_piter(I) p(f.domain());
mln_niter(N) n(nbh, p);
- for_all(p) if (o(p) != 0) // p in M
- for_all(n) if (f.has(n) and o(n) == 0) // n not in M
+ for_all(p) if (o(p) != 0u) // p in M
+ for_all(n) if (f.has(n) && o(n) == 0u) // n not in M
{
q.push(p);
que(p) = true;
@@ -94,7 +90,7 @@
++n_pops;
for_all(n) if (f.has(n))
{
- if (o(n) < o(p) and o(n) != g(n))
+ if (o(n) < o(p) && o(n) != g(n))
{
o(n) = min(o(p), g(n));
if (echo) std::cout << " push " << n;
@@ -110,12 +106,11 @@
if (echo) std::cout << std::endl;
}
+ if (echo)
std::cout << "n_init_pushs = " << n_init_pushs << std::endl
<< "n_body_pushs = " << n_body_pushs << std::endl
<< "n_pops = " << n_pops << std::endl;
- print_counts();
-
return o;
}
Index: milena/sandbox/geraud/Rd/parallel.cc
--- milena/sandbox/geraud/Rd/parallel.cc (revision 2439)
+++ milena/sandbox/geraud/Rd/parallel.cc (working copy)
@@ -1,7 +1,7 @@
#include <iostream>
-#include <mln/core/image2d.hh>
-#include <mln/core/neighb2d.hh>
+#include <mln/core/image/image2d.hh>
+#include <mln/core/alias/neighb2d.hh>
#include <mln/value/int_u8.hh>
#include <mln/debug/println.hh>
@@ -14,7 +14,7 @@
void usage(char* argv[])
{
std::cerr << "usage: " << argv[0] << " f.pgm g.pgm c
output.pgm" << std::endl
- << "reconstruction by dilation (parallel version; may 2007)"
<< std::endl
+ << "reconstruction by dilation (parallel version; sep 2008)"
<< std::endl
<< "f = marker (to be dilated)" << std::endl
<< "g = mask (constraint >= f)" << std::endl
<< "c: 4 or 8" << std::endl;
@@ -30,22 +30,25 @@
using namespace mln;
using value::int_u8;
+ border::thickness = 0; // Safety.
+
typedef image2d<int_u8> I;
int c = atoi(argv[3]);
if (c != 4 and c != 8)
usage(argv);
- I f = io::pgm::load<int_u8>(argv[1]);
- I g = io::pgm::load<int_u8>(argv[2]);
+ I f, g;
+ io::pgm::load(f, argv[1]);
+ io::pgm::load(g, argv[2]);
- if (not (f <= g))
+ if (! (f <= g))
{
- std::cerr << "pb" << std::endl;
+ std::cerr << "error: the precondition 'f <= g' is not
true" << std::endl;
return 1;
}
- io::pgm::save(morpho::Rd::parallel(f, g,
- (c == 4 ? c4() : c8())),
- argv[4]);
+ I o = morpho::Rd::parallel(f, g,
+ (c == 4 ? c4() : c8()));
+ io::pgm::save(o, argv[4]);
}
Index: milena/sandbox/geraud/Rd/union_find.hh
--- milena/sandbox/geraud/Rd/union_find.hh (revision 2439)
+++ milena/sandbox/geraud/Rd/union_find.hh (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
@@ -44,7 +44,7 @@
template <typename I, typename N>
struct union_find_t
{
- typedef mln_point(I) point;
+ typedef mln_site(I) point;
typedef mln_value(I) value;
// in:
@@ -56,28 +56,21 @@
// aux:
std::vector<point> S;
- // was: I data;
- mln_ch_value(I, bool) isproc;
+ mln_ch_value(I, bool) deja_vu;
mln_ch_value(I, point) parent;
union_find_t(const I& f, const I& g, const N& nbh)
: f(f), g(g), nbh(nbh)
{
- f.name_it("f");
- g.name_it("g");
initialize(o, f);
- o.name_it("o");
initialize(parent, f);
- parent.name_it("parent");
- initialize(isproc, f);
- isproc.name_it("isproc");
- // was: initialize(data, f);
+ initialize(deja_vu, f);
// init
- level::fill(isproc, false);
+ level::fill(deja_vu, false);
S = histo_reverse_sort(g);
- level::paste(f, o); // new: replace make_set(p) { data(p) = f(p) }
+ level::paste(f, o); // Replace: for all p, make_set(p) { data(p) = f(p) }
// first pass
@@ -90,11 +83,11 @@
for_all(n)
{
if (f.has(n))
- mln_invariant(isproc(n) == is_proc(n, p));
- if (f.has(n) and isproc(n))
+ mln_invariant(deja_vu(n) == is_proc(n, p));
+ if (f.has(n) && deja_vu(n))
do_union(n, p);
}
- isproc(p) = true;
+ deja_vu(p) = true;
}
// second pass
@@ -109,13 +102,12 @@
o(p) = o(parent(p));
}
- print_counts();
-
}
bool is_proc(const point& n, const point& p) const
{
- return g(n) > g(p) or (g(n) == g(p) and n < p);
+ return g(n) > g(p) or (g(n) == g(p) &&
+ util::ord_strict(n, p));
}
void make_set(const point& p)
Index: milena/sandbox/geraud/Rd/parallel.hh
--- milena/sandbox/geraud/Rd/parallel.hh (revision 2439)
+++ milena/sandbox/geraud/Rd/parallel.hh (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
@@ -45,21 +45,14 @@
I parallel(const I& f, const I& g, const N& nbh,
bool test = true)
{
-// if (test)
-// mln_precondition(f <= g);
-
- f.name_it("f");
- g.name_it("g");
+ if (test)
+ mln_precondition(f <= g);
I o_(f.domain());
- o_.name_it("o_");
mln_piter(I) p(f.domain());
// initialisation
- I o(f.domain());
- o.name_it("o");
- level::paste(f, o);
- // WAS: I o = clone(f);
+ I o = clone(f);
bool stability;
do
@@ -77,9 +70,8 @@
}
while (not stability);
- print_counts();
-
- // mln_postcondition(o <= g);
+ if (test)
+ mln_postcondition(o <= g);
return o;
}
Index: milena/sandbox/geraud/Rd/sequential.cc
--- milena/sandbox/geraud/Rd/sequential.cc (revision 2439)
+++ milena/sandbox/geraud/Rd/sequential.cc (working copy)
@@ -1,5 +1,5 @@
-#include <mln/core/image2d.hh>
-#include <mln/core/neighb2d.hh>
+#include <mln/core/image/image2d.hh>
+#include <mln/core/alias/neighb2d.hh>
#include <mln/debug/println.hh>
#include <mln/io/pgm/load.hh>
@@ -11,7 +11,7 @@
void usage(char* argv[])
{
std::cerr << "usage: " << argv[0] << " f.pgm g.pgm c
output.pgm" << std::endl
- << "reconstruction by dilation (sequential version; may
2007)" << std::endl
+ << "reconstruction by dilation (sequential version; sep
2008)" << std::endl
<< "f = marker (to be dilated)" << std::endl
<< "g = mask (constraint >= f)" << std::endl
<< "c: 4 or 8" << std::endl;
@@ -27,25 +27,24 @@
using namespace mln;
using value::int_u8;
+ border::thickness = 0; // Safety.
+
typedef image2d<int_u8> I;
int c = atoi(argv[3]);
if (c != 4 and c != 8)
usage(argv);
- I f = io::pgm::load<int_u8>(argv[1]);
- f.name_it("main.f");
-
- I g = io::pgm::load<int_u8>(argv[2]);
- g.name_it("main.g");
+ I f, g;
+ io::pgm::load(f, argv[1]);
+ io::pgm::load(g, argv[2]);
if (not (f <= g))
{
- std::cerr << "pb" << std::endl;
+ std::cerr << "error: the precondition 'f <= g' is not
true" << std::endl;
return 1;
}
- io::pgm::save(morpho::Rd::sequential(f, g,
- (c == 4 ? c4() : c8())),
- argv[4]);
+ I o = morpho::Rd::sequential(f, g, (c == 4 ? c4() : c8()));
+ io::pgm::save(o, argv[4]);
}
Index: milena/sandbox/geraud/Rd/utils.hh
--- milena/sandbox/geraud/Rd/utils.hh (revision 2439)
+++ milena/sandbox/geraud/Rd/utils.hh (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
@@ -31,9 +31,11 @@
# include <vector>
# include <mln/core/concept/image.hh>
-# include <mln/core/clone.hh>
+# include <mln/core/routine/clone.hh>
-# include <mln/level/fill.hh>
+# include <mln/util/ord.hh>
+
+# include <mln/level/fill_with_value.hh>
# include <mln/level/paste.hh>
# include <mln/level/compare.hh>
@@ -59,7 +61,7 @@
template <typename I>
I minimun(const I& ima1, const I& ima2)
{
- mln_precondition(ima1.has_data() and ima2.has_data());
+ mln_precondition(ima1.has_data() && ima2.has_data());
mln_precondition(ima1.domain() == ima2.domain());
I out(ima1.domain());
mln_piter(I) p(ima1.domain());
@@ -75,7 +77,7 @@
mln_value(I) v = ima(p);
mln_niter(N) n(nbh, p);
for_all(n)
- if (ima.has(n) and ima(n) > v)
+ if (ima.has(n) && ima(n) > v)
v = ima(n);
return v;
}
@@ -87,7 +89,9 @@
mln_value(I) v = ima(p);
mln_niter(N) n(nbh, p);
for_all(n)
- if (ima.has(n) and n > p and ima(n) > v)
+ if (ima.has(n) &&
+ util::ord_strict(p.to_site(), n.to_site()) &&
+ ima(n) > v)
v = ima(n);
return v;
}
@@ -98,7 +102,9 @@
mln_value(I) v = ima(p);
mln_niter(N) n(nbh, p);
for_all(n)
- if (ima.has(n) and n < p and ima(n) > v)
+ if (ima.has(n) &&
+ util::ord_strict(n.to_site(), p.to_site()) &&
+ ima(n) > v)
v = ima(n);
return v;
}
@@ -116,7 +122,7 @@
// template <typename I>
-// std::vector<mln_point(I)> histo_sort(const I& ima)
+// std::vector<mln_site(I)> histo_sort(const I& ima)
// {
// std::vector<unsigned> h = compute_histo(ima);
// // preparing output data
@@ -124,9 +130,9 @@
// loc[0] = 0;
// for (int l = 1; l < 256; ++l)
// loc[l] = loc[l-1] + h[l-1];
-// std::vector<mln_point(I)> vec(ima.points().npoints());
+// std::vector<mln_site(I)> vec(ima.nsites());
// // storing output data
-// mln_piter(I) p(ima.points());
+// mln_piter(I) p(ima.domain());
// for_all(p)
// vec[loc[ima(p)]++] = p;
// return vec;
@@ -134,7 +140,7 @@
template <typename I>
- std::vector<mln_point(I)> histo_reverse_sort(const I& ima)
+ std::vector<mln_site(I)> histo_reverse_sort(const I& ima)
{
std::vector<unsigned> h = compute_histo(ima);
// preparing output data
@@ -142,7 +148,7 @@
loc[255] = 0;
for (int l = 254; l >= 0; --l)
loc[l] = loc[l+1] + h[l+1];
- std::vector<mln_point(I)> vec(ima.domain().npoints());
+ std::vector<mln_site(I)> vec(ima.nsites());
// storing output data
mln_piter(I) p(ima.domain());
for_all(p)
@@ -155,7 +161,7 @@
template <typename I, typename N>
struct regional_maxima_t
{
- typedef mln_point(I) point;
+ typedef mln_site(I) point;
typedef mln_ch_value(I, bool) image_bool;
typedef mln_ch_value(I, point) image_point;
@@ -168,26 +174,21 @@
// aux:
std::vector<point> S;
- image_bool is_proc;
+ image_bool deja_vu;
image_bool attr;
image_point parent;
regional_maxima_t(const I& f, const N& nbh)
: f(f), nbh(nbh)
{
- f.name_it("rm.f");
initialize(o, f);
- o.name_it("rm.o");
initialize(parent, f);
- parent.name_it("rm.parent");
initialize(attr, f);
- attr.name_it("rm.attr");
- initialize(is_proc, f);
- is_proc.name_it("rm.is_proc");
+ initialize(deja_vu, f);
// init
- level::fill(is_proc, false);
+ level::fill_with_value(deja_vu, false);
S = histo_reverse_sort(f);
// first pass
@@ -199,14 +200,14 @@
make_set(p);
mln_niter(N) n(nbh, p);
for_all(n)
- if (f.has(n) and is_proc(n))
+ if (f.has(n) && deja_vu(n))
{
if (f(n) == f(p))
do_union(n, p);
else // f(n) > f(p)
attr(p) = false;
}
- is_proc(p) = true;
+ deja_vu(p) = true;
}
// second pass
@@ -242,7 +243,7 @@
if (r != p)
{
parent(r) = p;
- attr(p) = attr(p) and attr(r);
+ attr(p) = attr(p) && attr(r);
}
}
Index: milena/sandbox/geraud/Rd/hybrid.cc
--- milena/sandbox/geraud/Rd/hybrid.cc (revision 2439)
+++ milena/sandbox/geraud/Rd/hybrid.cc (working copy)
@@ -1,7 +1,7 @@
#include <iostream>
-#include <mln/core/image2d.hh>
-#include <mln/core/neighb2d.hh>
+#include <mln/core/image/image2d.hh>
+#include <mln/core/alias/neighb2d.hh>
#include <mln/value/int_u8.hh>
#include <mln/debug/println.hh>
@@ -14,7 +14,7 @@
void usage(char* argv[])
{
std::cerr << "usage: " << argv[0] << " f.pgm g.pgm c
output.pgm" << std::endl
- << "reconstruction by dilation (hybrid version; may 2007)"
<< std::endl
+ << "reconstruction by dilation (hybrid version; sep 2008)"
<< std::endl
<< "f = marker (to be dilated)" << std::endl
<< "g = mask (constraint >= f)" << std::endl
<< "c: 4 or 8" << std::endl;
@@ -30,22 +30,24 @@
using namespace mln;
using value::int_u8;
+ border::thickness = 0; // Safety.
+
typedef image2d<int_u8> I;
int c = atoi(argv[3]);
if (c != 4 and c != 8)
usage(argv);
- I f = io::pgm::load<int_u8>(argv[1]);
- I g = io::pgm::load<int_u8>(argv[2]);
+ I f, g;
+ io::pgm::load(f, argv[1]);
+ io::pgm::load(g, argv[2]);
if (not (f <= g))
{
- std::cerr << "pb" << std::endl;
+ std::cerr << "error: the precondition 'f <= g' is not
true" << std::endl;
return 1;
}
- io::pgm::save(morpho::Rd::hybrid(f, g,
- (c == 4 ? c4() : c8())),
- argv[4]);
+ I o = morpho::Rd::hybrid(f, g, (c == 4 ? c4() : c8()));
+ io::pgm::save(o, argv[4]);
}
Index: milena/sandbox/geraud/Rd/queue_based.cc
--- milena/sandbox/geraud/Rd/queue_based.cc (revision 2439)
+++ milena/sandbox/geraud/Rd/queue_based.cc (working copy)
@@ -1,5 +1,5 @@
-#include <mln/core/image2d.hh>
-#include <mln/core/neighb2d.hh>
+#include <mln/core/image/image2d.hh>
+#include <mln/core/alias/neighb2d.hh>
#include <mln/value/int_u8.hh>
#include <mln/debug/println.hh>
@@ -12,7 +12,7 @@
void usage(char* argv[])
{
std::cerr << "usage: " << argv[0] << " f.pgm g.pgm c
output.pgm" << std::endl
- << "reconstruction by dilation (queue_based version; may
2007)" << std::endl
+ << "reconstruction by dilation (queue_based version; sep
2008)" << std::endl
<< "f = marker (to be dilated)" << std::endl
<< "g = mask (constraint >= f)" << std::endl
<< "c: 4 or 8" << std::endl;
@@ -28,22 +28,24 @@
using namespace mln;
using value::int_u8;
+ border::thickness = 0; // Safety.
+
typedef image2d<int_u8> I;
int c = atoi(argv[3]);
if (c != 4 and c != 8)
usage(argv);
- I f = io::pgm::load<int_u8>(argv[1]);
- I g = io::pgm::load<int_u8>(argv[2]);
+ I f, g;
+ io::pgm::load(f, argv[1]);
+ io::pgm::load(g, argv[2]);
- if (not (f <= g))
+ if (! (f <= g))
{
- std::cerr << "pb" << std::endl;
+ std::cerr << "error: the precondition 'f <= g' is not
true" << std::endl;
return 1;
}
- io::pgm::save(morpho::Rd::queue_based(f, g,
- (c == 4 ? c4() : c8())),
- argv[4]);
+ I o = morpho::Rd::queue_based(f, g, (c == 4 ? c4() : c8()));
+ io::pgm::save(o, argv[4]);
}
Index: milena/sandbox/geraud/Rd/min.cc
--- milena/sandbox/geraud/Rd/min.cc (revision 2439)
+++ milena/sandbox/geraud/Rd/min.cc (working copy)
@@ -1,4 +1,4 @@
-#include <mln/core/image2d.hh>
+#include <mln/core/image/image2d.hh>
#include <mln/value/int_u8.hh>
#include <mln/io/pgm/load.hh>
#include <mln/io/pgm/save.hh>
@@ -7,7 +7,7 @@
void usage(char* argv[])
{
std::cerr << "usage: " << argv[0] << " 1.pgm 2.pgm
out.pgm" << std::endl
- << "(2008 Feb)" << std::endl;
+ << "(sep 2008)" << std::endl;
exit(1);
}
Index: milena/sandbox/geraud/Rd/sequential.hh
--- milena/sandbox/geraud/Rd/sequential.hh (revision 2439)
+++ milena/sandbox/geraud/Rd/sequential.hh (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
@@ -45,17 +45,10 @@
{
mln_precondition(f <= g);
- f.name_it("f");
- g.name_it("g");
-
I o_(f.domain());
- o_.name_it("o_");
// initialisation
- I o(f.domain());
- o.name_it("o");
- level::paste(f, o);
- // WAS: I o = clone(f);
+ I o = clone(f);
bool stability;
do
@@ -80,8 +73,6 @@
}
while (not stability);
- print_counts();
-
mln_postcondition(o <= g);
return o;
}
Index: milena/sandbox/geraud/Rd/union_find.cc
--- milena/sandbox/geraud/Rd/union_find.cc (revision 2439)
+++ milena/sandbox/geraud/Rd/union_find.cc (working copy)
@@ -1,5 +1,5 @@
-#include <mln/core/image2d.hh>
-#include <mln/core/neighb2d.hh>
+#include <mln/core/image/image2d.hh>
+#include <mln/core/alias/neighb2d.hh>
#include <mln/value/int_u8.hh>
#include <mln/debug/println.hh>
@@ -13,7 +13,7 @@
void usage(char* argv[])
{
std::cerr << "usage: " << argv[0] << " f.pgm g.pgm c
output.pgm" << std::endl
- << "reconstruction by dilation (union_find version; may
2007)" << std::endl
+ << "reconstruction by dilation (union_find version; sep
2008)" << std::endl
<< "f = marker (to be dilated)" << std::endl
<< "g = mask (constraint >= f)" << std::endl
<< "c: 4 or 8" << std::endl;
@@ -29,22 +29,24 @@
using namespace mln;
using value::int_u8;
+ border::thickness = 0; // Safety.
+
typedef image2d<int_u8> I;
int c = atoi(argv[3]);
if (c != 4 and c != 8)
usage(argv);
- I f = io::pgm::load<int_u8>(argv[1]);
- I g = io::pgm::load<int_u8>(argv[2]);
+ I f, g;
+ io::pgm::load(f, argv[1]);
+ io::pgm::load(g, argv[2]);
- if (not (f <= g))
+ if (! (f <= g))
{
- std::cerr << "pb" << std::endl;
+ std::cerr << "error: the precondition 'f <= g' is not
true" << std::endl;
return 1;
}
- io::pgm::save(morpho::Rd::union_find(f, g,
- (c == 4 ? c4() : c8())),
- argv[4]);
+ I o = morpho::Rd::union_find(f, g, (c == 4 ? c4() : c8()));
+ io::pgm::save(o, argv[4]);
}