Olena-patches
Threads by month
- ----- 2025 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- 9625 discussions
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Wow! I wanted to do this for *weeks*! Now it reads much better.
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Rename (and clean up a bit) graph-related classes.
* mln/util/graph.hh (add_edge): Fix the update of the list of
edges.
* mln/core/mesh_image.hh,
* mln/core/mesh_p.hh,
* mln/core/mesh_p_piter.hh,
* mln/core/mesh_psite.hh,
* mln/core/mesh_elt_window.hh,
* mln/core/mesh_window_piter.hh:
Rename as...
* mln/core/graph_image.hh,
* mln/core/p_graph.hh,
* mln/core/p_graph_piter.hh,
* mln/core/graph_psite.hh,
* mln/core/graph_elt_window.hh,
* mln/core/graph_window_piter.hh:
...these.
(mesh_image, mesh_p, mesh_p_piter_, mesh_psite)
(mesh_elt_window, mesh_window_fwd_piter):
Rename as...
(graph_image, p_graph, p_graph_piter_, graph_psite)
(graph_elt_window, graph_window_fwd_piter):
...these.
* mln/draw/mesh.hh:
Adjust.
Rename as...
* mln/draw/graph.hh: ...these.
(mesh(Image<I>&, const mesh_p<P>&, mln_value(I), mln_value(I)))
(mesh(Image<I>&, const mesh_image<P, V>&, mln_value(I))):
Rename as...
(graph(Image<I>&, const p_graph<P>&, mln_value(I), mln_value(I)))
(graph(Image<I>&, const graph_image<P, V>&, mln_value(I))):
...these.
* tests/core/mesh_elt_window.cc,
* tests/core/mesh_image.cc,
* tests/draw/mesh.cc:
Adjust.
Rename those tests as...
* tests/core/graph_elt_window.cc,
* tests/core/graph_image.cc,
* tests/draw/graph.cc:
...these.
* tests/core/Makefile.am, tests/draw/Makefile.am: Adjust names.
mln/core/graph_elt_window.hh | 94 ++++++++++++++++++++---------------------
mln/core/graph_image.hh | 90 +++++++++++++++++++--------------------
mln/core/graph_psite.hh | 50 ++++++++++-----------
mln/core/graph_window_piter.hh | 79 +++++++++++++++++-----------------
mln/core/p_graph.hh | 57 +++++++++++++-----------
mln/core/p_graph_piter.hh | 59 +++++++++++++------------
mln/draw/graph.hh | 86 ++++++++++++++++++-------------------
mln/util/graph.hh | 36 ++++++++++++---
tests/core/Makefile.am | 8 +--
tests/core/graph_elt_window.cc | 22 ++++-----
tests/core/graph_image.cc | 60 ++++++++++++--------------
tests/draw/Makefile.am | 4 -
tests/draw/graph.cc | 20 +++-----
13 files changed, 345 insertions(+), 320 deletions(-)
Index: mln/util/graph.hh
--- mln/util/graph.hh (revision 1703)
+++ mln/util/graph.hh (working copy)
@@ -79,7 +79,9 @@
template<typename T>
struct s_edge
{
- s_edge() : pair_node_ (0, 0) {}
+ s_edge()
+ : pair_node_ (0, 0)
+ {}
T data;
ordpair_<unsigned> pair_node_;
@@ -95,9 +97,11 @@
ordpair_<unsigned> pair_node_;
};
- bool operator==(const struct s_edge <void>& lhs, const struct s_edge <void>& rhs);
+ bool operator==(const struct s_edge <void>& lhs,
+ const struct s_edge <void>& rhs);
- bool operator< (const struct s_edge <void>& lhs, const struct s_edge <void>& rhs);
+ bool operator< (const struct s_edge <void>& lhs,
+ const struct s_edge <void>& rhs);
/// \brief Generic graph structure using s_node and s_edge.
/* FIXME: We don't mention anywhere whether this graph structure
@@ -105,6 +109,10 @@
template<typename N, typename E = void>
struct graph
{
+ /* FIXME: Do we really want handle edges and nodes through
+ pointers? In my (Roland) opinion, this is just a drawback,
+ here. */
+
/// The type of the set of nodes.
typedef std::vector< s_node<N>* > nodes;
/// The type of the set of edges.
@@ -217,12 +225,20 @@
edge = new s_edge<E>;
edge->pair_node_.first = n1;
edge->pair_node_.second = n2;
- if (links_.end () == std::find(links_.begin(), links_.end(), edge))
+ // Does this edge already exist in the graph?
+ if (std::find(links_.begin(), links_.end(), edge) != links_.end ())
+ {
delete edge;
+ edge = 0;
+ }
else
{
links_.push_back (edge);
++nb_link_;
+ /* FIXME: In fact, we should store adjaceny information in
+ *both* nodes. Change this globally later, and mention
+ that the graph is undirected in the documentation. And
+ don't forget to update clients! */
nodes_[n1]->links.push_back (n2);
}
}
@@ -234,15 +250,18 @@
{
mln_precondition(nodes_.size () == this->nb_node_);
mln_precondition(links_.size () == this->nb_link_);
- typename std::vector<struct s_node <N>*>::const_iterator it = nodes_.begin ();
+ typename std::vector<struct s_node <N>*>::const_iterator it =
+ nodes_.begin ();
for (; it != nodes_.end (); ++it)
{
- typename std::list<unsigned>::const_iterator it2 = (*it)->links.begin ();
+ typename std::list<unsigned>::const_iterator it2 =
+ (*it)->links.begin ();
for (; it2 != (*it)->links.end (); ++it2)
mln_precondition((*it2) < nb_node_);
}
- typename std::vector<struct s_edge<E>*>::const_iterator it3 = links_.begin ();
+ typename std::vector<struct s_edge<E>*>::const_iterator it3 =
+ links_.begin ();
for (; it3 != links_.end (); ++it3)
{
mln_precondition((*it3)->pair_node_.first < nb_node_);
@@ -257,7 +276,8 @@
{
ostr << "nodes :" << std::endl;
- typename std::vector<struct s_node<N>*>::const_iterator it = nodes_.begin ();
+ typename std::vector<struct s_node<N>*>::const_iterator it =
+ nodes_.begin ();
int i = 0;
for (; it != nodes_.end (); ++it, ++i)
{
Index: mln/core/graph_psite.hh
--- mln/core/graph_psite.hh (revision 1703)
+++ mln/core/graph_psite.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,35 +25,35 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_CORE_MESH_PSITE_HH
-# define MLN_CORE_MESH_PSITE_HH
+#ifndef MLN_CORE_GRAPH_PSITE_HH
+# define MLN_CORE_GRAPH_PSITE_HH
-/*! \file mln/core/mesh_psite.hh
+/*! \file mln/core/graph_psite.hh
*
* \brief Definition of a graph-based point site.
*
* \todo Clean-up!
*/
-# include <mln/core/mesh_p.hh>
+# include <mln/core/p_graph.hh>
namespace mln
{
// Fwd decl.
- template<typename P> class mesh_p;
+ template<typename P> class p_graph;
/*!
- * \brief Point site associate to mesh_image.
+ * \brief Point site associate to graph_image.
*
* \todo Fix access to member.
*/
template<typename P>
- class mesh_psite : public Point_Site< mesh_psite<P> >
+ class graph_psite : public Point_Site< graph_psite<P> >
{
- typedef mesh_psite<P> self_;
+ typedef graph_psite<P> self_;
public:
typedef mln_mesh(P) mesh;
@@ -64,8 +64,8 @@
/// Construction and assignment.
/// \{
- mesh_psite(const mesh_p<P>& mesh_, unsigned i);
- mesh_psite(const self_& rhs);
+ graph_psite(const p_graph<P>& pg_, unsigned i);
+ graph_psite(const self_& rhs);
self_& operator= (const self_& rhs);
/// \}
@@ -74,7 +74,7 @@
coord operator[](unsigned i) const;
// FIXME: These shouldn't be public.
- const mesh_p<P>& mesh_;
+ const p_graph<P>& pg_;
unsigned i_;
};
@@ -82,56 +82,56 @@
template<typename P>
inline
- mesh_psite<P>::mesh_psite(const mesh_p<P>& mesh, unsigned i)
- : mesh_(mesh),
+ graph_psite<P>::graph_psite(const p_graph<P>& g, unsigned i)
+ : pg_(g),
i_(i)
{
}
template<typename P>
inline
- mesh_psite<P>::mesh_psite(const mesh_psite<P>& rhs)
- : mesh_(rhs.mesh_),
+ graph_psite<P>::graph_psite(const graph_psite<P>& rhs)
+ : pg_(rhs.pg_),
i_(rhs.i_)
{
}
template<typename P>
inline
- mesh_psite<P>&
- mesh_psite<P>::operator= (const mesh_psite<P>& rhs)
+ graph_psite<P>&
+ graph_psite<P>::operator= (const graph_psite<P>& rhs)
{
if (&rhs == this)
return *this;
// FIXME: Could we get rid of this cast?
- const_cast< mesh_p<P>& >(mesh_) = rhs.mesh_;
+ const_cast< p_graph<P>& >(pg_) = rhs.pg_;
i_ = rhs.i_;
return *this;
}
template<typename P>
inline
- mesh_psite<P>::operator P() const
+ graph_psite<P>::operator P() const
{
// FIXME: This is quite unsafe: we should check that i_ is a valid
// index before dereferencing loc_ to ensure clear error messages.
- return mesh_.loc_[i_];
+ return pg_.loc_[i_];
}
template<typename P>
inline
const P&
- mesh_psite<P>::to_point() const
+ graph_psite<P>::to_point() const
{
// FIXME: This is quite unsafe: we should check that i_ is a valid
// index before dereferencing loc_ to ensure clear error messages.
- return mesh_.loc_[i_];
+ return pg_.loc_[i_];
}
template<typename P>
inline
mln_coord(P)
- mesh_psite<P>::operator[](unsigned i) const
+ graph_psite<P>::operator[](unsigned i) const
{
return to_point()[i];
}
@@ -141,4 +141,4 @@
} // end of mln
-#endif // MLN_CORE_MESH_PSITE_HH
+#endif // MLN_CORE_GRAPH_PSITE_HH
Index: mln/core/p_graph.hh
--- mln/core/p_graph.hh (revision 1703)
+++ mln/core/p_graph.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,48 +25,47 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_CORE_MESH_P_HH
-# define MLN_CORE_MESH_P_HH
+#ifndef MLN_CORE_GRAPH_P_HH
+# define MLN_CORE_GRAPH_P_HH
# include <mln/core/concept/point_site.hh>
# include <mln/core/internal/point_set_base.hh>
# include <mln/accu/bbox.hh>
# include <mln/util/graph.hh>
-# include <mln/core/mesh_psite.hh>
-# include <mln/core/mesh_p_piter.hh>
+# include <mln/core/graph_psite.hh>
+# include <mln/core/p_graph_piter.hh>
-// FIXME: Rename as mesh_p_set? We shall definitely write a coding
-// style somewhere.
-
-/*! \file mln/core/mesh_p.hh
- *
- * \brief Definition of an point set based on graph.
- */
+/// \file mln/core/p_graph.hh
+/// \brief Definition of a point set based on graph.
namespace mln
{
- template<typename P> class mesh_p_piter_;
+ template<typename P> class p_graph_piter_;
template<typename P>
- struct mesh_p : public internal::point_set_base_< mesh_psite<P>, mesh_p<P> >
+ struct p_graph : public internal::point_set_base_< graph_psite<P>, p_graph<P> >
{
typedef util::graph<void> graph;
- /// Construct a mesh psite set from a graph and an array of locations.
- mesh_p (graph& gr, std::vector<P>& loc);
+ /// Construct a graph psite set from a graph and an array of locations.
+ p_graph (graph& gr, std::vector<P>& loc);
/// Point_Site associated type.
- typedef mesh_psite<P> psite;
+ typedef graph_psite<P> psite;
/// Forward Point_Iterator associated type.
- typedef mesh_p_piter_<P> fwd_piter;
+ typedef p_graph_piter_<P> fwd_piter;
/// Backward Point_Iterator associated type.
- typedef mesh_p_piter_<P> bkd_piter; // FIXME
+ typedef p_graph_piter_<P> bkd_piter;
+ /// Return The number of points (i.e., nodes) in the graph.
std::size_t npoints() const;
+ /// Return The number of lines (i.e., edges) in the graph.
+ std::size_t nlines() const;
+
/// Give the exact bounding box.
const box_<P>& bbox() const;
@@ -75,7 +74,7 @@
graph gr_;
std::vector<P> loc_;
// FIXME: (Roland) Is it really useful/needed?
- /* 2007-12-19: It seems so, since mesh_image must implement a method
+ /* 2007-12-19: It seems so, since graph_image must implement a method
named bbox(). Now the question is: should each image type have a
bounding box? */
box_<P> bb_;
@@ -85,7 +84,7 @@
template<typename P>
inline
- mesh_p<P>::mesh_p (util::graph<void>& gr, std::vector<P>& loc)
+ p_graph<P>::p_graph (util::graph<void>& gr, std::vector<P>& loc)
: gr_ (gr),
loc_ (loc)
{
@@ -98,15 +97,23 @@
template<typename P>
inline
std::size_t
- mesh_p<P>::npoints() const
+ p_graph<P>::npoints() const
{
return this->gr_.nb_node_;
}
template<typename P>
inline
+ std::size_t
+ p_graph<P>::nlines() const
+ {
+ return this->gr_.nb_link_;
+ }
+
+ template<typename P>
+ inline
const box_<P>&
- mesh_p<P>::bbox() const
+ p_graph<P>::bbox() const
{
return bb_;
}
@@ -114,7 +121,7 @@
template<typename P>
inline
bool
- mesh_p<P>::has(const psite& p) const
+ p_graph<P>::has(const psite& p) const
{
for (unsigned i = 0; i < loc_.size(); ++i)
if (loc_[i] == p)
@@ -128,4 +135,4 @@
} // end of mln
-#endif // MLN_CORE_MESH_P_HH
+#endif // MLN_CORE_P_GRAPH_HH
Index: mln/core/graph_window_piter.hh
--- mln/core/graph_window_piter.hh (revision 1703)
+++ mln/core/graph_window_piter.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,40 +25,42 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_CORE_MESH_WINDOW_PITER_HH
-# define MLN_CORE_MESH_WINDOW_PITER_HH
+#ifndef MLN_CORE_GRAPH_WINDOW_PITER_HH
+# define MLN_CORE_GRAPH_WINDOW_PITER_HH
-/*!
- * \file mln/core/mesh_window_piter.hh
- *
- * \brief Definition of point iterator of mesh window.
- *
- */
+/// \file mln/core/graph_window_piter.hh
+/// \brief Definition of a point iterator on a graph window.
# include <mln/core/concept/point_iterator.hh>
-# include <mln/core/mesh_p.hh>
-# include <mln/core/mesh_psite.hh>
+# include <mln/core/p_graph.hh>
+# include <mln/core/graph_psite.hh>
+/* FIXME: Doc. */
+
+/* FIXME: Due to the poor interface of mln::p_graph and
+ mln::util::graph, we show to much implementation details here.
+ Enrich their interfaces to avoid that. */
namespace mln
{
// Fwd decls.
- template <typename P> class mesh_p;
- template <typename P> class mesh_psite;
+ template <typename P> class p_graph;
+ template <typename P> class graph_psite;
template <typename P>
- class mesh_window_fwd_piter :
- public Point_Iterator< mesh_window_fwd_piter<P> > // or Iterator<...>?
+ class graph_window_fwd_piter :
+ public Point_Iterator< graph_window_fwd_piter<P> > // or Iterator<...>?
{
- typedef mesh_window_fwd_piter<P> self_;
+ typedef graph_window_fwd_piter<P> self_;
typedef Point_Iterator< self_ > super_;
public:
- typedef mesh_psite<P> psite;
+ typedef graph_psite<P> psite;
enum { dim = P::dim };
- typedef mesh_p<P> mesh;
+ // FIXME: Dummy value.
+ typedef void mesh;
typedef P point;
// FIXME: Dummy typedef.
@@ -67,8 +69,7 @@
public:
template <typename W, typename Pref>
- mesh_window_fwd_piter(const W& win,
- const Point_Site<Pref>& p_ref);
+ graph_window_fwd_piter(const W& win, const Point_Site<Pref>& p_ref);
bool is_valid() const;
void invalidate();
@@ -78,7 +79,7 @@
bool adjacent_or_equal_to_p_ref_() const;
// FIXME: In fact, this method should be named `to_psite', since
- // it return as mln::mesh_psite<P> object, not a P object.
+ // it returns a mln::graph_psite<P> object, not a P object.
const point& to_point() const;
operator psite () const;
coord operator[](unsigned i) const;
@@ -91,7 +92,7 @@
unsigned i_;
};
- // FIXME: mesh_window_bkd_piter.
+ // FIXME: Implement graph_window_bkd_piter.
# ifndef MLN_INCLUDE_ONLY
@@ -99,7 +100,7 @@
// FIXME: Currently, argument win is ignored.
template <typename P>
template <typename W, typename Pref>
- mesh_window_fwd_piter<P>::mesh_window_fwd_piter(const W& /* win */,
+ graph_window_fwd_piter<P>::graph_window_fwd_piter(const W& /* win */,
const Point_Site<Pref>& p_ref)
: p_ref_(exact(p_ref).to_psite())
{
@@ -109,24 +110,24 @@
template <typename P>
bool
- mesh_window_fwd_piter<P>::is_valid() const
+ graph_window_fwd_piter<P>::is_valid() const
{
// FIXME: We depend too much on the implementation of util::graph
// here. The util::graph should provide the service to abstract
// these manipulations.
- return i_ >= 0 && i_ < p_ref_.mesh_.gr_.nb_node_;
+ return i_ >= 0 && i_ < p_ref_.pg_.gr_.nb_node_;
}
template <typename P>
void
- mesh_window_fwd_piter<P>::invalidate()
+ graph_window_fwd_piter<P>::invalidate()
{
- i_ = p_ref_.mesh_.gr_.nb_node_;
+ i_ = p_ref_.pg_.gr_.nb_node_;
}
template <typename P>
void
- mesh_window_fwd_piter<P>::start()
+ graph_window_fwd_piter<P>::start()
{
i_ = 0;
if (!adjacent_or_equal_to_p_ref_())
@@ -135,7 +136,7 @@
template <typename P>
void
- mesh_window_fwd_piter<P>::next_()
+ graph_window_fwd_piter<P>::next_()
{
// FIXME: This is inefficient. The graph structure should be able
// to produce the set of adjacent nodes fast. Boost Graphs
@@ -148,7 +149,7 @@
template <typename P>
bool
- mesh_window_fwd_piter<P>::adjacent_or_equal_to_p_ref_() const
+ graph_window_fwd_piter<P>::adjacent_or_equal_to_p_ref_() const
{
// FIXME: Likewise, this is inefficient.
@@ -162,9 +163,9 @@
{
// Paranoid assertion.
assert (p_ref_.i_ >= 0 &&
- p_ref_.i_ < p_ref_.mesh_.gr_.nodes_.size ());
+ p_ref_.i_ < p_ref_.pg_.gr_.nodes_.size ());
const adjacency_type& p_ref_neighbs =
- p_ref_.mesh_.gr_.nodes_[p_ref_.i_]->links;
+ p_ref_.pg_.gr_.nodes_[p_ref_.i_]->links;
adjacency_type::const_iterator j =
std::find (p_ref_neighbs.begin(), p_ref_neighbs.end(), i_);
if (j != p_ref_neighbs.end())
@@ -174,7 +175,7 @@
// Check whether P_REF_ is among the neighbors of the iterator.
{
assert (is_valid ());
- const adjacency_type& i_neighbs = p_ref_.mesh_.gr_.nodes_[i_]->links;
+ const adjacency_type& i_neighbs = p_ref_.pg_.gr_.nodes_[i_]->links;
adjacency_type::const_iterator k =
std::find (i_neighbs.begin(), i_neighbs.end(), p_ref_.i_);
if (k != i_neighbs.end())
@@ -187,21 +188,21 @@
template <typename P>
const P&
- mesh_window_fwd_piter<P>::to_point() const
+ graph_window_fwd_piter<P>::to_point() const
{
- return p_ref_.mesh_.loc_[i_];
+ return p_ref_.pg_.loc_[i_];
}
template <typename P>
- mesh_window_fwd_piter<P>::operator mesh_psite<P> () const
+ graph_window_fwd_piter<P>::operator graph_psite<P> () const
{
- return mesh_psite<P>(p_ref_.mesh_, i_);
+ return graph_psite<P>(p_ref_.pg_, i_);
}
template <typename P>
inline
mln_coord(P)
- mesh_window_fwd_piter<P>::operator[](unsigned i) const
+ graph_window_fwd_piter<P>::operator[](unsigned i) const
{
assert(i < dim);
return to_point()[i];
@@ -211,4 +212,4 @@
} // end of namespace mln
-#endif // ! MLN_CORE_MESH_WINDOW_PITER_HH
+#endif // ! MLN_CORE_GRAPH_WINDOW_PITER_HH
Index: mln/core/graph_image.hh
--- mln/core/graph_image.hh (revision 1703)
+++ mln/core/graph_image.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,10 +25,10 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_CORE_MESH_IMAGE_HH
-# define MLN_CORE_MESH_IMAGE_HH
+#ifndef MLN_CORE_GRAPH_IMAGE_HH
+# define MLN_CORE_GRAPH_IMAGE_HH
-/*! \file mln/core/mesh_image.hh
+/*! \file mln/core/graph_image.hh
*
* \brief Definition of a graph-based image.
*/
@@ -37,8 +37,8 @@
# include <mln/core/internal/image_primary.hh>
# include <mln/metal/vec.hh>
-# include <mln/core/mesh_p.hh>
-# include <mln/core/mesh_psite.hh>
+# include <mln/core/p_graph.hh>
+# include <mln/core/graph_psite.hh>
# include <mln/value/set.hh>
# include <vector>
@@ -46,19 +46,19 @@
{
// Fwd decl.
- template <typename P, typename V> struct mesh_image;
+ template <typename P, typename V> struct graph_image;
namespace internal
{
- /// \internal Data structure for \c mln::mesh_image<P,V>.
+ /// \internal Data structure for \c mln::graph_image<P,V>.
template <typename P, typename V>
- struct data_< mesh_image<P, V> >
+ struct data_< graph_image<P, V> >
{
- data_(mesh_p<P>& mesh, std::vector<V>& val);
+ data_(p_graph<P>& g, std::vector<V>& val);
std::vector<V> val_;
- mesh_p<P>& mesh_;
+ p_graph<P>& pg_;
};
} // end of namespace mln::internal
@@ -68,7 +68,7 @@
{
template <typename P, typename V>
- struct image_< mesh_image<P, V> > : default_image_< V, mesh_image<P, V> >
+ struct image_< graph_image<P, V> > : default_image_< V, graph_image<P, V> >
{
typedef trait::image::category::primary category;
@@ -91,11 +91,11 @@
*
*/
template <typename P, typename V>
- struct mesh_image :
- public internal::image_primary_< mesh_p<P>, mesh_image<P, V> >
+ struct graph_image :
+ public internal::image_primary_< p_graph<P>, graph_image<P, V> >
{
- typedef mln::internal::image_base_< mesh_p<P>, mesh_image<P, V> > super_;
+ typedef mln::internal::image_base_< p_graph<P>, graph_image<P, V> > super_;
/// Value associated type.
typedef V value;
@@ -111,20 +111,20 @@
/// Skeleton.
- typedef mesh_image< tag::psite_<P>, tag::value_<V> > skeleton;
+ typedef graph_image< tag::psite_<P>, tag::value_<V> > skeleton;
/// Constructors.
- mesh_image(mesh_p<P>& mesh, std::vector<V>& val);
- mesh_image();
+ graph_image(p_graph<P>& g, std::vector<V>& val);
+ graph_image();
/// Initialize an empty image.
- void init_(mesh_p<P>& mesh, std::vector<V>& val);
+ void init_(p_graph<P>& g, std::vector<V>& val);
/// Read-only access of pixel value at point site \p p.
- const V& operator()(const mesh_psite<P>& p) const;
+ const V& operator()(const graph_psite<P>& p) const;
/// Read-write access of pixel value at point site \p p.
- V& operator()(const mesh_psite<P>& p);
+ V& operator()(const graph_psite<P>& p);
/// Give the set of values of the image.
const vset& values() const;
@@ -132,7 +132,7 @@
// FIXME: Keep this name?
const std::vector<V>& data_values () const;
- const mesh_p<P>& domain() const;
+ const p_graph<P>& domain() const;
/// Return the first node of the link at i from loc
const P& access_location_link_node1 (const unsigned& i) const;
@@ -144,7 +144,7 @@
// Fwd decl.
template <typename P, typename V>
void init_(tag::image_t,
- mesh_image<P, V>& target, const mesh_image<P, V>& model);
+ graph_image<P, V>& target, const graph_image<P, V>& model);
# ifndef MLN_INCLUDE_ONLY
@@ -156,7 +156,7 @@
template <typename P, typename V>
inline
void init_(tag::image_t,
- mesh_image<P, V>& target, const mesh_image<P, V>& model)
+ graph_image<P, V>& target, const graph_image<P, V>& model)
{
/* FIXME: Unfortunately, we cannot simply use
@@ -164,9 +164,9 @@
here, since domain() and data_values() return const data, and
init_ expects non mutable data. These constness problems exist
- also in mesh_psite (see uses of const_cast<>). Hence the
+ also in graph_psite (see uses of const_cast<>). Hence the
inelegant use of const_cast<>'s. */
- target.init_(const_cast<mesh_p<P>&> (model.domain()),
+ target.init_(const_cast<p_graph<P>&> (model.domain()),
const_cast<std::vector<V>&> (model.data_values ()));
}
@@ -178,9 +178,9 @@
{
template <typename P, typename V>
inline
- data_< mesh_image<P, V> >::data_(mesh_p<P>& mesh, std::vector<V>& val)
+ data_< graph_image<P, V> >::data_(p_graph<P>& g, std::vector<V>& val)
: val_ (val),
- mesh_ (mesh)
+ pg_ (g)
{
}
@@ -192,28 +192,28 @@
template <typename P, typename V>
inline
- mesh_image<P, V>::mesh_image(mesh_p<P>& mesh, std::vector<V>& val)
+ graph_image<P, V>::graph_image(p_graph<P>& g, std::vector<V>& val)
{
- init_(mesh, val);
+ init_(g, val);
}
template <typename P, typename V>
inline
- mesh_image<P, V>::mesh_image()
+ graph_image<P, V>::graph_image()
{
}
template <typename P, typename V>
inline
void
- mesh_image<P, V>::init_(mesh_p<P>& mesh, std::vector<V>& val)
+ graph_image<P, V>::init_(p_graph<P>& g, std::vector<V>& val)
{
/* FIXME: We leak memory here: calling init_ twice loses the
previous content pointed by data_.
We should definitely write down formal guidelines on
initialization and memory management in general! */
- this->data_ = new internal::data_< mesh_image<P, V> > (mesh, val);
+ this->data_ = new internal::data_< graph_image<P, V> > (g, val);
}
/*---------------.
@@ -223,9 +223,9 @@
template <typename P, typename V>
inline
const V&
- mesh_image<P, V>::operator()(const mesh_psite<P>& p) const
+ graph_image<P, V>::operator()(const graph_psite<P>& p) const
{
- mln_precondition(&p.mesh_ == &this->data_->mesh_);
+ mln_precondition(&p.pg_ == &this->data_->pg_);
mln_precondition(p.i_ < this->data_->val_.size());
return this->data_->val_[p.i_];
}
@@ -233,9 +233,9 @@
template <typename P, typename V>
inline
V&
- mesh_image<P, V>::operator()(const mesh_psite<P>& p)
+ graph_image<P, V>::operator()(const graph_psite<P>& p)
{
- mln_precondition(&p.mesh_ == &this->data_->mesh_);
+ mln_precondition(&p.pg_ == &this->data_->pg_);
mln_precondition(p.i_ < this->data_->val_.size());
return this->data_->val_[p.i_];
}
@@ -243,7 +243,7 @@
template <typename P, typename V>
inline
const mln::value::set<V> &
- mesh_image<P, V>::values() const
+ graph_image<P, V>::values() const
{
return vset::the();
}
@@ -251,24 +251,24 @@
template <typename P, typename V>
inline
const std::vector<V>&
- mesh_image<P, V>::data_values () const
+ graph_image<P, V>::data_values () const
{
return this->data_->val_;
}
template <typename P, typename V>
inline
- const mesh_p<P>&
- mesh_image<P, V>::domain() const
+ const p_graph<P>&
+ graph_image<P, V>::domain() const
{
mln_precondition(this->has_data());
- return this->data_->mesh_;
+ return this->data_->pg_;
}
template <typename P, typename V>
inline
const P&
- mesh_image<P, V>::access_location_link_node1 (const unsigned& i) const
+ graph_image<P, V>::access_location_link_node1 (const unsigned& i) const
{
// FIXME: This is ugly! Too much implementation details are shown here.
return this->domain().loc_[this->domain().gr_.links_[i]->pair_node_.first];
@@ -277,7 +277,7 @@
template <typename P, typename V>
inline
const P&
- mesh_image<P, V>::access_location_link_node2 (const unsigned& i) const
+ graph_image<P, V>::access_location_link_node2 (const unsigned& i) const
{
// FIXME: This is ugly! Too much implementation details are shown here.
return this->domain().loc_[this->domain().gr_.links_[i]->pair_node_.second];
@@ -288,4 +288,4 @@
} // end of namespace mln
-#endif // ! MLN_CORE_MESH_IMAGE_HH
+#endif // ! MLN_CORE_GRAPH_IMAGE_HH
Index: mln/core/p_graph_piter.hh
--- mln/core/p_graph_piter.hh (revision 1703)
+++ mln/core/p_graph_piter.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,14 +25,14 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_CORE_MESH_P_PITER_HH
-# define MLN_CORE_MESH_P_PITER_HH
+#ifndef MLN_CORE_P_GRAPH_PITER_HH
+# define MLN_CORE_P_GRAPH_PITER_HH
# include <mln/core/internal/point_iterator_base.hh>
-# include <mln/core/mesh_p.hh>
-# include <mln/core/mesh_psite.hh>
+# include <mln/core/p_graph.hh>
+# include <mln/core/graph_psite.hh>
-/*! \file mln/core/mesh_p_piter.hh
+/*! \file mln/core/p_graph_piter.hh
*
* \brief Definition of point iterator on graph-based point set.
*/
@@ -40,26 +40,27 @@
namespace mln
{
// Fwd decls.
- template<typename P> class mesh_p;
- template<typename P> class mesh_psite;
+ template<typename P> class p_graph;
+ template<typename P> class graph_psite;
- // FIXME: Why `mesh_p_piter_' and not `mesh_p_piter' (without `_')?
+ // FIXME: Why `p_graph_piter_' and not `p_graph_piter' (without `_')?
template<typename P>
- class mesh_p_piter_ : public internal::point_iterator_base_< P, mesh_p_piter_<P> >
+ class p_graph_piter_
+ : public internal::point_iterator_base_< P, p_graph_piter_<P> >
{
- typedef mesh_p_piter_<P> self_;
+ typedef p_graph_piter_<P> self_;
typedef internal::point_iterator_base_< P, self_ > super_;
public:
// Make definitions from super class available.
enum { dim = super_::dim };
- typedef mesh_psite<P> psite;
+ typedef graph_psite<P> psite;
typedef P point;
- mesh_p_piter_(const mesh_p<P>& psite_set);
+ p_graph_piter_(const p_graph<P>& psite_set);
/// Read-only access to the \p i-th coordinate.
mln_coord(P) operator[](unsigned i) const;
@@ -88,11 +89,11 @@
/// Convert the iterator into a point.
operator point() const;
- /// Convert the iterator into a mesh psite.
+ /// Convert the iterator into a graph psite.
operator psite() const;
protected:
- const mesh_p<P>& psite_set_;
+ const p_graph<P>& psite_set_;
unsigned i_;
P p_;
psite psite_;
@@ -104,7 +105,7 @@
template<typename P>
inline
- mesh_p_piter_<P>::mesh_p_piter_(const mesh_p<P>& psite_set)
+ p_graph_piter_<P>::p_graph_piter_(const p_graph<P>& psite_set)
: psite_set_(psite_set),
p_(),
// Initialize psite_ to a dummy value.
@@ -117,7 +118,7 @@
template<typename P>
inline
mln_coord(P)
- mesh_p_piter_<P>::operator[](unsigned i) const
+ p_graph_piter_<P>::operator[](unsigned i) const
{
return p_[i];
}
@@ -125,7 +126,7 @@
template<typename P>
inline
bool
- mesh_p_piter_<P>::is_valid() const
+ p_graph_piter_<P>::is_valid() const
{
return i_ != psite_set_.loc_.size();
}
@@ -133,7 +134,7 @@
template<typename P>
inline
void
- mesh_p_piter_<P>::invalidate()
+ p_graph_piter_<P>::invalidate()
{
i_ = psite_set_.loc_.size();
}
@@ -141,7 +142,7 @@
template<typename P>
inline
void
- mesh_p_piter_<P>::start()
+ p_graph_piter_<P>::start()
{
i_ = 0;
if (is_valid())
@@ -151,7 +152,7 @@
template<typename P>
inline
void
- mesh_p_piter_<P>::next_()
+ p_graph_piter_<P>::next_()
{
++i_;
if (is_valid())
@@ -161,18 +162,18 @@
template<typename P>
inline
void
- mesh_p_piter_<P>::update_()
+ p_graph_piter_<P>::update_()
{
// Update p_.
p_ = psite_set_.loc_[i_];
// Update psite_.
- psite_ = mesh_psite<P>(psite_set_, i_);
+ psite_ = graph_psite<P>(psite_set_, i_);
}
template<typename P>
inline
const P&
- mesh_p_piter_<P>::to_point() const
+ p_graph_piter_<P>::to_point() const
{
/* We don't check whether the iterator is valid before returning
the value using
@@ -190,8 +191,8 @@
template<typename P>
inline
- const mesh_psite<P>&
- mesh_p_piter_<P>::to_psite() const
+ const graph_psite<P>&
+ p_graph_piter_<P>::to_psite() const
{
/* We don't check whether the iterator is valid before returning
the value using
@@ -209,7 +210,7 @@
template<typename P>
inline
- mesh_p_piter_<P>::operator P() const
+ p_graph_piter_<P>::operator P() const
{
mln_precondition(is_valid());
return p_;
@@ -217,7 +218,7 @@
template<typename P>
inline
- mesh_p_piter_<P>::operator mesh_psite<P>() const
+ p_graph_piter_<P>::operator graph_psite<P>() const
{
mln_precondition(is_valid());
return psite_;
@@ -228,4 +229,4 @@
} // end of mln
-#endif // MLN_MESH_P_PITER_HH
+#endif // MLN_P_GRAPH_PITER_HH
Index: mln/core/graph_elt_window.hh
--- mln/core/graph_elt_window.hh (revision 1703)
+++ mln/core/graph_elt_window.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,39 +25,37 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_WIN_MESH_ELT_WINDOW_HH
-# define MLN_WIN_MESH_ELT_WINDOW_HH
+#ifndef MLN_WIN_GRAPH_ELT_WINDOW_HH
+# define MLN_WIN_GRAPH_ELT_WINDOW_HH
-/*! \file mln/core/mesh_elt_window.hh
+/*! \file mln/core/graph_elt_window.hh
*
- * \brief Definition of the elementary neighborhood (wrongly
- * -- but purposefully -- named "window" here, for consistency
- * reasons) on a mesh (a graph, in fact).
+ * \brief Definition of the elementary ``window'' on a graph.
*
* \todo Make naming coherent: we have window (without '_') but
* point_, neighb_, etc.
*/
# include <mln/core/concept/window.hh>
-# include <mln/core/mesh_psite.hh>
-# include <mln/core/mesh_window_piter.hh>
+# include <mln/core/graph_psite.hh>
+# include <mln/core/graph_window_piter.hh>
namespace mln
{
// Fwd decls.
- template <typename P> class mesh_window_fwd_piter;
- template <typename P> class mesh_window_bkd_piter;
+ template <typename P> class graph_window_fwd_piter;
+ template <typename P> class graph_window_bkd_piter;
- /*! \brief Elementary window on mesh class.
+ /*! \brief Elementary window on graph class.
*
* FIXME: Doc.
*/
template <typename P>
- class mesh_elt_window : public Window< mesh_elt_window<P> >
+ class graph_elt_window : public Window< graph_elt_window<P> >
{
- typedef mesh_elt_window<P> self_;
+ typedef graph_elt_window<P> self_;
public:
/// Associated types.
@@ -67,97 +65,101 @@
// psites, not points?
typedef P point;
- // FIXME: This is a dummy value. This is yet another evidence
- // that mesh_elt_window shall not be a Window, and therefore be
- // renamed as mesh_elt_neighb, or better: elt_graph_neighb.
+ // FIXME: This is a dummy value.
typedef void dpoint;
/*! \brief Point_Iterator type to browse the points of a generic window
* w.r.t. the ordering of delta-points.
*/
- typedef mesh_window_fwd_piter<P> fwd_qiter;
+ typedef graph_window_fwd_piter<P> fwd_qiter;
/*! \brief Point_Iterator type to browse the points of a generic window
* w.r.t. the reverse ordering of delta-points.
*/
- typedef mesh_window_bkd_piter<P> bkd_qiter;
+ typedef graph_window_bkd_piter<P> bkd_qiter;
/// The default qiter type.
typedef fwd_qiter qiter;
/// \}
- /// Construct an elementary mesh window centered on \a psite.
- mesh_elt_window(/*const mesh_psite<P>& psite*/);
+ /// Construct an elementary graph window.
+ graph_elt_window();
- // FIXME: The following methods make no sense for a
- // general-purpose neighborhood. Anyway, we provide
- // implementations for them for this first draft of graph
- // neighborhood.
+ /// Is the window is empty?
bool is_empty() const;
+
+ /// Is the window centered?
bool is_centered() const;
+
+ /// Is the window symmetric?
+ // FIXME: We should defin this more precisely.
bool is_symmetric() const;
- unsigned delta() const;
- self_& sym();
- // protected:
- // const mesh_psite<P>& psite_;
- };
+ /// Return the maximum coordinate gap between the window center
+ /// and a window point.
+ /* FIXME: This method returns a dummy value (0), since the delta
+ of a window on a graph
+ 1. is not constant (graph nodes are not necessarily aligned on
+ a regular grid);
- // FIXME: Add an operator<< on ostreams ?
+ 2. depends on the underlying graph, too.
+
+ It raises another question: should delta() be part of the
+ concept ``Window''? */
+ unsigned delta() const;
+
+ /// Apply a central symmetry to the target window.
+ self_& sym();
+ };
# ifndef MLN_INCLUDE_ONLY
template <typename P>
inline
- mesh_elt_window<P>::mesh_elt_window(/*const mesh_psite<P>& psite*/)
- // : psite_(psite)
+ graph_elt_window<P>::graph_elt_window()
{
}
template <typename P>
inline
bool
- mesh_elt_window<P>::is_empty() const
+ graph_elt_window<P>::is_empty() const
{
- // FIXME: Dummy value.
return false;
}
template <typename P>
inline
bool
- mesh_elt_window<P>::is_centered() const
+ graph_elt_window<P>::is_centered() const
{
- // FIXME: Dummy value.
return false;
}
template <typename P>
inline
bool
- mesh_elt_window<P>::is_symmetric() const
+ graph_elt_window<P>::is_symmetric() const
{
- // FIXME: Dummy value.
- return false;
+ return true;
}
template <typename P>
inline
unsigned
- mesh_elt_window<P>::delta() const
+ graph_elt_window<P>::delta() const
{
- // FIXME: Dummy value.
+ // Dummy value (see the interface of the method above).
return 0;
}
template <typename P>
inline
- mesh_elt_window<P>&
- mesh_elt_window<P>::sym()
+ graph_elt_window<P>&
+ graph_elt_window<P>::sym()
{
- // FIXME: Dummy value.
return *this;
}
@@ -166,4 +168,4 @@
} // end of namespace mln
-#endif // ! MLN_WIN_MESH_ELT_WINDOW_HH
+#endif // ! MLN_WIN_GRAPH_ELT_WINDOW_HH
Index: mln/draw/graph.hh
--- mln/draw/graph.hh (revision 1703)
+++ mln/draw/graph.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,103 +25,101 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_DRAW_MESH_HH
-# define MLN_DRAW_MESH_HH
+#ifndef MLN_DRAW_GRAPH_HH
+# define MLN_DRAW_GRAPH_HH
-/*! \file mln/draw/mesh.hh
- *
- * \brief Draw an image from type mesh_image.
- *
- */
+/// \file mln/draw/graph.hh
+/// \brief Draw an (classical) image from a mln::graph_image.
# include <mln/pw/image.hh>
# include <mln/level/fill.hh>
# include <mln/draw/line.hh>
-# include <mln/core/mesh_p.hh>
-# include <mln/core/mesh_image.hh>
+# include <mln/core/p_graph.hh>
+# include <mln/core/graph_image.hh>
namespace mln
{
namespace draw
{
- /* FIXME: `draw::mesh' is not a good name. These functions do not
- actually draw the mesh/mesh_image; it *converts* it to a
+ /* FIXME: `draw::graph' is not a good name. These functions do not
+ actually _draw_ the graph/graph_image; it *converts* it to a
printable image. These functions should be put elsewhere
(e.g., in debug::). */
- /*! Draw an image \p ima from a mesh_p \p m, with value \p node_v
- * for nodes, value \p link_v for links and 0 for the background.
+ /*! \brief Draw an image \p ima from a mln::p_graph \p pg, with
+ * value \p node_v for nodes, value \p link_v for links and 0 for
+ * the background.
*
* \param[in,out] ima The image to be drawn.
- * \param[in] m The mesh_p which contains nodes and links positions.
- * \param[in] node_v The value to assign to pixels which contains nodes.
- * \param[in] link_v The value to assign to pixels which contains links.
- *
+ * \param[in] pg The p_graph which contains nodes and links
+ * positions.
+ * \param[in] node_v The value to assign to pixels which contains
+ * nodes.
+ * \param[in] link_v The value to assign to pixels which contains
+ * links.
*/
template <typename I, typename P>
void
- mesh(Image<I>& ima, const mesh_p<P>& m,
- mln_value(I) node_v,
- mln_value(I) link_v);
+ graph(Image<I>& ima, const p_graph<P>& pg,
+ mln_value(I) node_v, mln_value(I) link_v);
- /*! Draw an image \p ima from a mesh_image \p mesh.
- * The background is filled to value 0.
+ /*! \brief Draw an image \p ima from a mln::graph_image \p gi.
+ *
+ * The background is filled with value 0.
*
* \param[in,out] ima The image to be drawn.
- * \param[in] mesh The mesh_image which contains nodes, links
+ * \param[in] gi The graph_image which contains the nodes, links
* positions and the values of it.
- * \param[in] link_v The value to assign to pixels which contains links,
- * defaulting to 1.
- *
+ * \param[in] link_v The value to assign to pixels which contains
+ * links, defaulting to 1.
*/
// FIXME: The type of the last argument cannot always been
// constructed from `int'! We should remove this last argument.
template <typename I, typename P, typename V>
void
- mesh(Image<I>& ima, const mesh_image<P, V>& mesh,
+ graph(Image<I>& ima, const graph_image<P, V>& gi,
mln_value(I) link_v = 1);
# ifndef MLN_INCLUDE_ONLY
// FIXME: Add assertions on the size of the image: it must be large
- // enough to hold the reprensentation of the graph.
+ // enough to hold the representation of the graph/graph_image.
template <typename I, typename P>
inline
void
- mesh(Image<I>& ima, const mesh_p<P>& m,
- mln_value(I) node_v,
- mln_value(I) link_v)
+ graph(Image<I>& ima, const p_graph<P>& pg,
+ mln_value(I) node_v, mln_value(I) link_v)
{
level::fill(ima, 0);
- for (unsigned i = 0; i < m.gr_.nb_link_; ++i)
+ for (unsigned i = 0; i < pg.nlines(); ++i)
line (exact(ima),
- m.loc_[m.gr_.links_[i]->pair_node_.first],
- m.loc_[m.gr_.links_[i]->pair_node_.second],
+ pg.loc_[pg.gr_.links_[i]->pair_node_.first],
+ pg.loc_[pg.gr_.links_[i]->pair_node_.second],
link_v);
- for (unsigned i = 0; i < m.gr_.nb_node_; ++i)
- exact(ima)(m.loc_[i]) = node_v;
+ for (unsigned i = 0; i < pg.npoints(); ++i)
+ exact(ima)(pg.loc_[i]) = node_v;
}
template <typename I, typename P, typename V>
inline
void
- mesh(Image<I>& ima, const mesh_image<P, V>& mesh,
+ graph(Image<I>& ima, const graph_image<P, V>& gi,
mln_value(I) link_v)
{
level::fill(ima, 0);
- for (unsigned i = 0; i < mesh.domain().gr_.nb_link_; ++i)
+ for (unsigned i = 0; i < gi.domain().nlines(); ++i)
line (exact(ima),
- mesh.access_location_link_node1 (i),
- mesh.access_location_link_node2 (i),
+ gi.access_location_link_node1 (i),
+ gi.access_location_link_node2 (i),
link_v);
- for (unsigned i = 0; i < mesh.domain().gr_.nb_node_; ++i)
- exact(ima)(mesh.domain().loc_[i]) = mesh.data_values ()[i];
+ for (unsigned i = 0; i < gi.domain().npoints(); ++i)
+ exact(ima)(gi.domain().loc_[i]) = gi.data_values ()[i];
}
# endif // ! MLN_INCLUDE_ONLY
@@ -130,4 +128,4 @@
} // end of namespace mln
-#endif // MLN_MESH_PSITE_HH
+#endif // MLN_GRAPH_PSITE_HH
Index: tests/core/graph_elt_window.cc
--- tests/core/graph_elt_window.cc (revision 1703)
+++ tests/core/graph_elt_window.cc (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,15 +25,15 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/core/mesh_elt_window.cc
+/*! \file tests/core/graph_elt_window.cc
*
- * \brief Tests on mln::win::mesh_elt_window.
+ * \brief Tests on mln::win::graph_elt_window.
*/
#include <vector>
#include <mln/core/point2d.hh>
-#include <mln/core/mesh_elt_window.hh>
+#include <mln/core/graph_elt_window.hh>
#include <mln/debug/iota.hh>
#include <mln/debug/println.hh>
@@ -70,13 +70,13 @@
g.add_edge(4, 2);
/*------------------.
- | Mesh and window. |
+ | Graph and window. |
`------------------*/
- // Mesh psite set.
- mesh_p<p_t> mesh(g, points);
- // Mesh point site.
- mesh_psite<p_t> psite(mesh, 0);
- // ``Sliding'' window (in fact, neighborhood) of a psite of MESH.
- mesh_elt_window<p_t> win;
+ // Graph psite set.
+ p_graph<p_t> pg(g, points);
+ // Graph point site.
+ graph_psite<p_t> psite(pg, 0);
+ // ``Sliding'' window (in fact, neighborhood) of a psite of PG.
+ graph_elt_window<p_t> win;
}
Index: tests/core/graph_image.cc
--- tests/core/graph_image.cc (revision 1703)
+++ tests/core/graph_image.cc (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,19 +25,19 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/// \file tests/core/mesh_image.cc
-/// \brief Tests on mln::mesh_image.
+/// \file tests/core/graph_image.cc
+/// \brief Tests on mln::graph_image.
#include <vector>
#include <mln/core/point2d.hh>
-#include <mln/core/mesh_image.hh>
-#include <mln/core/mesh_elt_window.hh>
-#include <mln/core/mesh_window_piter.hh>
+#include <mln/core/graph_image.hh>
+#include <mln/core/graph_elt_window.hh>
+#include <mln/core/graph_window_piter.hh>
#include <mln/morpho/dilation.hh>
-#include <mln/draw/mesh.hh>
+#include <mln/draw/graph.hh>
#include <mln/debug/iota.hh>
#include <mln/debug/println.hh>
@@ -71,45 +71,45 @@
g.add_edge(4, 2);
/*-------.
- | Mesh. |
+ | Graph. |
`-------*/
- mesh_p<point2d> mesh(g, points);
+ p_graph<point2d> pg(g, points);
/*-------------.
- | Mesh image. |
+ | Graph image. |
`-------------*/
// Values ("empty" vector).
std::vector<int> values(5);
- // Mesh image.
- typedef mesh_image<point2d, int> ima_t;
- ima_t ima(mesh, values);
+ // Graph image.
+ typedef graph_image<point2d, int> ima_t;
+ ima_t ima(pg, values);
// Initialize values.
debug::iota(ima);
// Print the image.
- /* FIXME: Unfortunately, displaying mesh images is not easy right
- now (2007-12-19). We could use
+ /* FIXME: Unfortunately, displaying graph images is not easy right
+ now (2008-02-05). We could use
debug::println(ima);
- but there's not specialization working for mesh_image; the one
+ but there's not specialization working for graph_image; the one
selected by the compiler is based on a 2-D bbox, and expects the
- interface of mesh_image to work with points (not psites).
- Moreover, this iplementation only shows *values*, not the graph
+ interface of graph_image to work with points (not psites).
+ Moreover, this implementation only shows *values*, not the graph
itslef.
- An alternative is to use draw::mesh (which, again, is misnamed),
+ An alternative is to use draw::graph (which, again, is misnamed),
but it doesn't show the values, only the nodes and edges of the
graph.
- The current solution is a mix between draw::mesh and hand-made
+ The current solution is a mix between draw::graph and hand-made
iterations. */
image2d<int> ima_rep(ima.bbox());
- // We use the value 9 in draw::mesh instead of the default (which is
+ // We use the value 9 in draw::graph instead of the default (which is
// 1) to represent edges to distinguish it from nodes holding a
// value of 1.
- draw::mesh (ima_rep, ima, 9);
+ draw::graph (ima_rep, ima, 9);
debug::println (ima_rep);
@@ -123,10 +123,7 @@
std::cout << "ima (" << p << ") = " << ima(p) << std::endl;
// Manual iterations over the neighborhoods of each point site of IMA.
- /* FIXME: In fact, this class should be named
- `mesh_elt_neighborhood' (there's no such thing as an elementary
- window on a mesh/graph!). */
- typedef mesh_elt_window<point2d> win_t;
+ typedef graph_elt_window<point2d> win_t;
win_t win;
mln_qiter_(win_t) q(win, p);
for_all (p)
@@ -136,16 +133,17 @@
for_all (q)
std::cout << " " << q << " (level = " << ima(q) << ")" << std::endl;
}
+ std::cout << std::endl;
/*-------------------------.
- | Processing mesh images. |
+ | Processing graph images. |
`-------------------------*/
- mesh_image<point2d, int> ima_dil = morpho::dilation(ima, win);
- draw::mesh(ima_rep, ima_dil, 9);
+ graph_image<point2d, int> ima_dil = morpho::dilation(ima, win);
+ draw::graph(ima_rep, ima_dil, 9);
debug::println(ima_rep);
- mesh_image<point2d, int> ima_ero = morpho::erosion(ima, win);
- draw::mesh(ima_rep, ima_ero, 9);
+ graph_image<point2d, int> ima_ero = morpho::erosion(ima, win);
+ draw::graph(ima_rep, ima_ero, 9);
debug::println(ima_rep);
}
Index: tests/core/Makefile.am
--- tests/core/Makefile.am (revision 1703)
+++ tests/core/Makefile.am (working copy)
@@ -8,8 +8,8 @@
exact \
h_vec \
initialize \
- mesh_elt_window \
- mesh_image \
+ graph_elt_window \
+ graph_image \
mono_obased_rle_image \
mono_rle_image \
obased_rle_image \
@@ -29,8 +29,8 @@
exact_SOURCES = exact.cc
h_vec_SOURCES = h_vec.cc
initialize_SOURCES = initialize.cc
-mesh_elt_window_SOURCES = mesh_elt_window.cc
-mesh_image_SOURCES = mesh_image.cc
+graph_elt_window_SOURCES = graph_elt_window.cc
+graph_image_SOURCES = graph_image.cc
mono_obased_rle_image_SOURCES = mono_obased_rle_image.cc
mono_rle_image_SOURCES = mono_rle_image.cc
obased_rle_image_SOURCES = obased_rle_image.cc
Index: tests/draw/graph.cc
--- tests/draw/graph.cc (revision 1703)
+++ tests/draw/graph.cc (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,9 +25,9 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/draw/mesh.cc
+/*! \file tests/draw/graph.cc
*
- * \brief Tests on mln::draw::mesh.
+ * \brief Tests on mln::draw::graph.
*
* Build a graph, convert it to an image, and compare it with a
* reference images.
@@ -40,10 +40,10 @@
#include <mln/core/point2d.hh>
#include <mln/debug/println.hh>
#include <mln/util/graph.hh>
-#include <mln/core/mesh_p.hh>
-#include <mln/core/mesh_psite.hh>
-#include <mln/draw/mesh.hh>
-#include <mln/core/mesh_image.hh>
+#include <mln/core/p_graph.hh>
+#include <mln/core/graph_psite.hh>
+#include <mln/draw/graph.hh>
+#include <mln/core/graph_image.hh>
#include <mln/level/compare.hh>
@@ -71,12 +71,10 @@
// Check its consistency.
g.consistency ();
- mln::mesh_p<point2d> m(g, points);
+ mln::p_graph<point2d> pg(g, points);
image2d<int> ima(nrows, ncols);
- // FIXME: `draw::mesh' is not a good name. This function doesn't
- // actually draw the mesh; it *converts* it to a printable image.
- draw::mesh (ima, m, 2, 1);
+ draw::graph (ima, pg, 2, 1);
mln_assertion (ima == ref);
}
Index: tests/draw/Makefile.am
--- tests/draw/Makefile.am (revision 1703)
+++ tests/draw/Makefile.am (working copy)
@@ -5,10 +5,10 @@
check_PROGRAMS = \
all_headers \
line \
- mesh
+ graph
all_headers_SOURCES = all_headers.cc
line_SOURCES = line.cc
-mesh_SOURCES = mesh.cc
+graph_SOURCES = graph.cc
TESTS = $(check_PROGRAMS)
1
1
1703: Fix mesh_image w.r.t. the recently updated interface of graphs.
by Roland Levillain 05 Feb '08
by Roland Levillain 05 Feb '08
05 Feb '08
https://svn.lrde.epita.fr/svn/oln/trunk/milena
When altering something as central as a graph class, please pay attention
to all client code using it! Thanks in advance.
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Fix mesh_image w.r.t. the recently updated interface of graphs.
* mln/core/mesh_image.hh:
(mesh_image<P, V>::access_location_link_node1 (const unsigned&))
(mesh_image<P, V>::access_location_link_node2 (const unsigned&)):
Catch up with the new interface of mln::util::s_edge.
mesh_image.hh | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
Index: mln/core/mesh_image.hh
--- mln/core/mesh_image.hh (revision 1702)
+++ mln/core/mesh_image.hh (working copy)
@@ -212,7 +212,7 @@
previous content pointed by data_.
We should definitely write down formal guidelines on
- initializaion and memory management in general! */
+ initialization and memory management in general! */
this->data_ = new internal::data_< mesh_image<P, V> > (mesh, val);
}
@@ -270,7 +270,8 @@
const P&
mesh_image<P, V>::access_location_link_node1 (const unsigned& i) const
{
- return this->domain().loc_[this->domain().gr_.links_[i]->node1];
+ // FIXME: This is ugly! Too much implementation details are shown here.
+ return this->domain().loc_[this->domain().gr_.links_[i]->pair_node_.first];
}
template <typename P, typename V>
@@ -278,7 +279,8 @@
const P&
mesh_image<P, V>::access_location_link_node2 (const unsigned& i) const
{
- return this->domain().loc_[this->domain().gr_.links_[i]->node2];
+ // FIXME: This is ugly! Too much implementation details are shown here.
+ return this->domain().loc_[this->domain().gr_.links_[i]->pair_node_.second];
}
# endif // ! MLN_INCLUDE_ONLY
1
0
05 Feb '08
https://svn.lrde.epita.fr/svn/oln/trunk/milena
This is just a fix. There's still some work to do there (see
https://trac.lrde.org/olena/ticket/134)
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Have the documentation compile again with parallel builds.
* doc/Makefile.am (html-local, html_user): Fix paths.
(Doxyfile): Likewise.
Use information from Milena's ChangeLog, not from the top-most
ChangeLog.
Makefile.am | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
Index: doc/Makefile.am
--- doc/Makefile.am (revision 1701)
+++ doc/Makefile.am (working copy)
@@ -1,3 +1,5 @@
+# FIXME: To be overhauled! (See ticket #134).
+
DOXYGEN = doxygen
.PHONY: doc user-doc internal-doc html html_user
@@ -10,10 +12,10 @@
html-local: Doxyfile
- $(DOXYGEN) $(srcdir)/Doxyfile_internal
+ $(DOXYGEN) Doxyfile_internal
-html_user:: Doxyfile
- $(DOXYGEN) $(srcdir)/Doxyfile_user
+html_user: Doxyfile
+ $(DOXYGEN) Doxyfile_user
edit = sed -e "s|@ID@|$$Id|" \
@@ -22,6 +24,10 @@
-e 's,@top_builddir\@,$(top_builddir),g' \
-e 's,@top_srcdir\@,$(top_srcdir),g'
+# FIXME: This is not good. We should set these parameters for both
+# documentation (internal and user) using @VARIABLES@. Don't generate
+# Doxyfile_user from Doxyfile_internal! Both should be a product
+# derived from a single source, Doxyfile.in.
edit_user = sed -e 's,OUTPUT_DIRECTORY = ./internal/,OUTPUT_DIRECTORY = ./user/,g' \
-e 's,EXTRACT_ALL = YES,EXTRACT_ALL = NO,g' \
-e 's,EXTRACT_PRIVATE = YES,EXTRACT_PRIVATE = NO,g' \
@@ -44,10 +50,10 @@
# configure, because the former is way faster than the latter.
# Moreover, this file is updated whenever ChangeLog is touched: using
# sed instead of configure saves us a lot of time.
-Doxyfile: $(top_srcdir)/ChangeLog $(srcdir)/Doxyfile.in
- Id=`grep '^\$$Id' $(top_srcdir)/ChangeLog`; \
- $(edit) $(srcdir)/Doxyfile.in >Doxyfile_internal; \
- $(edit_user) $(srcdir)/Doxyfile_internal >Doxyfile_user
+Doxyfile: $(top_srcdir)/milena/ChangeLog $(srcdir)/Doxyfile.in
+ Id=`grep '^\$$Id' $(top_srcdir)/milena/ChangeLog`; \
+ $(edit) $(srcdir)/Doxyfile.in >Doxyfile_internal && \
+ $(edit_user) Doxyfile_internal >Doxyfile_user
clean-local:
rm -rf internal user
1
0
1701: Remove morpho::level_components and morpho::extrema_components.
by Roland Levillain 30 Jan '08
by Roland Levillain 30 Jan '08
30 Jan '08
https://svn.lrde.epita.fr/svn/oln/trunk/milena
labeling::flat_zones and labeling::regional_minima /
labeling::regional_maxima provide the same services.
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Remove morpho::level_components and morpho::extrema_components.
* mln/morpho/extrema_components.hh,
* mln/morpho/level_components.hh:
Remove.
* tests/morpho/extrema_components.cc,
* tests/morpho/level_components.cc:
Remove test.
* tests/morpho/Makefile.am (check_PROGRAMS): Remove
extrema_components and level_components_SOURCES.
(extrema_components_SOURCES, level_components_SOURCES): Remove.
Makefile.am | 5 -----
1 file changed, 5 deletions(-)
Index: tests/morpho/Makefile.am
--- tests/morpho/Makefile.am (revision 1700)
+++ tests/morpho/Makefile.am (working copy)
@@ -9,11 +9,9 @@
dilation_max_h \
erosion \
erosion_min_h \
- extrema_components \
gradient \
hit_or_miss \
laplacian \
- level_components \
meyer_wst \
meyer_wst_long \
opening_area \
@@ -28,9 +26,6 @@
opening_area_SOURCES = opening_area.cc
closing_area_SOURCES = closing_area.cc
-level_components_SOURCES = level_components.cc
-extrema_components_SOURCES = extrema_components.cc
-
contrast_SOURCES = contrast.cc
gradient_SOURCES = gradient.cc
hit_or_miss_SOURCES = hit_or_miss.cc
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/milena
This way we'll keep track of Boost things we depend on, and maybe should
turn into non Boost-dependent ones. We should prevent circumvent the
compilation of Boost-dependent tests is the required Boost libraries are
missing on the host.
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Add a memo file on Boost features used in Milena.
* README.BOOST: New.
README.BOOST | 3 +++
1 file changed, 3 insertions(+)
Index: README.BOOST
--- README.BOOST (revision 0)
+++ README.BOOST (revision 0)
@@ -0,0 +1,3 @@
+Milena components depending on one or several Boost libraries.
+
+- accu::tuple (depends on Boost Tuple and The Boost Preprocessor Library).
1
0
29 Jan '08
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Convert Meyer's WST implementation to neighborhood-based.
* mln/morpho/meyer_wst.hh: Use neighborhoods instead of windows to
express the connexity of the markers.
Use mln::labeling::regional_minima instead of
mln::morpho::minima_components.
* tests/morpho/meyer_wst.cc,
* tests/morpho/meyer_wst_long.cc:
Adjust tests.
mln/morpho/meyer_wst.hh | 91 ++++++++++++++++++++++++++---------------
tests/morpho/meyer_wst.cc | 10 +---
tests/morpho/meyer_wst_long.cc | 15 ++++--
3 files changed, 70 insertions(+), 46 deletions(-)
Index: mln/morpho/meyer_wst.hh
--- mln/morpho/meyer_wst.hh (revision 1698)
+++ mln/morpho/meyer_wst.hh (working copy)
@@ -45,7 +45,8 @@
# include <mln/util/greater_point.hh>
# include <mln/morpho/includes.hh>
-# include <mln/morpho/extrema_components.hh>
+# include <mln/labeling/regional_minima.hh>
+
namespace mln
@@ -61,34 +62,58 @@
processing it. Then, add a reference to
mln/morpho/lower_completion.hh. */
- /* FIXME: More doc. */
+ /** \brief Meyer's Watershed Transform (WST) algorithm.
- /// Meyer's Watershed Transform (WST) algorithm.
- template <typename DestValue, typename I, typename W>
- mln_ch_value(I, DestValue)
- meyer_wst(const Image<I>& input, const Window<W>& win, unsigned& nbasins);
-
- /// Meyer's Watershed Transform (WST) algorithm, with no count of
- /// basins.
- template <typename DestValue, typename I, typename W>
- mln_ch_value(I, DestValue)
- meyer_wst(const Image<I>& input, const Window<W>& win);
+ \param[in] input The input image.
+ \param[in] nbh The connexity of markers.
+ \param[out] nbasins The number of basins.
+
+ \li \p L is the type of labels, used to number the watershed
+ itself (with the minimal value), and the basins.
+ \li \p I is the exact type of the input image.
+ \li \p N is the exact type of the neighborhood used to express
+ \a input's connexity. */
+ template <typename L, typename I, typename N>
+ mln_ch_value(I, L)
+ meyer_wst(const Image<I>& input, const Neighborhood<N>& nbh,
+ L& nbasins);
+
+ /** \brief Meyer's Watershed Transform (WST) algorithm, with no
+ count of basins.
+
+ \param[in] input The input image.
+ \param[in] nbh The connexity of markers.
+
+ \li \p L is the type of labels, used to number the watershed
+ itself (with the minimal value), and the basins.
+ \li \p I is the exact type of the input image.
+ \li \p N is the exact type of the neighborhood used to express
+ \a input's connexity.
+
+ Note that the first parameter, \p L, is not automatically
+ valued from the type of the actual argument during implicit
+ instantiation: you have to explicitly pass this parameter at
+ call sites. */
+ template <typename L, typename I, typename N>
+ mln_ch_value(I, L)
+ meyer_wst(const Image<I>& input, const Neighborhood<N>& nbh);
# ifndef MLN_INCLUDE_ONLY
- template <typename DestValue, typename I, typename W>
- mln_ch_value(I, DestValue)
- meyer_wst(const Image<I>& input, const Window<W>& win, unsigned& nbasins)
+ template <typename L, typename I, typename N>
+ mln_ch_value(I, L)
+ meyer_wst(const Image<I>& input, const Neighborhood<N>& nbh,
+ L& nbasins)
{
/* FIXME: Ensure the input image has scalar values. */
- typedef DestValue marker;
+ typedef L marker;
const marker unmarked = mln_min(marker);
// Initialize the output with the markers (minima components).
mln_ch_value(I, marker) markers =
- minima_components<marker>(input, win, nbasins);
+ labeling::regional_minima (input, nbh, nbasins);
// Ordered queue.
typedef mln_point(I) point;
@@ -101,11 +126,11 @@
// hierarchical queue, with a priority level corresponding to
// the grey level input(P).
mln_piter(I) p(markers.domain());
- mln_qiter(W) q(win, p);
+ mln_niter(N) n(nbh, p);
for_all (p)
if (markers(p) == unmarked)
- for_all(q)
- if (markers.has(q) && markers(q) != unmarked)
+ for_all(n)
+ if (markers.has(n) && markers(n) != unmarked)
{
queue.push(p);
break;
@@ -122,16 +147,16 @@
marker adjacent_marker = unmarked;
// Has P a single adjacent marker?
bool single_adjacent_marker_p = true;
- mln_qiter(W) q(win, p);
- for_all(q)
- if (markers.has(q) && markers(q) != unmarked)
+ mln_niter(N) n(nbh, p);
+ for_all(n)
+ if (markers.has(n) && markers(n) != unmarked)
if (adjacent_marker == unmarked)
{
- adjacent_marker = markers(q);
+ adjacent_marker = markers(n);
single_adjacent_marker_p = true;
}
else
- if (adjacent_marker != markers(q))
+ if (adjacent_marker != markers(n))
{
single_adjacent_marker_p = false;
break;
@@ -143,20 +168,20 @@
if (single_adjacent_marker_p)
{
markers(p) = adjacent_marker;
- for_all(q)
- if (markers.has(q) && markers(q) == unmarked)
- queue.push(q);
+ for_all(n)
+ if (markers.has(n) && markers(n) == unmarked)
+ queue.push(n);
}
}
return markers;
}
- template <typename DestValue, typename I, typename W>
- mln_ch_value(I, DestValue)
- meyer_wst(const Image<I>& input, const Window<W>& win)
+ template <typename L, typename I, typename N>
+ mln_ch_value(I, L)
+ meyer_wst(const Image<I>& input, const Neighborhood<N>& nbh)
{
- unsigned nbasins;
- return meyer_wst<DestValue>(input, nbasins);
+ L nbasins;
+ return meyer_wst<L>(input, nbh, nbasins);
}
# endif // ! MLN_INCLUDE_ONLY
Index: tests/morpho/meyer_wst.cc
--- tests/morpho/meyer_wst.cc (revision 1698)
+++ tests/morpho/meyer_wst.cc (working copy)
@@ -34,8 +34,6 @@
#include <mln/core/window2d.hh>
#include <mln/core/neighb2d.hh>
-#include <mln/convert/to_window.hh>
-
#include <mln/value/int_u8.hh>
#include <mln/morpho/meyer_wst.hh>
@@ -54,11 +52,9 @@
image2d<int_u8> input;
io::pgm::load(input, MLN_IMG_DIR "/squares.pgm");
- typedef int_u8 output_val;
- unsigned nbasins;
- // FIXME: Do we really need to use a neighborood to express a 4-c window?
- image2d<int_u8> output =
- morpho::meyer_wst<output_val>(input, convert::to_window(c4()), nbasins);
+ typedef int_u8 wst_val;
+ wst_val nbasins;
+ image2d<int_u8> output = morpho::meyer_wst(input, c4(), nbasins);
std::cout << "nbasins = " << nbasins << std::endl;
io::pgm::save(output, "out.pgm");
}
Index: tests/morpho/meyer_wst_long.cc
--- tests/morpho/meyer_wst_long.cc (revision 1698)
+++ tests/morpho/meyer_wst_long.cc (working copy)
@@ -35,15 +35,17 @@
#include <mln/core/window2d.hh>
#include <mln/core/neighb2d.hh>
-#include <mln/convert/to_window.hh>
#include <mln/level/stretch.hh>
#include <mln/value/int_u8.hh>
#include <mln/value/int_u16.hh>
+#include <mln/morpho/gradient.hh>
#include <mln/morpho/closing_area.hh>
#include <mln/morpho/meyer_wst.hh>
+#include <mln/convert/to_window.hh>
+
#include <mln/pw/cst.hh>
#include <mln/pw/value.hh>
@@ -63,16 +65,17 @@
image2d<int_u8> input;
io::pgm::load(input, MLN_IMG_DIR "/lena.pgm");
+ image2d<int_u8> gradient =
+ morpho::gradient (input, convert::to_window(c4()));
+
// Simplify the input image.
image2d<int_u8> work(input.domain());
- morpho::closing_area(input, c4(), 200, work);
+ morpho::closing_area(gradient, c4(), 200, work);
// Perform a Watershed Transform.
typedef int_u16 wst_val;
- unsigned nbasins;
- // FIXME: Do we really need to use a neighborood to express a 4-c window?
- image2d<wst_val> ws =
- morpho::meyer_wst<wst_val>(work, convert::to_window(c4()), nbasins);
+ wst_val nbasins;
+ image2d<wst_val> ws = morpho::meyer_wst(work, c4(), nbasins);
std::cout << "nbasins = " << nbasins << std::endl;
// Save the image in color.
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Move convert::to_upper_window into its own file.
* mln/convert/to_window.hh
(convert::to_upper_window(const Neighborhood<N>&)): Move this
function...
* mln/convert/to_upper_window.hh: ...here (new file).
(convert::to_upper_window(const Windows<W>&)): New function.
* mln/canvas/labeling.hh: Adjust.
* mln/labeling/background.hh,
* mln/labeling/blobs.hh,
* mln/labeling/flat_zones.hh,
* mln/labeling/foreground.hh,
* mln/labeling/level.hh,
* mln/labeling/level.spe.hh,
* mln/labeling/regional_maxima.hh,
* mln/labeling/regional_minima.hh:
Adjust comments.
canvas/labeling.hh | 2
convert/to_upper_window.hh | 104 ++++++++++++++++++++++++++++++++++++++++++++
convert/to_window.hh | 22 ---------
labeling/background.hh | 6 --
labeling/blobs.hh | 6 --
labeling/flat_zones.hh | 6 --
labeling/foreground.hh | 6 --
labeling/level.hh | 6 --
labeling/level.spe.hh | 6 --
labeling/regional_maxima.hh | 6 --
labeling/regional_minima.hh | 6 --
11 files changed, 122 insertions(+), 54 deletions(-)
Index: mln/convert/to_window.hh
--- mln/convert/to_window.hh (revision 1697)
+++ mln/convert/to_window.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -53,10 +53,6 @@
template <typename N>
window<mln_dpoint(N)> to_window(const Neighborhood<N>& nbh);
- /// Convert a neighborhood \p nbh into an upper window.
- template <typename N>
- window<mln_dpoint(N)> to_upper_window(const Neighborhood<N>& nbh);
-
/// Convert a binary image \p ima into a window.
template <typename I>
window<mln_dpoint(I)> to_window(const Image<I>& ima);
@@ -96,22 +92,6 @@
}
// FIXME: Same remark as for to_window(const Neighborhood<N>&)
- template <typename N>
- inline
- window<mln_dpoint(N)> to_upper_window(const Neighborhood<N>& nbh_)
- {
- const N& nbh = exact(nbh_);
- typedef mln_dpoint(N) D;
- typedef mln_point(D) P;
- window<D> win;
- mln_niter(N) n(nbh, P::origin);
- for_all(n)
- if (n > P::origin)
- win.insert(n - P::origin);
- return win;
- }
-
- // FIXME: Same remark as for to_window(const Neighborhood<N>&)
template <typename I>
inline
window<mln_dpoint(I)> to_window(const Image<I>& ima_)
Index: mln/convert/to_upper_window.hh
--- mln/convert/to_upper_window.hh (revision 0)
+++ mln/convert/to_upper_window.hh (revision 0)
@@ -0,0 +1,104 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena 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 MLN_CONVERT_TO_UPPER_WINDOW_HH
+# define MLN_CONVERT_TO_UPPER_WINDOW_HH
+
+/*! \file mln/convert/to_upper_window.hh
+ *
+ * \brief Conversions to upper mln::window.
+ */
+
+# include <mln/core/concept/delta_point_site.hh>
+# include <mln/core/concept/neighborhood.hh>
+# include <mln/core/window.hh>
+
+
+namespace mln
+{
+
+ namespace convert
+ {
+
+ /// Convert a window \p nbh into an upper window.
+ template <typename W>
+ window<mln_dpoint(W)> to_upper_window(const Window<W>& win);
+
+ /// Convert a neighborhood \p nbh into an upper window.
+ template <typename N>
+ window<mln_dpoint(N)> to_upper_window(const Neighborhood<N>& nbh);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ /* FIXME: According to milena/core/concepts/README, windows are
+ not necessarily based on a set of dpoints. So the current
+ algorithm won't work on non dpoint-set-based windows. In the
+ general case (of windows not being a set of dpoints), the
+ window resulting from this conversion (as well as the iterators
+ based on such windows!) should depend on the initial
+ neighborhood (i.e., delegate the actual iteration to the
+ aggregated neighborhood). When this is fixed, document this in
+ depth in milena/core/concepts/README. */
+ template <typename W>
+ inline
+ window<mln_dpoint(W)> to_upper_window(const Window<W>& win_)
+ {
+ const W& input_win = exact(win_);
+ typedef mln_dpoint(W) D;
+ typedef mln_point(D) P;
+ window<D> win;
+ mln_qiter(W) q(input_win, P::origin);
+ for_all(q)
+ if (q > P::origin)
+ win.insert(q - P::origin);
+ return win;
+ }
+
+ template <typename N>
+ inline
+ window<mln_dpoint(N)> to_upper_window(const Neighborhood<N>& nbh_)
+ {
+ const N& nbh = exact(nbh_);
+ typedef mln_dpoint(N) D;
+ typedef mln_point(D) P;
+ window<D> win;
+ mln_niter(N) n(nbh, P::origin);
+ for_all(n)
+ if (n > P::origin)
+ win.insert(n - P::origin);
+ return win;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::convert
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CONVERT_TO_WINDOW_HH
Index: mln/canvas/labeling.hh
--- mln/canvas/labeling.hh (revision 1697)
+++ mln/canvas/labeling.hh (working copy)
@@ -36,7 +36,7 @@
# include <mln/core/concept/image.hh>
# include <mln/level/fill.hh>
-# include <mln/convert/to_window.hh> // FIXME: to_upper_window
+# include <mln/convert/to_upper_window.hh>
namespace mln
Index: mln/labeling/blobs.hh
--- mln/labeling/blobs.hh (revision 1697)
+++ mln/labeling/blobs.hh (working copy)
@@ -48,15 +48,13 @@
{
/* FIXME: The neighborhood shall not be passed as argument, but
- bound to the input image. We can also optionnaly provide a
- version of this function for regular-grid-based images where
- the neighborhood is replaced by a (user-provided) window. */
+ bound to the input image. */
/*! Connected component labeling of the binary objects of a binary
* image.
*
* \param[in] input The input image.
- * \param[in] nbh The neighborhood.
+ * \param[in] nbh The connexity of the objects.
* \param[out] nlabels The number of labels.
* \return The label image.
*
Index: mln/labeling/flat_zones.hh
--- mln/labeling/flat_zones.hh (revision 1697)
+++ mln/labeling/flat_zones.hh (working copy)
@@ -45,14 +45,12 @@
{
/* FIXME: The neighborhood shall not be passed as argument, but
- bound to the input image. We can also optionnaly provide a
- version of this function for regular-grid-based images where
- the neighborhood is replaced by a (user-provided) window. */
+ bound to the input image. */
/*! Connected component labeling of the flat zones of an image.
*
* \param[in] input The input image.
- * \param[in] nbh The neighborhood to consider.
+ * \param[in] nbh The connexity of the flat zones.
* \param[out] nlabels The number of labels.
* \return The label image.
*/
Index: mln/labeling/level.hh
--- mln/labeling/level.hh (revision 1697)
+++ mln/labeling/level.hh (working copy)
@@ -51,16 +51,14 @@
{
/* FIXME: The neighborhood shall not be passed as argument, but
- bound to the input image. We can also optionnaly provide a
- version of this function for regular-grid-based images where
- the neighborhood is replaced by a (user-provided) window. */
+ bound to the input image. */
/*! Connected component labeling of the image objects at a given
* level.
*
* \param[in] input The input image.
* \param[in] val The level to consider for the labeling.
- * \param[in] nbh The neighborhood.
+ * \param[in] nbh The connexity of the level components.
* \param[out] nlabels The number of labels.
* \return The label image.
*/
Index: mln/labeling/foreground.hh
--- mln/labeling/foreground.hh (revision 1697)
+++ mln/labeling/foreground.hh (working copy)
@@ -44,15 +44,13 @@
{
/* FIXME: The neighborhood shall not be passed as argument, but
- bound to the input image. We can also optionnaly provide a
- version of this function for regular-grid-based images where
- the neighborhood is replaced by a (user-provided) window. */
+ bound to the input image. */
/*! Connected component labeling of the object part in a binary
* image.
*
* \param[in] input The input image.
- * \param[in] nbh The neighborhood to consider.
+ * \param[in] nbh The connexity of the foreground.
* \param[out] nlabels The number of labels.
* \return The label image.
*
Index: mln/labeling/regional_minima.hh
--- mln/labeling/regional_minima.hh (revision 1697)
+++ mln/labeling/regional_minima.hh (working copy)
@@ -48,15 +48,13 @@
{
/* FIXME: The neighborhood shall not be passed as argument, but
- bound to the input image. We can also optionnaly provide a
- version of this function for regular-grid-based images where
- the neighborhood is replaced by a (user-provided) window. */
+ bound to the input image. */
/*! Connected component labeling of the regional minima of an
* image.
*
* \param[in] input The input image.
- * \param[in] nbh The neighborhood to consider.
+ * \param[in] nbh The connexity of the regional minima.
* \param[out] nlabels The number of labeled regions.
* \return The label image.
*
Index: mln/labeling/regional_maxima.hh
--- mln/labeling/regional_maxima.hh (revision 1697)
+++ mln/labeling/regional_maxima.hh (working copy)
@@ -48,15 +48,13 @@
{
/* FIXME: The neighborhood shall not be passed as argument, but
- bound to the input image. We can also optionnaly provide a
- version of this function for regular-grid-based images where
- the neighborhood is replaced by a (user-provided) window. */
+ bound to the input image. */
/*! Connected component labeling of the regional maxima of an
* image.
*
* \param[in] input The input image.
- * \param[in] nbh The neighborhood to consider.
+ * \param[in] nbh The connexity of the regional maxima.
* \param[out] nlabels The number of labeled regions.
* \return The label image.
*
Index: mln/labeling/level.spe.hh
--- mln/labeling/level.spe.hh (revision 1697)
+++ mln/labeling/level.spe.hh (working copy)
@@ -50,16 +50,14 @@
{
/* FIXME: The neighborhood shall not be passed as argument, but
- bound to the input image. We can also optionnaly provide a
- version of this function for regular-grid-based images where
- the neighborhood is replaced by a (user-provided) window. */
+ bound to the input image. */
/*! Connected component labeling of the image objects at a given
* level.
*
* \param[in] input The input image.
* \param[in] val The level to consider for the labeling.
- * \param[in] nbh The neighborhood.
+ * \param[in] nbh The connexity of the level components.
* \param[out] nlabels The number of labels.
* \return The label image.
*/
Index: mln/labeling/background.hh
--- mln/labeling/background.hh (revision 1697)
+++ mln/labeling/background.hh (working copy)
@@ -44,15 +44,13 @@
{
/* FIXME: The neighborhood shall not be passed as argument, but
- bound to the input image. We can also optionnaly provide a
- version of this function for regular-grid-based images where
- the neighborhood is replaced by a (user-provided) window. */
+ bound to the input image. */
/*! Connected component labeling of the background part in a
* binary image.
*
* \param[in] input The input image.
- * \param[in] nbh The neighborhood to consider.
+ * \param[in] nbh The connexity of the background.
* \param[out] nlabels The number of labels.
* \return The label image.
*
1
0
Patch (non) proposal (Convert mln/labelling/ from neighborhoods to windows)
by Roland Levillain 29 Jan '08
by Roland Levillain 29 Jan '08
29 Jan '08
As the time of checking in, I realized this patch might be reverted very
soon, since labeling algorithms actually *do* need neighborhoods to
express a connexity, not windows (which lack the symmetry property).
So, instead of checking in this patch now, I just leave it here (in
olena-patches) so that we can possibly use it later, if needed (but I
doubt so).
ChangeLog:
Convert mln/labelling/ from neighborhoods to windows.
* mln/canvas/labeling.hh: Use windows instead of neighborhoods.
* mln/labeling/blobs.hh,
* mln/labeling/flat_zones.hh,
* mln/labeling/level.hh,
* mln/labeling/foreground.hh,
* mln/labeling/regional_minima.hh,
* mln/labeling/regional_maxima.hh,
* mln/labeling/level.spe.hh,
* mln/labeling/background.hh:
Convert routine calls using neighborhoods to windows.
canvas/labeling.hh | 24 +++++++++++++---------
labeling/background.hh | 18 +++++++----------
labeling/blobs.hh | 46 +++++++++++++++++++
+------------------------
labeling/flat_zones.hh | 40 +++++++++++++++++
+--------------------
labeling/foreground.hh | 18 +++++++----------
labeling/level.hh | 35 ++++++++++++++++++---------------
labeling/level.spe.hh | 42 +++++++++++++++++++
+--------------------
labeling/regional_maxima.hh | 40 +++++++++++++++++
+--------------------
labeling/regional_minima.hh | 40 +++++++++++++++++
+--------------------
9 files changed, 148 insertions(+), 155 deletions(-)
Index: mln/canvas/labeling.hh
--- mln/canvas/labeling.hh (revision 1697)
+++ mln/canvas/labeling.hh (working copy)
@@ -36,7 +36,7 @@
# include <mln/core/concept/image.hh>
# include <mln/level/fill.hh>
-# include <mln/convert/to_window.hh> // FIXME: to_upper_window
+# include <mln/convert/to_upper_window.hh>
namespace mln
@@ -53,9 +53,13 @@
// Functor.
F& f;
+ // Image type.
typedef typename F::I I;
- typedef typename F::N N;
+ // Window type.
+ typedef typename F::W W;
+ // Label type.
typedef typename F::L L;
+ // Point set.
typedef typename F::S S;
// Local type.
@@ -100,7 +104,7 @@
F& f;
typedef typename F::I I;
- typedef typename F::N N;
+ typedef typename F::W W;
typedef typename F::L L;
// Auxiliary data.
@@ -163,16 +167,16 @@
labeling<F>::pass_1()
{
mln_fwd_piter(S) p(f.s);
- mln_niter(N) n(f.nbh, p);
+ mln_qiter(W) q(f.win, p);
for_all(p) if (f.handles(p))
{
make_set(p);
- for_all(n)
- if (f.input.has(n) && deja_vu(n))
- if (f.equiv(n, p))
- do_union(n, p);
+ for_all(q)
+ if (f.input.has(q) && deja_vu(q))
+ if (f.equiv(q, p))
+ do_union(q, p);
else
- f.do_no_union(n, p);
+ f.do_no_union(q, p);
deja_vu(p) = true;
}
}
@@ -272,7 +276,7 @@
mln_bkd_pixter(const I) p(f.input);
typedef window<mln_dpoint(I)> W;
- W win = mln::convert::to_upper_window(f.nbh);
+ W win = mln::convert::to_upper_window(f.win);
mln_qixter(const I, W) n(p, win);
for_all(p) if (f.handles(p))
Index: mln/labeling/blobs.hh
--- mln/labeling/blobs.hh (revision 1697)
+++ mln/labeling/blobs.hh (working copy)
@@ -35,7 +35,7 @@
*/
# include <mln/core/concept/image.hh>
-# include <mln/core/concept/neighborhood.hh>
+# include <mln/core/concept/window.hh>
# include <mln/level/fill.hh>
# include <mln/core/p_queue_fast.hh>
@@ -47,16 +47,14 @@
namespace labeling
{
- /* FIXME: The neighborhood shall not be passed as argument, but
- bound to the input image. We can also optionnaly provide a
- version of this function for regular-grid-based images where
- the neighborhood is replaced by a (user-provided) window. */
+ // FIXME: Provide a neighborhood-aware version of these
+ // algorithms.
/*! Connected component labeling of the binary objects of a binary
* image.
*
* \param[in] input The input image.
- * \param[in] nbh The neighborhood.
+ * \param[in] win The connexity of the objects.
* \param[out] nlabels The number of labels.
* \return The label image.
*
@@ -65,10 +63,9 @@
* A fast queue is used so that the algorithm is not recursive and
* can handle large binary objects (blobs).
*/
- template <typename I, typename N>
+ template <typename I, typename W>
mln_ch_value(I, unsigned)
- blobs(const Image<I>& input, const Neighborhood<N>& nbh,
- unsigned& nlabels);
+ blobs(const Image<I>& input, const Window<W>& win, unsigned&
nlabels);
# ifndef MLN_INCLUDE_ONLY
@@ -79,14 +76,14 @@
namespace generic
{
- template <typename I, typename N>
+ template <typename I, typename W>
mln_ch_value(I, unsigned)
- blobs_(const I& input, const N& nbh, unsigned& nlabels)
+ blobs_(const I& input, const W& win, unsigned& nlabels)
{
typedef mln_psite(I) P;
P cur;
- mln_niter(N) n(nbh, cur);
+ mln_qiter(W) q(win, cur);
p_queue_fast<P> qu;
// Initialization.
@@ -109,12 +106,12 @@
{
cur = qu.front();
qu.pop();
- for_all(n) if (input.has(n))
- if (input(n) && ! output(n))
+ for_all(q) if (input.has(q))
+ if (input(q) && ! output(q))
{
- mln_invariant(! qu.has(n));
- qu.push(n);
- output(n) = nlabels;
+ mln_invariant(! qu.has(q));
+ qu.push(q);
+ output(q) = nlabels;
}
}
while (! qu.is_empty());
@@ -126,12 +123,12 @@
} // end of namespace mln::labeling::impl::generic
- template <typename I, typename N>
+ template <typename I, typename W>
mln_ch_value(I, unsigned)
- blobs_(const I& input, const N& nbh, unsigned& nlabels)
+ blobs_(const I& input, const W& win, unsigned& nlabels)
{
// The only implementation is the generic one.
- return generic::blobs_(input, nbh, nlabels);
+ return generic::blobs_(input, win, nlabels);
}
} // end of namespace mln::labeling::impl
@@ -139,20 +136,19 @@
// Facade.
- template <typename I, typename N>
+ template <typename I, typename W>
inline
mln_ch_value(I, unsigned)
- blobs(const Image<I>& input_, const Neighborhood<N>& nbh_,
- unsigned& nlabels)
+ blobs(const Image<I>& input_, const Window<W>& win_, unsigned&
nlabels)
{
trace::entering("labeling::blobs");
mlc_equal(mln_trait_image_kind(I),
mln::trait::image::kind::binary)::check();
const I& input = exact(input_);
- const N& nbh = exact(nbh_);
+ const W& win = exact(win_);
mln_precondition(input.has_data());
- mln_ch_value(I, unsigned) output = impl::blobs_(input, nbh,
nlabels);
+ mln_ch_value(I, unsigned) output = impl::blobs_(input, win,
nlabels);
trace::exiting("labeling::blobs");
return output;
Index: mln/labeling/flat_zones.hh
--- mln/labeling/flat_zones.hh (revision 1697)
+++ mln/labeling/flat_zones.hh (working copy)
@@ -34,7 +34,7 @@
*/
# include <mln/core/concept/image.hh>
-# include <mln/core/concept/neighborhood.hh>
+# include <mln/core/concept/window.hh>
# include <mln/canvas/labeling.hh>
@@ -44,21 +44,19 @@
namespace labeling
{
- /* FIXME: The neighborhood shall not be passed as argument, but
- bound to the input image. We can also optionnaly provide a
- version of this function for regular-grid-based images where
- the neighborhood is replaced by a (user-provided) window. */
+ // FIXME: Provide a neighborhood-aware version of these
+ // algorithms.
/*! Connected component labeling of the flat zones of an image.
*
* \param[in] input The input image.
- * \param[in] nbh The neighborhood to consider.
+ * \param[in] win The connexity of the flat zones.
* \param[out] nlabels The number of labels.
* \return The label image.
*/
- template <typename I, typename N, typename L>
+ template <typename I, typename W, typename L>
mln_ch_value(I, L)
- flat_zones(const Image<I>& input, const Neighborhood<N>& nbh, L&
nlabels);
+ flat_zones(const Image<I>& input, const Window<W>& win, L&
nlabels);
@@ -69,7 +67,7 @@
// Flat zone functor for the labeling canvas.
- template <typename I_, typename N_, typename L_>
+ template <typename I_, typename W_, typename L_>
struct flat_zones_functor
{
typedef mln_psite(I_) P;
@@ -77,12 +75,12 @@
// requirements from mln::canvas::labeling:
typedef I_ I;
- typedef N_ N;
+ typedef W_ W;
typedef L_ L;
typedef mln_pset(I) S;
const I& input;
- const N& nbh;
+ const W& win;
const S& s;
bool handles(const P&) const { return true; }
@@ -97,9 +95,9 @@
// end of requirements
- flat_zones_functor(const I_& input, const N_& nbh)
+ flat_zones_functor(const I_& input, const W_& win)
: input(input),
- nbh(nbh),
+ win(win),
s(input.domain())
{}
};
@@ -110,14 +108,14 @@
namespace generic
{
- template <typename I, typename N, typename L>
+ template <typename I, typename W, typename L>
mln_ch_value(I, L)
- flat_zones_(const I& input, const N& nbh, L& nlabels)
+ flat_zones_(const I& input, const W& win, L& nlabels)
{
trace::entering("labeling::impl::generic::flat_zones_");
- typedef flat_zones_functor<I,N,L> F;
- F f(input, nbh);
+ typedef flat_zones_functor<I,W,L> F;
+ F f(input, win);
canvas::labeling<F> run(f);
nlabels = run.nlabels;
@@ -134,19 +132,19 @@
// Facade.
- template <typename I, typename N, typename L>
+ template <typename I, typename W, typename L>
mln_ch_value(I, L)
- flat_zones(const Image<I>& input_, const Neighborhood<N>& nbh_,
+ flat_zones(const Image<I>& input_, const Window<W>& win_,
L& nlabels)
{
trace::entering("labeling::flat_zones");
const I& input = exact(input_);
- const N& nbh = exact(nbh_);
+ const W& win = exact(win_);
mln_precondition(input.has_data());
// Calls the only (generic) impl.
mln_ch_value(I, L) output =
- impl::generic::flat_zones_(input, nbh, nlabels);
+ impl::generic::flat_zones_(input, win, nlabels);
trace::exiting("labeling::flat_zones");
return output;
Index: mln/labeling/level.hh
--- mln/labeling/level.hh (revision 1697)
+++ mln/labeling/level.hh (working copy)
@@ -35,7 +35,7 @@
*/
# include <mln/core/concept/image.hh>
-# include <mln/core/concept/neighborhood.hh>
+# include <mln/core/concept/window.hh>
# include <mln/canvas/labeling.hh>
# include <mln/level/fill.hh>
@@ -50,6 +50,9 @@
namespace labeling
{
+ // FIXME: Provide a neighborhood-aware version of these
+ // algorithms.
+
/* FIXME: The neighborhood shall not be passed as argument, but
bound to the input image. We can also optionnaly provide a
version of this function for regular-grid-based images where
@@ -60,14 +63,14 @@
*
* \param[in] input The input image.
* \param[in] val The level to consider for the labeling.
- * \param[in] nbh The neighborhood.
+ * \param[in] win The connexity of the components.
* \param[out] nlabels The number of labels.
* \return The label image.
*/
- template <typename I, typename N, typename L>
+ template <typename I, typename W, typename L>
mln_ch_value(I, L)
level(const Image<I>& input, const mln_value(I)& val,
- const Neighborhood<N>& nbh, L& nlabels);
+ const Window<W>& win, L& nlabels);
# ifndef MLN_INCLUDE_ONLY
@@ -77,7 +80,7 @@
// Generic functor.
- template <typename I_, typename N_, typename L_>
+ template <typename I_, typename W_, typename L_>
struct level_functor
{
typedef mln_psite(I_) P;
@@ -85,12 +88,12 @@
// requirements from mln::canvas::labeling:
typedef I_ I;
- typedef N_ N;
+ typedef W_ W;
typedef L_ L;
typedef mln_pset(I) S;
const I& input;
- const N& nbh;
+ const W& win;
const S& s;
bool handles(const P& p) const { return input(p) == val; }
@@ -106,9 +109,9 @@
const mln_value(I_)& val;
- level_functor(const I_& input, const mln_value(I_)& val, const N_&
nbh)
+ level_functor(const I_& input, const mln_value(I_)& val, const W_&
win)
: input(input),
- nbh(nbh),
+ win(win),
s(input.domain()),
val(val)
{}
@@ -120,15 +123,15 @@
namespace generic
{
- template <typename I, typename N, typename L>
+ template <typename I, typename W, typename L>
mln_ch_value(I, L)
- level_(const I& input, const mln_value(I)& val, const N& nbh,
+ level_(const I& input, const mln_value(I)& val, const W& win,
L& nlabels)
{
trace::entering("labeling::impl::generic::level_");
- typedef level_functor<I,N,L> F;
- F f(input, val, nbh);
+ typedef level_functor<I,W,L> F;
+ F f(input, val, win);
canvas::labeling<F> run(f);
nlabels = run.nlabels;
@@ -147,17 +150,17 @@
// Facade.
- template <typename I, typename N, typename L>
+ template <typename I, typename W, typename L>
mln_ch_value(I, L)
level(const Image<I>& input, const mln_value(I)& val,
- const Neighborhood<N>& nbh, L& nlabels)
+ const Window<W>& win, L& nlabels)
{
trace::entering("labeling::level");
mln_precondition(exact(input).has_data());
mln_ch_value(I, L) output =
impl::level_(mln_trait_image_speed(I)(),
- exact(input), val, exact(nbh), nlabels);
+ exact(input), val, exact(win), nlabels);
trace::exiting("labeling::level");
return output;
Index: mln/labeling/foreground.hh
--- mln/labeling/foreground.hh (revision 1697)
+++ mln/labeling/foreground.hh (working copy)
@@ -43,16 +43,14 @@
namespace labeling
{
- /* FIXME: The neighborhood shall not be passed as argument, but
- bound to the input image. We can also optionnaly provide a
- version of this function for regular-grid-based images where
- the neighborhood is replaced by a (user-provided) window. */
+ // FIXME: Provide a neighborhood-aware version of these
+ // algorithms.
/*! Connected component labeling of the object part in a binary
* image.
*
* \param[in] input The input image.
- * \param[in] nbh The neighborhood to consider.
+ * \param[in] win The connexity of the foreground.
* \param[out] nlabels The number of labels.
* \return The label image.
*
@@ -63,18 +61,18 @@
*
* \see mln::labeling::level
*/
- template <typename I, typename N>
+ template <typename I, typename W>
mln_ch_value(I, unsigned)
- foreground(const Image<I>& input, const Neighborhood<N>& nbh,
+ foreground(const Image<I>& input, const Window<W>& win,
unsigned& nlabels);
# ifndef MLN_INCLUDE_ONLY
- template <typename I, typename N>
+ template <typename I, typename W>
inline
mln_ch_value(I, unsigned)
- foreground(const Image<I>& input, const Neighborhood<N>& nbh,
+ foreground(const Image<I>& input, const Window<W>& win,
unsigned& nlabels)
{
trace::entering("labeling::foreground");
@@ -83,7 +81,7 @@
mln_precondition(exact(input).has_data());
mln_ch_value(I, unsigned) output =
- labeling::level(input, true, nbh, nlabels);
+ labeling::level(input, true, win, nlabels);
trace::exiting("labeling::foreground");
return output;
Index: mln/labeling/regional_minima.hh
--- mln/labeling/regional_minima.hh (revision 1697)
+++ mln/labeling/regional_minima.hh (working copy)
@@ -35,7 +35,7 @@
*/
# include <mln/core/concept/image.hh>
-# include <mln/core/concept/neighborhood.hh>
+# include <mln/core/concept/window.hh>
# include <mln/canvas/labeling.hh>
# include <mln/level/fill.hh>
# include <mln/level/sort_points.hh>
@@ -47,23 +47,21 @@
namespace labeling
{
- /* FIXME: The neighborhood shall not be passed as argument, but
- bound to the input image. We can also optionnaly provide a
- version of this function for regular-grid-based images where
- the neighborhood is replaced by a (user-provided) window. */
+ // FIXME: Provide a neighborhood-aware version of these
+ // algorithms.
/*! Connected component labeling of the regional minima of an
* image.
*
* \param[in] input The input image.
- * \param[in] nbh The neighborhood to consider.
+ * \param[in] win The connexity of the minima.
* \param[out] nlabels The number of labeled regions.
* \return The label image.
*
*/
- template <typename I, typename N, typename L>
+ template <typename I, typename W, typename L>
mln_ch_value(I, L)
- regional_minima(const Image<I>& input, const Neighborhood<N>& nbh,
+ regional_minima(const Image<I>& input, const Window<W>& win,
L& nlabels);
@@ -74,7 +72,7 @@
// Generic functor.
- template <typename I_, typename N_, typename L_>
+ template <typename I_, typename W_, typename L_>
struct regional_minima_functor
{
typedef mln_psite(I_) P;
@@ -82,12 +80,12 @@
// requirements from mln::canvas::labeling:
typedef I_ I;
- typedef N_ N;
+ typedef W_ W;
typedef L_ L;
typedef p_array<P> S;
const I& input;
- const N& nbh;
+ const W& win;
S s;
void init() { level::fill(attr,
true); }
@@ -106,9 +104,9 @@
mln_ch_value(I, bool) attr;
- regional_minima_functor(const I_& input, const N_& nbh)
+ regional_minima_functor(const I_& input, const W_& win)
: input(input),
- nbh(nbh),
+ win(win),
s(level::sort_points_increasing(input)), // FIXME:
//
sort_psites_increasing
attr(input.domain())
@@ -122,15 +120,15 @@
namespace generic
{
- template <typename I, typename N, typename L>
+ template <typename I, typename W, typename L>
mln_ch_value(I, L)
- regional_minima_(const I& input, const N& nbh,
+ regional_minima_(const I& input, const W& win,
L& nlabels)
{
trace::entering("labeling::impl::generic::regional_minima_");
- typedef impl::regional_minima_functor<I,N,L> F;
- F f(input, nbh);
+ typedef impl::regional_minima_functor<I,W,L> F;
+ F f(input, win);
canvas::labeling<F> run(f);
nlabels = run.nlabels;
@@ -147,19 +145,19 @@
// Facade.
- template <typename I, typename N, typename L>
+ template <typename I, typename W, typename L>
mln_ch_value(I, L)
- regional_minima(const Image<I>& input_, const Neighborhood<N>&
nbh_,
+ regional_minima(const Image<I>& input_, const Window<W>& win_,
L& nlabels)
{
trace::entering("labeling::regional_minima");
const I& input = exact(input_);
- const N& nbh = exact(nbh_);
+ const W& win = exact(win_);
mln_precondition(input.has_data());
// Calls the only (generic) impl.
mln_ch_value(I, L) output =
- impl::generic::regional_minima_(input, nbh, nlabels);
+ impl::generic::regional_minima_(input, win, nlabels);
trace::exiting("labeling::regional_minima");
return output;
Index: mln/labeling/regional_maxima.hh
--- mln/labeling/regional_maxima.hh (revision 1697)
+++ mln/labeling/regional_maxima.hh (working copy)
@@ -35,7 +35,7 @@
*/
# include <mln/core/concept/image.hh>
-# include <mln/core/concept/neighborhood.hh>
+# include <mln/core/concept/window.hh>
# include <mln/canvas/labeling.hh>
# include <mln/level/fill.hh>
# include <mln/level/sort_points.hh>
@@ -47,23 +47,21 @@
namespace labeling
{
- /* FIXME: The neighborhood shall not be passed as argument, but
- bound to the input image. We can also optionnaly provide a
- version of this function for regular-grid-based images where
- the neighborhood is replaced by a (user-provided) window. */
+ // FIXME: Provide a neighborhood-aware version of these
+ // algorithms.
/*! Connected component labeling of the regional maxima of an
* image.
*
* \param[in] input The input image.
- * \param[in] nbh The neighborhood to consider.
+ * \param[in] nbh The connexity of the maxima.
* \param[out] nlabels The number of labeled regions.
* \return The label image.
*
*/
- template <typename I, typename N, typename L>
+ template <typename I, typename W, typename L>
mln_ch_value(I, L)
- regional_maxima(const Image<I>& input, const Neighborhood<N>&
nbh,
+ regional_maxima(const Image<I>& input, const Window<W>& win,
L& nlabels);
@@ -75,7 +73,7 @@
// Generic functor.
- template <typename I_, typename N_, typename L_>
+ template <typename I_, typename W_, typename L_>
struct regional_maxima_functor
{
typedef mln_psite(I_) P;
@@ -83,12 +81,12 @@
// requirements from mln::canvas::labeling:
typedef I_ I;
- typedef N_ N;
+ typedef W_ W;
typedef L_ L;
typedef p_array<P> S;
const I& input;
- const N& nbh;
+ const W& win;
S s;
void init() { level::fill(attr,
true); }
@@ -107,9 +105,9 @@
mln_ch_value(I, bool) attr;
- regional_maxima_functor(const I_& input, const N_& nbh)
+ regional_maxima_functor(const I_& input, const W_& win)
: input(input),
- nbh(nbh),
+ win(win),
s(level::sort_points_decreasing(input)), // FIXME:
//
sort_psites_decreasing
attr(input.domain())
@@ -123,15 +121,15 @@
namespace generic
{
- template <typename I, typename N, typename L>
+ template <typename I, typename W, typename L>
mln_ch_value(I, L)
- regional_maxima_(const I& input, const N& nbh,
+ regional_maxima_(const I& input, const W& win,
L& nlabels)
{
trace::entering("labeling::impl::generic::regional_maxima_");
- typedef impl::regional_maxima_functor<I,N,L> F;
- F f(input, nbh);
+ typedef impl::regional_maxima_functor<I,W,L> F;
+ F f(input, win);
canvas::labeling<F> run(f);
nlabels = run.nlabels;
@@ -148,19 +146,19 @@
// Facade.
- template <typename I, typename N, typename L>
+ template <typename I, typename W, typename L>
mln_ch_value(I, L)
- regional_maxima(const Image<I>& input_, const Neighborhood<N>&
nbh_,
+ regional_maxima(const Image<I>& input_, const Window<W>& win_,
L& nlabels)
{
trace::entering("labeling::regional_maxima");
const I& input = exact(input_);
- const N& nbh = exact(nbh_);
+ const W& win = exact(win_);
mln_precondition(input.has_data());
// Calls the only (generic) impl.
mln_ch_value(I, L) output =
- impl::generic::regional_maxima_(input, nbh, nlabels);
+ impl::generic::regional_maxima_(input, win, nlabels);
trace::exiting("labeling::regional_maxima");
return output;
Index: mln/labeling/level.spe.hh
--- mln/labeling/level.spe.hh (revision 1697)
+++ mln/labeling/level.spe.hh (working copy)
@@ -59,14 +59,14 @@
*
* \param[in] input The input image.
* \param[in] val The level to consider for the labeling.
- * \param[in] nbh The neighborhood.
+ * \param[in] win The connexity of the components.
* \param[out] nlabels The number of labels.
* \return The label image.
*/
- template <typename I, typename N, typename L>
+ template <typename I, typename W, typename L>
mln_ch_value(I, L)
level(const Image<I>& input, const mln_value(I)& val,
- const Neighborhood<N>& nbh, L& nlabels);
+ const Window<W>& win, L& nlabels);
# ifndef MLN_INCLUDE_ONLY
@@ -79,9 +79,9 @@
namespace generic
{
- template <typename I, typename N, typename L>
+ template <typename I, typename W, typename L>
mln_ch_value(I, L)
- level_(const I& input, const mln_value(I)& val, const N& nbh,
+ level_(const I& input, const mln_value(I)& val, const W& win,
L& nlabels);
} // end of namespace mln::labeling::impl::generic
@@ -90,18 +90,18 @@
// Fastest functor.
- template <typename I_, typename N_, typename L_>
+ template <typename I_, typename W_, typename L_>
struct level_fastest_functor
{
// requirements from mln::canvas::labeling:
typedef I_ I;
- typedef N_ N;
+ typedef W_ W;
typedef L_ L;
typedef mln_pset(I) S;
const I& input;
- const N& nbh;
+ const W& win;
const S& s;
bool handles(unsigned p) const { return input[p] == val; }
@@ -118,9 +118,9 @@
const mln_value(I_)& val;
level_fastest_functor(const I_& input, const mln_value(I_)& val,
- const N_& nbh)
+ const W_& win)
: input(input),
- nbh(nbh),
+ win(win),
s(input.domain()),
val(val)
{}
@@ -129,18 +129,18 @@
// Fastest routine.
- template <typename I, typename N, typename L>
+ template <typename I, typename W, typename L>
mln_ch_value(I, L)
- level_fastest_(const I& input, const mln_value(I)& val, const N& nbh,
+ level_fastest_(const I& input, const mln_value(I)& val, const W& win,
L& nlabels)
{
trace::entering("labeling::impl::level_fastest_");
- border::adjust(input, nbh.delta());
+ border::adjust(input, win.delta());
border::fill(input, value::other(val));
- typedef level_fastest_functor<I,N,L> F;
- F f(input, val, nbh);
+ typedef level_fastest_functor<I,W,L> F;
+ F f(input, val, win);
canvas::labeling_fastest<F> run(f);
nlabels = run.nlabels;
@@ -153,22 +153,22 @@
// Disjunction between "fastest" and "not fastest".
- template <typename I, typename N, typename L>
+ template <typename I, typename W, typename L>
mln_ch_value(I, L)
level_(trait::image::speed::any,
- const I& input, const mln_value(I)& val, const N& nbh,
+ const I& input, const mln_value(I)& val, const W& win,
L& nlabels)
{
- return generic::level_(input, val, nbh, nlabels);
+ return generic::level_(input, val, win, nlabels);
}
- template <typename I, typename N, typename L>
+ template <typename I, typename W, typename L>
mln_ch_value(I, L)
level_(trait::image::speed::fastest,
- const I& input, const mln_value(I)& val, const N& nbh,
+ const I& input, const mln_value(I)& val, const W& win,
L& nlabels)
{
- return level_fastest_(input, val, nbh, nlabels);
+ return level_fastest_(input, val, win, nlabels);
}
Index: mln/labeling/background.hh
--- mln/labeling/background.hh (revision 1697)
+++ mln/labeling/background.hh (working copy)
@@ -43,16 +43,14 @@
namespace labeling
{
- /* FIXME: The neighborhood shall not be passed as argument, but
- bound to the input image. We can also optionnaly provide a
- version of this function for regular-grid-based images where
- the neighborhood is replaced by a (user-provided) window. */
+ // FIXME: Provide a neighborhood-aware version of these
+ // algorithms.
/*! Connected component labeling of the background part in a
* binary image.
*
* \param[in] input The input image.
- * \param[in] nbh The neighborhood to consider.
+ * \param[in] win The connexity of the background.
* \param[out] nlabels The number of labels.
* \return The label image.
*
@@ -63,18 +61,18 @@
*
* \see mln::labeling::level
*/
- template <typename I, typename N>
+ template <typename I, typename W>
mln_ch_value(I, unsigned)
- background(const Image<I>& input, const Neighborhood<N>& nbh,
+ background(const Image<I>& input, const Window<W>& win,
unsigned& nlabels);
# ifndef MLN_INCLUDE_ONLY
- template <typename I, typename N>
+ template <typename I, typename W>
inline
mln_ch_value(I, unsigned)
- background(const Image<I>& input, const Neighborhood<N>& nbh,
+ background(const Image<I>& input, const Window<W>& win,
unsigned& nlabels)
{
trace::entering("labeling::background");
@@ -83,7 +81,7 @@
mln_precondition(exact(input).has_data());
mln_ch_value(I, unsigned) output =
- labeling::level(input, false, nbh, nlabels);
+ labeling::level(input, false, win, nlabels);
trace::exiting("labeling::background");
return output;
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
More tests on Meyer's WST.
* tests/morpho/meyer_wst_long.cc: New test.
* tests/morpho/Makefile.am (check_PROGRAMS): Add meyer_wst and
meyer_wst_long.
(meyer_wst_SOURCES)
(meyer_wst_long_SOURCES, meyer_wst_long_CXXFLAGS):
New.
Makefile.am | 21 ++++++++++++++++-----
meyer_wst.cc | 1 -
meyer_wst_long.cc | 29 +++++++++++++++++++++++------
3 files changed, 39 insertions(+), 12 deletions(-)
Index: tests/morpho/meyer_wst.cc
--- tests/morpho/meyer_wst.cc (revision 1696)
+++ tests/morpho/meyer_wst.cc (working copy)
@@ -55,7 +55,6 @@
io::pgm::load(input, MLN_IMG_DIR "/squares.pgm");
typedef int_u8 output_val;
-
unsigned nbasins;
// FIXME: Do we really need to use a neighborood to express a 4-c window?
image2d<int_u8> output =
Index: tests/morpho/meyer_wst_long.cc
--- tests/morpho/meyer_wst_long.cc (revision 1695)
+++ tests/morpho/meyer_wst_long.cc (working copy)
@@ -30,18 +30,26 @@
#include <iostream>
+#include <mln/core/image_if.hh>
#include <mln/core/image2d.hh>
#include <mln/core/window2d.hh>
#include <mln/core/neighb2d.hh>
#include <mln/convert/to_window.hh>
+#include <mln/level/stretch.hh>
#include <mln/value/int_u8.hh>
+#include <mln/value/int_u16.hh>
+#include <mln/morpho/closing_area.hh>
#include <mln/morpho/meyer_wst.hh>
+#include <mln/pw/cst.hh>
+#include <mln/pw/value.hh>
+
+#include <mln/display/color_pretty.hh>
#include <mln/io/pgm/load.hh>
-#include <mln/io/pgm/save.hh>
+#include <mln/io/ppm/save.hh>
#include "tests/data.hh"
@@ -50,16 +58,25 @@
{
using namespace mln;
using value::int_u8;
+ using value::int_u16;
image2d<int_u8> input;
- io::pgm::load(input, MLN_IMG_DIR "/squares.pgm");
+ io::pgm::load(input, MLN_IMG_DIR "/lena.pgm");
- typedef int_u8 output_val;
+ // Simplify the input image.
+ image2d<int_u8> work(input.domain());
+ morpho::closing_area(input, c4(), 200, work);
+ // Perform a Watershed Transform.
+ typedef int_u16 wst_val;
unsigned nbasins;
// FIXME: Do we really need to use a neighborood to express a 4-c window?
- image2d<int_u8> output =
- morpho::meyer_wst<output_val>(input, convert::to_window(c4()), nbasins);
+ image2d<wst_val> ws =
+ morpho::meyer_wst<wst_val>(work, convert::to_window(c4()), nbasins);
std::cout << "nbasins = " << nbasins << std::endl;
- io::pgm::save(output, "out.pgm");
+
+ // Save the image in color.
+ image2d<value::rgb8> input_plus_ws =
+ display::color_pretty(input | (pw::value(ws) != pw::cst(0)));
+ io::ppm::save(input_plus_ws, "out.ppm");
}
Index: tests/morpho/Makefile.am
--- tests/morpho/Makefile.am (revision 1696)
+++ tests/morpho/Makefile.am (working copy)
@@ -14,21 +14,32 @@
hit_or_miss \
laplacian \
level_components \
+ meyer_wst \
+ meyer_wst_long \
opening_area \
thinning
-closing_area_SOURCES = closing_area.cc
-contrast_SOURCES = contrast.cc
dilation_SOURCES = dilation.cc
-dilation_max_h_SOURCES = dilation_max_h.cc
erosion_SOURCES = erosion.cc
+
+dilation_max_h_SOURCES = dilation_max_h.cc
erosion_min_h_SOURCES = erosion_min_h.cc
+
+opening_area_SOURCES = opening_area.cc
+closing_area_SOURCES = closing_area.cc
+
+level_components_SOURCES = level_components.cc
extrema_components_SOURCES = extrema_components.cc
+
+contrast_SOURCES = contrast.cc
gradient_SOURCES = gradient.cc
hit_or_miss_SOURCES = hit_or_miss.cc
laplacian_SOURCES = laplacian.cc
-level_components_SOURCES = level_components.cc
-opening_area_SOURCES = opening_area.cc
thinning_SOURCES = thinning.cc
+meyer_wst_SOURCES = meyer_wst.cc
+# FIXME: We should isolate this test, as it takes a long time.
+meyer_wst_long_SOURCES = meyer_wst_long.cc
+meyer_wst_long_CXXFLAGS = -O3
+
TESTS = $(check_PROGRAMS)
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/milena
It's cool, because I'm doing two tasks in one time:
1. adding things to support my research work (at the moment, some
watershed/morphological experiments); and
2. reviewing the contents of mln/morpho/, which was one of my assignments
about two or three months ago. :-P
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Add an area closing filter.
* mln/morpho/closing_attribute.hh: New.
Dual of mln/morpho/opening_attribute.hh
* mln/morpho/closing_area.hh: New.
Dual of mln/morpho/opening_area.hh
* tests/morpho/closing_area.cc: New test.
* tests/morpho/Makefile.am (check_PROGRAMS): Add closing_area.
(closing_area_SOURCES): New.
mln/morpho/closing_area.hh | 77 +++++++++++++++++++++
mln/morpho/closing_attribute.hh | 146 ++++++++++++++++++++++++++++++++++++++++
tests/morpho/Makefile.am | 2
tests/morpho/closing_area.cc | 57 +++++++++++++++
4 files changed, 282 insertions(+)
Index: mln/morpho/closing_attribute.hh
--- mln/morpho/closing_attribute.hh (revision 0)
+++ mln/morpho/closing_attribute.hh (revision 0)
@@ -0,0 +1,146 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena 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 MLN_MORPHO_CLOSING_ATTRIBUTE_HH
+# define MLN_MORPHO_CLOSING_ATTRIBUTE_HH
+
+/*! \file mln/morpho/closing_attribute.hh
+ *
+ * \brief Morphological attribute closing.
+ */
+
+# include <mln/morpho/includes.hh>
+# include <mln/canvas/morpho/algebraic_union_find.hh>
+# include <mln/level/sort_points.hh>
+# include <mln/util/pix.hh>
+
+
+namespace mln
+{
+
+ namespace morpho
+ {
+
+ /* FIXME: The neighborhood shall not be passed as argument, but
+ bound to the input image. We can also optionnaly provide a
+ version of this function for regular-grid-based images where
+ the neighborhood is replaced by a (user-provided) window. */
+
+ /// Morphological attribute closing.
+ template <typename A,
+ typename I, typename N, typename O>
+ void closing_attribute(const Image<I>& input, const Neighborhood<N>& nbh,
+ mln_result(A) lambda, Image<O>& output);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace impl
+ {
+
+ template <typename A_,
+ typename I_, typename N_, typename O_>
+ struct closing_attribute_t
+ {
+ typedef mln_point(I_) P;
+
+ // requirements from mln::canvas::morpho::algebraic_union_find
+
+ typedef A_ A;
+ typedef I_ I;
+ typedef N_ N;
+ typedef O_ O;
+ typedef p_array<P> S;
+ typedef util::pix<I> pix_t;
+
+ const I& input;
+ const N& nbh;
+ mln_result(A) lambda;
+ O& output;
+
+ const S s;
+
+ inline
+ void init()
+ {
+ // FIXME: border::fill(input, mln_max(mln_value(I)));
+ }
+
+ inline
+ bool is_active(const A& attr) const
+ {
+ return attr.to_result() < lambda;
+ }
+
+ inline
+ void inactivate(A& attr)
+ {
+ attr.set_value(lambda);
+ }
+
+ // end of requirements
+
+ inline
+ closing_attribute_t(const I_& input, const N_& nbh,
+ mln_result(A) lambda, O_& output)
+ : input(input), nbh(nbh), lambda(lambda), output(output),
+ s(level::sort_points_increasing(input))
+ {
+ }
+
+ };
+
+ } // end of namespace mln::morpho::impl
+
+
+ template <typename A,
+ typename I, typename N, typename O>
+ inline
+ void closing_attribute(const Image<I>& input_,
+ const Neighborhood<N>& nbh_, mln_result(A) lambda,
+ Image<O>& output_)
+ {
+ const I& input = exact(input_);
+ const N& nbh = exact(nbh_);
+ O& output = exact(output_);
+ mln_precondition(output.domain() == input.domain());
+
+ typedef impl::closing_attribute_t<A,I,N,O> F;
+ F f(input, nbh, lambda, output);
+ canvas::morpho::algebraic_union_find<F> run(f);
+
+ mln_postcondition(output >= input);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::morpho
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MORPHO_CLOSING_ATTRIBUTE_HH
Index: mln/morpho/closing_area.hh
--- mln/morpho/closing_area.hh (revision 0)
+++ mln/morpho/closing_area.hh (revision 0)
@@ -0,0 +1,77 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena 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 MLN_MORPHO_CLOSING_AREA_HH
+# define MLN_MORPHO_CLOSING_AREA_HH
+
+/*! \file mln/morpho/closing_area.hh
+ *
+ * \brief Morphological area closing.
+ */
+
+# include <mln/morpho/closing_attribute.hh>
+# include <mln/accu/count.hh>
+
+
+namespace mln
+{
+
+ namespace morpho
+ {
+
+ /* FIXME: The neighborhood shall not be passed as argument, but
+ bound to the input image. We can also optionnaly provide a
+ version of this function for regular-grid-based images where
+ the neighborhood is replaced by a (user-provided) window. */
+
+ /// Morphological area closing.
+ template <typename I, typename N, typename O>
+ void closing_area(const Image<I>& input, const Neighborhood<N>& nbh,
+ std::size_t lambda, Image<O>& output);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I, typename N, typename O>
+ inline
+ void closing_area(const Image<I>& input, const Neighborhood<N>& nbh,
+ std::size_t lambda, Image<O>& output)
+ {
+ mln_precondition(exact(output).domain() == exact(input).domain());
+ typedef util::pix<I> pix_t;
+ // FIXME: Change sig of closing_attribute!
+ closing_attribute< accu::count_<pix_t> >(input, nbh, lambda, output);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::morpho
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MORPHO_CLOSING_AREA_HH
Index: tests/morpho/closing_area.cc
--- tests/morpho/closing_area.cc (revision 0)
+++ tests/morpho/closing_area.cc (revision 0)
@@ -0,0 +1,57 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena 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.
+
+/*! \file tests/morpho/closing_area.cc
+ *
+ * \brief Test on mln::morpho::closing_area.
+ */
+
+#include <mln/core/image2d.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/core/neighb2d.hh>
+
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+
+#include <mln/morpho/closing_area.hh>
+
+#include "tests/data.hh"
+
+
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+
+ image2d<int_u8> lena;
+ io::pgm::load(lena, MLN_IMG_DIR "/lena.pgm");
+ image2d<int_u8> out(lena.domain());
+
+ morpho::closing_area(lena, c4(), 510, out);
+ io::pgm::save(out, "out.pgm");
+}
Index: tests/morpho/Makefile.am
--- tests/morpho/Makefile.am (revision 1695)
+++ tests/morpho/Makefile.am (working copy)
@@ -3,6 +3,7 @@
include $(top_srcdir)/milena/tests/tests.mk
check_PROGRAMS = \
+ closing_area \
contrast \
dilation \
dilation_max_h \
@@ -16,6 +17,7 @@
opening_area \
thinning
+closing_area_SOURCES = closing_area.cc
contrast_SOURCES = contrast.cc
dilation_SOURCES = dilation.cc
dilation_max_h_SOURCES = dilation_max_h.cc
1
0