https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
Index: ChangeLog
from Ugo Jardonnet <jardonnet(a)lrde.epita.fr>
Comment. Fix wrong fusing condition, dec condition.
* jardonnet/n_cmpt/n_cmpt5.cc: Comment. Change fusing/dec conditions.
* jardonnet/n_cmpt/n_cmpt5.hh: Remove old hack.
n_cmpt5.cc | 2 --
n_cmpt5.hh | 43 ++++++++++++++++++++++++++++++++++---------
2 files changed, 34 insertions(+), 11 deletions(-)
Index: jardonnet/n_cmpt/n_cmpt5.cc
--- jardonnet/n_cmpt/n_cmpt5.cc (revision 3039)
+++ jardonnet/n_cmpt/n_cmpt5.cc (working copy)
@@ -35,8 +35,6 @@
io::pgm::load(ima, argv[1]);
unsigned lambda = atoi(argv[2]);
- ima(point2d(0,3)) = 106;
-
int_u8 tab[] = {2,3,1,0,2,3,4,5,1,1,0,5,6,8,7,1,1,2,3,4};
image1d<int_u8> ima1= make::image(tab);
Index: jardonnet/n_cmpt/n_cmpt5.hh
--- jardonnet/n_cmpt/n_cmpt5.hh (revision 3039)
+++ jardonnet/n_cmpt/n_cmpt5.hh (working copy)
@@ -149,16 +149,40 @@
P r = find_root(parent, n);
if (r != p)
{
+ std::cout << "neighb: " << n << std::endl;
+ std::cout << "v(r): " << volume(r) << "
v(p): " << volume(p) << " f(p): " << fused(p) <<
std::endl;
+
+ //if (volume(r) != volume(p)) // r and p have different volumes
+ // This check was wrong.
+ // you just fused with a minima.
+ // then you fuse with a neighbor already fused that has the same volume as
you
+ // a) 1 50 1
+ // 2 2 2
+ // we don't have ( volume(r) == volume(p) ) => not fused(r)
+ // even if r and p are not minima
+
+ // problem :
+ // - when fusing minima : same level, both fused. NOT DEC
+ // - when fusing cmpts (a) : same level, both fused. DEC
+
// One cmpt less if
- if (volume(r) != volume(p)) // r and p have differerent volumes
+ if (fused(r) && min_v(p) == 0) // p is not a minima
if (fused(p)) // p already belong to a cmpt (fused for an another n)
- if (cmpts >= lambda) // union is still alowed
+ if (cmpts >= lambda) // union is still allowed
+ {
cmpts--;
+ std::cout << "dec" << std::endl;
+ }
- if (cmpts >= lambda ||
- volume(r) == volume(p) ||
- not fused(p))
+ mln_invariant(fused(r) || volume(r) == volume(p));
+
+ // Union made if
+ if (cmpts >= lambda || // union is still allowed or
+ not fused(r) || // r not fused or
+ not fused(p) || // p not fused or
+ min_v(p) != 0) // p is a minima
{
+ std::cout << "fuse" << p << n <<
std::endl;
parent(r) = p;
// This test is mandatory. Sometimes (--_) points are fused
@@ -170,6 +194,7 @@
if (fused(r))
fused(p) = true;
+
// If I try to fuse with something never fused I am on a plateau.
// not fused(r) => ( volume(r) == volume(p) )
mln_invariant(fused(r) || volume(r) == volume(p));
@@ -181,8 +206,8 @@
// fused(n) is not an invariant: --_. And it is ok (I think).
// We don't have to retro-propagate fused.
- //std::cout << "volume " << volume(p) <<
" - " << cmpts << std::endl;
- debug::println(fused);
+ std::cerr << "volume " << volume(p) << "
- " << cmpts << std::endl;
+ //debug::println(fused);
}
}
}
@@ -190,7 +215,7 @@
deja_vu(p) = true;
}
- I iota(ima.domain());
+ mln_ch_value(I,value::int_u<16>) iota(ima.domain());
debug::iota(iota);
std::cout << std::endl;
@@ -202,7 +227,7 @@
mln_bkd_piter(S) p(sp);
for_all(p)
if (parent(p) == p) // p is root.
- output(p) = iota(p) * 10;
+ output(p) = iota(p);
else
output(p) = output(parent(p));
}