* 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 | 82 ++++++++++++++++----
.../mesh-segm-skel/mesh-complex-pinv-curv-skel.cc | 82 ++++++++++++++++----
milena/apps/mesh-segm-skel/mesh-complex-skel.cc | 82 ++++++++++++++++----
4 files changed, 205 insertions(+), 51 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index bff25d3..40e876c 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 edb943e..641b0b4 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>
@@ -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<mln_psite_(bin_ima_t), 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<mln_psite_(bin_ima_t), bin_ima_t::dim> constraint_p;
- bin_ima_t skel =
- mln::topo::skeleton::breadth_first_thinning(surface, nbh,
- is_simple_p,
- mln::topo::detach_cell<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 e2bdf45..5096efa 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>
@@ -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<mln_psite_(bin_ima_t), 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<mln_psite_(bin_ima_t), bin_ima_t::dim> constraint_p;
- bin_ima_t skel =
- mln::topo::skeleton::breadth_first_thinning(surface, nbh,
- is_simple_p,
- mln::topo::detach_cell<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 b8b7da8..4f5ca78 100644
--- a/milena/apps/mesh-segm-skel/mesh-complex-skel.cc
+++ b/milena/apps/mesh-segm-skel/mesh-complex-skel.cc
@@ -36,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>
@@ -210,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<mln_psite_(bin_ima_t), 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<mln_psite_(bin_ima_t), bin_ima_t::dim> constraint_p;
- bin_ima_t skel =
- mln::topo::skeleton::breadth_first_thinning(surface, nbh,
- is_simple_p,
- mln::topo::detach_cell<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