https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Introduce the notion of literals.
Introduce literal zero.
* mln/core/concept/literal.hh: New.
* mln/literal: New directory.
* mln/literal/zero.hh: New.
* tests/literal_zero.cc: New.
* mln/accu/sum.hh: Update.
* mln/core/concept/object.hh: Include zero.
* mln/metal/vec.hh (vec): Split ctor.
(vec): Overload ctor for literal zero.
Minor update for traits.
* mln/trait/images.hh: Precise includes.
* mln/trait/ch_value.hh: Prefer fwd decl for vec.
* mln/trait/op_minus.hh,
* mln/trait/op_times.hh (set_binary_): Use category.
* mln/core/trait/op_minus.hh: Remove; obsolete.
* mln/core/trait/op_uminus.hh: Remove.
* mln/core/trait/all.hh: Update.
Misc.
* mln/core/dpoint1d.hh: Layout.
* mln/core/point.hh: Sort includes.
* mln/core/h_vec.hh (FIXME): New.
* mln/core/image2d_b.hh: Sort includes.
* mln/trace/exiting.hh,
* mln/trace/entering.hh: Fix missing include.
* tests/t_image.cc: Rename as...
* tests/t_image.cxx: ...this; deactivate.
* TODO: Update.
TODO | 54 ++++++++++++++++----------
mln/accu/sum.hh | 3 -
mln/core/concept/literal.hh | 91 ++++++++++++++++++++++++++++++++++++++++++++
mln/core/concept/object.hh | 3 -
mln/core/h_vec.hh | 3 -
mln/core/image2d_b.hh | 2
mln/core/point.hh | 4 -
mln/core/trait/all.hh | 5 --
mln/literal/zero.hh | 77 +++++++++++++++++++++++++++++++++++++
mln/metal/vec.hh | 18 +++++++-
mln/trace/entering.hh | 2
mln/trace/exiting.hh | 2
mln/trait/ch_value.hh | 7 ++-
mln/trait/images.hh | 6 ++
mln/trait/op_minus.hh | 5 --
mln/trait/op_times.hh | 5 --
tests/literal_zero.cc | 46 ++++++++++++++++++++++
17 files changed, 291 insertions(+), 42 deletions(-)
Index: tests/literal_zero.cc
--- tests/literal_zero.cc (revision 0)
+++ tests/literal_zero.cc (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.
+
+/*! \file tests/literal_zero.cc
+ *
+ * \brief Tests on mln::literal::zero.
+ */
+
+#include <mln/literal/zero.hh>
+// #include <mln/core/concept/object.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ unsigned char c;
+ c = literal::zero;
+
+ double d;
+ d = literal::zero;
+}
Index: TODO
--- TODO (revision 1235)
+++ TODO (working copy)
@@ -1,7 +1,8 @@
-*- outline -*-
-* URGENT
+
+* mathieu
** accu
@@ -17,46 +18,61 @@
tests ?
+* guillaume
+
+** chamfer
+
+Cf. vieilles versions
+algo avec front
+
+
+* simon
+
+** lines
+
+ajouter win::line<Mesh, dir>
+hline2d et vline2d deviennent des aliases
+retoucher les routines avec {h,v}line en argument
+
-* large changes
+* theo
-introduce grids
+hiérarchie de concepts sous Value
+maj trait solver
+virer is_fast -> changer le meta-plug
+virer core/trait
-* adds-on
-** abstractions
+* misc
-Function_i2i
-Weighted_Window
+** big change
-** types
+** add
+
+*** abstraction
+
+*** type
value::proxy to dispatch read/write + the corresponding image type
a mean_value object { sum; count } and operator+
-** extensions
+*** other
in Fast_Image: memcpy and memset-like methods (?)
.offset() into GenPixel
built-in op objects -> reverse lhs/rhs
+** rename
-* renaming
-
-
+value::cast(something) -> mln::cast_image or mln::fun::casted<F> etc.
-* clean-up
+** clean-up
select_function in fun::internal::selector_p2? etc.
-value::cast(something) -> mln::cast_image or mln::fun::casted<F> etc.
-
-* processing routines
+** processing routines
reconstructions + their canvases
-fast versions of level::fill and level::paste
sorting points w.r.t. their value (array of offsets, psites, points)
-arith::inplace_plus et al.
-linear:: for convolutions
Index: mln/trait/images.hh
--- mln/trait/images.hh (revision 1235)
+++ mln/trait/images.hh (working copy)
@@ -39,7 +39,11 @@
# include <string>
# include <mln/value/props.hh>
-# include <mln/metal/all.hh>
+
+# include <mln/metal/bexpr.hh>
+# include <mln/metal/equal.hh>
+# include <mln/metal/if.hh>
+# include <mln/metal/is_const.hh>
# define mln_trait_image_category(I) typename mln::trait::image_< I >::category
Index: mln/trait/ch_value.hh
--- mln/trait/ch_value.hh (revision 1235)
+++ mln/trait/ch_value.hh (working copy)
@@ -35,7 +35,6 @@
# include <mln/tag/skeleton.hh>
# include <mln/trait/image_from_mesh.hh>
-# include <mln/metal/vec.hh>
# define mln_ch_value(I, V) typename mln::trait::ch_value< I, V >::ret
@@ -45,6 +44,12 @@
namespace mln
{
+ // Fwd decl.
+ namespace metal { template <unsigned n, typename T> class vec; }
+
+
+
+
namespace trait
{
Index: mln/trait/op_minus.hh
--- mln/trait/op_minus.hh (revision 1235)
+++ mln/trait/op_minus.hh (working copy)
@@ -50,9 +50,8 @@
/// Default definition of op_minus is given by the promote trait.
- template <template <class> class Category_L, typename L,
- template <class> class Category_R, typename R>
- struct set_binary_< op_minus, Category_L, L, Category_R, R >
+ template <typename L, typename R>
+ struct set_binary_< op_minus, Object, L, Object, R >
:
public promote< L, R >
{
Index: mln/trait/op_times.hh
--- mln/trait/op_times.hh (revision 1235)
+++ mln/trait/op_times.hh (working copy)
@@ -50,9 +50,8 @@
/// Default definition of op_times is given by the promote trait.
- template <template <class> class Category_L, typename L,
- template <class> class Category_R, typename R>
- struct set_binary_< op_times, Category_L, L, Category_R, R >
+ template <typename L, typename R>
+ struct set_binary_< op_times, Object, L, Object, R >
:
public promote< L, R >
{
Index: mln/core/dpoint1d.hh
Index: mln/core/point.hh
--- mln/core/point.hh (revision 1235)
+++ mln/core/point.hh (working copy)
@@ -35,8 +35,8 @@
# include <mln/core/concept/point.hh>
# include <mln/core/internal/coord_impl.hh>
-# include <mln/core/h_vec.hh>
# include <mln/fun/i2v/all.hh>
+
# include <mln/metal/vec.hh>
# include <mln/core/h_vec.hh>
@@ -207,8 +207,6 @@
return coord_;
}
-
-
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln
Index: mln/core/h_vec.hh
--- mln/core/h_vec.hh (revision 1235)
+++ mln/core/h_vec.hh (working copy)
@@ -46,7 +46,7 @@
{
h_vec()
: metal::vec<dim + 1, T>(make::vec<dim + 1, T>(0))
- {
+ { // FIXME: Move in MLN_INCLUDE_ONLY
this->data_[dim] = 1;
}
@@ -55,6 +55,7 @@
operator metal::vec<dim, T>() const;
};
+
# ifndef MLN_INCLUDE_ONLY
template <unsigned dim, typename T>
Index: mln/core/image2d_b.hh
--- mln/core/image2d_b.hh (revision 1235)
+++ mln/core/image2d_b.hh (working copy)
@@ -33,8 +33,8 @@
* \brief Definition of the basic mln::image2d_b class.
*/
-# include <mln/core/internal/fixme.hh>
# include <mln/core/internal/image_primary.hh>
+# include <mln/core/internal/fixme.hh>
# include <mln/core/box2d.hh>
# include <mln/border/thickness.hh>
Index: mln/core/trait/all.hh
--- mln/core/trait/all.hh (revision 1235)
+++ mln/core/trait/all.hh (working copy)
@@ -46,11 +46,6 @@
# include <mln/core/trait/is_fast.hh>
# include <mln/core/trait/pixter.hh>
-# include <mln/core/trait/op_mult.hh>
-// FIXME # include <mln/core/trait/op_plus.hh>
-# include <mln/core/trait/op_minus.hh>
-# include <mln/core/trait/op_uminus.hh>
-// FIXME # include <mln/core/trait/promote.hh>
#endif // ! MLN_CORE_TRAIT_ALL_HH
Index: mln/core/concept/literal.hh
--- mln/core/concept/literal.hh (revision 0)
+++ mln/core/concept/literal.hh (revision 0)
@@ -0,0 +1,91 @@
+// 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_CONCEPT_LITERAL_HH
+# define MLN_CORE_CONCEPT_LITERAL_HH
+
+/*! \file mln/core/concept/literal.hh
+ * \brief Definition of the concept of mln::literal.
+ */
+
+# include <mln/core/concept/object.hh>
+
+
+namespace mln
+{
+
+ // Fwd decl.
+ template <typename E> struct Literal;
+
+ // Literal category flag type.
+ template <>
+ struct Literal<void>
+ {
+ typedef Object<void> super;
+ };
+
+
+ /*! \brief Base class for implementation classes of literals.
+ *
+ * \see mln::doc::Literal for a complete documentation of this class
+ * contents.
+ */
+ template <typename E>
+ struct Literal : public Object<E>
+ {
+ typedef Literal<void> category;
+
+ static const E& the();
+
+ protected:
+ Literal();
+ };
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename E>
+ Literal<E>::Literal()
+ {
+ }
+
+ template <typename E>
+ const E&
+ Literal<E>::the()
+ {
+ static E the_;
+ return the_;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_CONCEPT_LITERAL_HH
Index: mln/core/concept/object.hh
--- mln/core/concept/object.hh (revision 1235)
+++ mln/core/concept/object.hh (working copy)
@@ -42,6 +42,7 @@
# include <mln/core/internal/fixme.hh>
# include <mln/trace/all.hh>
# include <mln/metal/is_a.hh>
+# include <mln/metal/is.hh>
/*! \namespace mln
@@ -98,7 +99,7 @@
# include <mln/core/exact.hh>
-# include <mln/metal/all.hh>
+# include <mln/literal/zero.hh>
# include <mln/core/ops.hh> // FIXME: Read FIXME in mln/metal/binary_arith_trait.hh!
Index: mln/literal/zero.hh
--- mln/literal/zero.hh (revision 0)
+++ mln/literal/zero.hh (revision 0)
@@ -0,0 +1,77 @@
+// 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_LITERAL_ZERO_HH
+# define MLN_LITERAL_ZERO_HH
+
+/*! \file mln/literal/zero.hh
+ * \brief Definition of the literal of mln::zero.
+ *
+ * \todo Macro-ification of similar code (when no trivial conversion ops are involved).
+ */
+
+# include <mln/core/concept/literal.hh>
+# include <mln/metal/converts_to.hh>
+
+
+namespace mln
+{
+
+ namespace literal
+ {
+
+ /// Type of literal zero.
+ struct zero_t : public Literal<zero_t>
+ {
+ // FIXME: (for the record) Add "friend class Literal<zero_t>;" and a protected ctor.
+
+ template <typename T>
+ operator T () const;
+ };
+
+
+ /// Literal zero.
+ static zero_t zero = zero_t();
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename T>
+ zero_t::operator T () const
+ {
+ mlc_converts_to(int, T)::check();
+ return 0;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::literal
+
+} // end of namespace mln
+
+
+#endif // ! MLN_LITERAL_ZERO_HH
Index: mln/metal/vec.hh
--- mln/metal/vec.hh (revision 1235)
+++ mln/metal/vec.hh (working copy)
@@ -35,6 +35,7 @@
# include <mln/trait/all.hh>
# include <mln/value/props.hh>
# include <mln/fun/i2v/all.hh>
+# include <mln/literal/zero.hh>
// FIXME: Document.
@@ -132,9 +133,9 @@
typedef T value_type;
enum { dim = n };
- vec()
- {
- }
+ vec();
+
+ vec(mln::literal::zero_t);
vec(const vec<n, T>& rhs);
@@ -313,6 +314,17 @@
# ifndef MLN_INCLUDE_ONLY
template <unsigned n, typename T>
+ vec<n,T>::vec()
+ {
+ }
+
+ template <unsigned n, typename T>
+ vec<n,T>::vec(mln::literal::zero_t)
+ {
+ this->set_all( mln::literal::zero );
+ }
+
+ template <unsigned n, typename T>
vec<n,T>::vec(const vec<n,T>& rhs)
: super_()
{
Index: mln/accu/sum.hh
--- mln/accu/sum.hh (revision 1235)
+++ mln/accu/sum.hh (working copy)
@@ -36,6 +36,7 @@
# include <mln/core/concept/meta_accumulator.hh>
# include <mln/value/props.hh>
# include <mln/util/pix.hh>
+# include <mln/literal/zero.hh>
namespace mln
@@ -99,7 +100,7 @@
void
sum_<V,S>::init()
{
- s_ = S::zero; // FIXME
+ s_ = literal::zero;
}
template <typename V, typename S>
Index: mln/trace/exiting.hh
--- mln/trace/exiting.hh (revision 1235)
+++ mln/trace/exiting.hh (working copy)
@@ -34,6 +34,8 @@
*/
# include <string>
+# include <iostream>
+
# include <mln/trace/quiet.hh>
Index: mln/trace/entering.hh
--- mln/trace/entering.hh (revision 1235)
+++ mln/trace/entering.hh (working copy)
@@ -34,6 +34,8 @@
*/
# include <string>
+# include <iostream>
+
# include <mln/trace/quiet.hh>
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-10-03 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Add test for fast labeling.
* labeling_level_fast.cc: New test.
---
labeling_level_fast.cc | 63 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 63 insertions(+)
Index: trunk/milena/tests/labeling_level_fast.cc
===================================================================
--- trunk/milena/tests/labeling_level_fast.cc (revision 0)
+++ trunk/milena/tests/labeling_level_fast.cc (revision 1235)
@@ -0,0 +1,63 @@
+// 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/labeling_foreground.cc
+ *
+ * \brief Test on mln::labeling::foreground.
+ */
+
+#include <mln/core/image2d_b.hh>
+#include <mln/core/image1d_b.hh>
+#include <mln/core/neighb2d.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/pw/all.hh>
+
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+#include <mln/labeling/level.hh>
+#include <mln/debug/iota.hh>
+#include <mln/debug/println.hh>
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+
+ unsigned border = 1;
+
+ image2d_b<value::int_u8> i1(5, 5, border);
+ debug::iota(i1);
+ i1[10] = i1[17] = i1[18] = i1[25] = i1[26] = i1[22] = i1[29] = 2;
+ debug::println(i1);
+
+ unsigned n;
+ image2d_b<value::int_u8> out(i1.domain(), border);
+ labeling::level_fast(i1, 2, c4(), out, n);
+
+ std::cout << "n = " << n << std::endl;
+ debug::println(out);
+}
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-10-03 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Add test for voronoi algorithm.
* labeling_algo.cc: New.
---
labeling_algo.cc | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 82 insertions(+)
Index: trunk/milena/tests/labeling_algo.cc
===================================================================
--- trunk/milena/tests/labeling_algo.cc (revision 0)
+++ trunk/milena/tests/labeling_algo.cc (revision 1233)
@@ -0,0 +1,82 @@
+// 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/labeling_foreground.cc
+ *
+ * \brief Test on mln::labeling::foreground.
+ */
+
+# include <mln/core/image2d_b.hh>
+# include <mln/core/sub_image.hh>
+# include <mln/core/neighb2d.hh>
+# include <mln/value/int_u8.hh>
+# include <mln/level/fill.hh>
+# include <mln/level/stretch.hh>
+# include <mln/border/fill.hh>
+# include <mln/io/pbm/load.hh>
+# include <mln/io/pgm/save.hh>
+# include <mln/labeling/foreground.hh>
+# include <mln/debug/println.hh>
+# include <mln/draw/mesh.hh>
+# include <mln/geom/seeds2tiling.hh>
+# include <mln/make/voronoi.hh>
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+
+ image2d_b<bool> in = io::pbm::load("../img/toto.pbm");
+
+ image2d_b<int_u8> lab(in.domain());
+ image2d_b<int_u8> inte(in.domain());
+ image2d_b<int_u8> out(in.domain());
+
+ unsigned n;
+ labeling::foreground(in, c8(), lab, n);
+ std::cout << "number of labels = " << n << std::endl;
+ std::vector<int_u8> vec;
+
+ image2d_b<int> input(in.domain());
+ level::fill(input, lab);
+ lab(make::point2d (0,0)) = 0;
+
+ inte = geom::seeds2tiling(lab, c4 ());
+ border::fill (inte, 0);
+
+ image2d_b<int_u8> inte2(inte.domain());
+
+ level::stretch (inte, inte2);
+
+ io::pgm::save(inte2, "inte.pgm");
+
+ mesh_p<point2d> m = make::voronoi(inte, lab, c4());
+ std::cout << "OK : generate inte.pgm and out.pgm" << std::endl;
+ draw::mesh (out, m, 255, 128);
+
+ io::pgm::save(out, "out.pgm");
+}
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-10-03 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Add voronoi algorithm.
* voronoi.hh: New.
---
voronoi.hh | 129 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 129 insertions(+)
Index: trunk/milena/mln/make/voronoi.hh
===================================================================
--- trunk/milena/mln/make/voronoi.hh (revision 0)
+++ trunk/milena/mln/make/voronoi.hh (revision 1232)
@@ -0,0 +1,129 @@
+// 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_MAKE_VORONOI_HH
+# define MLN_MAKE_VORONOI_HH
+
+/*! \file mln/make/voronoi.hh
+ *
+ * \brief Routine to construct an mln::make::voronoi.
+ */
+
+# include <vector>
+# include <map>
+
+# include <mln/core/mesh_p.hh>
+# include <mln/accu/mean.hh>
+# include <mln/estim/min_max.hh>
+
+namespace mln
+{
+
+ namespace make
+ {
+
+ template <typename I, typename N>
+ mesh_p<mln_psite(I)>
+ voronoi (Image<I>& ima_,
+ Image<I>& orig_,
+ const Neighborhood<N>& nbh);
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I, typename N>
+ mesh_p<mln_psite(I)>
+ voronoi (Image<I>& ima_,
+ Image<I>& orig_,
+ const Neighborhood<N>& nbh)
+ {
+ typedef metal::vec<2,float> X;
+ typedef mln_value(I) V;
+ typedef mln_psite(I) P;
+
+ I& ima = exact(ima_);
+ I& orig = exact(orig_);
+ util::graph<void> gr;
+ V min, max;
+ estim::min_max (ima, min, max);
+ unsigned nb = max - min + 1;
+ std::vector<P> v(nb);
+ std::vector< accu::mean_< X > > tab_mean (nb);
+ std::map<std::pair<V, V>, bool> m;
+
+ /// Take original point.
+ {
+ mln_piter(I) p(orig.domain());
+
+ for_all(p)
+ {
+ if (orig(p) != 0)
+ {
+ X x = mln_point(I)(p);
+ tab_mean[orig(p) - min].take(x);
+ }
+ }
+ }
+
+ /// Compute links between link.
+ {
+ mln_piter(I) p(ima.domain());
+ mln_niter(N) n(nbh, p);
+
+ for_all(p)
+ {
+ for_all (n) if (ima.has(n))
+ if (ima(p) != ima(n))
+ m[std::pair<V, V>(ima(p) - min, ima(n) - min)] = true;
+ }
+ }
+
+ /// Compute the center of label.
+ for (unsigned i = 0; i < nb; ++i)
+ {
+ gr.add_node ();
+
+ /// FIXME
+ v[i] = make::point2d ((unsigned)tab_mean[i].to_result ()[0],
+ (unsigned)tab_mean[i].to_result ()[1]);
+ }
+
+ typename std::map<std::pair<V, V>, bool>::const_iterator it = m.begin ();
+ for (; it != m.end (); ++it)
+ gr.add_edge((*it).first.first, (*it).first.second);
+
+ mesh_p<P> res(gr, v);
+ return res;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::make
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MAKE_VORONOI_HH
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-10-03 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Add seeds2tiling.hh.
* seeds2tiling.hh: New.
---
seeds2tiling.hh | 126 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 126 insertions(+)
Index: trunk/milena/mln/geom/seeds2tiling.hh
===================================================================
--- trunk/milena/mln/geom/seeds2tiling.hh (revision 0)
+++ trunk/milena/mln/geom/seeds2tiling.hh (revision 1231)
@@ -0,0 +1,126 @@
+// 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_GEOM_SEEDS2TILING_HH
+# define MLN_GEOM_SEEDS2TILING_HH
+
+/*! \file mln/geom/seeds2tiling.hh
+ *
+ * \brief .
+ */
+
+# include <map>
+
+# include <mln/core/queue_p.hh>
+# include <mln/core/clone.hh>
+# include <mln/accu/mean.hh>
+# include <mln/estim/min_max.hh>
+# include <mln/metal/vec.hh>
+
+
+namespace mln
+{
+ namespace geom
+ {
+
+ template <typename I, typename N>
+ I seeds2tiling (Image<I>& ima_, const Neighborhood<N>& nbh);
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ template <typename I, typename N>
+ I
+ seeds2tiling (Image<I>& ima_,
+ const Neighborhood<N>& nbh)
+ {
+ I& ima = exact(ima_);
+ I out = clone(ima_);
+ queue_p<mln_psite(I)> q;
+
+ // Init.
+ {
+ mln_piter(I) p(ima.domain());
+ mln_niter(N) n(nbh, p);
+
+ for_all(p) if (ima(p) == 0)
+ for_all(n) if (ima(n) != 0)
+ {
+ q.push(p);
+ break;
+ }
+ }
+
+// // Body.
+// {
+// while (! q.empty())
+// {
+// mln_psite(I) p = q.front();
+// q.pop();
+// mln_invariant(ima(p) == 0);
+
+// mln_niter(N) n(nbh, p);
+// for_all(n) if (ima.has(n))
+// if (out(n) != 0)
+// out(p) = out(n);
+// else
+// if (! q.has(n))
+// q.push(n);
+// }
+// }
+
+ // Body: alternative version.
+ {
+ while (! q.empty())
+ {
+ mln_psite(I) p = q.front();
+ q.pop();
+ if (out(p) != 0) // p has already been processed so ignore
+ continue;
+
+ mln_niter(N) n(nbh, p);
+ for_all(n) if (ima.has(n))
+ if (out(n) != 0)
+ out(p) = out(n);
+ else
+ q.push_force(n); // n may already be in the queue,
+ // yet we then queue again this psite
+ }
+ }
+
+ return out;
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::geom
+
+} // end of namespace mln
+
+
+#endif // ! MLN_GEOM_SEEDS2TILING_HH
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-10-03 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Add color sub_image in sandbox.
* color_sub.cc: New.
Update
* labeling_algo.cc,
* labeling_level_fast.cc: Update.
---
color_sub.cc | 83 +++++++++++++++++++++++++++++++++++++++++++++++++
labeling_algo.cc | 2 -
labeling_level_fast.cc | 2 -
3 files changed, 85 insertions(+), 2 deletions(-)
Index: trunk/milena/sandbox/duhamel/labeling_algo.cc
===================================================================
--- trunk/milena/sandbox/duhamel/labeling_algo.cc (revision 1229)
+++ trunk/milena/sandbox/duhamel/labeling_algo.cc (revision 1230)
@@ -52,7 +52,7 @@
using value::int_u8;
// image2d_b<bool> in = io::pbm::load("../../img/toto.pbm");
- image2d_b<bool> in = io::pbm::load("../../img/toto.pbm");
+ image2d_b<bool> in = io::pbm::load("test.pbm");
image2d_b<int_u8> lab(in.domain());
image2d_b<int_u8> inte(in.domain());
Index: trunk/milena/sandbox/duhamel/color_sub.cc
===================================================================
--- trunk/milena/sandbox/duhamel/color_sub.cc (revision 0)
+++ trunk/milena/sandbox/duhamel/color_sub.cc (revision 1230)
@@ -0,0 +1,83 @@
+// 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/sub_image.cc
+ *
+ * \brief Tests on mln::sub_image.
+ */
+
+#include <mln/core/image2d_b.hh>
+#include <mln/core/sub_image.hh>
+#include <mln/core/inplace.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/value/rgb8.hh>
+#include <mln/level/fill.hh>
+#include <mln/debug/println.hh>
+
+#include <mln/core/image2d_b.hh>
+#include <mln/core/point2d.hh>
+#include <mln/debug/println.hh>
+#include <mln/util/graph.hh>
+#include <mln/io/ppm/save.hh>
+#include <mln/fun/p2b/chess.hh>
+
+#include <mln/core/image_if_value.hh>
+#include <mln/debug/iota.hh>
+
+namespace mln
+{
+ template <typename I, typename J>
+ void
+ color (Image<I>& ima_, Image<J>& out_)
+ {
+ I& ima = exact (ima_);
+ J& out = exact (out_);
+
+ level::fill (out, value::rgb8(255, 0, 0));
+
+ {
+ mln_piter(I) p (ima.domain ());
+ for_all (p)
+ {
+ out(p) = value::rgb8(ima(p));
+ }
+ }
+ }
+}
+
+int main()
+{
+ using namespace mln;
+
+ image2d_b<value::int_u8> ima(3,3);
+ debug::iota(ima);
+ image2d_b<value::rgb8> out(ima.domain ().bbox ());
+ std::cout << ima.domain() << std::endl;
+ color(inplace (ima | 6), out);
+ io::ppm::save(out, "out.ppm");
+ debug::println(out);
+}
Index: trunk/milena/sandbox/duhamel/labeling_level_fast.cc
===================================================================
--- trunk/milena/sandbox/duhamel/labeling_level_fast.cc (revision 1229)
+++ trunk/milena/sandbox/duhamel/labeling_level_fast.cc (revision 1230)
@@ -38,7 +38,7 @@
#include <mln/io/pgm/load.hh>
#include <mln/io/pgm/save.hh>
-#include "labeling_level.hh"
+#include <mln/labeling/level.hh>
#include <mln/debug/iota.hh>
#include <mln/debug/println_with_border.hh>