https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
Index: ChangeLog
from Alexandre Abraham <abraham(a)lrde.epita.fr>
Mixin working for op_less.
* abraham/tests/morpho/test_watershed_topo.cc: .
* abraham/tests/morpho/Makefile: .
* abraham/tests/value/mixin.cc: New.
* abraham/mln/core/image/thru.hh: .
* abraham/mln/value/mixin.hh: New.
* abraham/mln/value/op_less.hh: New.
* abraham/mln/value/shell.hh: .
mln/core/image/thru.hh | 4 -
mln/value/mixin.hh | 117 ++++++++++++++++++++++++++++++++++++
mln/value/op_less.hh | 46 ++++++++++++++
mln/value/shell.hh | 3
tests/morpho/Makefile | 2
tests/morpho/test_watershed_topo.cc | 46 ++++----------
tests/value/mixin.cc | 64 +++++++++++++++++++
7 files changed, 247 insertions(+), 35 deletions(-)
Index: abraham/tests/morpho/test_watershed_topo.cc
--- abraham/tests/morpho/test_watershed_topo.cc (revision 2926)
+++ abraham/tests/morpho/test_watershed_topo.cc (working copy)
@@ -13,49 +13,33 @@
#include <string>
#include <iostream>
-int print_and_exit (std::string s)
-{
- std::cerr << s << std::endl;
- return 1;
-}
-
-int main ()
+int main (int argc, const char * argv[])
{
using namespace mln;
using value::int_u8;
typedef image2d<int_u8> image2dint;
- image2dint input, mverif, wverif;
-
- // #define TEST
-
- // io::pgm::load(input, "./images/test_watershed.pgm");
- // io::pgm::load(input, "./images/little_test.pgm");
- io::pgm::load(input, "./images/test.pgm");
- // io::pgm::load(input, "../../img/dots.pgm");
- //io::pgm::load(input, "./images/+irm6.pgm");
-
- // io::pgm::load(input, "./images/lena_light.pgm");
- // io::pgm::load(mverif, "./images/result_m_watershed.pgm");
- // io::pgm::load(wverif, "./images/result_topo_watershed.pgm");
-
- morpho::topo_wst< image2d<int_u8>, neighb2d> n(input, c4());
+ if (argc < 2) {
+ std::cerr << "usage: " << argv[0] << " in.pgm [other_files.pgm]" << std::endl;
+ return 1;
+ }
- /*
- image2dint::fwd_piter it(input.domain());
- for_all(it)
+ for (int i = 1; i < argc; ++i)
{
- input(it) = input(it)/17;
- mverif(it) = mverif(it)/17;
- }
- */
- // io::tikz::save(input, "start.tex");
+ image2dint ima;
+ io::pgm::load(ima, argv[i]);
+
+ morpho::topo_wst< image2d<int_u8>, neighb2d> n(ima, c4());
n.go();
- io::pgm::save(n.pima, "out.pgm");
+ std::string name(argv[i]);
+ name.erase(name.length() - 4);
+
+ io::pgm::save(n.pima, name.append("_wsd.pgm"));
+ }
return 0;
}
Index: abraham/tests/morpho/Makefile
--- abraham/tests/morpho/Makefile (revision 2926)
+++ abraham/tests/morpho/Makefile (working copy)
@@ -2,7 +2,7 @@
OBJ=$(SRC:.cc=.o)
EXEC=$(SRC:.cc=)
CC=g++
-CXXFLAGS=-Wall -W -I ../../ -I ../../../../ -g
+CXXFLAGS=-Wall -W -I ../../ -I ../../../../ -O3 -DNDEBUG
all: $(EXEC)
Index: abraham/tests/value/mixin.cc
--- abraham/tests/value/mixin.cc (revision 0)
+++ abraham/tests/value/mixin.cc (revision 0)
@@ -0,0 +1,64 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// 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/value/mixin.hh
+ *
+ * \brief Mixin types.
+ */
+
+
+#include <mln/value/mixin.hh>
+#include <mln/value/rgb.hh>
+#include <mln/value/rgb8.hh>
+
+
+namespace mln
+{
+
+ namespace value
+ {
+ template <unsigned int n>
+ struct op_less< mln::value::rgb<n> >
+ {
+ bool operator()(const mln::value::rgb<n> &a, const mln::value::rgb<n> &b)
+ {
+ return a.red() < b.red();
+ }
+ };
+ }
+}
+
+int main ()
+{
+ mln::value::rgb8 r(12, 13, 14);
+ mln::value::rgb8 s(13, 14, 15);
+
+ std::cout
+ << ( *(mln::value::mixin<mln::value::rgb8, mln::value::op_less>*)(void*) &r <
+ *(mln::value::mixin<mln::value::rgb8, mln::value::op_less>*)(void*) &s )
+ << std::endl;
+}
Index: abraham/mln/core/image/thru.hh
--- abraham/mln/core/image/thru.hh (revision 2926)
+++ abraham/mln/core/image/thru.hh (working copy)
@@ -118,6 +118,8 @@
/// Mutable access is for reading and writing.
lvalue operator()(const mln_psite(I)& p);
+
+ F f;
};
# ifndef MLN_INCLUDE_ONLY
@@ -164,7 +166,7 @@
thru<F,I>::operator()(const mln_psite(I)& p) const
{
mln_precondition(this->data_->ima_.has(p));
- return F()( this->data_->ima_(p) );
+ return f( this->data_->ima_(p) );
}
template <typename F, typename I>
Index: abraham/mln/value/mixin.hh
--- abraham/mln/value/mixin.hh (revision 0)
+++ abraham/mln/value/mixin.hh (revision 0)
@@ -0,0 +1,117 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// 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_CORE_VALUE_MIXIN_HH
+# define MLN_CORE_VALUE_MIXIN_HH
+
+# include <mln/core/concept/function.hh>
+# include <mln/core/concept/image.hh>
+# include <mln/value/internal/value_like.hh>
+# include <mln/value/op_less.hh> // FIXME : include all modificators
+
+namespace mln
+{
+ namespace value
+ {
+ template <typename T, template <typename> class F>
+ struct mixin;
+ }
+
+ namespace trait
+ {
+
+ template <typename T, template <typename> class F>
+ struct value_< mln::value::mixin<T, F> >
+ : value_< T > // FIXME
+ {
+ };
+
+ } // end of namespace trait
+
+ namespace value
+ {
+
+ template <typename T, template <typename> class F>
+ struct mixin : T, Value < mixin<T, F> >, internal::value_like_ <T, mln_enc(T), mixin<T, F>, mixin<T, F> >
+ {
+ typedef T value;
+
+ // Ctor ?
+
+ // operator (T) ();
+
+ };
+ }
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace value
+ {
+
+ template <typename T>
+ struct mixin <T, op_less> : T, Value < mixin<T, op_less> >, internal::value_like_ <T, mln_enc(T), mixin<T, op_less>, mixin<T, op_less> >
+ {
+ typedef mixin<T, op_less> exact;
+
+ bool operator< (const exact &rhs)
+ {
+ static op_less<T> l;
+ return l((T)*this, (T)rhs);
+ }
+ };
+
+ // Ctor
+
+ // template <typename T, template <typename> class F>
+ // mixin<T, F>::operator(T)()
+ // {
+ // return (T)*this;
+ // }
+
+ }
+
+/*
+ template <typename F, typename I>
+ std::ostream& operator<<(std::ostream& ostr, value::shell<F, I> &s)
+ {
+ ostr << (typename value::shell<F, I>::value) s;
+ return ostr;
+ }
+
+ template <typename F, typename I>
+ std::istream& operator>>(std::istream& istr, value::shell<F, I> &s)
+ {
+ (typename value::shell<F, I>::value) s >> istr;
+ return istr;
+ }
+*/
+
+# endif // MLN_INCLUDE_ONLY
+
+}; // end of namespace mln
+
+#endif // MLN_CORE_VALUE_MIXIN_HH
Index: abraham/mln/value/op_less.hh
--- abraham/mln/value/op_less.hh (revision 0)
+++ abraham/mln/value/op_less.hh (revision 0)
@@ -0,0 +1,46 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// 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_CORE_VALUE_OP_LESS_HH
+# define MLN_CORE_VALUE_OP_LESS_HH
+
+namespace mln
+{
+
+ namespace value
+ {
+
+ template <typename T>
+ struct op_less
+ {
+ // Should have an operator() (T& lhs, T& rhs)
+ };
+
+ } // end of namespace value
+} // end of namespace mln
+
+#endif // ! MLN_CORE_VALUE_OP_LESS_HH
Index: abraham/mln/value/shell.hh
--- abraham/mln/value/shell.hh (revision 2926)
+++ abraham/mln/value/shell.hh (working copy)
@@ -48,8 +48,7 @@
template <typename F, typename I>
struct value_< mln::value::shell<F, I> >
- :
- value_< mln_result(F) >
+ : value_< mln_result(F) >
{
};
#174: Merge back branch cleanup-2008 into the trunk
------------------------+---------------------------------------------------
Reporter: levill_r | Owner: levill_r
Type: task | Status: new
Priority: major | Milestone: Olena 1.0
Component: Milena | Version: 1.0
Keywords: repository |
------------------------+---------------------------------------------------
As of r2335 (2009-09-17), source:trunk/ has been entirely merged into
source:branches/cleanup-2008/, and everybody is using the cleanup-2008
branch. So, there is not point in maintaining two branches. Moreover, as
more and more Olena Team members are using Git, we should avoid using
Subversion branches (e.g., on the SVN ''server''), and use Git's instead.
The plan is as follow :
1. Warn contributors about the forthcoming merge, to
* '''prevent them from committing to Olena''' until further notice;
* have them switch (all of their) Subbversion working copies (or Git
repositories) to source:trunk/.
1. Overwrite the content of source:trunk/ with the latest revision of
source:branch/cleanup-2008/ (probably using `svn rm` then `svn cp`).
Don't try to reintegrate patches one by one, since there have been many
merges from trunk to cleanup-2008, and we'll probably end up with a very
complicated set of conflicting merges. Remember we're not ''really''
merging back cleanup-2008 to trunk, as the merge(s) ''already occurred'',
and cleanup-2008 already contains what trunk has (see
source:branches/README.branches). We're merely replacing the current
trunk with the content of cleanup-2008.
1. Notify contributors they can work from the trunk again.
1. Update source:branches/README.branches, but don't close (remove) the
branch source:branch/cleanup-2008/, as it might disturb Git repositories
aware of this branch. Simply set its status as 'CLOSED'.
I (Roland) should be the one performing this task.
--
Ticket URL: <https://trac.lrde.org/olena/ticket/174>
Olena <http://olena.lrde.epita.fr>
Olena, a generic and efficient C++ image processing library.
URL: https://svn.lrde.epita.fr/svn/oln/branches
Index: README.branches
===================================================================
--- README.branches (revision 2921)
+++ README.branches (revision 2922)
@@ -2,7 +2,7 @@
* cleanup-2008
-** Status: OPEN
+** Status: CLOSED
** Object: Cleanup of Olena 1.0
Should be merged back, then closed, as soon as all cleanup changes
have been applied.
@@ -14,6 +14,8 @@
on 2008-09-05 by Guillaume Lazzara.
- Sync'd (merge) trunk (r2189:2315) into cleanup-2008 by (the set of)
revisions 2316..2335 on 2008-09-17 by Roland Levillain.
+- Merge back cleanup-2008 (r2335:2920) into trunk by revision 2921 by
+ Roland Levillain, and ``close'' branch (although not deleted).
rev. branches
@@ -45,15 +47,19 @@
| | .
2335 | `o
| |
- ... | |
+ | .
+ ... | .
+ | .
| |
- v |
- trunk |
- |
- v
- branches/cleanup-2008
+2920 | .o close branches/cleanup-2008
+ | /
+2921 o' merge branches/cleanup-2008 (r2335:2920) -> trunk
+ |
+ ... |
+ |
+ v
+ trunk
-
* olena-ng
** Status: OPEN
** Object: Olena NG (Next Generation), based on the SCOOP 2 paradigm
* doc/examples/mk_graph.cc: new example.
---
milena/ChangeLog | 6 +++
milena/doc/examples/mk_graph.cc | 93 +++++++++++++++++++++++++++++++++++++++
2 files changed, 99 insertions(+), 0 deletions(-)
create mode 100644 milena/doc/examples/mk_graph.cc
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 9275628..9ca0020 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,11 @@
2008-11-19 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Add an example using make::graph.
+
+ * doc/examples/mk_graph.cc: new example.
+
+2008-11-19 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Revamp labeling::compute.
* mln/labeling/compute.hh: Add compute_dispatch and compute_tests.
diff --git a/milena/doc/examples/mk_graph.cc b/milena/doc/examples/mk_graph.cc
new file mode 100644
index 0000000..18b7a86
--- /dev/null
+++ b/milena/doc/examples/mk_graph.cc
@@ -0,0 +1,93 @@
+// Copyright (C) 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 doc/examples/mk_graph.cc
+///
+/// This example shows how to create a graph from an influence zone image
+
+# include <mln/essential/2d.hh>
+
+# include <mln/core/site_set/p_vertices.hh>
+# include <mln/core/site_set/p_edges.hh>
+
+# include <mln/debug/colorize.hh>
+# include <mln/debug/draw_graph.hh>
+
+# include <mln/make/graph.hh>
+
+# include <mln/transform/influence_zone_geodesic.hh>
+
+# include <mln/util/graph.hh>
+
+
+int main(int argc, char *argv[])
+{
+ using namespace mln;
+ using value::int_u8;
+
+ if (argc < 2)
+ {
+ std::cout << "Usage: " << argv[0] << " <image.pbm>" << std::endl;
+ return 1;
+ }
+
+ image2d<bool> ima = io::pbm::load(argv[1]);
+ logical::not_inplace(ima);
+
+ // Create a label image and compute the influence zones.
+ int_u8 nlabels;
+ image2d<int_u8> lbl = labeling::blobs(ima, c8(), nlabels);
+ io::ppm::save(debug::colorize< image2d<value::rgb8> >(lbl, nlabels),
+ "1_blobs.ppm");
+ image2d<int_u8> iz = transform::influence_zone_geodesic(lbl,
+ c8(),
+ lbl.ncols());
+ io::ppm::save(debug::colorize< image2d<value::rgb8> >(iz, nlabels),
+ "2_influence_zone_geodesic.ppm");
+
+ /// Make a graph from the influence zone image.
+ util::graph g = make::graph(iz, nlabels);
+
+ // Use the center of each bbox component as vertex in the graph.
+ typedef fun::i2v::array<point2d> i2v_t;
+ util::array<point2d> centers = labeling::compute(accu::center<point2d>(), iz, nlabels);
+ i2v_t f = convert::to<i2v_t>(centers);
+ p_vertices<util::graph, i2v_t> pv(g, f);
+
+ // Find lines (sites) associated to edges.
+ typedef fun::i2v::array<p_line2d> i2e_t;
+ util::array<p_line2d> lines;
+ mln_edge_iter_(util::graph) e(g);
+ for_all(e)
+ lines.append(p_line2d(f(e.v1()), f(e.v2())));
+ p_edges<util::graph, i2e_t> pe(g, convert::to<i2e_t>(lines));
+
+ // Draw graph.
+ image2d<value::rgb8> out(ima.domain());
+ debug::draw_graph(out, pv, literal::red, literal::green);
+ io::ppm::save(out, "3_graph.ppm");
+}
--
1.5.6.5