URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
Area_on_vertices was the last file using old code, so we can now
delete old implementation.
ChangeLog:
2009-03-01 Edwin Carlinet <carlinet(a)lrde.epita.fr>
Make area_on_vertices work with new algebraic code [POST-RUSH].
* mln/morpho/attribute/count_adjacent_vertices.hh,
* mln/morpho/closing/area_on_vertices.hh,
* mln/morpho/opening/area_on_vertices.hh:
Make area_on_vertices work with new algebraic code, and
adapt count_adjacent_vertices accumulator as a morpho attribute.
* mln/morpho/closing_area_on_vertices.hh,
* mln/morpho/closing_attribute.hh,
* mln/morpho/opening_area_on_vertices.hh,
* mln/morpho/opening_attribute.hh:
Delete old implementations.
* tests/morpho/artificial_line_graph_image_wst.cc,
* tests/morpho/lena_line_graph_image_wst2.cc:
Update test files using area_on_vertices.
---
mln/morpho/attribute/count_adjacent_vertices.hh | 197 ++++++++++++++++++++++++
mln/morpho/closing/area_on_vertices.hh | 91 +++++++++++
mln/morpho/opening/area_on_vertices.hh | 91 +++++++++++
tests/morpho/artificial_line_graph_image_wst.cc | 2
tests/morpho/lena_line_graph_image_wst2.cc | 4
5 files changed, 382 insertions(+), 3 deletions(-)
Index: trunk/milena/tests/morpho/artificial_line_graph_image_wst.cc
===================================================================
--- trunk/milena/tests/morpho/artificial_line_graph_image_wst.cc (revision 3450)
+++ trunk/milena/tests/morpho/artificial_line_graph_image_wst.cc (revision 3451)
@@ -62,7 +62,7 @@
#include <mln/util/graph.hh>
#include <mln/morpho/line_gradient.hh>
-#include <mln/morpho/closing_area_on_vertices.hh>
+#include <mln/morpho/closing/area_on_vertices.hh>
#include <mln/morpho/meyer_wst.hh>
#include <mln/level/stretch.hh>
Index: trunk/milena/tests/morpho/lena_line_graph_image_wst2.cc
===================================================================
--- trunk/milena/tests/morpho/lena_line_graph_image_wst2.cc (revision 3450)
+++ trunk/milena/tests/morpho/lena_line_graph_image_wst2.cc (revision 3451)
@@ -64,7 +64,7 @@
#include <mln/util/graph.hh>
#include <mln/morpho/line_gradient.hh>
-#include <mln/morpho/closing_area_on_vertices.hh>
+#include <mln/morpho/closing/area_on_vertices.hh>
#include <mln/morpho/meyer_wst.hh>
#include <mln/level/stretch.hh>
@@ -115,7 +115,7 @@
typedef line_graph_elt_neighborhood<util::graph, lg_ima_t::pset::fun_t> nbh_t;
nbh_t nbh;
- lg_ima_t closed_lg_ima = morpho::closing_area_on_vertices(lg_ima, nbh, 20);
+ lg_ima_t closed_lg_ima = morpho::closing::area_on_vertices(lg_ima, nbh, 20);
/*------.
| WST. |
Index: trunk/milena/mln/morpho/opening_area_on_vertices.hh (deleted)
===================================================================
Index: trunk/milena/mln/morpho/closing_attribute.hh (deleted)
===================================================================
Index: trunk/milena/mln/morpho/opening_attribute.hh (deleted)
===================================================================
Index: trunk/milena/mln/morpho/closing_area_on_vertices.hh (deleted)
===================================================================
Index: trunk/milena/mln/morpho/closing/area_on_vertices.hh
===================================================================
--- trunk/milena/mln/morpho/closing/area_on_vertices.hh (revision 0)
+++ trunk/milena/mln/morpho/closing/area_on_vertices.hh (revision 3451)
@@ -0,0 +1,91 @@
+// 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_ON_VERTICES_HH
+# define MLN_MORPHO_CLOSING_AREA_ON_VERTICES_HH
+
+/// \file mln/morpho/closing/area_on_vertices.hh
+///
+/// Morphological area closing on a line graph image computing
+/// the area in terms of adjacent vertices.
+
+# include <mln/pw/image.hh>
+# include <mln/core/site_set/p_edges.hh>
+# include <mln/morpho/closing/algebraic.hh>
+# include <mln/morpho/attribute/count_adjacent_vertices.hh>
+
+
+namespace mln
+{
+
+ namespace morpho
+ {
+
+ namespace closing
+ {
+
+ /// Morphological area closing on a mln::line_graph_image computing
+ /// the area in terms of adjacent vertices.
+ template <typename P2V, typename G, typename V2P, typename N>
+ pw::image<P2V, p_edges<G, V2P> >
+ area_on_vertices(const pw::image<P2V, p_edges<G, V2P> >& input,
+ const Neighborhood<N>& nbh,
+ unsigned lambda);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename P2V, typename G, typename V2P, typename N>
+ inline
+ pw::image<P2V, p_edges<G, V2P> >
+ area_on_vertices(const pw::image<P2V, p_edges<G, V2P> >& input,
+ const Neighborhood<N>& nbh,
+ unsigned lambda)
+ {
+ trace::entering("morpho::closing::area_on_vertices");
+ mln_precondition(exact(input).is_valid());
+
+ typedef p_edges<G, V2P> pe_t;
+ typedef attribute::count_adjacent_vertices< pw::image<P2V, pe_t> > attribute_t;
+
+ pw::image<P2V, p_edges<G, V2P> > output;
+ output = closing::algebraic(input, nbh, attribute_t(), lambda);
+
+ trace::exiting("morpho::closing::area_on_vertices");
+ return output;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+ } // end of namespace mln::morpho::closing
+
+ } // end of namespace mln::morpho
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MORPHO_CLOSING_AREA_ON_VERTICES_HH
Index: trunk/milena/mln/morpho/attribute/count_adjacent_vertices.hh
===================================================================
--- trunk/milena/mln/morpho/attribute/count_adjacent_vertices.hh (revision 0)
+++ trunk/milena/mln/morpho/attribute/count_adjacent_vertices.hh (revision 3451)
@@ -0,0 +1,197 @@
+// Copyright (C) 2007, 2008, 2009 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_ATTRIBUTE_COUNT_ADJACENT_VERTICES_HH_
+# define MLN_MORPHO_ATTRIBUTE_COUNT_ADJACENT_VERTICES_HH_
+
+/// \file mln/accu/count_adjacent_vertices.hh
+///
+/// Define an accumulator that counts the vertices adjacent to a
+/// set of p_edges psites.
+
+# include <mln/accu/internal/base.hh>
+# include <mln/pw/image.hh>
+# include <mln/util/pix.hh>
+
+namespace mln
+{
+
+ // Forward declaration.
+ namespace morpho {
+ namespace attribute {
+ template <typename I>
+ struct count_adjacent_vertices;
+ }
+ }
+
+
+ // Traits.
+
+ namespace trait
+ {
+
+ template <typename I>
+ struct accumulator_< morpho::attribute::count_adjacent_vertices<I> >
+ {
+ typedef accumulator::has_untake::no has_untake;
+ typedef accumulator::has_set_value::no has_set_value;
+ typedef accumulator::has_stop::no has_stop;
+ typedef accumulator::when_pix::use_p when_pix;
+ };
+
+ } // end of namespace mln::trait
+
+
+ namespace morpho
+ {
+
+ namespace attribute
+ {
+
+ /// Count_Adjacent_Vertices accumulator class.
+ ///
+ /// The parameter \p I is the image type on which the accumulator
+ /// of pixels is built.
+
+ template <typename F, typename S>
+ struct count_adjacent_vertices< pw::image<F, S> >
+ : public accu::internal::base< unsigned , count_adjacent_vertices< pw::image<F, S> > >
+ {
+ typedef pw::image<F, S> I;
+ typedef mln_psite(I) argument;
+
+ count_adjacent_vertices();
+
+ /// Manipulators.
+ /// \{
+ void init();
+
+ void take(const argument& px);
+ void take(const count_adjacent_vertices<I>& other);
+
+ void take_as_init(const argument& px);
+ /// \}
+
+ /// Get the value of the accumulator.
+ unsigned to_result() const;
+
+ /// Check whether this accu is able to return a result.
+ bool is_valid() const;
+
+
+ protected:
+ /// Update the value of the counter.
+ void update_ ();
+
+ /// The value of the counter.
+ unsigned count__;
+ /// The set of adjacent vertices.
+ std::set<unsigned> vertices_;
+ };
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename F, typename S>
+ inline
+ count_adjacent_vertices< pw::image<F, S> >::count_adjacent_vertices()
+ {
+ init();
+ }
+
+ template <typename F, typename S>
+ inline
+ void
+ count_adjacent_vertices< pw::image<F, S> >::init()
+ {
+ vertices_.clear();
+ update_();
+ }
+
+ template <typename F, typename S>
+ inline
+ void
+ count_adjacent_vertices< pw::image<F,S> >::take(const argument& p)
+ {
+ vertices_.insert(p.v1());
+ vertices_.insert(p.v2());
+ update_();
+ }
+
+ template <typename F, typename S>
+ inline
+ void
+ count_adjacent_vertices< pw::image<F,S> >::take(const count_adjacent_vertices< pw::image <F,S> >& other)
+ {
+ vertices_.insert (other.vertices_.begin(), other.vertices_.end());
+ update_();
+ }
+
+ template <typename F, typename S>
+ inline
+ void
+ count_adjacent_vertices< pw::image<F,S> >::take_as_init(const argument& px)
+ {
+ vertices_.clear();
+ take(px);
+ }
+
+ template <typename F, typename S>
+ inline
+ unsigned
+ count_adjacent_vertices< pw::image<F,S> >::to_result() const
+ {
+ return count__;
+ }
+
+ template <typename F, typename S>
+ inline
+ void
+ count_adjacent_vertices< pw::image<F,S> >::update_()
+ {
+ count__ = vertices_.size();
+ }
+
+ template <typename F, typename S>
+ inline
+ bool
+ count_adjacent_vertices< pw::image<F,S> >::is_valid() const
+ {
+ return true;
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::morpho::attribute
+
+ } // end of namespace mln::morpho
+
+} // end of namespace mln
+
+#endif /* !MLN_MORPHO_ATTRIBUTE_COUNT_ADJACENT_VERTICES_HH_ */
Index: trunk/milena/mln/morpho/opening/area_on_vertices.hh
===================================================================
--- trunk/milena/mln/morpho/opening/area_on_vertices.hh (revision 0)
+++ trunk/milena/mln/morpho/opening/area_on_vertices.hh (revision 3451)
@@ -0,0 +1,91 @@
+// 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_OPENING_AREA_ON_VERTICES_HH
+# define MLN_MORPHO_OPENING_AREA_ON_VERTICES_HH
+
+/// \file mln/morpho/opening/area_on_vertices.hh
+///
+/// Morphological area opening on a line graph image computing
+/// the area in terms of adjacent vertices.
+
+# include <mln/pw/image.hh>
+# include <mln/core/site_set/p_edges.hh>
+# include <mln/morpho/opening/algebraic.hh>
+# include <mln/morpho/attribute/count_adjacent_vertices.hh>
+
+
+namespace mln
+{
+
+ namespace morpho
+ {
+
+ namespace opening
+ {
+
+ /// Morphological area opening on a mln::line_graph_image computing
+ /// the area in terms of adjacent vertices.
+ template <typename P2V, typename G, typename V2P, typename N>
+ pw::image<P2V, p_edges<G, V2P> >
+ area_on_vertices(const pw::image<P2V, p_edges<G, V2P> >& input,
+ const Neighborhood<N>& nbh,
+ unsigned lambda);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename P2V, typename G, typename V2P, typename N>
+ inline
+ pw::image<P2V, p_edges<G, V2P> >
+ area_on_vertices(const pw::image<P2V, p_edges<G, V2P> >& input,
+ const Neighborhood<N>& nbh,
+ unsigned lambda)
+ {
+ trace::entering("morpho::opening::area_on_vertices");
+ mln_precondition(exact(input).is_valid());
+
+ typedef p_edges<G, V2P> pe_t;
+ typedef attribute::count_adjacent_vertices< pw::image<P2V, pe_t> > attribute_t;
+
+ pw::image<P2V, p_edges<G, V2P> > output;
+ output = opening::algebraic(input, nbh, attribute_t(), lambda);
+
+ trace::exiting("morpho::opening::area_on_vertices");
+ return output;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+ } // end of namespace mln::morpho::opening
+
+ } // end of namespace mln::morpho
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MORPHO_OPENING_AREA_ON_VERTICES_HH