URL:
https://svn.lrde.epita.fr/svn/oln
Git branch: cleanup (HEAD: 9517158)
ChangeLog:
2008-09-05 Guillaume Lazzara <z(a)lrde.epita.fr>
Merge last changes from trunk to cleanup.
* milena/ChangeLog: .
* milena/mln/fun/x2x/rotation.hh: .
* milena/mln/fun/x2x/translation.hh: .
* milena/mln/metal/all.hh: .
* milena/mln/metal/array.hh: New.
* milena/mln/metal/array1d.hh: New.
* milena/mln/metal/array2d.hh: New.
* milena/mln/metal/array3d.hh: New.
* milena/sandbox/ChangeLog: .
* milena/sandbox/geraud/fllt/fllt.svg.7.hh: .
* milena/sandbox/jardonnet/array/Makefile: New.
* milena/sandbox/jardonnet/array/array.cc: .
* milena/sandbox/jardonnet/array/array.hh: .
* milena/sandbox/jardonnet/array/old/1d.hh: .
* milena/sandbox/jardonnet/registration/tools.hh: .
* milena/sandbox/jardonnet/test/icp.cc: .
* milena/sandbox/jardonnet/virtual/Makefile: New.
* milena/sandbox/jardonnet/virtual/access.cc: New.
* milena/sandbox/jardonnet/virtual/access.hh: New.
* milena/sandbox/nivault/plugin-gimp/autogen.sh: .
* milena/sandbox/nivault/plugin-gimp/configure.ac: .
* milena/sandbox/nivault/plugin-gimp/src/main.cc: .
---
ChangeLog | 26 ++
milena/ChangeLog | 18 ++
milena/mln/fun/x2x/rotation.hh | 2 +-
milena/mln/fun/x2x/translation.hh | 6 +-
milena/mln/metal/all.hh | 5 +
milena/mln/metal/array.hh | 117 +++++++++
milena/mln/metal/array1d.hh | 298 ++++++++++++++++++++++
milena/mln/metal/array2d.hh | 309 ++++++++++++++++++++++
milena/mln/metal/array3d.hh | 310 +++++++++++++++++++++++
milena/sandbox/ChangeLog | 41 +++
milena/sandbox/geraud/fllt/fllt.svg.7.hh | 96 ++++++-
milena/sandbox/jardonnet/array/Makefile | 2 +
milena/sandbox/jardonnet/array/array.cc | 12 +-
milena/sandbox/jardonnet/array/array.hh | 121 +++++++++-
milena/sandbox/jardonnet/array/old/1d.hh | 4 +-
milena/sandbox/jardonnet/registration/tools.hh | 54 +---
milena/sandbox/jardonnet/test/icp.cc | 1 +
milena/sandbox/jardonnet/virtual/Makefile | 2 +
milena/sandbox/jardonnet/virtual/access.cc | 36 +++
milena/sandbox/jardonnet/virtual/access.hh | 126 +++++++++
milena/sandbox/nivault/plugin-gimp/autogen.sh | 2 +-
milena/sandbox/nivault/plugin-gimp/configure.ac | 3 +-
milena/sandbox/nivault/plugin-gimp/src/main.cc | 2 +-
23 files changed, 1529 insertions(+), 64 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 335521e..c39c773 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,29 @@
+2008-09-05 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Merge last changes from trunk to cleanup.
+ * milena/ChangeLog: .
+ * milena/mln/fun/x2x/rotation.hh: .
+ * milena/mln/fun/x2x/translation.hh: .
+ * milena/mln/metal/all.hh: .
+ * milena/mln/metal/array.hh: New.
+ * milena/mln/metal/array1d.hh: New.
+ * milena/mln/metal/array2d.hh: New.
+ * milena/mln/metal/array3d.hh: New.
+ * milena/sandbox/ChangeLog: .
+ * milena/sandbox/geraud/fllt/fllt.svg.7.hh: .
+ * milena/sandbox/jardonnet/array/Makefile: New.
+ * milena/sandbox/jardonnet/array/array.cc: .
+ * milena/sandbox/jardonnet/array/array.hh: .
+ * milena/sandbox/jardonnet/array/old/1d.hh: .
+ * milena/sandbox/jardonnet/registration/tools.hh: .
+ * milena/sandbox/jardonnet/test/icp.cc: .
+ * milena/sandbox/jardonnet/virtual/Makefile: New.
+ * milena/sandbox/jardonnet/virtual/access.cc: New.
+ * milena/sandbox/jardonnet/virtual/access.hh: New.
+ * milena/sandbox/nivault/plugin-gimp/autogen.sh: .
+ * milena/sandbox/nivault/plugin-gimp/configure.ac: .
+ * milena/sandbox/nivault/plugin-gimp/src/main.cc: .
+
2008-09-05 Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Augment tutorial example for Z.
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 10983ef..479dea2 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,21 @@
+2008-09-05 Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
+
+ Minor fix : Translation Rotation.
+
+ * mln/fun/x2x/translation.hh,
+ * mln/fun/x2x/rotation.hh: Fix wrong namespaces.
+ * sandbox/jardonnet/virtual/access.hh: Fix concept check.
+
+2008-09-03 Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
+
+ Add metal::array (1d,2d,3d).
+
+ * mln/metal/all.hh: Update.
+ * mln/metal/array.hh: Generic.
+ * mln/metal/array1d.hh: Container 1d.
+ * mln/metal/array2d.hh: Container 2d.
+ * mln/metal/array3d.hh: Container 3d.
+
2008-09-04 Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add a tutorial example for Z.
diff --git a/milena/mln/fun/x2x/rotation.hh b/milena/mln/fun/x2x/rotation.hh
index 3fb3ef5..af1a0ca 100644
--- a/milena/mln/fun/x2x/rotation.hh
+++ b/milena/mln/fun/x2x/rotation.hh
@@ -53,7 +53,7 @@ namespace mln
*/
template <unsigned n, typename C>
struct rotation
- : internal::x2x_linear_impl_< algebra::vec<n,C>, rotation<n,C> >
+ : fun::internal::x2x_linear_impl_< algebra::vec<n,C>, rotation<n,C> >
, public Bijection_x2x< rotation<n,C> >
{
typedef fun::internal::x2x_linear_impl_< algebra::vec<n,C>, rotation<n,C>
> super_;
diff --git a/milena/mln/fun/x2x/translation.hh b/milena/mln/fun/x2x/translation.hh
index 86713bf..f2075e0 100644
--- a/milena/mln/fun/x2x/translation.hh
+++ b/milena/mln/fun/x2x/translation.hh
@@ -53,10 +53,8 @@ namespace mln
*/
template <unsigned n, typename C>
struct translation
-
- : internal::x2x_linear_impl_< algebra::vec<n,C>, translation<n,C> >
- ,
- public Bijection_x2x< translation<n,C> >
+ : fun::internal::x2x_linear_impl_< algebra::vec<n,C>, translation<n,C>
>
+ , public Bijection_x2x< translation<n,C> >
{
typedef fun::internal::x2x_linear_impl_< algebra::vec<n,C>,
translation<n,C> > super_;
diff --git a/milena/mln/metal/all.hh b/milena/mln/metal/all.hh
index 511083f..e006e45 100644
--- a/milena/mln/metal/all.hh
+++ b/milena/mln/metal/all.hh
@@ -80,6 +80,11 @@ namespace mln
# include <mln/metal/math/all.hh>
+# include <mln/metal/array.hh>
+# include <mln/metal/array1d.hh>
+# include <mln/metal/array2d.hh>
+# include <mln/metal/array3d.hh>
+
// FIXME: Remove the following includes below!
# include <mln/metal/same_coord.hh>
# include <mln/metal/same_point.hh>
diff --git a/milena/mln/metal/array.hh b/milena/mln/metal/array.hh
new file mode 100644
index 0000000..1e2bb60
--- /dev/null
+++ b/milena/mln/metal/array.hh
@@ -0,0 +1,117 @@
+// Copyright (C) 2008 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_METAL_ARRAY_HH
+# define MLN_METAL_ARRAY_HH
+
+# include <mln/metal/array1d.hh>
+# include <mln/metal/array2d.hh>
+# include <mln/metal/array3d.hh>
+
+namespace mln
+{
+
+ namespace metal
+ {
+
+ // a1
+
+ template<unsigned i, class T, unsigned n> inline
+ T get_at(const array1d<T, n>& arr)
+ {
+ return arr.template get_at_<i>();
+ }
+
+ template<unsigned i, class T, unsigned n> inline
+ T get(const array1d<T, n>& arr)
+ {
+ return arr.template get_<i>();
+ }
+
+ // a2
+
+ template<unsigned row, unsigned col, class T,
+ unsigned r, unsigned c> inline
+ T get_at(const array2d<T, r, c>& arr)
+ {
+ return arr.template get_at_<row, col>();
+ }
+
+ template<unsigned row, unsigned col, class T,
+ unsigned r, unsigned c> inline
+ T get(const array2d<T, r, c>& arr)
+ {
+ return arr.template get_<row, col>();
+ }
+
+ // a3
+
+ template<unsigned sli, unsigned row, unsigned col,
+ class T, unsigned s, unsigned r, unsigned c> inline
+ T get_at(const array3d<T, s, r, c>& arr)
+ {
+ return arr.template get_at_<sli, row, col>();
+ }
+
+ template<unsigned sli, unsigned row, unsigned col,
+ class T, unsigned s, unsigned r, unsigned c> inline
+ T get_(const array3d<T, s, r, c>& arr)
+ {
+ return arr.template get_<sli, row, col>();
+ }
+
+ // print
+
+ template<typename T, unsigned n>
+ std::ostream& operator<<(std::ostream& ostr, const array1d<T,
n>& rhs)
+ {
+ for (unsigned i = 0; i < n; ++i)
+ ostr << rhs[i] << " ";
+ ostr << std::endl;
+
+ return ostr;
+ }
+
+ template<typename T, unsigned r, unsigned c>
+ std::ostream& operator<<(std::ostream& ostr, const array2d<T, r,
c>& rhs)
+ {
+ for (unsigned i = 0; i < r; ++i)
+ {
+ for (unsigned j = 0; j < c; ++j)
+ ostr << rhs(i,j) << '\t';
+ ostr << '\n';
+ }
+ ostr << std::endl;
+
+ return ostr;
+ }
+
+ }
+
+}
+
+#endif /* MLN_METAL_ARRAY_HH */
diff --git a/milena/mln/metal/array1d.hh b/milena/mln/metal/array1d.hh
new file mode 100644
index 0000000..7f441d8
--- /dev/null
+++ b/milena/mln/metal/array1d.hh
@@ -0,0 +1,298 @@
+// Copyright (C) 2008 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_METAL_ARRAY1D_HH
+# define MLN_METAL_ARRAY1D_HH
+
+# include <mln/core/concept/object.hh>
+
+# include <mln/trait/all.hh>
+# include <mln/trait/value_.hh>
+
+# include <mln/value/ops.hh>
+
+namespace mln
+{
+
+ // Fwd decls.
+ namespace metal {
+ template <typename T, unsigned Size> struct array1d;
+ }
+
+ namespace trait
+ {
+
+ template <typename T, unsigned Size>
+ struct value_< mln::metal::array1d<T,Size> >
+ {
+ typedef trait::value::nature::vectorial nature;
+ typedef trait::value::kind::data kind;
+
+ enum {
+ nbits = Size * mln_nbits(T),
+ card = Size * mln_card(T)
+ };
+ typedef mln_value_quant_from_(card) quant;
+
+ typedef metal::array1d<mln_sum(T),Size> sum;
+ };
+
+ } // end of namespace mln::trait
+
+
+ namespace metal
+ {
+
+ template <typename T, unsigned Size>
+ struct array1d : public Object< array1d<T,Size> >
+ {
+
+ //
+ // Constructors
+ //
+
+ array1d();
+ array1d(T* ptr);
+
+ // Copy
+
+ array1d(const array1d<T, Size>& rhs);
+ array1d<T, Size>& operator=(const array1d<T, Size>& rhs);
+
+ // Operators
+
+ template <class U>
+ array1d<T, Size> operator*(U w);
+
+ template <class U>
+ array1d<mln_trait_op_div(T,U), Size>
+ operator/(U w);
+
+ template <typename U>
+ array1d<mln_trait_op_plus(T,U), Size>
+ operator+(const array1d<U, Size>& rhs) const;
+ array1d<T, Size>& operator+=(const array1d<T, Size>& rhs);
+
+ template <typename U>
+ array1d<mln_trait_op_minus(T,U), Size>
+ operator-(const array1d<U, Size>& rhs) const;
+ array1d<T, Size>&
+ operator-=(const array1d<T, Size>& rhs);
+
+
+ // dynamic accessors:
+
+ T operator[](unsigned i) const {
+ mln_precondition(i < Size);
+ return buffer_[i];
+ }
+ T& operator[](unsigned i) {
+ mln_precondition(i < Size);
+ return buffer_[i];
+ }
+
+ // static accessor
+
+ template<unsigned i>
+ T get() const {
+ return buffer_[i];
+ }
+ template<unsigned i>
+ T& get() {
+ return buffer_[i];
+ }
+
+ enum { length = Size };
+ protected:
+
+ T buffer_[Size];
+ };
+
+ }
+
+ namespace trait
+ {
+
+ // For unary traits.
+
+ template < template <class> class Name,
+ unsigned n, typename T >
+ struct set_precise_unary_< Name, metal::array1d<T, n> >
+ {
+ typedef mln_trait_unary(Name, T) V;
+ typedef metal::array1d<V, n> ret;
+ };
+
+ // For binary traits.
+
+ template < template <class, class> class Name,
+ unsigned n, typename T,
+ typename U >
+ struct set_precise_binary_< Name,
+ metal::array1d<T, n>, metal::array1d<U, n> >
+ {
+ typedef mln_trait_binary(Name, T, U) V;
+ typedef metal::array1d<V, n> ret;
+ };
+
+ template < unsigned n, typename T,
+ typename U >
+ struct set_precise_binary_< op::times,
+ metal::array1d<T, n>, metal::array1d<U, n> >
+ {
+ typedef mln_sum_x(T,U) ret;
+ };
+
+ template < template <class, class> class Name,
+ unsigned n, typename T,
+ typename S >
+ struct set_precise_binary_< Name,
+ metal::array1d<T, n>, mln::value::scalar_<S> >
+ {
+ typedef mln_trait_binary(Name, T, S) V;
+ typedef metal::array1d<V, n> ret;
+ };
+
+ template < template<class, class> class Name,
+ unsigned n, typename T,
+ typename S >
+ struct set_binary_< Name,
+ mln::Object, metal::array1d<T, n>,
+ mln::value::Scalar, S >
+ {
+ typedef mln_trait_binary(Name, T, S) V;
+ typedef metal::array1d<T, n> ret;
+ };
+
+ } // end of namespace mln::trait
+
+
+ namespace metal
+ {
+
+ //
+ // Constructors
+ //
+
+ template <typename T, unsigned Size>
+ array1d<T,Size>::array1d()
+ {
+ }
+
+ template <typename T, unsigned Size>
+ array1d<T,Size>::array1d(T* ptr)
+ {
+ for (unsigned i = 0; i < Size; ++i)
+ buffer_[i] = *ptr++;
+ }
+
+ // Copy
+
+ template <typename T, unsigned Size>
+ array1d<T,Size>::array1d(const array1d<T, Size>& rhs)
+ {
+ for (unsigned i = 0; i < Size; ++i)
+ buffer_[i] = rhs[i];
+ }
+ template <typename T, unsigned Size>
+ array1d<T, Size>&
+ array1d<T,Size>::operator=(const array1d<T, Size>& rhs)
+ {
+ for (unsigned i = 0; i < Size; ++i)
+ buffer_[i] = rhs[i];
+ return *this;
+ }
+
+ // Operators
+
+ template <typename T, unsigned Size>
+ template <class U>
+ array1d<T, Size>
+ array1d<T,Size>::operator*(U w)
+ {
+ //fixme mln_trait_op_mult<int,U>
+ array1d<T, Size> tmp;
+ for (unsigned i = 0; i < Size; ++i)
+ tmp[i] = this->buffer_[i] * w;
+ return tmp;
+ }
+
+ template <typename T, unsigned Size>
+ template <class U>
+ array1d<mln_trait_op_div(T,U), Size>
+ array1d<T,Size>::operator/(U w)
+ {
+ array1d<T, Size> tmp;
+ for (unsigned i = 0; i < Size; ++i)
+ tmp[i] = this->buffer_[i] / w;
+ return tmp;
+ }
+
+ template <typename T, unsigned Size>
+ template <typename U>
+ array1d<mln_trait_op_plus(T,U), Size>
+ array1d<T,Size>::operator+(const array1d<U, Size>& rhs) const
+ {
+ array1d<T, Size> tmp;
+ for (unsigned i = 0; i < Size; ++i)
+ tmp[i] = this->buffer_[i] + rhs.buffer_[i];
+ return tmp;
+ }
+ template <typename T, unsigned Size>
+ array1d<T, Size>&
+ array1d<T,Size>::operator+=(const array1d<T, Size>& rhs)
+ {
+ for (unsigned i = 0; i < Size; ++i)
+ this->buffer_[i] += rhs.buffer_[i];
+ return *this;
+ }
+
+ template <typename T, unsigned Size>
+ template <typename U>
+ array1d<mln_trait_op_minus(T,U), Size>
+ array1d<T,Size>::operator-(const array1d<U, Size>& rhs) const
+ {
+ array1d<T, Size> tmp;
+ for (unsigned i = 0; i < Size; ++i)
+ tmp[i] = this->buffer_[i] - rhs.buffer_[i];
+ return tmp;
+ }
+ template <typename T, unsigned Size>
+ array1d<T, Size>&
+ array1d<T,Size>::operator-=(const array1d<T, Size>& rhs)
+ {
+ for (unsigned i = 0; i < Size; ++i)
+ this->buffer_[i] -= rhs.buffer_[i];
+ return *this;
+ }
+
+ } // end of namespace metal
+
+} // end of namespace mln
+
+#endif /* MLN_METAL_ARRAY1D_HH */
+
diff --git a/milena/mln/metal/array2d.hh b/milena/mln/metal/array2d.hh
new file mode 100644
index 0000000..4f3992a
--- /dev/null
+++ b/milena/mln/metal/array2d.hh
@@ -0,0 +1,309 @@
+// Copyright (C) 2008 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_METAL_ARRAY2D_HH
+# define MLN_METAL_ARRAY2D_HH
+
+# include <mln/core/concept/object.hh>
+
+# include <mln/trait/all.hh>
+# include <mln/trait/value_.hh>
+
+# include <mln/value/ops.hh>
+
+namespace mln
+{
+
+ // Fwd decls.
+ namespace metal {
+ template <typename T, unsigned r, unsigned c> struct array2d;
+ }
+
+ namespace trait
+ {
+
+ template <typename T, unsigned r, unsigned c>
+ struct value_< mln::metal::array2d<T, r, c> >
+ {
+ typedef trait::value::nature::vectorial nature;
+ typedef trait::value::kind::data kind;
+
+ enum {
+ nbits = r * c * mln_nbits(T),
+ card = r * c * mln_card(T)
+ };
+ typedef mln_value_quant_from_(card) quant;
+
+ typedef metal::array2d<mln_sum(T),r, c> sum;
+ };
+
+ } // end of namespace mln::trait
+
+
+ namespace metal
+ {
+
+ template <typename T, unsigned r, unsigned c>
+ struct array2d : public Object< array2d<T, r, c> >
+ {
+
+ //
+ // Constructors
+ //
+
+ array2d();
+ array2d(T* ptr);
+
+ // Copy
+
+ array2d(const array2d<T, r, c>& rhs);
+
+ array2d<T, r, c>& operator=(const array2d<T, r, c>& rhs);
+
+ // Operators
+
+ template <class U>
+ array2d<T, r, c> operator*(U w);
+
+ template <class U>
+ array2d<mln_trait_op_div(T,U), r, c>
+ operator/(U w);
+
+ template <typename U>
+ array2d<mln_trait_op_plus(T,U), r, c>
+ operator+(const array2d<U, r, c>& rhs) const;
+ array2d<T, r, c>& operator+=(const array2d<T, r, c>& rhs);
+
+ template <typename U>
+ array2d<mln_trait_op_minus(T,U), r, c>
+ operator-(const array2d<U, r, c>& rhs)
const;
+ array2d<T, r, c>&
+ operator-=(const array2d<T, r, c>& rhs);
+
+ // dynamic accessors:
+
+ T operator()(unsigned row, unsigned col) const {
+ mln_precondition(row < r * c);
+ return buffer_[col * r + row];
+ }
+ T& operator()(unsigned row, unsigned col) {
+ mln_precondition(row < r * c);
+ return buffer_[col * r + row];
+ }
+
+ // static accessor
+
+ template<unsigned row, unsigned col>
+ T get() const {
+ return buffer_[col * r + row];
+ }
+ template<unsigned row, unsigned col>
+ T& get() {
+ return buffer_[col * r + row];
+ }
+
+ template<unsigned row, unsigned col>
+ T get_at() const {
+ mln_precondition(col * r + row < r *c);
+ return buffer_[col * r + row];
+ }
+ template<unsigned row, unsigned col>
+ T& get_at() {
+ mln_precondition(col * r + row < r *c);
+ return buffer_[col * r + row];
+ }
+
+ enum { length = r * c };
+ protected:
+
+ T buffer_[r * c];
+ };
+
+ }
+
+ namespace trait
+ {
+
+ // For unary traits.
+
+ template < template <class> class Name,
+ unsigned r, unsigned c, typename T >
+ struct set_precise_unary_< Name, metal::array2d<T, r, c> >
+ {
+ typedef mln_trait_unary(Name, T) V;
+ typedef metal::array2d<V, r, c> ret;
+ };
+
+ // For binary traits.
+
+ template < template <class, class> class Name,
+ unsigned r, unsigned c, typename T,
+ typename U >
+ struct set_precise_binary_< Name,
+ metal::array2d<T, r, c>, metal::array2d<U, r, c> >
+ {
+ typedef mln_trait_binary(Name, T, U) V;
+ typedef metal::array2d<V, r, c> ret;
+ };
+
+ template < unsigned r, unsigned c, typename T,
+ typename U >
+ struct set_precise_binary_< op::times,
+ metal::array2d<T, r, c>, metal::array2d<U, r, c> >
+ {
+ typedef mln_sum_x(T,U) ret;
+ };
+
+ template < template <class, class> class Name,
+ unsigned r, unsigned c, typename T,
+ typename S >
+ struct set_precise_binary_< Name,
+ metal::array2d<T, r, c>, mln::value::scalar_<S> >
+ {
+ typedef mln_trait_binary(Name, T, S) V;
+ typedef metal::array2d<V, r, c> ret;
+ };
+
+ template < template<class, class> class Name,
+ unsigned r, unsigned c, typename T,
+ typename S >
+ struct set_binary_< Name,
+ mln::Object, metal::array2d<T, r, c>,
+ mln::value::Scalar, S >
+ {
+ typedef mln_trait_binary(Name, T, S) V;
+ typedef metal::array2d<T, r, c> ret;
+ };
+
+ } // end of namespace mln::trait
+
+
+ namespace metal
+ {
+
+ //
+ // Constructors
+ //
+
+ template <typename T, unsigned r, unsigned c>
+ array2d<T, r, c>::array2d()
+ {
+ }
+
+ template <typename T, unsigned r, unsigned c>
+ array2d<T, r, c>::array2d(T* ptr)
+ {
+ for (unsigned i = 0; i < r * c; ++i)
+ buffer_[i] = *ptr++;
+ }
+
+ // Copy
+
+ template <typename T, unsigned r, unsigned c>
+ array2d<T, r, c>::array2d(const array2d<T, r, c>& rhs)
+ {
+ for (unsigned i = 0; i < r * c; ++i)
+ buffer_[i] = rhs[i];
+ }
+ template <typename T, unsigned r, unsigned c>
+ array2d<T, r, c>&
+ array2d<T, r, c>::operator=(const array2d<T, r, c>& rhs)
+ {
+ for (unsigned i = 0; i < r * c; ++i)
+ buffer_[i] = rhs[i];
+ return *this;
+ }
+
+ // Operators
+
+ template <typename T, unsigned r, unsigned c>
+ template <class U>
+ array2d<T, r, c>
+ array2d<T, r, c>::operator*(U w)
+ {
+ //fixme mln_trait_op_mult<int,U>
+ array2d<T, r, c> tmp;
+ for (unsigned i = 0; i < r * c; ++i)
+ tmp[i] = this->buffer_[i] * w;
+ return tmp;
+ }
+
+ template <typename T, unsigned r, unsigned c>
+ template <class U>
+ array2d<mln_trait_op_div(T,U), r, c>
+ array2d<T,r, c>::operator/(U w)
+ {
+ array2d<T, r, c> tmp;
+ for (unsigned i = 0; i < r * c; ++i)
+ tmp[i] = this->buffer_[i] / w;
+ return tmp;
+ }
+
+ template <typename T, unsigned r, unsigned c>
+ template <typename U>
+ array2d<mln_trait_op_plus(T,U), r, c>
+ array2d<T,r, c>::operator+(const array2d<U, r, c>& rhs) const
+ {
+ array2d<T, r, c> tmp;
+ for (unsigned i = 0; i < r * c; ++i)
+ tmp[i] = this->buffer_[i] + rhs.buffer_[i];
+ return tmp;
+ }
+ template <typename T, unsigned r, unsigned c>
+ array2d<T, r, c>&
+ array2d<T, r, c>::operator+=(const array2d<T, r, c>& rhs)
+ {
+ for (unsigned i = 0; i < r * c; ++i)
+ this->buffer_[i] += rhs.buffer_[i];
+ return *this;
+ }
+
+ template <typename T, unsigned r, unsigned c>
+ template <typename U>
+ array2d<mln_trait_op_minus(T,U), r, c>
+ array2d<T,r, c>::operator-(const array2d<U, r, c>& rhs) const
+ {
+ array2d<T, r, c> tmp;
+ for (unsigned i = 0; i < r * c; ++i)
+ tmp[i] = this->buffer_[i] - rhs.buffer_[i];
+ return tmp;
+ }
+ template <typename T, unsigned r, unsigned c>
+ array2d<T, r, c>&
+ array2d<T, r, c>::operator-=(const array2d<T, r, c>& rhs)
+ {
+ for (unsigned i = 0; i < r * c; ++i)
+ this->buffer_[i] -= rhs.buffer_[i];
+ return *this;
+ }
+
+ } // end of namespace metal
+
+} // end of namespace mln
+
+#endif /* MLN_METAL_ARRAY2D_HH */
+
diff --git a/milena/mln/metal/array3d.hh b/milena/mln/metal/array3d.hh
new file mode 100644
index 0000000..574d2a6
--- /dev/null
+++ b/milena/mln/metal/array3d.hh
@@ -0,0 +1,310 @@
+// Copyright (C) 2008 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_METAL_ARRAY3D_HH
+# define MLN_METAL_ARRAY3D_HH
+
+# include <mln/core/concept/object.hh>
+
+# include <mln/trait/all.hh>
+# include <mln/trait/value_.hh>
+
+# include <mln/value/ops.hh>
+
+namespace mln
+{
+
+ // Fwd decls.
+ namespace metal {
+ template <typename T, unsigned s, unsigned r, unsigned c> struct array3d;
+ }
+
+ namespace trait
+ {
+
+ template <typename T, unsigned s, unsigned r, unsigned c>
+ struct value_< mln::metal::array3d<T,s, r, c> >
+ {
+ typedef trait::value::nature::vectorial nature;
+ typedef trait::value::kind::data kind;
+
+ enum {
+ nbits = s * r * c * mln_nbits(T),
+ card = s * r * c * mln_card(T)
+ };
+ typedef mln_value_quant_from_(card) quant;
+
+ typedef metal::array3d<mln_sum(T), s, r, c> sum;
+ };
+
+ } // end of namespace mln::trait
+
+
+ namespace metal
+ {
+
+ template <typename T, unsigned s, unsigned r, unsigned c>
+ struct array3d : public Object< array3d<T, s, r, c> >
+ {
+
+ //
+ // Constructors
+ //
+
+ array3d();
+ array3d(T* ptr);
+
+ // Copy
+
+ array3d(const array3d<T, s, r, c>& rhs);
+ array3d<T, s, r, c>& operator=(const array3d<T, s, r, c>&
rhs);
+
+ // Operators
+
+ template <class U>
+ array3d<T, s, r, c> operator*(U w);
+
+ template <class U>
+ array3d<mln_trait_op_div(T,U), s, r, c>
+ operator/(U w);
+
+ template <typename U>
+ array3d<mln_trait_op_plus(T,U), s, r, c>
+ operator+(const array3d<U, s, r, c>& rhs) const;
+ array3d<T, s, r, c>& operator+=(const array3d<T, s, r, c>&
rhs);
+
+ template <typename U>
+ array3d<mln_trait_op_minus(T,U), s, r, c>
+ operator-(const array3d<U, s, r, c>& rhs) const;
+ array3d<T, s, r, c>&
+ operator-=(const array3d<T, s, r, c>& rhs);
+
+
+ // dynamic accessors:
+
+ T operator[](unsigned i) const {
+ mln_precondition(i < s * r * c);
+ return buffer_[i];
+ }
+ T& operator[](unsigned i) {
+ mln_precondition(i < s * r * c);
+ return buffer_[i];
+ }
+
+ // static accessor
+
+ template <unsigned sli, unsigned row, unsigned col>
+ T get() const {
+ return buffer_[sli * (row * col) + col * r + row];
+ }
+ template <unsigned sli, unsigned row, unsigned col>
+ T& get() {
+ return buffer_[sli * (row * col) + col * r + row];
+ }
+
+
+ template <unsigned sli, unsigned row, unsigned col>
+ T get_at() const {
+ mln_precondition(sli * (row * col) + col * r + row < s * r * c );
+ return buffer_[sli * (row * col) + col * r + row];
+ }
+ template <unsigned sli, unsigned row, unsigned col>
+ T& get_at() {
+ mln_precondition(sli * (row * col) + col * r + row < s * r * c );
+ return buffer_[sli * (row * col) + col * r + row];
+ }
+
+ enum { length = s * r * c };
+ protected:
+
+ T buffer_[s * r * c];
+ };
+
+ }
+
+ namespace trait
+ {
+
+ // For unary traits.
+
+ template < template <class> class Name,
+ unsigned s, unsigned r, unsigned c, typename T >
+ struct set_precise_unary_< Name, metal::array3d<T, s, r, c> >
+ {
+ typedef mln_trait_unary(Name, T) V;
+ typedef metal::array3d<V, s, r, c> ret;
+ };
+
+ // For binary traits.
+
+ template < template <class, class> class Name,
+ unsigned s, unsigned r, unsigned c, typename T,
+ typename U >
+ struct set_precise_binary_< Name,
+ metal::array3d<T, s, r, c>, metal::array3d<U, s, r, c> >
+ {
+ typedef mln_trait_binary(Name, T, U) V;
+ typedef metal::array3d<V, s, r, c> ret;
+ };
+
+ template < unsigned s, unsigned r, unsigned c, typename T,
+ typename U >
+ struct set_precise_binary_< op::times,
+ metal::array3d<T, s, r, c>, metal::array3d<U, s, r, c> >
+ {
+ typedef mln_sum_x(T,U) ret;
+ };
+
+ template < template <class, class> class Name,
+ unsigned s, unsigned r, unsigned c, typename T,
+ typename S >
+ struct set_precise_binary_< Name,
+ metal::array3d<T, s, r, c>, mln::value::scalar_<S> >
+ {
+ typedef mln_trait_binary(Name, T, S) V;
+ typedef metal::array3d<V, s, r, c> ret;
+ };
+
+ template < template<class, class> class Name,
+ unsigned s, unsigned r, unsigned c, typename T,
+ typename S >
+ struct set_binary_< Name,
+ mln::Object, metal::array3d<T, s, r, c>,
+ mln::value::Scalar, S >
+ {
+ typedef mln_trait_binary(Name, T, S) V;
+ typedef metal::array3d<T, s, r, c> ret;
+ };
+
+ } // end of namespace mln::trait
+
+
+ namespace metal
+ {
+
+ //
+ // Constructors
+ //
+
+ template <typename T, unsigned s, unsigned r, unsigned c>
+ array3d<T,s, r, c>::array3d()
+ {
+ }
+
+ template <typename T, unsigned s, unsigned r, unsigned c>
+ array3d<T,s, r, c>::array3d(T* ptr)
+ {
+ for (unsigned i = 0; i < s * r * c; ++i)
+ buffer_[i] = *ptr++;
+ }
+
+ // Copy
+
+ template <typename T, unsigned s, unsigned r, unsigned c>
+ array3d<T,s, r, c>::array3d(const array3d<T, s, r, c>& rhs)
+ {
+ for (unsigned i = 0; i < s * r * c; ++i)
+ buffer_[i] = rhs[i];
+ }
+ template <typename T, unsigned s, unsigned r, unsigned c>
+ array3d<T, s, r, c>&
+ array3d<T,s, r, c>::operator=(const array3d<T, s, r, c>& rhs)
+ {
+ for (unsigned i = 0; i < s * r * c; ++i)
+ buffer_[i] = rhs[i];
+ return *this;
+ }
+
+ // Operators
+
+ template <typename T, unsigned s, unsigned r, unsigned c>
+ template <class U>
+ array3d<T, s, r, c>
+ array3d<T,s, r, c>::operator*(U w)
+ {
+ //fixme mln_trait_op_mult<int,U>
+ array3d<T, s, r, c> tmp;
+ for (unsigned i = 0; i < s * r * c; ++i)
+ tmp[i] = this->buffer_[i] * w;
+ return tmp;
+ }
+
+ template <typename T, unsigned s, unsigned r, unsigned c>
+ template <class U>
+ array3d<mln_trait_op_div(T,U), s, r, c>
+ array3d<T,s, r, c>::operator/(U w)
+ {
+ array3d<T, s, r, c> tmp;
+ for (unsigned i = 0; i < s * r * c; ++i)
+ tmp[i] = this->buffer_[i] / w;
+ return tmp;
+ }
+
+ template <typename T, unsigned s, unsigned r, unsigned c>
+ template <typename U>
+ array3d<mln_trait_op_plus(T,U), s, r, c>
+ array3d<T,s, r, c>::operator+(const array3d<U, s, r, c>& rhs) const
+ {
+ array3d<T, s, r, c> tmp;
+ for (unsigned i = 0; i < s * r * c; ++i)
+ tmp[i] = this->buffer_[i] + rhs.buffer_[i];
+ return tmp;
+ }
+ template <typename T, unsigned s, unsigned r, unsigned c>
+ array3d<T, s, r, c>&
+ array3d<T,s, r, c>::operator+=(const array3d<T, s, r, c>& rhs)
+ {
+ for (unsigned i = 0; i < s * r * c; ++i)
+ this->buffer_[i] += rhs.buffer_[i];
+ return *this;
+ }
+
+ template <typename T, unsigned s, unsigned r, unsigned c>
+ template <typename U>
+ array3d<mln_trait_op_minus(T,U), s, r, c>
+ array3d<T,s, r, c>::operator-(const array3d<U, s, r, c>& rhs) const
+ {
+ array3d<T, s, r, c> tmp;
+ for (unsigned i = 0; i < s * r * c; ++i)
+ tmp[i] = this->buffer_[i] - rhs.buffer_[i];
+ return tmp;
+ }
+ template <typename T, unsigned s, unsigned r, unsigned c>
+ array3d<T, s, r, c>&
+ array3d<T,s, r, c>::operator-=(const array3d<T, s, r, c>& rhs)
+ {
+ for (unsigned i = 0; i < s * r * c; ++i)
+ this->buffer_[i] -= rhs.buffer_[i];
+ return *this;
+ }
+
+ } // end of namespace metal
+
+} // end of namespace mln
+
+#endif /* MLN_METAL_ARRAY3D_HH */
+
diff --git a/milena/sandbox/ChangeLog b/milena/sandbox/ChangeLog
index 64366fc..9043427 100644
--- a/milena/sandbox/ChangeLog
+++ b/milena/sandbox/ChangeLog
@@ -1,3 +1,44 @@
+2008-09-05 Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
+
+ Sandbox: virtual transform, Add concept check.
+
+ * jardonnet/virtual/access.hh: Add concept check.
+ * jardonnet/virtual/access.cc: Update in consequence.
+
+2008-09-05 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
+
+ Fixes to install the gimp plugin.
+ * nivault/plugin-gimp/autogen.sh: s/main.c/main.cc
+ * nivault/plugin-gimp/configure.ac: move install dir to home to
+ install it without administrator rights (dirty)
+ * nivault/plugin-gimp/src/main.cc: Change place in the gimp menu.
+
+2008-09-04 Ugo Jardonnet <jardonnet(a)lrde.epita.fr>
+
+ Start working on image virtual transformation.
+
+ * jardonnet/virtual: New.
+ * jardonnet/virtual/access.hh (access): Virtual access to image.
+ It also contains image interpolation routines.
+ * jardonnet/virtual/access.cc: Test file.
+ * jardonnet/virtual/Makefile: New.
+
+2008-09-02 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
+
+ * geraud/fllt/fllt.svg.7.hh: Add comments to the working version of
+ FLLT.
+
+2008-09-01 Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
+
+ Sandbox: Update metal::array.
+
+ * jardonnet/array/array.cc: Update Test.
+ * jardonnet/array/array.hh: Add stc/dyn getters.
+ * jardonnet/array/Makefile: New.
+
+ * jardonnet/test/icp.cc: .
+ * jardonnet/registration/tools.hh: .
+
2008-06-19 Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add kruskal algorithm in a sample morphological chain.
diff --git a/milena/sandbox/geraud/fllt/fllt.svg.7.hh
b/milena/sandbox/geraud/fllt/fllt.svg.7.hh
index c2a2df3..105e4e6 100644
--- a/milena/sandbox/geraud/fllt/fllt.svg.7.hh
+++ b/milena/sandbox/geraud/fllt/fllt.svg.7.hh
@@ -331,9 +331,6 @@ namespace mln
++label;
- // if (holes.size() == 2)
- // std::cout << holes[0] << holes[1] << std::endl;
- // std::cout << " <<<<<<<exiting blob."
<< std::endl;
}
template <typename P, typename V>
@@ -393,7 +390,8 @@ namespace mln
}
}
- // LOWER LEVEL SET : region = c4, border = c8
+ // LOWER LEVEL SET information to compute the max tree.
+ // -> region = c4, border = c8
template <typename V>
struct lower
{
@@ -421,7 +419,8 @@ namespace mln
};
- // UPPER LEVEL SET : region = c8, border = c4
+ // UPPER LEVEL SET information to compute the max tree.
+ // -> region = c8, border = c4
template <typename V>
struct upper
{
@@ -445,6 +444,14 @@ namespace mln
static const neighb2d& reg_nbh() { return c8(); }
};
+ /*! Fast computation of a min/max tree.
+ *
+ * \param[in] input_ An input image.
+ * \param[out] smallest_shapes We stock in this image, for each point, a pointer
+ * to the smallest shape containing it.
+ * \return The min/max tree built.
+ *
+ */
template <typename I, typename Set>
fllt_tree(mln_point(I), mln_value(I))&
level_set(const Image<I>& input_,
@@ -560,7 +567,7 @@ namespace mln
deja_vu(x) = in_N;
}
}
- // gN = min u(x) for all x in N
+ // gN <- min u(x) for all x in N
update_gN(N, gN, Set());
// FIXME: update the number of CC of the border of R
@@ -609,7 +616,6 @@ namespace mln
// c)
else
{
- // FIXME: IDEA: this change might be performed while R is constructed(?)
n_step_4c++;
mln_piter(I) r(N_box);
for_all(r)
@@ -627,6 +633,15 @@ namespace mln
return *new tree_type(current_cc);
}
+ /*! Get the hole of a shape which contains a given point.
+ *
+ * \param[in] node a shape.
+ * \param[in] p a point.
+ * \param[in] other_reg The map which associate a point with its smallest shape
+ * of the oposite tree.
+ * \return true if A is included in B.
+ *
+ */
// F is the set in which we get the node.
template <typename P, typename V, typename F>
fllt_node(P, V)*
@@ -636,6 +651,7 @@ namespace mln
{
fllt_node(P, V)* s = other_reg(p);
mln_assertion(s);
+ // Go up the tree.
while (s->parent() && F::compare(s->parent()->elt().value,
node.elt().value))
{
mln_assertion(s);
@@ -649,6 +665,14 @@ namespace mln
return s;
}
+ /*! Test the inclusion of two shapes of the same tree
+ *
+ * \param[in] A a shape.
+ * \param[in] B a shape.
+ * \return true if A is included in B.
+ *
+ * \pre The shapes have to come from the same tree.
+ */
template <typename P, typename V>
bool shape_is_included(fllt_node(P, V)* A,
fllt_node(P, V)* B)
@@ -656,6 +680,17 @@ namespace mln
return A->parent() == B || A == B;
}
+ /*! Associated the points of the holes of the min/max tree's shapes.
+ *
+ * \param[in] lower_tree The min tree.
+ * \param[in] upper_tree The max tree.
+ * \param[in] low_reg The map which associate a point with its smallest shape
+ * of the min tree.
+ * \param[in] upp_reg The map which associate a point with its smallest shape
+ * of the max tree.
+ * \return The merged tree.
+ *
+ */
template <typename P, typename V>
void find_all_holes(fllt_tree(P, V)& lower_tree,
fllt_tree(P, V)& upper_tree,
@@ -665,6 +700,7 @@ namespace mln
typedef p_array<P> arr_t;
typedef fllt_node(P, V) node_type;
+ // Get the holes of the min tree
{
fllt_branch_iter_ind(P, V) node_(lower_tree.main_branch());
for_all(node_)
@@ -676,6 +712,7 @@ namespace mln
}
}
+ // Get the holes of the max tree
{
fllt_branch_iter_ind(P, V) node_(upper_tree.main_branch());
for_all(node_)
@@ -688,6 +725,17 @@ namespace mln
}
}
+ /*! Merge the Min and the max tree.
+ *
+ * \param[in] lower_tree The min tree.
+ * \param[in] upper_tree The max tree.
+ * \param[in] low_reg The map which associate a point with its smallest shape
+ * of the min tree.
+ * \param[in] upp_reg The map which associate a point with its smallest shape
+ * of the max tree.
+ * \return The merged tree.
+ *
+ */
template <typename I>
fllt_tree(mln_point(I), mln_value(I))
merge_trees(fllt_tree(mln_point(I), mln_value(I))& lower_tree,
@@ -706,17 +754,24 @@ namespace mln
typedef p_array<P> arr_t;
+ // Here, a hole of a shape of the max or min tree is represented
+ // by a point belonging to this hole. We need to associate each of
+ // these points with its shape in the oposite tree.
find_all_holes(lower_tree, upper_tree, low_reg, upp_reg);
std::vector<node_type*> to_fill;
fllt_branch_iter_ind(P, V) node_(lower_tree.main_branch());
+ // Browse the shapes of the min_tree, in order to put as child of
+ // min tree's shapes the shapes of the max tree corresponding to
+ // their holes.
for_all(node_)
{
node_type& node = *node_;
+ // If the node was not in the min tree at the begining, we ignore it.
if (node.elt().set_id != lower<V>::id)
continue;
- // std::cout << "Fill " << &node << std::endl;
+ // Browse the holes of the shape.
typename std::vector<fllt_node(P, V)*>::iterator hole_;
for (hole_ = node.elt().hole_shapes.begin();
hole_ != node.elt().hole_shapes.end();
@@ -724,6 +779,7 @@ namespace mln
{
fllt_node(P, V)* hole = *hole_;
+ // Check if hole_ is contained by a hole of the children of node.
bool child_has_bigger_hole = false;
typename fllt_node(P, V)::children_t::iterator it;
for (it = node.children().begin(); it != node.children().end() &&
!child_has_bigger_hole; it++)
@@ -735,8 +791,6 @@ namespace mln
child_hole_++)
{
fllt_node(P, V)* child_hole = *child_hole_;
- // std::cout << "hole : " << hole << "
" << hole->elt().points << " " << std::endl;
- // std::cout << "child hole : " << child_hole <<
" " << child_hole->elt().points << std::endl;
if (shape_is_included(hole, child_hole))
{
child_has_bigger_hole = true;
@@ -744,6 +798,9 @@ namespace mln
}
} // end of browsing child's holes.
} // end of browsing childs.
+
+ // If no, move the shape of the max tree previously associated to this hole.
+ // as child of node.
if (!child_has_bigger_hole)
{
// // std::cout << "move " << hole << " as child
of " << &node << std::endl;
@@ -754,6 +811,12 @@ namespace mln
node.elt().holes.clear();
} // end of browsing lower_tree.
+ // At this step, we have filled all the holes of the min
+ // tree. But, by filling these holes, we introduced somes holes of
+ // the max tree in the result tree. We need to fill them.
+
+ // Thus, we browse the shapes of the max tree previously merged in
+ // the min tree, in order to check their holes.
for(typename std::vector<node_type*>::iterator node_ = to_fill.begin();
node_ != to_fill.end();
node_++)
@@ -767,6 +830,7 @@ namespace mln
if (node.elt().set_id != upper<V>::id)
continue;
+ // Check if hole_ is contained by a hole of the children of node.
typename std::vector<fllt_node(P, V)*>::iterator hole_;
for (hole_ = node.elt().hole_shapes.begin();
hole_ != node.elt().hole_shapes.end();
@@ -785,7 +849,6 @@ namespace mln
child_hole_++)
{
fllt_node(P, V)* child_hole = *child_hole_;
- //if (hole->elt().points <= child_hole->elt().points)
if (shape_is_included(hole, child_hole))
{
child_has_bigger_hole = true;
@@ -794,6 +857,8 @@ namespace mln
} // end of browsing child's holes.
} // end of browsing childs.
+ // If no, move the shape of the max tree previously associated to this hole.
+ // as child of node.
if (!child_has_bigger_hole)
node.add_child(hole);
@@ -806,6 +871,12 @@ namespace mln
return lower_tree;
}
+ /*! This function compute the fllt tree of an image.
+ *
+ * \param[in] input_ An input image.
+ * \return The computed tree.
+ *
+ */
template <typename I>
fllt_tree(mln_point(I), mln_value(I))
fllt(const Image<I>& input_)
@@ -820,12 +891,15 @@ namespace mln
image2d<fllt_node(P, V)*> low_reg(input.domain());
image2d<fllt_node(P, V)*> upp_reg(input.domain());
+ // Compute the Min tree.
std::cout << "1/ Compute the lower level
set.----------------------------------------" << std::endl;
lower_tree = level_set<I, lower<V> >(input, low_reg);
+ // Compute the Max tree.
std::cout << "2/ Compute the upper level
set.----------------------------------------" << std::endl;
upper_tree = level_set<I, upper<V> >(input, upp_reg);
+ // Merge the two trees.
std::cout << "3/
Merge.---------------------------------------------------------------" <<
std::endl;
fllt_tree(P, V) result_tree = merge_trees(lower_tree, upper_tree, low_reg, upp_reg,
input);
diff --git a/milena/sandbox/jardonnet/array/Makefile
b/milena/sandbox/jardonnet/array/Makefile
new file mode 100644
index 0000000..07c5494
--- /dev/null
+++ b/milena/sandbox/jardonnet/array/Makefile
@@ -0,0 +1,2 @@
+all:
+ g++ array.cc -I../../..
\ No newline at end of file
diff --git a/milena/sandbox/jardonnet/array/array.cc
b/milena/sandbox/jardonnet/array/array.cc
index 1eb1447..d01897a 100644
--- a/milena/sandbox/jardonnet/array/array.cc
+++ b/milena/sandbox/jardonnet/array/array.cc
@@ -1,6 +1,6 @@
#include <iostream>
-#include <mln/metal/array.hh>
+#include "array.hh"
int main(int, char **)
{
@@ -9,4 +9,14 @@ int main(int, char **)
mln::metal::array1d<int, 5> c;
c = a + b;
+
+ a.get<0>() = 0;
+ a.get<1>() = 1;
+ a.get<2>() = 2;
+ a.get<3>() = 3;
+
+ for (int i = 0 ; i < a.length; i++)
+ std::cout << a[i] << " ";
+
+ std::cout << std::endl;
}
diff --git a/milena/sandbox/jardonnet/array/array.hh
b/milena/sandbox/jardonnet/array/array.hh
index 57b798d..0934856 100644
--- a/milena/sandbox/jardonnet/array/array.hh
+++ b/milena/sandbox/jardonnet/array/array.hh
@@ -28,16 +28,47 @@
#ifndef MLN_METAL_ARRAY1D_HH
# define MLN_METAL_ARRAY1D_HH
+# include <mln/core/concept/object.hh>
+
# include <mln/trait/all.hh>
+# include <mln/trait/value_.hh>
+
+# include <mln/value/ops.hh>
namespace mln
{
+ // Fwd decls.
+ namespace metal {
+ template <typename T, unsigned Size> struct array1d;
+ }
+
+ namespace trait
+ {
+
+ template <typename T, unsigned Size>
+ struct value_< mln::metal::array1d<T,Size> >
+ {
+ typedef trait::value::nature::vectorial nature;
+ typedef trait::value::kind::data kind;
+
+ enum {
+ nbits = Size * mln_nbits(T),
+ card = Size * mln_card(T)
+ };
+ typedef mln_value_quant_from_(card) quant;
+
+ typedef metal::array1d<mln_sum(T),Size> sum;
+ };
+
+ } // end of namespace mln::trait
+
+
namespace metal
{
template <typename T, unsigned Size>
- struct array1d
+ struct array1d : public Object< array1d<T,Size> >
{
//
@@ -72,11 +103,99 @@ namespace mln
array1d<T, Size>&
operator-=(const array1d<T, Size>& rhs);
+
+ // dynamic accessors:
+
+ T operator[](unsigned i) const
+ {
+ mln_precondition(i < Size);
+ return buffer_[i];
+ }
+ T& operator[](unsigned i)
+ {
+ mln_precondition(i < Size);
+ return buffer_[i];
+ }
+
+ // static accessor
+
+ template<unsigned i>
+ T get() const {
+ return *(buffer_ + i);
+ }
+ template<unsigned i>
+ T& get() {
+ return *(buffer_ + i);
+ }
+
+ enum { length = Size };
protected:
T buffer_[Size];
};
+ }
+
+ namespace trait
+ {
+
+ // For unary traits.
+
+ template < template <class> class Name,
+ unsigned n, typename T >
+ struct set_precise_unary_< Name, metal::array1d<T, n> >
+ {
+ typedef mln_trait_unary(Name, T) V;
+ typedef metal::array1d<V, n> ret;
+ };
+
+ // For binary traits.
+
+ template < template <class, class> class Name,
+ unsigned n, typename T,
+ typename U >
+ struct set_precise_binary_< Name,
+ metal::array1d<T, n>, metal::array1d<U, n> >
+ {
+ typedef mln_trait_binary(Name, T, U) V;
+ typedef metal::array1d<V, n> ret;
+ };
+
+ template < unsigned n, typename T,
+ typename U >
+ struct set_precise_binary_< op::times,
+ metal::array1d<T, n>, metal::array1d<U, n> >
+ {
+ typedef mln_sum_x(T,U) ret;
+ };
+
+ template < template <class, class> class Name,
+ unsigned n, typename T,
+ typename S >
+ struct set_precise_binary_< Name,
+ metal::array1d<T, n>, mln::value::scalar_<S> >
+ {
+ typedef mln_trait_binary(Name, T, S) V;
+ typedef metal::array1d<V, n> ret;
+ };
+
+ template < template<class, class> class Name,
+ unsigned n, typename T,
+ typename S >
+ struct set_binary_< Name,
+ mln::Object, metal::array1d<T, n>,
+ mln::value::Scalar, S >
+ {
+ typedef mln_trait_binary(Name, T, S) V;
+ typedef metal::array1d<T, n> ret;
+ };
+
+ } // end of namespace mln::trait
+
+
+ namespace metal
+ {
+
//
// Constructors
//
diff --git a/milena/sandbox/jardonnet/array/old/1d.hh
b/milena/sandbox/jardonnet/array/old/1d.hh
index c161e79..0da9f1a 100644
--- a/milena/sandbox/jardonnet/array/old/1d.hh
+++ b/milena/sandbox/jardonnet/array/old/1d.hh
@@ -236,9 +236,7 @@ namespace mlc
template<int i>
T get_() const {
- lesseq<-Info_::center, i>::ensure();
- lesseq<i, Info_::card - Info_::center - 1>::ensure();
- return *(buffer_ + Info_::center + i);
+ return *(buffer_ + i);
}
protected:
diff --git a/milena/sandbox/jardonnet/registration/tools.hh
b/milena/sandbox/jardonnet/registration/tools.hh
index 99ee7de..624af17 100644
--- a/milena/sandbox/jardonnet/registration/tools.hh
+++ b/milena/sandbox/jardonnet/registration/tools.hh
@@ -193,23 +193,23 @@ namespace mln
namespace convert
{
- // to_p_array
- template <typename I>
- inline
- p_array<mln_psite(I)>
- to_p_array(const Image<I>& img_)
- {
- const I& img = exact(img_);
+// // to_p_array
+// template <typename I>
+// inline
+// p_array<mln_psite(I)>
+// to_p_array(const Image<I>& img_)
+// {
+// const I& img = exact(img_);
- p_array<mln_psite(I)> a;
+// p_array<mln_psite(I)> a;
- mln_piter(I) p(img.domain());
- for_all(p)
- if (img(p))
- a.append(p);
+// mln_piter(I) p(img.domain());
+// for_all(p)
+// if (img(p))
+// a.append(p);
- return a;
- }
+// return a;
+// }
template < typename P >
@@ -316,32 +316,6 @@ namespace mln
} // end of namespace convert
- namespace algebra
- {
-
- // transpose
- template<unsigned n, unsigned m, typename T>
- mat<m,n,T>
- trans(const mat<n,m,T>& matrice)
- {
- mat<m,n,T> tmp;
- for (unsigned i = 0; i < n; ++i)
- for (unsigned j = 0; j < m; ++j)
- tmp(j,i) = matrice(i,j);
- return tmp;
- }
-
- // trace
- template<unsigned n, typename T> inline
- float tr(const mat<n,n,T>& m)
- {
- float f = 0.f;
- for (unsigned i = 0; i < n; ++i)
- f += m(i,i);
- return f;
- }
-
- } // end of namespace algebra
} // end of namespace mln
diff --git a/milena/sandbox/jardonnet/test/icp.cc b/milena/sandbox/jardonnet/test/icp.cc
index bf7eebc..70b4f88 100644
--- a/milena/sandbox/jardonnet/test/icp.cc
+++ b/milena/sandbox/jardonnet/test/icp.cc
@@ -3,6 +3,7 @@
#include <mln/io/pbm/load.hh>
#include <mln/io/pbm/save.hh>
#include <mln/io/ppm/save.hh>
+#include <mln/convert/to_p_array.hh>
#include <mln/norm/l2.hh>
#include <sandbox/jardonnet/registration/icp.hh>
diff --git a/milena/sandbox/jardonnet/virtual/Makefile
b/milena/sandbox/jardonnet/virtual/Makefile
new file mode 100644
index 0000000..f2fd44f
--- /dev/null
+++ b/milena/sandbox/jardonnet/virtual/Makefile
@@ -0,0 +1,2 @@
+all:
+ g++ access.cc -I../../..
\ No newline at end of file
diff --git a/milena/sandbox/jardonnet/virtual/access.cc
b/milena/sandbox/jardonnet/virtual/access.cc
new file mode 100644
index 0000000..620ab74
--- /dev/null
+++ b/milena/sandbox/jardonnet/virtual/access.cc
@@ -0,0 +1,36 @@
+
+#include <iostream>
+#include "access.hh"
+#include <mln/core/image2d.hh>
+#include <mln/fun/x2x/all.hh>
+#include <mln/debug/iota.hh>
+#include <mln/algebra/vec.hh>
+
+int main()
+{
+ using namespace mln;
+ image2d<int> img(50,50);
+ point2d p(5,5);
+ algebra::vec<2,float> v = make::vec(3,4);
+ fun::x2x::translation<2,float> t(v);
+ interpolation::nearest_neighbor< image2d<int> > nn;
+
+ debug::iota(img);
+
+ for (int i = 0; i < 50; i++)
+ {
+ for (int j = 0; j < 50; j++)
+ std::cout << img(point2d(i,j));
+ std::cout << std::endl;
+ }
+
+ std::cout << std::endl;
+
+ for (int i = 3; i < 53; i++)
+ {
+ for (int j = 4; j < 54; j++)
+ std::cout <<
+ mln::access::access(img, point2d(i,j), t, nn);
+ std::cout << std::endl;
+ }
+}
diff --git a/milena/sandbox/jardonnet/virtual/access.hh
b/milena/sandbox/jardonnet/virtual/access.hh
new file mode 100644
index 0000000..d5684e7
--- /dev/null
+++ b/milena/sandbox/jardonnet/virtual/access.hh
@@ -0,0 +1,126 @@
+#ifndef _ACCESS_HH
+# define _ACCESS_HH
+
+# include <mln/core/image1d.hh>
+# include <mln/core/image2d.hh>
+# include <mln/metal/is.hh>
+# include <mln/core/concept/function.hh>
+
+namespace mln
+{
+
+ namespace interpolation
+ {
+
+ template < typename I >
+ struct nearest_neighbor
+ : public Function_x2x< nearest_neighbor<I> >
+ {
+ typedef mln_value(I) result;
+
+ template < typename V >
+ mln_value(I)
+ operator()(const I& img, const V& v) const
+ {
+ mln_point(I) p = algebra::to_point<mln_point(I)>(v);
+ return img(p);
+ }
+
+ };
+
+ template < typename I >
+ struct linear
+ : public Function_x2x< linear<I> >
+ {
+ typedef mln_value(I) result;
+
+ template <typename C>
+ mln_value(I)
+ operator()(const I& img,
+ const algebra::vec<1,C>& v) const
+ {
+ // looking for img(x);
+ double x = v[0];
+
+ // p1
+ double xa = mln_point(I)::coord(v[0]);
+ double ya = img(point1d(xa));
+
+ // x makes sens in img
+ if (x == xa)
+ return img(xa);
+
+ // p2
+ double xb = mln_point(I)::coord(v[0] + 1);
+ double yb = img(point1d(xb));
+
+ // Taylor-young
+ return ya + (x - xa) * (yb - ya) / (xb - xa);
+ }
+ };
+
+ template < typename I >
+ struct bilinear
+ : public Function_x2x< bilinear<I> >
+ {
+ typedef mln_value(I) result;
+
+ template <typename V>
+ mln_value(I)
+ operator()(const I& img, const V& v) const
+ {
+ // q12----r2----q22
+ // | | |
+ // | x |
+ // | | |
+ // q11----r1----q21
+
+ // looking for img(P(x,y))
+ double x = v[0];
+ double y = v[1];
+
+ double x1 = mln_point(I)::coord(v[0]);
+ double x2 = mln_point(I)::coord(v[0]+ 1);
+ double y1 = mln_point(I)::coord(v[1]);
+ double y2 = mln_point(I)::coord(v[1]+ 1);
+
+ point2d q11 = point2d(x1, y1);
+ point2d q12 = point2d(x1, y2);
+ point2d q21 = point2d(x2, y1);
+ point2d q22 = point2d(x2, y2);
+
+ // linear interpolation #1
+ mln_value(I) img_r1 = img(q11) * (x2 - x) / (x2 - x1) +
+ img(q21) * (x - x1) / (x2 - x1);
+
+ // linear interpolation #2
+ mln_value(I) img_r2 = img(q12) * (x2 - x) / (x2 - x1) +
+ img(q22) * (x - x1) / (x2 - x1);
+
+ // interpolating in y direction
+ return img_r1 * (y2 - y) / (y2 -y1)
+ + img_r2 * (y - y1) /(y2 - y1);
+ }
+ };
+ }
+
+ namespace access
+ {
+
+ template <typename I, typename T, typename F>
+ mln_value(I)
+ access(const I& img, const mln_point(I)& p,
+ const T& trans, const F& interp)
+ {
+ mlc_is(typename T::invert, Bijection_x2x<typename T::invert>)::check();
+ mlc_is(F, Function_x2x<F>)::check();
+
+ return interp(img, (trans.inv())(p));
+ }
+
+ }
+
+}
+
+#endif /* _ACCESS_HH */
+
diff --git a/milena/sandbox/nivault/plugin-gimp/autogen.sh
b/milena/sandbox/nivault/plugin-gimp/autogen.sh
index 67c0744..2a28f72 100755
--- a/milena/sandbox/nivault/plugin-gimp/autogen.sh
+++ b/milena/sandbox/nivault/plugin-gimp/autogen.sh
@@ -10,7 +10,7 @@
PROJECT="GIMP Plug-In Template"
TEST_TYPE=-f
-FILE=src/main.c
+FILE=src/main.cc
AUTOCONF_REQUIRED_VERSION=2.54
AUTOMAKE_REQUIRED_VERSION=1.6
diff --git a/milena/sandbox/nivault/plugin-gimp/configure.ac
b/milena/sandbox/nivault/plugin-gimp/configure.ac
index a91ecdf..85a24d2 100644
--- a/milena/sandbox/nivault/plugin-gimp/configure.ac
+++ b/milena/sandbox/nivault/plugin-gimp/configure.ac
@@ -59,7 +59,8 @@ PKG_CHECK_MODULES(GIMP,
AC_SUBST(GIMP_CFLAGS)
AC_SUBST(GIMP_LIBS)
-GIMP_LIBDIR=`$PKG_CONFIG --variable=gimplibdir gimp-2.0`
+#GIMP_LIBDIR=`$PKG_CONFIG --variable=gimplibdir gimp-2.0`
+GIMP_LIBDIR=`echo ~/.gimp-2.4`
AC_SUBST(GIMP_LIBDIR)
diff --git a/milena/sandbox/nivault/plugin-gimp/src/main.cc
b/milena/sandbox/nivault/plugin-gimp/src/main.cc
index d9f38ea..aa49d7f 100644
--- a/milena/sandbox/nivault/plugin-gimp/src/main.cc
+++ b/milena/sandbox/nivault/plugin-gimp/src/main.cc
@@ -84,7 +84,7 @@ query (void)
G_N_ELEMENTS (args), 0,
args, NULL);
- gimp_plugin_menu_register (PROCEDURE_NAME, "<Image>/Tools/");
+ gimp_plugin_menu_register (PROCEDURE_NAME, "<Image>/Filters/Milena");
}
static void