* apps/mesh-segm-skel/mesh-complex-skel.cc,
* apps/mesh-segm-skel/mesh-complex-max-curv-skel.cc,
* apps/mesh-segm-skel/mesh-complex-pinv-curv-skel.cc:
Catch up with the new interface of breadth-first thinning and
auxiliary routines.
---
milena/ChangeLog | 10 ++
.../mesh-segm-skel/mesh-complex-max-curv-skel.cc | 84 +++++++++++++++----
.../mesh-segm-skel/mesh-complex-pinv-curv-skel.cc | 84 +++++++++++++++----
milena/apps/mesh-segm-skel/mesh-complex-skel.cc | 87 +++++++++++++++----
4 files changed, 210 insertions(+), 55 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index b15ba2a..2c88979 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,15 @@
2010-09-09 Roland Levillain <roland(a)lrde.epita.fr>
+ Update mesh skeleton applications.
+
+ * apps/mesh-segm-skel/mesh-complex-skel.cc,
+ * apps/mesh-segm-skel/mesh-complex-max-curv-skel.cc,
+ * apps/mesh-segm-skel/mesh-complex-pinv-curv-skel.cc:
+ Catch up with the new interface of breadth-first thinning and
+ auxiliary routines.
+
+2010-09-09 Roland Levillain <roland(a)lrde.epita.fr>
+
More generic breadth-first-thinning-based skeleton transformations.
* mln/topo/is_simple_cell.hh: Make this functor more generic.
diff --git a/milena/apps/mesh-segm-skel/mesh-complex-max-curv-skel.cc
b/milena/apps/mesh-segm-skel/mesh-complex-max-curv-skel.cc
index b910aae..d04354d 100644
--- a/milena/apps/mesh-segm-skel/mesh-complex-max-curv-skel.cc
+++ b/milena/apps/mesh-segm-skel/mesh-complex-max-curv-skel.cc
@@ -39,7 +39,9 @@
#include <mln/core/image/complex_image.hh>
#include <mln/core/image/complex_neighborhoods.hh>
-#include <mln/core/site_set/p_set.hh>
+#include <mln/core/image/dmorph/image_if.hh>
+#include <mln/core/image/dmorph/mutable_extension_ima.hh>
+#include <mln/core/routine/mutable_extend.hh>
#include <mln/value/label_16.hh>
@@ -48,7 +50,7 @@
#include <mln/topo/is_n_face.hh>
#include <mln/topo/is_simple_cell.hh>
-#include <mln/topo/detach.hh>
+#include <mln/topo/detach_cell.hh>
#include <mln/topo/skeleton/breadth_first_thinning.hh>
#include <mln/io/off/load.hh>
@@ -252,31 +254,77 @@ main(int argc, char* argv[])
| Skeleton. |
`-----------*/
- mln::topo::is_simple_cell<bin_ima_t> is_simple_p;
- /* FIXME: Cheat! We'd like to iterate on cells of highest
- dimension (2-cells) only, but we cannot constrain the domain of
- the input using image_if (yet) like this
+ // ---------------- //
+ // Skeleton image. //
+ // ---------------- //
+
+ // Predicate type: is a face a triangle (2-face)?
+ typedef mln::topo::is_n_face<D> is_a_triangle_t;
+ is_a_triangle_t is_a_triangle;
+ // Surface image type, of which domain is restricted to triangles.
+ typedef mln::image_if<bin_ima_t, is_a_triangle_t> bin_triangle_only_ima_t;
+ // Surface image type, of which iteration (not domain) is restricted
+ // to triangles.
+ typedef mln::mutable_extension_ima<bin_triangle_only_ima_t, bin_ima_t>
+ bin_triangle_ima_t;
+ // FIXME: Find a shorter name (skel_ima ? Careful, there is already a `skel' image
below).
+ bin_triangle_ima_t bin_triangle_ima =
+ mln::mutable_extend((surface | is_a_triangle).rw(), surface);
+
+ // ------------------------ //
+ // Simple point predicate. //
+ // ------------------------ //
+
+ // Neighborhood type returning the set of (n-1)- and (n+1)-faces
+ // adjacent to a an n-face.
+ typedef mln::complex_lower_higher_neighborhood<D, G> adj_nbh_t;
+ // Neighborhood type returning the set of (n-1)-faces adjacent to a
+ // an n-face.
+ typedef mln::complex_lower_neighborhood<D, G> lower_adj_nbh_t;
+ // Neighborhood type returning the set of (n+1)-faces adjacent to a
+ // an n-face.
+ typedef mln::complex_higher_neighborhood<D, G> higher_adj_nbh_t;
+ // Predicate type: is a triangle (2-face) simple?
+ typedef mln::topo::is_simple_cell< bin_triangle_ima_t,
+ adj_nbh_t,
+ lower_adj_nbh_t,
+ higher_adj_nbh_t >
+ is_simple_triangle_t;
+ is_simple_triangle_t is_simple_triangle;
+
+ // ------------------------------- //
+ // Simple point detach procedure. //
+ // ------------------------------- //
+
+ // Type of adjacency relationships between faces of immediately
+ // lower and higher dimensions.
+ adj_nbh_t adj_nbh;
+ // Functor detaching a cell.
+ mln::topo::detach_cell<bin_triangle_ima_t, adj_nbh_t> detach(adj_nbh);
+
+ mln_concrete_(bin_triangle_ima_t) skel =
+ mln::topo::skeleton::breadth_first_thinning(bin_triangle_ima,
+ nbh,
+ is_simple_triangle,
+ detach);
- breadth_first_thinning(surface | is_n_face<2>, nbh, is_simple_p);
-
- As a workaround, we use the constraint predicate of the
- skeleton routine to restrict the iteration to 2-cells. */
- mln::topo::is_n_face<bin_ima_t::dim> constraint_p;
- bin_ima_t skel =
- mln::topo::skeleton::breadth_first_thinning(surface, nbh,
- is_simple_p,
- mln::topo::detach<D, G>,
- constraint_p);
/*---------.
| Output. |
`---------*/
/* FIXME: This does not work (yet).
- Use workaround mln::io::off::save_bin_alt instead (bad!) */
+ Use workaround mln::io::off::save_bin_alt instead (bad!)
+
+ Moreover, even if it worked, it would not have the same meaning
+ as mln::io::off::save_bin_alt. Maybe the latter is useful, after
+ all. But we need to factor it with the code of
+ mln::io::off::save, anyway. */
#if 0
mln::io::off::save(skel | mln::pw::value(skel) == mln::pw::cst(true),
output_filename);
#endif
- mln::io::off::save_bin_alt(skel, output_filename);
+ // FIXME: We have to ``unmorph'' (twice!) SKEL first, since save_bin_alt only
+ // handles complex_image's.
+ mln::io::off::save_bin_alt(skel.unmorph_().unmorph_(), output_filename);
}
diff --git a/milena/apps/mesh-segm-skel/mesh-complex-pinv-curv-skel.cc
b/milena/apps/mesh-segm-skel/mesh-complex-pinv-curv-skel.cc
index 4a59a6b..07f1925 100644
--- a/milena/apps/mesh-segm-skel/mesh-complex-pinv-curv-skel.cc
+++ b/milena/apps/mesh-segm-skel/mesh-complex-pinv-curv-skel.cc
@@ -39,7 +39,9 @@
#include <mln/core/image/complex_image.hh>
#include <mln/core/image/complex_neighborhoods.hh>
-#include <mln/core/site_set/p_set.hh>
+#include <mln/core/image/dmorph/image_if.hh>
+#include <mln/core/image/dmorph/mutable_extension_ima.hh>
+#include <mln/core/routine/mutable_extend.hh>
#include <mln/value/label_16.hh>
@@ -48,7 +50,7 @@
#include <mln/topo/is_n_face.hh>
#include <mln/topo/is_simple_cell.hh>
-#include <mln/topo/detach.hh>
+#include <mln/topo/detach_cell.hh>
#include <mln/topo/skeleton/breadth_first_thinning.hh>
#include <mln/io/off/load.hh>
@@ -257,31 +259,77 @@ main(int argc, char* argv[])
| Skeleton. |
`-----------*/
- mln::topo::is_simple_cell<bin_ima_t> is_simple_p;
- /* FIXME: Cheat! We'd like to iterate on cells of highest
- dimension (2-cells) only, but we cannot constrain the domain of
- the input using image_if (yet) like this
+ // ---------------- //
+ // Skeleton image. //
+ // ---------------- //
+
+ // Predicate type: is a face a triangle (2-face)?
+ typedef mln::topo::is_n_face<D> is_a_triangle_t;
+ is_a_triangle_t is_a_triangle;
+ // Surface image type, of which domain is restricted to triangles.
+ typedef mln::image_if<bin_ima_t, is_a_triangle_t> bin_triangle_only_ima_t;
+ // Surface image type, of which iteration (not domain) is restricted
+ // to triangles.
+ typedef mln::mutable_extension_ima<bin_triangle_only_ima_t, bin_ima_t>
+ bin_triangle_ima_t;
+ // FIXME: Find a shorter name (skel_ima ? Careful, there is already a `skel' image
below).
+ bin_triangle_ima_t bin_triangle_ima =
+ mln::mutable_extend((surface | is_a_triangle).rw(), surface);
+
+ // ------------------------ //
+ // Simple point predicate. //
+ // ------------------------ //
+
+ // Neighborhood type returning the set of (n-1)- and (n+1)-faces
+ // adjacent to a an n-face.
+ typedef mln::complex_lower_higher_neighborhood<D, G> adj_nbh_t;
+ // Neighborhood type returning the set of (n-1)-faces adjacent to a
+ // an n-face.
+ typedef mln::complex_lower_neighborhood<D, G> lower_adj_nbh_t;
+ // Neighborhood type returning the set of (n+1)-faces adjacent to a
+ // an n-face.
+ typedef mln::complex_higher_neighborhood<D, G> higher_adj_nbh_t;
+ // Predicate type: is a triangle (2-face) simple?
+ typedef mln::topo::is_simple_cell< bin_triangle_ima_t,
+ adj_nbh_t,
+ lower_adj_nbh_t,
+ higher_adj_nbh_t >
+ is_simple_triangle_t;
+ is_simple_triangle_t is_simple_triangle;
+
+ // ------------------------------- //
+ // Simple point detach procedure. //
+ // ------------------------------- //
+
+ // Type of adjacency relationships between faces of immediately
+ // lower and higher dimensions.
+ adj_nbh_t adj_nbh;
+ // Functor detaching a cell.
+ mln::topo::detach_cell<bin_triangle_ima_t, adj_nbh_t> detach(adj_nbh);
+
+ mln_concrete_(bin_triangle_ima_t) skel =
+ mln::topo::skeleton::breadth_first_thinning(bin_triangle_ima,
+ nbh,
+ is_simple_triangle,
+ detach);
- breadth_first_thinning(surface | is_n_face<2>, nbh, is_simple_p);
-
- As a workaround, we use the constraint predicate of the
- skeleton routine to restrict the iteration to 2-cells. */
- mln::topo::is_n_face<bin_ima_t::dim> constraint_p;
- bin_ima_t skel =
- mln::topo::skeleton::breadth_first_thinning(surface, nbh,
- is_simple_p,
- mln::topo::detach<D, G>,
- constraint_p);
/*---------.
| Output. |
`---------*/
/* FIXME: This does not work (yet).
- Use workaround mln::io::off::save_bin_alt instead (bad!) */
+ Use workaround mln::io::off::save_bin_alt instead (bad!)
+
+ Moreover, even if it worked, it would not have the same meaning
+ as mln::io::off::save_bin_alt. Maybe the latter is useful, after
+ all. But we need to factor it with the code of
+ mln::io::off::save, anyway. */
#if 0
mln::io::off::save(skel | mln::pw::value(skel) == mln::pw::cst(true),
output_filename);
#endif
- mln::io::off::save_bin_alt(skel, output_filename);
+ // FIXME: We have to ``unmorph'' (twice!) SKEL first, since save_bin_alt only
+ // handles complex_image's.
+ mln::io::off::save_bin_alt(skel.unmorph_().unmorph_(), output_filename);
}
diff --git a/milena/apps/mesh-segm-skel/mesh-complex-skel.cc
b/milena/apps/mesh-segm-skel/mesh-complex-skel.cc
index 5cd97b4..af57de0 100644
--- a/milena/apps/mesh-segm-skel/mesh-complex-skel.cc
+++ b/milena/apps/mesh-segm-skel/mesh-complex-skel.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2008, 2009, 2010 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of the Milena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -35,7 +36,9 @@
#include <mln/core/image/complex_image.hh>
#include <mln/core/image/complex_neighborhoods.hh>
-#include <mln/core/site_set/p_set.hh>
+#include <mln/core/image/dmorph/image_if.hh>
+#include <mln/core/image/dmorph/mutable_extension_ima.hh>
+#include <mln/core/routine/mutable_extend.hh>
#include <mln/value/label_16.hh>
@@ -44,7 +47,7 @@
#include <mln/topo/is_n_face.hh>
#include <mln/topo/is_simple_cell.hh>
-#include <mln/topo/detach.hh>
+#include <mln/topo/detach_cell.hh>
#include <mln/topo/skeleton/breadth_first_thinning.hh>
#include <mln/io/off/load.hh>
@@ -209,31 +212,77 @@ main(int argc, char* argv[])
| Skeleton. |
`-----------*/
- mln::topo::is_simple_cell<bin_ima_t> is_simple_p;
- /* FIXME: Cheat! We'd like to iterate on cells of highest
- dimension (2-cells) only, but we cannot constrain the domain of
- the input using image_if (yet) like this
+ // ---------------- //
+ // Skeleton image. //
+ // ---------------- //
+
+ // Predicate type: is a face a triangle (2-face)?
+ typedef mln::topo::is_n_face<D> is_a_triangle_t;
+ is_a_triangle_t is_a_triangle;
+ // Surface image type, of which domain is restricted to triangles.
+ typedef mln::image_if<bin_ima_t, is_a_triangle_t> bin_triangle_only_ima_t;
+ // Surface image type, of which iteration (not domain) is restricted
+ // to triangles.
+ typedef mln::mutable_extension_ima<bin_triangle_only_ima_t, bin_ima_t>
+ bin_triangle_ima_t;
+ // FIXME: Find a shorter name (skel_ima ? Careful, there is already a `skel' image
below).
+ bin_triangle_ima_t bin_triangle_ima =
+ mln::mutable_extend((surface | is_a_triangle).rw(), surface);
+
+ // ------------------------ //
+ // Simple point predicate. //
+ // ------------------------ //
+
+ // Neighborhood type returning the set of (n-1)- and (n+1)-faces
+ // adjacent to a an n-face.
+ typedef mln::complex_lower_higher_neighborhood<D, G> adj_nbh_t;
+ // Neighborhood type returning the set of (n-1)-faces adjacent to a
+ // an n-face.
+ typedef mln::complex_lower_neighborhood<D, G> lower_adj_nbh_t;
+ // Neighborhood type returning the set of (n+1)-faces adjacent to a
+ // an n-face.
+ typedef mln::complex_higher_neighborhood<D, G> higher_adj_nbh_t;
+ // Predicate type: is a triangle (2-face) simple?
+ typedef mln::topo::is_simple_cell< bin_triangle_ima_t,
+ adj_nbh_t,
+ lower_adj_nbh_t,
+ higher_adj_nbh_t >
+ is_simple_triangle_t;
+ is_simple_triangle_t is_simple_triangle;
+
+ // ------------------------------- //
+ // Simple point detach procedure. //
+ // ------------------------------- //
+
+ // Type of adjacency relationships between faces of immediately
+ // lower and higher dimensions.
+ adj_nbh_t adj_nbh;
+ // Functor detaching a cell.
+ mln::topo::detach_cell<bin_triangle_ima_t, adj_nbh_t> detach(adj_nbh);
+
+ mln_concrete_(bin_triangle_ima_t) skel =
+ mln::topo::skeleton::breadth_first_thinning(bin_triangle_ima,
+ nbh,
+ is_simple_triangle,
+ detach);
- breadth_first_thinning(surface | is_n_face<2>, nbh, is_simple_p);
-
- As a workaround, we use the constraint predicate of the
- skeleton routine to restrict the iteration to 2-cells. */
- mln::topo::is_n_face<bin_ima_t::dim> constraint_p;
- bin_ima_t skel =
- mln::topo::skeleton::breadth_first_thinning(surface, nbh,
- is_simple_p,
- mln::topo::detach<D, G>,
- constraint_p);
/*---------.
| Output. |
`---------*/
/* FIXME: This does not work (yet).
- Use workaround mln::io::off::save_bin_alt instead (bad!) */
+ Use workaround mln::io::off::save_bin_alt instead (bad!)
+
+ Moreover, even if it worked, it would not have the same meaning
+ as mln::io::off::save_bin_alt. Maybe the latter is useful, after
+ all. But we need to factor it with the code of
+ mln::io::off::save, anyway. */
#if 0
mln::io::off::save(skel | mln::pw::value(skel) == mln::pw::cst(true),
output_filename);
#endif
- mln::io::off::save_bin_alt(skel, output_filename);
+ // FIXME: We have to ``unmorph'' (twice!) SKEL first, since save_bin_alt only
+ // handles complex_image's.
+ mln::io::off::save_bin_alt(skel.unmorph_().unmorph_(), output_filename);
}
--
1.5.6.5