https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Update different files.
* theo/exec/superpose.cc: New.
* theo/esiee/laurent/presentation/wst2d.cc: Update.
* theo/esiee/laurent/presentation/classif.cc: Update.
* theo/csi/edwin.cc: Update.
csi/edwin.cc | 36 +++++++++++++++++++++++++------
esiee/laurent/presentation/classif.cc | 4 +--
esiee/laurent/presentation/wst2d.cc | 8 ++++++
exec/superpose.cc | 39 ++++++++++++++++++++++++++++++++++
4 files changed, 78 insertions(+), 9 deletions(-)
Index: theo/exec/superpose.cc
--- theo/exec/superpose.cc (revision 0)
+++ theo/exec/superpose.cc (revision 0)
@@ -0,0 +1,39 @@
+#include "filetype.hh"
+
+#include <mln/core/image/image_if.hh>
+#include <mln/data/fill.hh>
+#include <mln/pw/all.hh>
+
+
+
+void usage(char* argv[])
+{
+ std::cerr << "usage: " << argv[0] << "
input_int_u8.dump input_bool.dump output.dump" << std::endl
+ << " Superpose." << std::endl;
+ std::abort();
+}
+
+
+
+int main(int argc, char* argv[])
+{
+ using namespace mln;
+ using value::int_u8;
+
+ if (argc != 4)
+ usage(argv);
+
+ trace::entering("main");
+
+ image3d<int_u8> ima;
+ io::dump::load(ima, argv[1]);
+
+ image3d<bool> msk;
+ io::dump::load(msk, argv[2]);
+
+ data::fill( (ima | pw::value(msk)).rw(), 255 );
+
+ io::dump::save(ima, argv[3]);
+
+ trace::exiting("main");
+}
Index: theo/esiee/laurent/presentation/wst2d.cc
--- theo/esiee/laurent/presentation/wst2d.cc (revision 3409)
+++ theo/esiee/laurent/presentation/wst2d.cc (working copy)
@@ -5,6 +5,7 @@
# include <mln/io/pgm/load.hh>
# include <mln/io/ppm/save.hh>
+# include <mln/io/pgm/save.hh>
# include <mln/core/var.hh>
# include <mln/core/image/image2d.hh>
@@ -15,12 +16,15 @@
# include <mln/literal/black.hh>
# include <mln/debug/println.hh>
+# include <mln/extension/adjust_duplicate.hh>
+
# include <mln/morpho/closing_area.hh>
# include <mln/morpho/gradient.hh>
# include <mln/accu/min_max.hh>
# include <mln/morpho/meyer_wst.hh>
+
using namespace mln;
using value::int_u8;
@@ -32,6 +36,8 @@
const I& input = exact(input_);
const N& nbh = exact(nbh_);
+ extension::adjust_duplicate(input, nbh);
+
mln_concrete(I) output;
initialize(output, input);
accu::min_max<mln_value(I)> mm;
@@ -92,6 +98,8 @@
{
I grad = morpho_gradient(ima, nbh);
+ io::pgm::save(grad, "temp_grad.pgm");
+
I clo;
if (lambda > 1)
clo = morpho::closing_area(grad, nbh, lambda);
Index: theo/esiee/laurent/presentation/classif.cc
--- theo/esiee/laurent/presentation/classif.cc (revision 3409)
+++ theo/esiee/laurent/presentation/classif.cc (working copy)
@@ -358,8 +358,8 @@
`-----------------*/
// Currently, does nothing (lambda = 1).
- dist_ima_t closed_dist_ima (dist_ima.domain());
- morpho::closing_height(dist_ima, nbh, atoi(argv[1]), closed_dist_ima);
+ dist_ima_t closed_dist_ima; // (dist_ima.domain());
+ closed_dist_ima = morpho::closing_height(dist_ima, nbh, atoi(argv[1]));
/*------.
| WST. |
Index: theo/csi/edwin.cc
--- theo/csi/edwin.cc (revision 3409)
+++ theo/csi/edwin.cc (working copy)
@@ -28,7 +28,7 @@
void
back_propagate(const T& t, A& a)
// a value propagates from the representative point to every point
- // of the component...
+ // of the component at the same level (NOT to the branch points!)
{
mln_fwd_piter(T) p(t.domain());
for_all(p)
@@ -41,6 +41,19 @@
template <typename T, typename A>
+ void
+ back_propagate_II(const T& t, A& a)
+ // a value propagates from a representative point to every point
+ // of the component and the children components (branch).
+ {
+ mln_bkd_piter(T) p(t.domain());
+ for_all(p)
+ if (t.is_a_node(p) && a(t.parent(p)) == true)
+ a(p) = a(t.parent(p));
+ }
+
+
+ template <typename T, typename A>
inline
A
sample(const T& t, const A& a, bool echo = false)
@@ -57,6 +70,7 @@
if (echo) debug::println("aa (before)", aa);
+ back_propagate_II(t, aa);
back_propagate(t, aa);
if (echo) debug::println("aa (after)", aa);
@@ -71,7 +85,8 @@
void usage(char* argv[])
{
- std::cerr << "usage: " << argv[0] << " input.pgm
output.pbm" << std::endl;
+ std::cerr << "usage: " << argv[0] << " input.pgm echo
output.pbm" << std::endl;
+ std::cerr << " echo: 0 (none) or 1 (verbose)" << std::endl;
abort();
}
@@ -84,11 +99,15 @@
mln_VAR(nbh, c4());
- if (argc != 3)
+ if (argc != 4)
usage(argv);
- bool echo = false;
-
+ int echo = std::atoi(argv[2]);
+ if (echo != 0 && echo != 1)
+ {
+ std::cerr << "bad 'echo' value!" << std::endl;
+ usage(argv);
+ }
typedef image2d<int_u8> I;
@@ -96,6 +115,7 @@
io::pgm::load(input, argv[1]);
if (echo) debug::println("input", input);
+// I f = input;
I f = morpho::elementary::gradient(input, nbh);
if (echo) debug::println("f", f);
@@ -115,8 +135,10 @@
debug::println("a | nodes", a | t.nodes());
}
- image2d<bool> b = duplicate((pw::value(a) < pw::cst(10)) | a.domain());
+ image2d<bool> b = duplicate((pw::value(a) < pw::cst(21)) | a.domain());
if (echo) debug::println("b", b | t.nodes());
- io::pbm::save(sample(t, b), argv[2]);
+ io::pbm::save(sample(t, b,
+ echo),
+ argv[3]);
}