* apps/generic-skel/image2d-skel-unconstrained.cc,
* apps/generic-skel/image2d-skel-with-end-points.cc,
* apps/generic-skel/image2d-skel.hh:
New.
* apps/generic-skel/test-image2d-skel-unconstrained.in,
* apps/generic-skel/test-image2d-skel-with-end-points.in:
New tests.
* apps/generic-skel/Makefile.am: New.
* apps/Makefile.am (SUBDIRS): Add generic-skel.
---
milena/ChangeLog | 14 ++
milena/apps/Makefile.am | 6 +-
milena/apps/generic-skel/Makefile.am | 54 ++++++
.../image2d-skel-unconstrained.cc} | 53 +++++--
.../image2d-skel-with-end-points.cc} | 52 +++++--
milena/apps/generic-skel/image2d-skel.hh | 174 ++++++++++++++++++++
.../test-image2d-skel-unconstrained.in} | 7 +-
.../test-image2d-skel-with-end-points.in} | 7 +-
8 files changed, 330 insertions(+), 37 deletions(-)
create mode 100644 milena/apps/generic-skel/Makefile.am
copy milena/apps/{mesh-segm-skel/off-to-vtk-bin.cc => generic-skel/image2d-skel-unconstrained.cc} (53%)
copy milena/apps/{mesh-segm-skel/off-to-vtk-bin.cc => generic-skel/image2d-skel-with-end-points.cc} (53%)
create mode 100644 milena/apps/generic-skel/image2d-skel.hh
copy milena/apps/{mesh-segm-skel/test-mesh-complex-2-collapse.in => generic-skel/test-image2d-skel-unconstrained.in} (71%)
copy milena/apps/{mesh-segm-skel/test-mesh-complex-2-collapse.in => generic-skel/test-image2d-skel-with-end-points.in} (70%)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index f567ea8..16b07b7 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,17 @@
+2010-08-20 Roland Levillain <roland(a)lrde.epita.fr>
+
+ New apps on generic skeletonization.
+
+ * apps/generic-skel/image2d-skel-unconstrained.cc,
+ * apps/generic-skel/image2d-skel-with-end-points.cc,
+ * apps/generic-skel/image2d-skel.hh:
+ New.
+ * apps/generic-skel/test-image2d-skel-unconstrained.in,
+ * apps/generic-skel/test-image2d-skel-with-end-points.in:
+ New tests.
+ * apps/generic-skel/Makefile.am: New.
+ * apps/Makefile.am (SUBDIRS): Add generic-skel.
+
2011-04-12 Roland Levillain <roland(a)lrde.epita.fr>
apps/graph-morpho: Catch up with current mln::topo::is_n_face.
diff --git a/milena/apps/Makefile.am b/milena/apps/Makefile.am
index c42ffd7..c15569b 100644
--- a/milena/apps/Makefile.am
+++ b/milena/apps/Makefile.am
@@ -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 Olena.
#
@@ -13,10 +14,9 @@
#
# You should have received a copy of the GNU General Public License
# along with Olena. If not, see <http://www.gnu.org/licenses/>.
-#
# Applied examples of Milena.
-SUBDIRS = mesh-segm-skel graph-morpho constrained-connectivity
+SUBDIRS = mesh-segm-skel generic-skel graph-morpho constrained-connectivity
# Examples from papers.
SUBDIRS += papers
diff --git a/milena/apps/generic-skel/Makefile.am b/milena/apps/generic-skel/Makefile.am
new file mode 100644
index 0000000..5ae65f5
--- /dev/null
+++ b/milena/apps/generic-skel/Makefile.am
@@ -0,0 +1,54 @@
+# Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE).
+#
+# This file is part of Olena.
+#
+# Olena is free software: you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free
+# Software Foundation, version 2 of the License.
+#
+# Olena is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Olena. If not, see <http://www.gnu.org/licenses/>.
+
+# Find Milena and trimesh headers.
+AM_CPPFLAGS = -I$(top_srcdir)/milena
+# Produce fast code.
+APPS_CXXFLAGS = @APPS_CXXFLAGS@
+AM_CXXFLAGS = $(APPS_CXXFLAGS)
+
+
+bin_PROGRAMS = image2d-skel-unconstrained image2d-skel-with-end-points
+image2d_skel_unconstrained_SOURCES = image2d-skel-unconstrained.cc image2d-skel.hh
+image2d_skel_with_end_points_SOURCES = image2d-skel-with-end-points.cc image2d-skel.hh
+
+EXTRA_DIST = test-image2d-skel-unconstrained.in test-image2d-skel-with-end-points.in
+
+# Use Make to generate Doxyfile instead of `configure', as advised by
+# Autoconf's manual (see section ``Installation Directory
+# Variables'').
+edit = sed -e 's|@top_srcdir[@]|$(top_srcdir)|g'
+
+test-image2d-skel-unconstrained test-image2d-skel-with-end-points: Makefile
+ rm -f $@ $@.tmp
+ srcdir=''; \
+ test -f ./$@.in || srcdir=$(srcdir)/; \
+ $(edit) $${srcdir}$@.in >$@.tmp
+ chmod +x $@.tmp
+ chmod a-w $@.tmp
+ mv $@.tmp $@
+
+test-image2d-skel-unconstrained: $(srcdir)/test-image2d-skel-unconstrained.in
+test-image2d-skel-with-end-points: $(srcdir)/test-image2d-skel-with-end-points.in
+
+TESTS = test-image2d-skel-unconstrained test-image2d-skel-with-end-points
+CLEANFILES = test-image2d-skel-unconstrained test-image2d-skel-with-end-points
+
+MOSTLYCLEANFILES = \
+ picasso-skel-unconstrained.pbm \
+ picasso-skel-with-end-points.pbm \
+ tiny-skel-unconstrained.pbm \
+ tiny-skel-with-end-points.pbm
diff --git a/milena/apps/mesh-segm-skel/off-to-vtk-bin.cc b/milena/apps/generic-skel/image2d-skel-unconstrained.cc
similarity index 53%
copy from milena/apps/mesh-segm-skel/off-to-vtk-bin.cc
copy to milena/apps/generic-skel/image2d-skel-unconstrained.cc
index 926da7d..4459ba4 100644
--- a/milena/apps/mesh-segm-skel/off-to-vtk-bin.cc
+++ b/milena/apps/generic-skel/image2d-skel-unconstrained.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 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
@@ -26,22 +26,26 @@
// Public License.
/// \file
+/// \brief A program computing an unconstrained skeleton of a 2D image.
-/// \brief A program converting a binary OFF file (e.g. no value
-/// attached to faces) into a VTK file.
+#include <mln/core/image/image2d.hh>
+#include <mln/core/alias/neighb2d.hh>
-#include <iostream>
+#include <mln/topo/skeleton/breadth_first_thinning.hh>
-#include <mln/io/off/load.hh>
-#include <mln/io/vtk/save.hh>
+#include <mln/io/pbm/all.hh>
+
+#include "image2d-skel.hh"
int
main(int argc, char* argv[])
{
+ using namespace mln;
+
if (argc != 3)
{
- std::cerr << "usage: " << argv[0] << " input.off output.vtk"
+ std::cerr << "usage: " << argv[0] << " input.pbm output.pbm"
<< std::endl;
std::exit(1);
}
@@ -49,12 +53,33 @@ main(int argc, char* argv[])
std::string input_filename = argv[1];
std::string output_filename = argv[2];
- typedef mln::bin_2complex_image3df ima_t;
- ima_t ima;
+ typedef image2d<bool> I;
+ typedef neighb2d N;
+
+ // Add a border of (at least) 1 pixel, to a guarantee a meaningful
+ // result of the computation of connectivity numbers (called within
+ // is_simple_2d); indeed, this computation always expects each pixel
+ // to have 8 neighboring sites.
+ border::thickness = 1;
+
+ I input = io::pbm::load(input_filename);
+
+ // FIXME: Use a dual neighborhood instead?
+
+ // Foreground neighborhood.
+ neighb2d nbh_fg = c4();
+ // Background neighborhood.
+ neighb2d nbh_bg = c8();
+
+ // Simplicity criterion functor.
+ ::is_simple_2d<I, N> is_simple(nbh_fg, nbh_bg);
+ // Detach procedure.
+ ::detach<I> detach;
+ // (Lack of) constraint.
+ fun::p2b::tautology constraint;
- // FIXME: Converting bunny-holefilled.off to VTK took 30 sec, which
- // is awfully slow. Time the load and save operations and find
- // where is (are) the issue(s).
- mln::io::off::load(ima, input_filename);
- mln::io::vtk::save(ima, output_filename);
+ I output = topo::skeleton::breadth_first_thinning(input, nbh_fg,
+ is_simple, detach,
+ constraint);
+ io::pbm::save(output, output_filename);
}
diff --git a/milena/apps/mesh-segm-skel/off-to-vtk-bin.cc b/milena/apps/generic-skel/image2d-skel-with-end-points.cc
similarity index 53%
copy from milena/apps/mesh-segm-skel/off-to-vtk-bin.cc
copy to milena/apps/generic-skel/image2d-skel-with-end-points.cc
index 926da7d..604b065 100644
--- a/milena/apps/mesh-segm-skel/off-to-vtk-bin.cc
+++ b/milena/apps/generic-skel/image2d-skel-with-end-points.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 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
@@ -26,22 +26,27 @@
// Public License.
/// \file
+/// \brief A program computing a skeleton of a 2D image, preserving
+/// end points.
-/// \brief A program converting a binary OFF file (e.g. no value
-/// attached to faces) into a VTK file.
+#include <mln/core/image/image2d.hh>
+#include <mln/core/alias/neighb2d.hh>
-#include <iostream>
+#include <mln/topo/skeleton/breadth_first_thinning.hh>
-#include <mln/io/off/load.hh>
-#include <mln/io/vtk/save.hh>
+#include <mln/io/pbm/all.hh>
+
+#include "image2d-skel.hh"
int
main(int argc, char* argv[])
{
+ using namespace mln;
+
if (argc != 3)
{
- std::cerr << "usage: " << argv[0] << " input.off output.vtk"
+ std::cerr << "usage: " << argv[0] << " input.pbm output.pbm"
<< std::endl;
std::exit(1);
}
@@ -49,12 +54,31 @@ main(int argc, char* argv[])
std::string input_filename = argv[1];
std::string output_filename = argv[2];
- typedef mln::bin_2complex_image3df ima_t;
- ima_t ima;
+ typedef image2d<bool> I;
+ typedef neighb2d N;
+
+ // Add a border of (at least) 1 pixel, to a guarantee a meaningful
+ // result of the computation of connectivity numbers (called within
+ // is_simple_2d); indeed, this computation always expects each pixel
+ // to have 8 neighboring sites.
+ border::thickness = 1;
+
+ I input = io::pbm::load(input_filename);
+
+ // Foreground neighborhood.
+ neighb2d nbh_fg = c4();
+ // Background neighborhood.
+ neighb2d nbh_bg = c8();
+
+ // Simplicity criterion functor.
+ ::is_simple_2d<I, N> is_simple(nbh_fg, nbh_bg);
+ // Detach procedure.
+ ::detach<I> detach;
+ // Constraint: do not remove end points.
+ is_not_end_point<I, N> constraint(nbh_fg, input);
- // FIXME: Converting bunny-holefilled.off to VTK took 30 sec, which
- // is awfully slow. Time the load and save operations and find
- // where is (are) the issue(s).
- mln::io::off::load(ima, input_filename);
- mln::io::vtk::save(ima, output_filename);
+ I output = topo::skeleton::breadth_first_thinning(input, nbh_fg,
+ is_simple, detach,
+ constraint);
+ io::pbm::save(output, output_filename);
}
diff --git a/milena/apps/generic-skel/image2d-skel.hh b/milena/apps/generic-skel/image2d-skel.hh
new file mode 100644
index 0000000..6cd8c50
--- /dev/null
+++ b/milena/apps/generic-skel/image2d-skel.hh
@@ -0,0 +1,174 @@
+// Copyright (C) 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
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// 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
+// 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
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef APPS_GENERIC_SKEL_IMAGE2D_SKEL_HH
+# define APPS_GENERIC_SKEL_IMAGE2D_SKEL_HH
+
+/// \file
+/// \brief Definitions for a simplicity criterion and a constraint
+/// to be used in the breadth-first thinning of a 2D regular image.
+
+# include <mln/topo/is_simple_2d.hh>
+
+
+// FIXME: Split this file?
+
+
+/** \brief An equivalent (for mln::image2d) of the
+ mln::topo::is_simple_cell functor, based on the mask-based
+ criterion mln::topo::is_simple_2d.
+
+ This functor acts as an adapter, since mln::topo::is_simple_2d
+ does not fit (yet) in the canvas of
+ mln::topo::skeleton::breadth_first_thinning. Moreover, this code
+ is a bit easier to read since it does not make use of a dual
+ neighborhood (having a long and complex type). */
+template <typename I, typename N>
+class is_simple_2d : public mln::Function_v2b< is_simple_2d<I, N> >
+{
+public:
+ /// Result type of the functor.
+ typedef bool result;
+
+ /// Build a functor.
+ ///
+ /// \param nbh_fg The foreground neighborhood.
+ /// \param nbh_bg The background neighborhood.
+ is_simple_2d(const mln::Neighborhood<N>& nbh_fg,
+ const mln::Neighborhood<N>& nbh_bg)
+ : nbh_fg_(mln::exact(nbh_fg)), nbh_bg_(mln::exact(nbh_bg)),
+ ima_(0)
+ {
+ }
+
+ /// Build a functor, and assign an image to it.
+ ///
+ /// \param nbh_fg The foreground neighborhood.
+ /// \param nbh_bg The background neighborhood.
+ /// \apram ima The image.
+ is_simple_2d(const mln::Neighborhood<N>& nbh_fg,
+ const mln::Neighborhood<N>& nbh_bg,
+ const mln::Image<I>& ima)
+ : nbh_fg_(mln::exact(nbh_fg)), nbh_bg_(mln::exact(nbh_bg)),
+ ima_(mln::exact(&ima))
+ {
+ }
+
+ /// Set the underlying image.
+ void set_image(const mln::Image<I>& ima)
+ {
+ ima_ = mln::exact(&ima);
+ }
+
+ /// Based on connectivity numbers.
+ bool operator()(const mln_psite(I)& p) const
+ {
+ return
+ mln::connectivity_number_2d(*ima_, nbh_fg_, p, true ) == 1 &&
+ mln::connectivity_number_2d(*ima_, nbh_bg_, p, false) == 1;
+ }
+
+private:
+ /// The foreground neighborhood.
+ const N& nbh_fg_;
+ /// The background neighborhood.
+ const N& nbh_bg_;
+ /// The image.
+ const I* ima_;
+};
+
+
+template <typename I>
+class detach
+{
+public:
+ /// Build a functor.
+ detach()
+ : ima_(0)
+ {
+ }
+
+ /// Build a functor, and assign an image to it.
+ ///
+ /// \apram ima The image.
+ detach(mln::Image<I>& ima)
+ : ima_(mln::exact(&ima))
+ {
+ }
+
+ /// Set the underlying image.
+ void set_image(mln::Image<I>& ima)
+ {
+ ima_ = mln::exact(&ima);
+ }
+
+ void operator()(const mln_psite(I)& p) const
+ {
+ (*ima_)(p) = false;
+ }
+
+private:
+ /// The image.
+ I* ima_;
+};
+
+
+template <typename I, typename N>
+struct is_not_end_point : public mln::Function_v2b< is_not_end_point<I, N> >
+{
+ /// Build a functor, and assign an image to it.
+ ///
+ /// \param nbh_fg The foreground neighborhood.
+ /// \apram ima The image.
+ is_not_end_point(const mln::Neighborhood<N>& nbh,
+ const mln::Image<I>& ima)
+ : nbh_(mln::exact(nbh)),
+ ima_(mln::exact(ima))
+ {
+ }
+
+ // Is \a p not a end point?
+ bool operator()(const mln_psite(I)& p) const
+ {
+ // Number of foreground neighbors pixels.
+ unsigned nneighbs = 0;
+ mln_niter(N) n(nbh_, p);
+ for_all(n)
+ if (ima_.has(n) && ima_(n))
+ ++nneighbs;
+ return nneighbs != 1;
+ }
+
+private:
+ /// The foreground neighborhood.
+ const N& nbh_;
+ /// The image.
+ const I& ima_;
+};
+
+
+#endif // ! APPS_GENERIC_SKEL_IMAGE2D_SKEL_HH
diff --git a/milena/apps/mesh-segm-skel/test-mesh-complex-2-collapse.in b/milena/apps/generic-skel/test-image2d-skel-unconstrained.in
similarity index 71%
copy from milena/apps/mesh-segm-skel/test-mesh-complex-2-collapse.in
copy to milena/apps/generic-skel/test-image2d-skel-unconstrained.in
index d2a286b..b9f6b44 100644
--- a/milena/apps/mesh-segm-skel/test-mesh-complex-2-collapse.in
+++ b/milena/apps/generic-skel/test-image2d-skel-unconstrained.in
@@ -1,6 +1,6 @@
#! /bin/sh
-# Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE).
+# Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE).
#
# This file is part of Olena.
#
@@ -18,6 +18,7 @@
set -ex
-mesh_dir=@top_srcdir@/milena/mesh
+img_dir=@top_srcdir@/milena/img
-time ./mesh-complex-2-collapse $mesh_dir/pseudo-manifold.vtk pseudo-manifold-2-collapse.vtk
+./image2d-skel-unconstrained $img_dir/tiny.pbm tiny-skel-unconstrained.pbm
+./image2d-skel-unconstrained $img_dir/picasso.pbm picasso-skel-unconstrained.pbm
diff --git a/milena/apps/mesh-segm-skel/test-mesh-complex-2-collapse.in b/milena/apps/generic-skel/test-image2d-skel-with-end-points.in
similarity index 70%
copy from milena/apps/mesh-segm-skel/test-mesh-complex-2-collapse.in
copy to milena/apps/generic-skel/test-image2d-skel-with-end-points.in
index d2a286b..946e8fd 100644
--- a/milena/apps/mesh-segm-skel/test-mesh-complex-2-collapse.in
+++ b/milena/apps/generic-skel/test-image2d-skel-with-end-points.in
@@ -1,6 +1,6 @@
#! /bin/sh
-# Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE).
+# Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE).
#
# This file is part of Olena.
#
@@ -18,6 +18,7 @@
set -ex
-mesh_dir=@top_srcdir@/milena/mesh
+img_dir=@top_srcdir@/milena/img
-time ./mesh-complex-2-collapse $mesh_dir/pseudo-manifold.vtk pseudo-manifold-2-collapse.vtk
+./image2d-skel-with-end-points $img_dir/tiny.pbm tiny-skel-with-end-points.pbm
+./image2d-skel-with-end-points $img_dir/picasso.pbm picasso-skel-with-end-points.pbm
--
1.5.6.5
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Olena, a generic and efficient image processing platform".
The branch skeletons has been deleted
was a087bc4d5c23b64db8ca8a3fe40c73387419ec70
-----------------------------------------------------------------------
a087bc4d5c23b64db8ca8a3fe40c73387419ec70 Catch up with the renaming to detach_cell.
-----------------------------------------------------------------------
hooks/post-receive
--
Olena, a generic and efficient image processing platform
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Olena, a generic and efficient image processing platform".
The branch more-generic-skel has been deleted
was 8cbc0864835adb146da03fde34e7f3328bc580a8
-----------------------------------------------------------------------
8cbc0864835adb146da03fde34e7f3328bc580a8 Use mln::data::paste to simplify mesh skeleton applications.
-----------------------------------------------------------------------
hooks/post-receive
--
Olena, a generic and efficient image processing platform
* apps/mesh-segm-skel/mesh-complex-max-curv-2-collapse.cc,
* apps/mesh-segm-skel/mesh-complex-max-curv-1-collapse.cc:
Here.
---
milena/ChangeLog | 8 +
.../mesh-complex-max-curv-1-collapse.cc | 196 +++++++++-----------
.../mesh-complex-max-curv-2-collapse.cc | 193 +++++++++----------
3 files changed, 188 insertions(+), 209 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 63b6054..8c32c8b 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,11 @@
+2011-03-20 Roland Levillain <roland(a)lrde.epita.fr>
+
+ Simplify curvature-based thinnings using 2- and 1-collapses apps.
+
+ * apps/mesh-segm-skel/mesh-complex-max-curv-2-collapse.cc,
+ * apps/mesh-segm-skel/mesh-complex-max-curv-1-collapse.cc:
+ Here.
+
2011-03-14 Roland Levillain <roland(a)lrde.epita.fr>
Miscellaneous changes in mesh-related operations.
diff --git a/milena/apps/mesh-segm-skel/mesh-complex-max-curv-1-collapse.cc b/milena/apps/mesh-segm-skel/mesh-complex-max-curv-1-collapse.cc
index 0cb29dd..8b12030 100644
--- a/milena/apps/mesh-segm-skel/mesh-complex-max-curv-1-collapse.cc
+++ b/milena/apps/mesh-segm-skel/mesh-complex-max-curv-1-collapse.cc
@@ -41,7 +41,7 @@
#include <mln/core/image/dmorph/image_if.hh>
#include <mln/core/image/dmorph/sub_image.hh>
-#include <mln/core/image/dmorph/mutable_extension_ima.hh>
+#include <mln/core/routine/extend.hh>
#include <mln/core/routine/mutable_extend.hh>
#include <mln/data/paste.hh>
@@ -49,6 +49,7 @@
#include <mln/labeling/regional_minima.hh>
#include <mln/morpho/closing/area.hh>
+#include <mln/morpho/dilation.hh>
#include <mln/topo/is_n_face.hh>
#include <mln/topo/is_simple_pair.hh>
@@ -101,31 +102,57 @@ main(int argc, char* argv[])
mln::math::sqr(curv.second(v)));
}
+ // 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;
+ lower_adj_nbh_t lower_adj_nbh;
+
+ // Values on edges.
+ /* FIXME: We could probably simplify this by using a
+ convolution-like operator and morphers (see
+ apps/graph-morpho). */
+ mln::p_n_faces_fwd_piter<D, G> e(float_ima.domain(), 1);
+ // For each edge (1-face) E, iterate on the the set of vertices
+ // (0-faces) adjacent to E.
+ mln_niter_(lower_adj_nbh_t) adj_v(lower_adj_nbh, e);
+ // Iterate on edges (1-faces).
+ for_all(e)
+ {
+ float s = 0.0f;
+ unsigned n = 0;
+ // Iterate on vertices (0-faces).
+ for_all(adj_v)
+ {
+ s += float_ima(adj_v);
+ ++n;
+ }
+ float_ima(e) = s / n;
+ // An edge should be adjacent to exactly two vertices.
+ mln_invariant(n == 2);
+ }
+
// Values on triangles.
+ /* FIXME: We could probably simplify this by using a
+ convolution-like operator and morphers (see
+ apps/graph-morpho). */
mln::p_n_faces_fwd_piter<D, G> t(float_ima.domain(), 2);
- // For each triangle (2-face) T, iterate on the the set of vertices
- // (0-faces) transitively adjacent to T.
- typedef mln::complex_m_face_neighborhood<D, G> adj_vertices_nbh_t;
- adj_vertices_nbh_t adj_vertices_nbh;
- mln_niter_(adj_vertices_nbh_t) adj_v(adj_vertices_nbh, t);
- /* FIXME: We should be able to pass this value (m) either at the
- construction of the neighborhood or at the construction of the
- iterator. */
- adj_v.iter().set_m(0);
+ // For each triangle (2-face) T, iterate on the the set of edges
+ // (1-faces) adjacent to T.
+ mln_niter_(lower_adj_nbh_t) adj_e(lower_adj_nbh, t);
// Iterate on triangles (2-faces).
for_all(t)
{
float s = 0.0f;
unsigned n = 0;
- // Iterate on vertices (0-faces).
- for_all(adj_v)
+ // Iterate on edges (1-faces).
+ for_all(adj_e)
{
- s += float_ima(adj_v);
+ s += float_ima(adj_e);
++n;
}
float_ima(t) = s / n;
- // A triangle should be adjacent to exactly two vertices.
- mln_invariant(n <= 3);
+ // A triangle should be adjacent to exactly three edges.
+ mln_invariant(n == 3);
}
// Convert the float image into an unsigned image because some
@@ -141,14 +168,6 @@ main(int argc, char* argv[])
for_all(t)
ima(t) = 1000 * float_ima(t);
- /* FIXME: Workaround: Set maximal values on vertices and edges to
- exclude them from the set of minimal values. */
- for_all(v)
- ima(v) = mln_max(mln_value_(ima_t));
- mln::p_n_faces_fwd_piter<D, G> e(float_ima.domain(), 1);
- for_all(e)
- ima(e) = mln_max(mln_value_(ima_t));
-
/*-----------------.
| Simplification. |
`-----------------*/
@@ -157,7 +176,15 @@ main(int argc, char* argv[])
typedef mln::complex_lower_dim_connected_n_face_neighborhood<D, G> nbh_t;
nbh_t nbh;
- ima_t closed_ima = mln::morpho::closing::area(ima, nbh, lambda);
+ // Predicate type: is a face a triangle (2-face)?
+ typedef mln::topo::is_n_face<mln_psite_(ima_t), 2> is_a_triangle_t;
+ is_a_triangle_t is_a_triangle;
+
+ // Consider only triangles.
+ ima_t closed_ima = mln::duplicate(ima);
+ mln::data::paste(mln::morpho::closing::area(ima | is_a_triangle,
+ nbh, lambda),
+ closed_ima);
/*---------------.
| Local minima. |
@@ -166,68 +193,13 @@ main(int argc, char* argv[])
typedef mln::value::label_16 label_t;
label_t nminima;
- /* FIXME: We should use something like `ima_t | p_n_faces(2)' instead
- of `ima_t' here. Or better: `input' should only associate data
- to 2-faces. */
+ // Consider only triangles.
typedef mln_ch_value_(ima_t, label_t) label_ima_t;
- label_ima_t minima =
- mln::labeling::regional_minima(closed_ima, nbh, nminima);
-
- typedef mln::complex_higher_neighborhood<D, G> higher_nbh_t;
- higher_nbh_t higher_nbh;
-
- // Propagate minima values from triangles to edges.
- // FIXME: Factor this inside a function.
- mln_niter_(higher_nbh_t) adj_t(higher_nbh, e);
- for_all(e)
- {
- label_t ref_adj_minimum = mln::literal::zero;
- for_all(adj_t)
- if (minima(adj_t) == mln::literal::zero)
- {
- // If E is adjacent to a non-minimal triangle, then it must
- // not belong to a minima.
- ref_adj_minimum = mln::literal::zero;
- break;
- }
- else
- {
- if (ref_adj_minimum == mln::literal::zero)
- // If this is the first minimum seen, use it as a reference.
- ref_adj_minimum = minima(adj_t);
- else
- // If this is not the first time a minimum is encountered,
- // ensure it is REF_ADJ_MINIMUM.
- mln_assertion(minima(adj_t) == ref_adj_minimum);
- }
- minima(e) = ref_adj_minimum;
- }
-
- // Likewise from edges to edges to vertices.
- mln_niter_(higher_nbh_t) adj_e(higher_nbh, v);
- for_all(v)
- {
- label_t ref_adj_minimum = mln::literal::zero;
- for_all(adj_e)
- if (minima(adj_e) == mln::literal::zero)
- {
- // If V is adjacent to a non-minimal triangle, then it must
- // not belong to a minima.
- ref_adj_minimum = mln::literal::zero;
- break;
- }
- else
- {
- if (ref_adj_minimum == mln::literal::zero)
- // If this is the first minimum seen, use it as a reference.
- ref_adj_minimum = minima(adj_e);
- else
- // If this is not the first time a minimum is encountered,
- // ensure it is REF_ADJ_MINIMUM.
- mln_assertion(minima(adj_e) == ref_adj_minimum);
- }
- minima(v) = ref_adj_minimum;
- }
+ label_ima_t minima;
+ mln::initialize(minima, closed_ima);
+ mln::data::paste(mln::labeling::regional_minima(closed_ima | is_a_triangle,
+ nbh, nminima),
+ minima);
/*-----------------------.
| Initial binary image. |
@@ -242,13 +214,39 @@ main(int argc, char* argv[])
typedef mln_ch_value_(ima_t, bool) bin_ima_t;
bin_ima_t surface(minima.domain());
- mln::data::fill(surface, true);
- // Dig ``holes'' in the surface surface by setting minima faces to false.
- // FIXME: Use fill with an image_if instead, when available/working.
- mln_piter_(bin_ima_t) f(minima.domain());
- for_all(f)
- if (minima(f) != mln::literal::zero)
- surface(f) = false;
+
+ // Predicate type: is a face an edge (1-face)?
+ typedef mln::topo::is_n_face<mln_psite_(ima_t), 1> is_an_edge_t;
+ is_an_edge_t is_an_edge;
+ // Predicate type: is a face a vertex (0-face)?
+ typedef mln::topo::is_n_face<mln_psite_(ima_t), 0> is_a_vertex_t;
+ is_a_vertex_t is_a_vertex;
+
+ // 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;
+ higher_adj_nbh_t higher_adj_nbh;
+
+ mln::data::fill(surface, false);
+ // Set non minima triangles to true;
+ mln::data::fill
+ ((surface |
+ mln::pw::value(minima) == mln::pw::cst(mln::literal::zero)).rw(),
+ true);
+ // Extend non minima values from triangles to edges.
+ mln::data::paste (mln::morpho::dilation(mln::extend(surface | is_an_edge,
+ surface),
+ /* Dilations require windows,
+ not neighborhoods. */
+ higher_adj_nbh.win()),
+ surface);
+ // Extend non minima values from edges to vertices.
+ mln::data::paste(mln::morpho::dilation(mln::extend(surface | is_a_vertex,
+ surface),
+ /* Dilations require windows,
+ not neighborhoods. */
+ higher_adj_nbh.win()),
+ surface);
/*-------------.
| 2-collapse. |
@@ -258,9 +256,6 @@ main(int argc, char* argv[])
// Image restricted to triangles. //
// ------------------------------- //
- // 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
@@ -272,14 +267,6 @@ main(int argc, char* argv[])
// Simple point predicate. //
// ------------------------ //
- // 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;
- lower_adj_nbh_t lower_adj_nbh;
- // 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;
- higher_adj_nbh_t higher_adj_nbh;
// Predicate type: is a triangle (2-face) simple?
typedef mln::topo::is_simple_pair< bin_triangle_ima_t,
lower_adj_nbh_t,
@@ -325,9 +312,6 @@ main(int argc, char* argv[])
// Image restricted to edges. //
// --------------------------- //
- // Predicate type: is a face an edge (1-face)?
- typedef mln::topo::is_n_face<mln_psite_(bin_ima_t), D - 1> is_an_edge_t;
- is_an_edge_t is_an_edge;
// Surface image type, of which domain is restricted to edges.
typedef mln::image_if<bin_ima_t, is_an_edge_t> bin_edge_only_ima_t;
// Surface image type, of which iteration (not domain) is restricted
diff --git a/milena/apps/mesh-segm-skel/mesh-complex-max-curv-2-collapse.cc b/milena/apps/mesh-segm-skel/mesh-complex-max-curv-2-collapse.cc
index 233756d..c88f10d 100644
--- a/milena/apps/mesh-segm-skel/mesh-complex-max-curv-2-collapse.cc
+++ b/milena/apps/mesh-segm-skel/mesh-complex-max-curv-2-collapse.cc
@@ -41,7 +41,7 @@
#include <mln/core/image/dmorph/image_if.hh>
#include <mln/core/image/dmorph/sub_image.hh>
-#include <mln/core/image/dmorph/mutable_extension_ima.hh>
+#include <mln/core/routine/extend.hh>
#include <mln/core/routine/mutable_extend.hh>
#include <mln/data/paste.hh>
@@ -49,6 +49,7 @@
#include <mln/labeling/regional_minima.hh>
#include <mln/morpho/closing/area.hh>
+#include <mln/morpho/dilation.hh>
#include <mln/topo/is_n_face.hh>
#include <mln/topo/is_simple_pair.hh>
@@ -101,31 +102,57 @@ main(int argc, char* argv[])
mln::math::sqr(curv.second(v)));
}
+ // 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;
+ lower_adj_nbh_t lower_adj_nbh;
+
+ // Values on edges.
+ /* FIXME: We could probably simplify this by using a
+ convolution-like operator and morphers (see
+ apps/graph-morpho). */
+ mln::p_n_faces_fwd_piter<D, G> e(float_ima.domain(), 1);
+ // For each edge (1-face) E, iterate on the the set of vertices
+ // (0-faces) adjacent to E.
+ mln_niter_(lower_adj_nbh_t) adj_v(lower_adj_nbh, e);
+ // Iterate on edges (1-faces).
+ for_all(e)
+ {
+ float s = 0.0f;
+ unsigned n = 0;
+ // Iterate on vertices (0-faces).
+ for_all(adj_v)
+ {
+ s += float_ima(adj_v);
+ ++n;
+ }
+ float_ima(e) = s / n;
+ // An edge should be adjacent to exactly two vertices.
+ mln_invariant(n == 2);
+ }
+
// Values on triangles.
+ /* FIXME: We could probably simplify this by using a
+ convolution-like operator and morphers (see
+ apps/graph-morpho). */
mln::p_n_faces_fwd_piter<D, G> t(float_ima.domain(), 2);
- // For each triangle (2-face) T, iterate on the the set of vertices
- // (0-faces) transitively adjacent to T.
- typedef mln::complex_m_face_neighborhood<D, G> adj_vertices_nbh_t;
- adj_vertices_nbh_t adj_vertices_nbh;
- mln_niter_(adj_vertices_nbh_t) adj_v(adj_vertices_nbh, t);
- /* FIXME: We should be able to pass this value (m) either at the
- construction of the neighborhood or at the construction of the
- iterator. */
- adj_v.iter().set_m(0);
+ // For each triangle (2-face) T, iterate on the the set of edges
+ // (1-faces) adjacent to T.
+ mln_niter_(lower_adj_nbh_t) adj_e(lower_adj_nbh, t);
// Iterate on triangles (2-faces).
for_all(t)
{
float s = 0.0f;
unsigned n = 0;
- // Iterate on vertices (0-faces).
- for_all(adj_v)
+ // Iterate on edges (1-faces).
+ for_all(adj_e)
{
- s += float_ima(adj_v);
+ s += float_ima(adj_e);
++n;
}
float_ima(t) = s / n;
- // A triangle should be adjacent to exactly two vertices.
- mln_invariant(n <= 3);
+ // A triangle should be adjacent to exactly three edges.
+ mln_invariant(n == 3);
}
// Convert the float image into an unsigned image because some
@@ -141,14 +168,6 @@ main(int argc, char* argv[])
for_all(t)
ima(t) = 1000 * float_ima(t);
- /* FIXME: Workaround: Set maximal values on vertices and edges to
- exclude them from the set of minimal values. */
- for_all(v)
- ima(v) = mln_max(mln_value_(ima_t));
- mln::p_n_faces_fwd_piter<D, G> e(float_ima.domain(), 1);
- for_all(e)
- ima(e) = mln_max(mln_value_(ima_t));
-
/*-----------------.
| Simplification. |
`-----------------*/
@@ -157,7 +176,15 @@ main(int argc, char* argv[])
typedef mln::complex_lower_dim_connected_n_face_neighborhood<D, G> nbh_t;
nbh_t nbh;
- ima_t closed_ima = mln::morpho::closing::area(ima, nbh, lambda);
+ // Predicate type: is a face a triangle (2-face)?
+ typedef mln::topo::is_n_face<mln_psite_(ima_t), 2> is_a_triangle_t;
+ is_a_triangle_t is_a_triangle;
+
+ // Consider only triangles.
+ ima_t closed_ima = mln::duplicate(ima);
+ mln::data::paste(mln::morpho::closing::area(ima | is_a_triangle,
+ nbh, lambda),
+ closed_ima);
/*---------------.
| Local minima. |
@@ -166,68 +193,13 @@ main(int argc, char* argv[])
typedef mln::value::label_16 label_t;
label_t nminima;
- /* FIXME: We should use something like `ima_t | p_n_faces(2)' instead
- of `ima_t' here. Or better: `input' should only associate data
- to 2-faces. */
+ // Consider only triangles.
typedef mln_ch_value_(ima_t, label_t) label_ima_t;
- label_ima_t minima =
- mln::labeling::regional_minima(closed_ima, nbh, nminima);
-
- typedef mln::complex_higher_neighborhood<D, G> higher_nbh_t;
- higher_nbh_t higher_nbh;
-
- // Propagate minima values from triangles to edges.
- // FIXME: Factor this inside a function.
- mln_niter_(higher_nbh_t) adj_t(higher_nbh, e);
- for_all(e)
- {
- label_t ref_adj_minimum = mln::literal::zero;
- for_all(adj_t)
- if (minima(adj_t) == mln::literal::zero)
- {
- // If E is adjacent to a non-minimal triangle, then it must
- // not belong to a minima.
- ref_adj_minimum = mln::literal::zero;
- break;
- }
- else
- {
- if (ref_adj_minimum == mln::literal::zero)
- // If this is the first minimum seen, use it as a reference.
- ref_adj_minimum = minima(adj_t);
- else
- // If this is not the first time a minimum is encountered,
- // ensure it is REF_ADJ_MINIMUM.
- mln_assertion(minima(adj_t) == ref_adj_minimum);
- }
- minima(e) = ref_adj_minimum;
- }
-
- // Likewise from edges to edges to vertices.
- mln_niter_(higher_nbh_t) adj_e(higher_nbh, v);
- for_all(v)
- {
- label_t ref_adj_minimum = mln::literal::zero;
- for_all(adj_e)
- if (minima(adj_e) == mln::literal::zero)
- {
- // If V is adjacent to a non-minimal triangle, then it must
- // not belong to a minima.
- ref_adj_minimum = mln::literal::zero;
- break;
- }
- else
- {
- if (ref_adj_minimum == mln::literal::zero)
- // If this is the first minimum seen, use it as a reference.
- ref_adj_minimum = minima(adj_e);
- else
- // If this is not the first time a minimum is encountered,
- // ensure it is REF_ADJ_MINIMUM.
- mln_assertion(minima(adj_e) == ref_adj_minimum);
- }
- minima(v) = ref_adj_minimum;
- }
+ label_ima_t minima;
+ mln::initialize(minima, closed_ima);
+ mln::data::paste(mln::labeling::regional_minima(closed_ima | is_a_triangle,
+ nbh, nminima),
+ minima);
/*-----------------------.
| Initial binary image. |
@@ -242,13 +214,39 @@ main(int argc, char* argv[])
typedef mln_ch_value_(ima_t, bool) bin_ima_t;
bin_ima_t surface(minima.domain());
- mln::data::fill(surface, true);
- // Dig ``holes'' in the surface surface by setting minima faces to false.
- // FIXME: Use fill with an image_if instead, when available/working.
- mln_piter_(bin_ima_t) f(minima.domain());
- for_all(f)
- if (minima(f) != mln::literal::zero)
- surface(f) = false;
+
+ // Predicate type: is a face an edge (1-face)?
+ typedef mln::topo::is_n_face<mln_psite_(ima_t), 1> is_an_edge_t;
+ is_an_edge_t is_an_edge;
+ // Predicate type: is a face a vertex (0-face)?
+ typedef mln::topo::is_n_face<mln_psite_(ima_t), 0> is_a_vertex_t;
+ is_a_vertex_t is_a_vertex;
+
+ // 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;
+ higher_adj_nbh_t higher_adj_nbh;
+
+ mln::data::fill(surface, false);
+ // Set non minima triangles to true;
+ mln::data::fill
+ ((surface |
+ mln::pw::value(minima) == mln::pw::cst(mln::literal::zero)).rw(),
+ true);
+ // Extend non minima values from triangles to edges.
+ mln::data::paste (mln::morpho::dilation(mln::extend(surface | is_an_edge,
+ surface),
+ /* Dilations require windows,
+ not neighborhoods. */
+ higher_adj_nbh.win()),
+ surface);
+ // Extend non minima values from edges to vertices.
+ mln::data::paste(mln::morpho::dilation(mln::extend(surface | is_a_vertex,
+ surface),
+ /* Dilations require windows,
+ not neighborhoods. */
+ higher_adj_nbh.win()),
+ surface);
/*-------------.
| 2-collapse. |
@@ -258,9 +256,6 @@ main(int argc, char* argv[])
// Image restricted to triangles. //
// ------------------------------- //
- // 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
@@ -272,14 +267,6 @@ main(int argc, char* argv[])
// Simple point predicate. //
// ------------------------ //
- // 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;
- lower_adj_nbh_t lower_adj_nbh;
- // 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;
- higher_adj_nbh_t higher_adj_nbh;
// Predicate type: is a triangle (2-face) simple?
typedef mln::topo::is_simple_pair< bin_triangle_ima_t,
lower_adj_nbh_t,
--
1.5.6.5
* mln/topo/is_simple_cell.hh: Add static preconditions.
Reduce the number of pointer manipulations.
Aesthetic changes.
* mln/topo/detach_cell.hh: Move a static precondition.
Aesthetic changes.
* mln/io/vtk/save.hh: Cosmetic changes.
---
milena/ChangeLog | 11 +++++++++++
milena/mln/io/vtk/save.hh | 8 ++++++--
milena/mln/topo/detach_cell.hh | 22 ++++++++++++----------
milena/mln/topo/is_simple_cell.hh | 24 ++++++++++++++----------
4 files changed, 43 insertions(+), 22 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index aa71fb7..63b6054 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,16 @@
2011-03-14 Roland Levillain <roland(a)lrde.epita.fr>
+ Miscellaneous changes in mesh-related operations.
+
+ * mln/topo/is_simple_cell.hh: Add static preconditions.
+ Reduce the number of pointer manipulations.
+ Aesthetic changes.
+ * mln/topo/detach_cell.hh: Move a static precondition.
+ Aesthetic changes.
+ * mln/io/vtk/save.hh: Cosmetic changes.
+
+2011-03-14 Roland Levillain <roland(a)lrde.epita.fr>
+
New apps: max curvature-based thinnings using 2- and 1-collapses.
* apps/mesh-segm-skel/mesh-complex-max-curv-2-collapse.cc,
diff --git a/milena/mln/io/vtk/save.hh b/milena/mln/io/vtk/save.hh
index fbe5a85..142608a 100644
--- a/milena/mln/io/vtk/save.hh
+++ b/milena/mln/io/vtk/save.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2008, 2009, 2010 EPITA Research and Development
+// Copyright (C) 2008, 2009, 2010, 2011 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of Olena.
@@ -269,7 +269,7 @@ namespace mln
/* ``1. The first part is the file version and
identifier. This part contains the single line:
- # vtk DataFile Version x.x.
+ # vtk DataFile Version x.x.
This line must be exactly as shown with the
exception of the version number x.x, which will vary
@@ -492,6 +492,10 @@ namespace mln
ostr << std::endl;
}
+ // -------------------- //
+ // Dataset attributes. //
+ // -------------------- //
+
/* ``5. The final part describes the dataset attributes.
This part begins with the keywords POINT_DATA or
CELL_DATA,followed by an integer number specifying
diff --git a/milena/mln/topo/detach_cell.hh b/milena/mln/topo/detach_cell.hh
index 761142e..0bf442c 100644
--- a/milena/mln/topo/detach_cell.hh
+++ b/milena/mln/topo/detach_cell.hh
@@ -30,10 +30,15 @@
/// \file
/// \brief Detaching a cell from a binary (probably complex-based) image.
+# include <mln/core/concept/function.hh>
+# include <mln/core/concept/image.hh>
+# include <mln/core/concept/neighborhood.hh>
+
# include <mln/core/site_set/p_set.hh>
-# include <mln/core/image/complex_image.hh>
+
# include <mln/make/detachment.hh>
+
namespace mln
{
@@ -66,7 +71,7 @@ namespace mln
\pre \a ima is an image of Boolean values.
\param ima The input image from which the cell is to be
- detached.
+ detached.
\param nbh An adjacency relationship between faces
(should return the set of (n-1)- and (n+1)-faces
adjacent to an n-face). */
@@ -80,14 +85,10 @@ namespace mln
\pre \a ima is an image of Boolean values. */
void set_image(mln::Image<I>& ima);
- /** Detach the cell corresponding to \a f from \a ima.
+ /** Detach the cell corresponding to \a f from \a ima_.
- \param f The psite corresponding to the cell to detach.
- \param nbh An adjacency relationship between faces
- (should return the set of (n-1)- and (n+1)-faces
- adjacent to an n-face). */
- void
- operator()(const mln_psite(I)& f);
+ \param f The psite corresponding to the cell to detach. */
+ void operator()(const mln_psite(I)& f);
private:
I* ima_;
@@ -95,6 +96,7 @@ namespace mln
};
+
# ifndef MLN_INCLUDE_ONLY
template <typename I, typename N>
@@ -102,6 +104,7 @@ namespace mln
detach_cell<I, N>::detach_cell(const Neighborhood<N>& nbh)
: ima_(0), nbh_(exact(nbh))
{
+ mlc_equal(mln_value(I), bool)::check();
}
template <typename I, typename N>
@@ -118,7 +121,6 @@ namespace mln
void
detach_cell<I, N>::set_image(mln::Image<I>& ima)
{
- mlc_equal(mln_value(I), bool)::check();
ima_ = exact(&ima);
}
diff --git a/milena/mln/topo/is_simple_cell.hh b/milena/mln/topo/is_simple_cell.hh
index 8796c16..9f1491a 100644
--- a/milena/mln/topo/is_simple_cell.hh
+++ b/milena/mln/topo/is_simple_cell.hh
@@ -34,15 +34,15 @@
# include <mln/core/concept/image.hh>
# include <mln/core/site_set/p_set.hh>
-# include <mln/core/site_set/complex_psite.hh>
-# include <mln/core/site_set/p_complex_piter.hh>
-# include <mln/core/image/complex_neighborhoods.hh>
-# include <mln/core/image/complex_neighborhood_piter.hh>
# include <mln/topo/is_facet.hh>
# include <mln/make/attachment.hh>
+// FIXME: Have the functor take N, NL and NH neighborhood objects at
+// the construction (instead of building them in operator()), as in
+// does is_simple_pair.
+
namespace mln
{
@@ -69,7 +69,8 @@ namespace mln
\tparam NH The neighborhood type returning the set of
(n+1)-faces adjacent to a an n-face. */
template <typename I, typename N, typename NL, typename NH>
- class is_simple_cell : public mln::Function_v2b< is_simple_cell<I, N, NL, NH> >
+ class is_simple_cell
+ : public mln::Function_v2b< is_simple_cell<I, N, NL, NH> >
{
public:
/// Result type of the functor.
@@ -108,6 +109,7 @@ namespace mln
is_simple_cell<I, N, NL, NH>::is_simple_cell()
: ima_(0)
{
+ mlc_equal(mln_value(I), bool)::check();
}
template <typename I, typename N, typename NL, typename NH>
@@ -115,6 +117,7 @@ namespace mln
is_simple_cell<I, N, NL, NH>::is_simple_cell(const mln::Image<I>& ima)
: ima_(exact(&ima))
{
+ mlc_equal(mln_value(I), bool)::check();
}
template <typename I, typename N, typename NL, typename NH>
@@ -131,23 +134,24 @@ namespace mln
is_simple_cell<I, N, NL, NH>::operator()(const mln_psite(I)& p) const
{
mln_precondition(ima_);
- // FIXME: Introduce `const I& ima = *ima_;' and use it instead of
- // `ima_'. Or introduce an `ima()' accessor?
+ // Shortcut.
+ // FIXME: Introduce an `ima()' accessor instead?
+ const I& ima = *ima_;
// The cell corresponding to P cannot be simple unless P is
// facet.
{
NH higher_adj_nbh;
- if (!is_facet(*ima_, p, higher_adj_nbh))
+ if (!is_facet(ima, p, higher_adj_nbh))
return false;
}
typedef p_set<mln_psite(I)> faces_t;
// Compute the attachment of the cell corresponding to P to the
- // domain of *IMA_.
+ // domain of IMA.
N adj_nbh;
- faces_t att = make::attachment(*ima_, p, adj_nbh);
+ faces_t att = make::attachment(ima, p, adj_nbh);
// A cell with an empty attachment is not simple.
/* FIXME: Why p_set does not provide an empty() predicate? */
--
1.5.6.5