Olena-patches
Threads by month
- ----- 2025 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- 9625 discussions
19 Oct '12
---
milena/ChangeLog | 4 +
milena/mln/world/k1/neighb2d.hh | 143 +++++++++++++++++++++++++++++++++++++++
2 files changed, 147 insertions(+), 0 deletions(-)
create mode 100644 milena/mln/world/k1/neighb2d.hh
diff --git a/milena/ChangeLog b/milena/ChangeLog
index d778238..6d98f7d 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,9 @@
2012-09-27 Guillaume Lazzara <z(a)lrde.epita.fr>
+ * mln/world/k1/neighb2d.hh: New neighborhoods.
+
+2012-09-27 Guillaume Lazzara <z(a)lrde.epita.fr>
+
More routines working on images immersed in K1.
* mln/core/concept/function.hh: Add Function_vvvv2v concept.
diff --git a/milena/mln/world/k1/neighb2d.hh b/milena/mln/world/k1/neighb2d.hh
new file mode 100644
index 0000000..7681af1
--- /dev/null
+++ b/milena/mln/world/k1/neighb2d.hh
@@ -0,0 +1,143 @@
+// Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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
+///
+/// \brief 2D neighborhood working in K1.
+
+#ifndef MLN_WORLD_K1_NEIGHB2D_HH
+# define MLN_WORLD_K1_NEIGHB2D_HH
+
+# include <mln/core/alias/point2d.hh>
+# include <mln/core/alias/neighb2d.hh>
+# include <mln/win/multiple.hh>
+# include <mln/make/double_neighb2d.hh>
+
+namespace mln
+{
+
+ namespace world
+ {
+
+ namespace k1
+ {
+
+ /*! \brief 2 faces to 1 faces neighborhood.
+
+ \verbatim
+ -
+ |x|
+ -
+ \endverbatim
+ */
+ const neighb2d& 2to1_faces();
+
+
+ /*! \brief 1 faces to 2 faces neighborhood.
+
+ \verbatim
+ o
+ oxo or x
+ o
+ \endverbatim
+
+ */
+ const dbl_neighb2d& 1to2_faces();
+
+
+ /*! \brief 1 faces to 1 faces neighborhood.
+
+ \verbatim
+ |
+ - - | |
+ x or - -
+ - - | |
+ |
+ \endverbatim
+ */
+ const dbl_neighb2d& 1to1_faces()
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace internal
+ {
+
+ inline
+ bool is_row_odd(const point2d& p)
+ {
+ return p.row() % 2;
+ }
+
+ }
+
+ typedef neighb< win::multiple<window2d, bool(*)(const point2d&)> > dbl_neighb2d;
+
+
+ const neighb2d& 2to1_faces()
+ {
+ return c4();
+ }
+
+ const dbl_neighb2d& 1to2_faces()
+ {
+ static bool 1face_h[] = { 0, 1, 0,
+ 0, 0, 0,
+ 0, 1, 0 };
+ static bool 1face_v[] = { 0, 0, 0,
+ 1, 0, 1,
+ 0, 0, 0 };
+ static dbl_neighb2d nbh = make::double_neighb2d(internal::is_row_odd, e2p_h, e2p_v);
+ return nbh;
+ }
+
+
+ const dbl_neighb2d& 1to1_faces()
+ {
+ static bool e2e_h[] = { 0, 0, 1, 0, 0,
+ 0, 1, 0, 1, 0,
+ 0, 0, 0, 0, 0,
+ 0, 1, 0, 1, 0,
+ 0, 0, 1, 0, 0 };
+ static bool e2e_v[] = { 0, 0, 0, 0, 0,
+ 0, 1, 0, 1, 0,
+ 1, 0, 0, 0, 1,
+ 0, 1, 0, 1, 0,
+ 0, 0, 0, 0, 0 };
+ static dbl_neighb2d nbh = make::double_neighb2d(internal::is_row_odd, e2e_h, e2e_v);
+ return nbh;
+ }
+
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::world::k1
+
+ } // end of namespace mln::world
+
+} // end of namespace mln
+
+#endif // ! MLN_WORLD_K1_NEIGHB2D_HH
--
1.7.2.5
1
0
olena-2.0-89-g7aacabf New routine for filling internal border in K1.
by Guillaume Lazzara 19 Oct '12
by Guillaume Lazzara 19 Oct '12
19 Oct '12
* mln/world/k1/fill_0_1_faces_internal_border.hh,
* tests/world/k1/fill_0_1_faces_internal_border.cc: New.
* tests/world/k1/Makefile.am: New target.
---
milena/ChangeLog | 9 ++
..._faces.hh => fill_0_1_faces_internal_border.hh} | 79 +++++++++----------
milena/tests/world/k1/Makefile.am | 2 +
...mmerse.cc => fill_0_1_faces_internal_border.cc} | 29 ++++---
4 files changed, 65 insertions(+), 54 deletions(-)
copy milena/mln/world/k1/{fill_0_from_primary_faces.hh => fill_0_1_faces_internal_border.hh} (53%)
copy milena/tests/world/k1/{un_immerse.cc => fill_0_1_faces_internal_border.cc} (76%)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 6d98f7d..174267b 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,12 @@
+2012-09-28 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ New routine for filling internal border in K1.
+
+ * mln/world/k1/fill_0_1_faces_internal_border.hh,
+ * tests/world/k1/fill_0_1_faces_internal_border.cc: New.
+
+ * tests/world/k1/Makefile.am: New target.
+
2012-09-27 Guillaume Lazzara <z(a)lrde.epita.fr>
* mln/world/k1/neighb2d.hh: New neighborhoods.
diff --git a/milena/mln/world/k1/fill_0_from_primary_faces.hh b/milena/mln/world/k1/fill_0_1_faces_internal_border.hh
similarity index 53%
copy from milena/mln/world/k1/fill_0_from_primary_faces.hh
copy to milena/mln/world/k1/fill_0_1_faces_internal_border.hh
index db3aed8..0ee3d27 100644
--- a/milena/mln/world/k1/fill_0_from_primary_faces.hh
+++ b/milena/mln/world/k1/fill_0_1_faces_internal_border.hh
@@ -25,13 +25,13 @@
/// \file
///
-/// \brief Fill 1 faces in a K1 2D image using its primary faces.
+/// \brief Fill 0 and 1 faces border with a value in a K1 2D image.
-#ifndef MLN_WORLD_K1_FILL_0_FROM_PRIMARY_FACES_HH
-# define MLN_WORLD_K1_FILL_0_FROM_PRIMARY_FACES_HH
+#ifndef MLN_WORLD_K1_FILL_0_1_FACES_INTERNAL_BORDER_HH
+# define MLN_WORLD_K1_FILL_0_1_FACES_INTERNAL_BORDER_HH
# include <mln/core/alias/point2d.hh>
-# include <mln/world/k1/fill_0_from_2_faces.hh>
+# include <mln/world/k1/is_0_face.hh>
namespace mln
@@ -43,27 +43,23 @@ namespace mln
namespace k1
{
- /*! \brief Fill 0 faces in a K1 2D image using its primary faces.
+ /*! \brief Fill 0 and 1 faces border with a value in a K1 2D image.
\param[in,out] inout A 2D image immersed in K1.
- \param[in,out] f A functor computing a result from four values.
+ \param[in] v The border value.
- This function use the following neighborhood:
-
- \verbatim
- x x
- .
- x x
- \endverbatim
+ Example with \p v=1:
+ . - . - . 1 1 1 1 1
+ | o | o | 1 o | o 1
+ . - . - . -> 1 - . - 1
+ | o | o | 1 o | o 1
+ . - . - . 1 1 1 1 1
*/
- template <typename I, typename F>
- void fill_0_from_primary_faces(Image<I>& inout, Function_vvvv2v<F>& f);
+ template <typename I>
+ void fill_0_1_faces_internal_border(Image<I>& inout, const mln_value(I)& v);
- /// \overload
- template <typename I, typename A>
- void fill_0_from_primary_faces(Image<I>& inout, const Accumulator<A>& accu);
# ifndef MLN_INCLUDE_ONLY
@@ -72,32 +68,31 @@ namespace mln
// Facade
- template <typename I, typename F>
- void fill_0_from_primary_faces(Image<I>& inout, Function_vvvv2v<F>& f)
- {
- trace::entering("mln::world::k1::fill_0_from_primary_faces");
-
- mln_precondition(exact(inout).is_valid());
-
- fill_0_from_2_faces(inout, f);
-
- trace::exiting("mln::world::k1::fill_0_from_primary_faces");
- }
-
-
- template <typename I, typename A>
- void fill_0_from_primary_faces(Image<I>& inout, const Accumulator<A>& accu)
+ template <typename I>
+ void fill_0_1_faces_internal_border(Image<I>& inout_, const mln_value(I)& v)
{
- trace::entering("mln::world::k1::fill_0_from_primary_faces");
-
- mln_precondition(exact(inout).is_valid());
-
- fill_0_from_2_faces(inout, accu);
-
- trace::exiting("mln::world::k1::fill_0_from_primary_faces");
+ trace::entering("mln::world::k1::fill_0_1_faces_internal_border");
+
+ mln_precondition(exact(inout_).is_valid());
+ I& inout = exact(inout_);
+
+ // Horizontal borders
+ for (mln::def::coord col = geom::min_col(inout); col <= geom::max_col(inout); ++col)
+ {
+ inout.at_(geom::min_row(inout), col) = v;
+ inout.at_(geom::max_row(inout), col) = v;
+ }
+
+ // Vertical borders
+ for (mln::def::coord row = geom::min_row(inout); row <= geom::max_row(inout); ++row)
+ {
+ inout.at_(row, geom::min_col(inout)) = v;
+ inout.at_(row, geom::max_col(inout)) = v;
+ }
+
+ trace::exiting("mln::world::k1::fill_0_1_faces_internal_border");
}
-
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::world::k1
@@ -106,4 +101,4 @@ namespace mln
} // end of namespace mln
-#endif // ! MLN_WORLD_K1_FILL_0_FROM_PRIMARY_FACES_HH
+#endif // ! MLN_WORLD_K1_FILL_0_1_FACES_INTERNAL_BORDER_HH
diff --git a/milena/tests/world/k1/Makefile.am b/milena/tests/world/k1/Makefile.am
index 68866fb..0027267 100644
--- a/milena/tests/world/k1/Makefile.am
+++ b/milena/tests/world/k1/Makefile.am
@@ -18,6 +18,7 @@ include $(top_srcdir)/milena/tests/tests.mk
check_PROGRAMS = \
display_enlarged \
+ fill_0_1_faces_internal_border \
fill_0_from_1_faces \
fill_0_from_2_faces \
fill_0_from_primary_faces \
@@ -37,6 +38,7 @@ check_PROGRAMS = \
un_immerse
display_enlarged_SOURCES = display_enlarged.cc
+fill_0_1_faces_border_SOURCES = fill_0_1_faces_border.cc
fill_0_from_1_faces_SOURCES = fill_0_from_1_faces.cc
fill_0_from_2_faces_SOURCES = fill_0_from_2_faces.cc
fill_0_from_primary_faces_SOURCES = fill_0_from_primary_faces.cc
diff --git a/milena/tests/world/k1/un_immerse.cc b/milena/tests/world/k1/fill_0_1_faces_internal_border.cc
similarity index 76%
copy from milena/tests/world/k1/un_immerse.cc
copy to milena/tests/world/k1/fill_0_1_faces_internal_border.cc
index 47e06e4..fbb9f73 100644
--- a/milena/tests/world/k1/un_immerse.cc
+++ b/milena/tests/world/k1/fill_0_1_faces_internal_border.cc
@@ -26,29 +26,34 @@
/// \file
#include <mln/core/image/image2d.hh>
-#include <mln/world/k1/un_immerse.hh>
#include <mln/make/box2d.hh>
#include <mln/data/compare.hh>
+#include <mln/world/k1/fill_0_1_faces_internal_border.hh>
int main()
{
using namespace mln;
- int refvals[2][2] = {
- {3, 3},
- {3, 3}
+ int refvals[5][5] = {
+ {1, 1, 1, 1, 1 },
+ {1, 2, 0, 2, 1 },
+ {1, 0, 0, 0, 1 },
+ {1, 2, 0, 2, 1 },
+ {1, 1, 1, 1, 1 }
};
- image2d<int> ref = make::image(refvals);
+ image2d<int> ref = make::image(refvals, point2d(-1, -1));
int vals[5][5] = {
- {1, 2, 1, 2, 1 },
- {2, 3, 2, 3, 2 },
- {1, 2, 1, 2, 1 },
- {2, 3, 2, 3, 2 },
- {1, 2, 1, 2, 1 }
+ {0, 0, 0, 0, 0 },
+ {0, 2, 0, 2, 0 },
+ {0, 0, 0, 0, 0 },
+ {0, 2, 0, 2, 0 },
+ {0, 0, 0, 0, 0 }
};
image2d<int> imak1 = make::image(vals, point2d(-1, -1));
- image2d<int> imak0 = world::k1::un_immerse(imak1);
- mln_assertion(imak0 == ref);
+ {
+ world::k1::fill_0_1_faces_internal_border(imak1, 1);
+ mln_assertion(ref == imak1);
+ }
}
--
1.7.2.5
1
0
* mln/value/next.hh: Add support for unsignedh.
* mln/value/range.hh,
* mln/value/unsignedh.hh,
* tests/value/range.cc,
* tests/value/unsignedh.cc: New.
* tests/value/Makefile.am: Add targets.
---
milena/ChangeLog | 13 +
milena/mln/value/next.hh | 20 +-
milena/mln/value/range.hh | 425 ++++++++++++++++++++
milena/mln/value/unsignedh.hh | 415 +++++++++++++++++++
milena/tests/value/Makefile.am | 16 +-
.../range.cc} | 62 ++--
.../tests/{fun/i2v/array.cc => value/unsignedh.cc} | 22 +-
7 files changed, 930 insertions(+), 43 deletions(-)
create mode 100644 milena/mln/value/range.hh
create mode 100644 milena/mln/value/unsignedh.hh
copy milena/tests/{world/k1/fill_0_1_faces_internal_border.cc => value/range.cc} (61%)
copy milena/tests/{fun/i2v/array.cc => value/unsignedh.cc} (80%)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 174267b..d66e76f 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,18 @@
2012-09-28 Guillaume Lazzara <z(a)lrde.epita.fr>
+ New value types.
+
+ * mln/value/next.hh: Add support for unsignedh.
+
+ * mln/value/range.hh,
+ * mln/value/unsignedh.hh,
+ * tests/value/range.cc,
+ * tests/value/unsignedh.cc: New.
+
+ * tests/value/Makefile.am: Add targets.
+
+2012-09-28 Guillaume Lazzara <z(a)lrde.epita.fr>
+
New routine for filling internal border in K1.
* mln/world/k1/fill_0_1_faces_internal_border.hh,
diff --git a/milena/mln/value/next.hh b/milena/mln/value/next.hh
index e1dac48..b9bc06e 100644
--- a/milena/mln/value/next.hh
+++ b/milena/mln/value/next.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2010, 2012 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -28,9 +29,10 @@
/// \file
///
-/// Return a given value incremented by 1.
+/// Return the next value.
# include <mln/value/label.hh>
+# include <mln/value/unsignedh.hh>
namespace mln
@@ -74,6 +76,14 @@ namespace mln
return v.next();
}
+
+ inline
+ mln::value::unsignedh
+ next_unsignedh(const mln::value::unsignedh& v)
+ {
+ return mln::value::succ(v);
+ }
+
} // end of namespace mln::value::implementation
@@ -91,6 +101,12 @@ namespace mln
return implementation::next_label(v);
}
+ inline
+ unsignedh
+ next_dispatch(const unsignedh& v)
+ {
+ return implementation::next_unsignedh(v);
+ }
template <typename V>
inline
diff --git a/milena/mln/value/range.hh b/milena/mln/value/range.hh
new file mode 100644
index 0000000..ca8f2f4
--- /dev/null
+++ b/milena/mln/value/range.hh
@@ -0,0 +1,425 @@
+// Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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_VALUE_RANGE_HH
+# define MLN_VALUE_RANGE_HH
+
+/// \file
+///
+/// Define a range value.
+
+# include <cstdlib>
+# include <iostream>
+# include <mln/value/next.hh>
+
+namespace mln
+{
+
+ namespace value
+ {
+
+ template <typename T>
+ class range
+ {
+ public:
+ range();
+
+ template <typename T_>
+ range(T_ value);
+
+ range(T lower, T upper);
+
+ range& operator=(const range& rhs);
+
+ template <typename T_>
+ range& operator=(T_ value);
+
+ bool has(const T& v) const;
+
+ T length() const;
+
+ unsigned nelements() const;
+
+ bool is_degenerated() const;
+
+ const T& lower() const;
+ const T& upper() const;
+
+ const T& first() const;
+ const T& last() const;
+
+ operator T() const;
+
+ private:
+ T lower_;
+ T upper_;
+ };
+
+// comparison
+
+ template <typename T>
+ bool
+ operator==(const range<T>& lhs, const range<T>& rhs);
+
+ template <typename T>
+ bool
+ operator!=(const range<T>& lhs, const range<T>& rhs);
+
+// deactivation of ordering related operators
+
+ template <typename T>
+ void operator<(const range<T>&, const range<T>&);
+
+ template <typename T>
+ void operator<=(const range<T>&, const range<T>&);
+
+ template <typename T>
+ void operator>(const range<T>&, const range<T>&);
+
+ template <typename T>
+ void operator>=(const range<T>&, const range<T>&);
+
+// set ops
+
+ template <typename T>
+ bool
+ are_adjacent(const range<T>& r1, const range<T>& r2);
+
+ template <typename T>
+ bool
+ do_intersect(const range<T>& r1, const range<T>& r2);
+
+ template <typename T>
+ range<T>
+ inter(const range<T>& r1, const range<T>& r2);
+
+// min / max
+
+ template <typename T>
+ range<T>
+ min(const range<T>& r1, const range<T>& r2);
+
+ template <typename T>
+ range<T>
+ max(const range<T>& r1, const range<T>& r2);
+
+// mean
+
+ template <typename T>
+ range<T>
+ mean(const range<T>& r1, const range<T>& r2);
+
+// span
+
+ template <typename T>
+ range<T>
+ span(const range<T>& r1, const range<T>& r2);
+
+// op<<
+
+ template <typename T>
+ std::ostream&
+ operator<<(std::ostream& ostr, const range<T>& i);
+
+ } // end of namespace mln::value
+
+} // end of namespace mln
+
+
+// for sorting purpose
+
+namespace std
+{
+
+ template <typename T>
+ struct less< mln::value::range<T> >
+ {
+ bool operator()(const mln::value::range<T>& l,
+ const mln::value::range<T>& r) const;
+ };
+
+} // std
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+namespace mln
+{
+
+ namespace value
+ {
+
+
+ template <typename T>
+ range<T>::range()
+ {
+ }
+
+ template <typename T>
+ template <typename T_>
+ range<T>::range(T_ value)
+ {
+ lower_ = upper_ = value;
+ }
+
+ template <typename T>
+ range<T>::range(T lower, T upper)
+ {
+ if (upper < lower)
+ std::abort();
+ lower_ = lower;
+ upper_ = upper;
+ }
+
+ template <typename T>
+ range<T>&
+ range<T>::operator=(const range& rhs)
+ {
+ lower_ = rhs.lower_;
+ upper_ = rhs.upper_;
+ return *this;
+ }
+
+ template <typename T>
+ template <typename T_>
+ range<T>&
+ range<T>::operator=(T_ value)
+ {
+ lower_ = upper_ = value;
+ return *this;
+ }
+
+ template <typename T>
+ bool
+ range<T>::has(const T& v) const
+ {
+ return lower_ <= v && v <= upper_;
+ }
+
+ template <typename T>
+ T
+ range<T>::length() const
+ {
+ return upper_ - lower_;
+ }
+
+ template <typename T>
+ unsigned
+ range<T>::nelements() const
+ {
+ unsigned n = 1;
+ T v = lower_;
+ for (; v != upper_; v = value::next(v))
+ n += 1;
+
+ return n;
+ }
+
+ template <typename T>
+ bool
+ range<T>::is_degenerated() const
+ {
+ return upper_ == lower_;
+ }
+
+ template <typename T>
+ const T&
+ range<T>::lower() const
+ {
+ return lower_;
+ }
+
+ template <typename T>
+ const T&
+ range<T>::upper() const
+ {
+ return upper_;
+ }
+
+ template <typename T>
+ const T&
+ range<T>::first() const
+ {
+ return lower_;
+ }
+
+ template <typename T>
+ const T&
+ range<T>::last() const
+ {
+ return upper_;
+ }
+
+ template <typename T>
+ range<T>::operator T() const
+ {
+ if (! is_degenerated())
+ std::abort();
+ return upper_;
+ }
+
+
+// comparison
+
+ template <typename T>
+ bool
+ operator==(const range<T>& lhs, const range<T>& rhs)
+ {
+ return lhs.lower() == rhs.lower() && lhs.upper() == rhs.upper();
+ }
+
+ template <typename T>
+ bool
+ operator!=(const range<T>& lhs, const range<T>& rhs)
+ {
+ return ! (lhs == rhs);
+ }
+
+
+// deactivation of ordering related operators
+
+ template <typename T>
+ void operator<(const range<T>&, const range<T>&);
+
+ template <typename T>
+ void operator<=(const range<T>&, const range<T>&);
+
+ template <typename T>
+ void operator>(const range<T>&, const range<T>&);
+
+ template <typename T>
+ void operator>=(const range<T>&, const range<T>&);
+
+
+
+// set ops
+
+ template <typename T>
+ bool
+ are_adjacent(const range<T>& r1, const range<T>& r2)
+ {
+ return span(r1, r2).length() == r1.length() + r2.length()
+ + (value::next(r2.lower()) - r2.lower());
+ }
+
+ template <typename T>
+ bool
+ do_intersect(const range<T>& r1, const range<T>& r2)
+ {
+ return span(r1, r2).length() <= r1.length() + r2.length();
+ }
+
+ template <typename T>
+ range<T>
+ inter(const range<T>& r1, const range<T>& r2)
+ {
+ if (! do_intersect(r1, r2))
+ std::abort();
+ return range<T>(std::max(r1.lower(), r2.lower()),
+ std::min(r1.upper(), r2.upper()));
+ }
+
+
+
+// min / max
+
+ template <typename T>
+ range<T>
+ min(const range<T>& r1, const range<T>& r2)
+ {
+ return range<T>(std::min(r1.lower(), r2.lower()),
+ std::min(r1.upper(), r2.upper()));
+ }
+
+ template <typename T>
+ range<T>
+ max(const range<T>& r1, const range<T>& r2)
+ {
+ return range<T>(std::max(r1.lower(), r2.lower()),
+ std::max(r1.upper(), r2.upper()));
+ }
+
+
+// mean
+
+ template <typename T>
+ range<T>
+ mean(const range<T>& r1, const range<T>& r2)
+ {
+ return range<T>(mean(r1.lower(), r2.lower()),
+ mean(r1.upper(), r2.upper()));
+ }
+
+
+// span
+
+ template <typename T>
+ range<T>
+ span(const range<T>& r1, const range<T>& r2)
+ {
+ return range<T>(std::min(r1.lower(), r2.lower()),
+ std::max(r1.upper(), r2.upper()));
+ }
+
+
+
+// op<<
+
+ template <typename T>
+ std::ostream&
+ operator<<(std::ostream& ostr, const range<T>& i)
+ {
+ if (i.is_degenerated())
+ return ostr << i.lower();
+ else
+ return ostr << '[' << i.lower() << ',' << i.upper() << ']';
+ }
+
+
+ } // end of namespace mln::value
+
+} // end of namespace mln
+
+
+namespace std
+{
+
+ template <typename T>
+ bool less< mln::value::range<T> >::operator()(const mln::value::range<T>& l,
+ const mln::value::range<T>& r) const
+ {
+ if (! l.is_degenerated() || ! r.is_degenerated())
+ std::abort();
+ return l.lower() < r.lower();
+ }
+
+} // std
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+#endif // ndef MLN_VALUE_RANGE_HH
diff --git a/milena/mln/value/unsignedh.hh b/milena/mln/value/unsignedh.hh
new file mode 100644
index 0000000..1f0281c
--- /dev/null
+++ b/milena/mln/value/unsignedh.hh
@@ -0,0 +1,415 @@
+// Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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_VALUE_UNSIGNEDH_HH
+# define MLN_VALUE_UNSIGNEDH_HH
+
+/// \file
+///
+/// Define a semi-unsigned value class.
+
+# include <cstdlib>
+# include <iostream>
+# include <sstream>
+
+// FIXME: parameterize unsignedh so that we also can have
+// Z/4 and so on...
+
+namespace mln
+{
+
+ namespace value
+ {
+
+
+ class unsignedh
+ {
+ public:
+ unsignedh();
+ unsignedh(const unsignedh& rhs);
+ unsignedh(unsigned i);
+ unsignedh(int i);
+
+ unsignedh& operator=(const unsignedh& rhs);
+ unsignedh& operator=(unsigned i);
+ unsignedh& operator=(int i);
+
+ unsigned enc() const;
+
+ /// Construct an unsignedh with value v
+ static unsignedh make(unsigned v);
+ /// Construct an unsignedh with value v. The given value is
+ /// rounded to the closest integer or half value.
+// static unsignedh make(float v);
+
+ bool is_integer() const;
+
+ unsigned to_unsigned() const;
+
+ /// Set this unsignedh to its next value and return itself.
+ unsignedh& goto_succ();
+
+ /// Set this unsignedh to its previous value and return itself.
+ unsignedh& goto_pred();
+
+ operator std::string() const;
+
+ private:
+ unsigned enc_;
+ };
+
+
+ extern const unsignedh half;
+
+
+// next
+
+ unsignedh succ(unsignedh i);
+ unsignedh pred(unsignedh i);
+
+// rounding
+
+ unsignedh floor(unsignedh i);
+ unsignedh ceil(unsignedh i);
+
+
+// comparison
+
+ bool operator==(unsignedh l, unsignedh r);
+ bool operator<=(unsignedh l, unsignedh r);
+ bool operator!=(unsignedh l, unsignedh r);
+ bool operator>=(unsignedh l, unsignedh r);
+ bool operator>(unsignedh l, unsignedh r);
+ bool operator<(unsignedh l, unsignedh r);
+
+// arithmetics
+
+ unsignedh operator+(unsignedh l, unsignedh r);
+ void operator+=(unsignedh& l, unsignedh r);
+ unsignedh operator-(unsignedh l, unsignedh r);
+ void operator-=(unsignedh& l, unsignedh r);
+ unsignedh operator/(unsignedh l, unsigned r);
+
+// other ops
+
+ unsignedh min(unsignedh u1, unsignedh u2);
+ unsignedh max(unsignedh u1, unsignedh u2);
+ unsignedh mean(unsignedh u1, unsignedh u2);
+
+// for a transparent use of both unsigned and unsignedh
+// FIXME: is it useful?
+
+ unsigned decode(unsigned u);
+ void encode(unsigned u, unsigned& dst);
+ unsigned decode(unsignedh u);
+ void encode(unsigned u, unsignedh& dst);
+
+// <<
+
+ std::ostream&
+ operator<<(std::ostream& ostr, const unsignedh& i);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ inline
+ unsignedh::unsignedh()
+ {
+ }
+
+ inline
+ unsignedh::unsignedh(const unsignedh& rhs)
+ : enc_(rhs.enc_)
+ {
+ }
+
+
+ inline
+ unsignedh::unsignedh(unsigned i)
+ {
+ enc_ = 2 * i;
+ }
+
+ inline
+ unsignedh::unsignedh(int i)
+ {
+ if (i < 0)
+ std::abort();
+ enc_ = 2 * i;
+ }
+
+ inline
+ unsignedh&
+ unsignedh::operator=(const unsignedh& rhs)
+ {
+ enc_ = rhs.enc_;
+ return *this;
+ }
+
+ inline
+ unsignedh&
+ unsignedh::operator=(unsigned i)
+ {
+ enc_ = 2 * i;
+ return *this;
+ }
+
+ inline
+ unsignedh&
+ unsignedh::operator=(int i)
+ {
+ if (i < 0)
+ std::abort();
+ enc_ = 2 * i;
+ return *this;
+ }
+
+ inline
+ unsigned
+ unsignedh::enc() const
+ {
+ return enc_;
+ }
+
+ inline
+ unsignedh unsignedh::make(unsigned enc)
+ {
+ unsignedh i;
+ i.enc_ = enc;
+ return i;
+ }
+
+ inline
+ bool
+ unsignedh::is_integer() const
+ {
+ return enc_ % 2 == 0;
+ }
+
+ inline
+ unsigned
+ unsignedh::to_unsigned() const
+ {
+ if (! this->is_integer())
+ std::abort();
+ return enc_ / 2;
+ }
+
+ inline
+ unsignedh&
+ unsignedh::goto_succ()
+ {
+ enc_ += 1;
+ return *this;
+ }
+
+ inline
+ unsignedh&
+ unsignedh::goto_pred()
+ {
+ if (enc_ == 0)
+ std::abort();
+ enc_ -= 1;
+ return *this;
+ }
+
+ inline
+ unsignedh::operator std::string() const
+ {
+ std::stringstream s;
+ s << *this;
+ return s.str();
+ }
+
+
+
+// half
+
+# ifndef MLN_WO_GLOBAL_VARS
+
+ const unsignedh half = unsignedh::make(1u);
+
+# endif // ! MLN_WO_GLOBAL_VARS
+
+
+// next
+
+ unsignedh succ(unsignedh i)
+ {
+ return unsignedh::make(i.enc() + 1);
+ }
+
+ unsignedh pred(unsignedh i)
+ {
+ if (i.enc() == 0)
+ std::abort();
+ return unsignedh::make(i.enc() - 1);
+ }
+
+
+
+// rounding
+
+ unsignedh floor(unsignedh i)
+ {
+ return i.is_integer() ? i : pred(i);
+ }
+
+ unsignedh ceil(unsignedh i)
+ {
+ return i.is_integer() ? i : succ(i);
+ }
+
+
+
+// comparison
+
+ bool operator==(unsignedh l, unsignedh r)
+ {
+ return l.enc() == r.enc();
+ }
+
+ bool operator<=(unsignedh l, unsignedh r)
+ {
+ return l.enc() <= r.enc();
+ }
+
+ bool operator!=(unsignedh l, unsignedh r)
+ {
+ return ! (l == r);
+ }
+
+ bool operator>=(unsignedh l, unsignedh r)
+ {
+ return r <= l;
+ }
+
+ bool operator>(unsignedh l, unsignedh r)
+ {
+ return ! (l <= r);
+ }
+
+ bool operator<(unsignedh l, unsignedh r)
+ {
+ return r > l;
+ }
+
+
+
+// arithmetics
+
+ unsignedh operator+(unsignedh l, unsignedh r)
+ {
+ return unsignedh::make(l.enc() + r.enc());
+ }
+
+ void operator+=(unsignedh& l, unsignedh r)
+ {
+ l = l + r;
+ }
+
+ unsignedh operator-(unsignedh l, unsignedh r)
+ {
+ if (r > l)
+ std::abort();
+ return unsignedh::make(l.enc() - r.enc());
+ }
+
+ void operator-=(unsignedh& l, unsignedh r)
+ {
+ if (r > l)
+ std::abort();
+ l = l - r;
+ }
+
+ unsignedh operator/(unsignedh l, unsigned r)
+ {
+ if (l.enc() % r != 0)
+ std::abort();
+ return unsignedh::make(l.enc() / r);
+ }
+
+
+
+// other ops
+
+ unsignedh min(unsignedh u1, unsignedh u2)
+ {
+ return unsignedh::make(u1.enc() < u2.enc() ? u1.enc() : u2.enc());
+ }
+
+ unsignedh max(unsignedh u1, unsignedh u2)
+ {
+ return unsignedh::make(u1.enc() > u2.enc() ? u1.enc() : u2.enc());
+ }
+
+ unsignedh mean(unsignedh u1, unsignedh u2)
+ {
+ return (u1 + u2) / 2;
+ }
+
+
+// for a transparent use of both unsigned and unsignedh
+// FIXME: is it useful?
+
+ unsigned decode(unsigned u)
+ {
+ return u;
+ }
+
+ void encode(unsigned u, unsigned& dst)
+ {
+ dst = u;
+ }
+
+ unsigned decode(unsignedh u)
+ {
+ return u.enc();
+ }
+
+ void encode(unsigned u, unsignedh& dst)
+ {
+ dst = unsignedh::make(u);
+ }
+
+
+// <<
+
+ std::ostream&
+ operator<<(std::ostream& ostr, const unsignedh& i)
+ {
+ if (i.is_integer())
+ return ostr << i.to_unsigned();
+ else
+ return ostr << floor(i).to_unsigned() << ".5";
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::value
+
+} // end of namespace mln
+
+#endif // ndef UNSIGNEDH_HH
diff --git a/milena/tests/value/Makefile.am b/milena/tests/value/Makefile.am
index 975d471..fb654fa 100644
--- a/milena/tests/value/Makefile.am
+++ b/milena/tests/value/Makefile.am
@@ -31,15 +31,17 @@ check_PROGRAMS = \
interop \
label \
proxy \
+ range \
rgb8 \
scalar \
set \
- sign
-# float01
-# float01_bis
-# float01_f
-# graylevel
-# graylevel_f
+ sign \
+ unsignedh
+# float01
+# float01_bis
+# float01_f
+# graylevel
+# graylevel_f
bool_SOURCES = bool.cc
equiv_SOURCES = equiv.cc
@@ -54,10 +56,12 @@ int_u8_SOURCES = int_u8.cc
interop_SOURCES = interop.cc
label_SOURCES = label.cc
proxy_SOURCES = proxy.cc
+range_SOURCES = range.cc
rgb8_SOURCES = rgb8.cc
scalar_SOURCES = scalar.cc
set_SOURCES = set.cc
sign_SOURCES = sign.cc
+unsignedh_SOURCES = unsignedh.cc
#<<lrde
# FIXME: Not distributed (yet).
diff --git a/milena/tests/world/k1/fill_0_1_faces_internal_border.cc b/milena/tests/value/range.cc
similarity index 61%
copy from milena/tests/world/k1/fill_0_1_faces_internal_border.cc
copy to milena/tests/value/range.cc
index fbb9f73..22421ed 100644
--- a/milena/tests/world/k1/fill_0_1_faces_internal_border.cc
+++ b/milena/tests/value/range.cc
@@ -25,35 +25,47 @@
/// \file
-#include <mln/core/image/image2d.hh>
-#include <mln/make/box2d.hh>
-#include <mln/data/compare.hh>
-#include <mln/world/k1/fill_0_1_faces_internal_border.hh>
+#include <cassert>
+#include <vector>
+#include <algorithm>
+
+#include <mln/value/unsignedh.hh>
+#include <mln/value/range.hh>
+
+static const char *ref[] = { "1", "1.5", "2", "2.5", "3", "3.5", "4", "4.5", "5" };
int main()
{
- using namespace mln;
-
- int refvals[5][5] = {
- {1, 1, 1, 1, 1 },
- {1, 2, 0, 2, 1 },
- {1, 0, 0, 0, 1 },
- {1, 2, 0, 2, 1 },
- {1, 1, 1, 1, 1 }
- };
- image2d<int> ref = make::image(refvals, point2d(-1, -1));
-
- int vals[5][5] = {
- {0, 0, 0, 0, 0 },
- {0, 2, 0, 2, 0 },
- {0, 0, 0, 0, 0 },
- {0, 2, 0, 2, 0 },
- {0, 0, 0, 0, 0 }
- };
- image2d<int> imak1 = make::image(vals, point2d(-1, -1));
+ using namespace mln::value;
+
+ typedef range<unsignedh> R;
+
+ {
+ R r(0, 0);
+ assert(r.is_degenerated());
+ assert(r.length() == 0);
+ assert(r.nelements() == 1);
+ }
+
+ {
+ assert(are_adjacent(R(0,1), R(1+half,2)));
+ }
{
- world::k1::fill_0_1_faces_internal_border(imak1, 1);
- mln_assertion(ref == imak1);
+ std::vector<R> v;
+ v.push_back(R(0,0));
+ std::sort(v.begin(), v.end(), std::less<R>());
}
+
+ {
+ R r(1, 5);
+ assert(!r.is_degenerated());
+ assert(r.length() == 4);
+ assert(r.nelements() == 9);
+
+ int ref_i = 0;
+ for (unsignedh v = r.first(); v != r.last(); v.goto_succ())
+ mln_assertion(static_cast<std::string>(v) == ref[ref_i++]);
+ }
+
}
diff --git a/milena/tests/fun/i2v/array.cc b/milena/tests/value/unsignedh.cc
similarity index 80%
copy from milena/tests/fun/i2v/array.cc
copy to milena/tests/value/unsignedh.cc
index 2633b41..ca98a59 100644
--- a/milena/tests/fun/i2v/array.cc
+++ b/milena/tests/value/unsignedh.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -23,20 +23,22 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#include <mln/fun/i2v/array.hh>
+/// \file
+
+#include <cassert>
+#include <mln/value/unsignedh.hh>
int main()
{
- using namespace mln;
+ using namespace mln::value;
- fun::i2v::array<int> f;
- mln_assertion(f.size() == 0u);
+ unsignedh i = 2;
+ i.goto_succ();
- f.append(0);
- mln_assertion(f(0) == 0);
+ // i == 2.5
+ assert(i == 2 + half);
- f.append(1);
- mln_assertion(f(1) == 1);
- mln_assertion(f.size() == 2u);
+ // (2.5 + 0.5) / 2 == 1.5
+ assert(mean(i, half) == 1 + half);
}
--
1.7.2.5
1
0
olena-2.0-91-g82a0e36 New routines to browse values into a value set.
by Guillaume Lazzara 19 Oct '12
by Guillaume Lazzara 19 Oct '12
19 Oct '12
* mln/accu/label_used.hh,
* mln/core/internal/labeled_image_base.hh,
* mln/labeling/colorize.hh,
* mln/labeling/compute.hh,
* mln/labeling/superpose.hh,
* mln/make/relabelfun.hh,
* mln/set/compute_with_weights.hh,
* mln/value/label.hh,
* mln/value/range.hh: Rename value::next to value::succ.
* mln/value/dec.hh,
* mln/value/inc.hh,
* mln/value/iota.hh,
* mln/value/next.hh,
* mln/value/prev.hh,
* mln/value/succ.hh: New.
---
milena/ChangeLog | 21 ++++++
milena/mln/accu/label_used.hh | 2 +-
milena/mln/core/internal/labeled_image_base.hh | 2 +-
milena/mln/labeling/colorize.hh | 2 +-
milena/mln/labeling/compute.hh | 22 +++---
milena/mln/labeling/superpose.hh | 2 +-
milena/mln/make/relabelfun.hh | 4 +-
milena/mln/set/compute_with_weights.hh | 2 +-
milena/mln/value/{next.hh => dec.hh} | 66 +++++++-------------
milena/mln/value/{next.hh => inc.hh} | 66 +++++++-------------
.../{world/k1/is_0_or_1_face.hh => value/iota.hh} | 59 ++++++++++--------
milena/mln/value/label.hh | 6 +-
milena/mln/value/{next.hh => prev.hh} | 54 ++++++----------
milena/mln/value/range.hh | 4 +-
milena/mln/value/{next.hh => succ.hh} | 51 +++++----------
15 files changed, 161 insertions(+), 202 deletions(-)
copy milena/mln/value/{next.hh => dec.hh} (68%)
copy milena/mln/value/{next.hh => inc.hh} (68%)
copy milena/mln/{world/k1/is_0_or_1_face.hh => value/iota.hh} (64%)
copy milena/mln/value/{next.hh => prev.hh} (69%)
rename milena/mln/value/{next.hh => succ.hh} (72%)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index d66e76f..26ffbf2 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,24 @@
+2012-10-03 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ New routines to browse values into a value set.
+
+ * mln/accu/label_used.hh,
+ * mln/core/internal/labeled_image_base.hh,
+ * mln/labeling/colorize.hh,
+ * mln/labeling/compute.hh,
+ * mln/labeling/superpose.hh,
+ * mln/make/relabelfun.hh,
+ * mln/set/compute_with_weights.hh,
+ * mln/value/label.hh,
+ * mln/value/range.hh: Rename value::next to value::succ.
+
+ * mln/value/dec.hh,
+ * mln/value/inc.hh,
+ * mln/value/iota.hh,
+ * mln/value/next.hh,
+ * mln/value/prev.hh,
+ * mln/value/succ.hh: New.
+
2012-09-28 Guillaume Lazzara <z(a)lrde.epita.fr>
New value types.
diff --git a/milena/mln/accu/label_used.hh b/milena/mln/accu/label_used.hh
index 69121b1..37fb459 100644
--- a/milena/mln/accu/label_used.hh
+++ b/milena/mln/accu/label_used.hh
@@ -118,7 +118,7 @@ namespace mln
label_used<L>::take(const argument& l)
{
if (label_used_.size() <= l)
- label_used_.resize(value::next(l), false);
+ label_used_.resize(value::succ(l), false);
label_used_(l) = true;
}
diff --git a/milena/mln/core/internal/labeled_image_base.hh b/milena/mln/core/internal/labeled_image_base.hh
index 45f3ed2..a80e5b8 100644
--- a/milena/mln/core/internal/labeled_image_base.hh
+++ b/milena/mln/core/internal/labeled_image_base.hh
@@ -281,7 +281,7 @@ namespace mln
labeled_image_base<I,E>::update_data(const fun::i2v::array<mln_value(I)>& relabel_fun)
{
util::array<accu::shape::bbox<mln_psite(I)> >
- new_bboxes(mln::value::next(this->data_->nlabels_));
+ new_bboxes(mln::value::succ(this->data_->nlabels_));
exact(this)->init_update_data_();
diff --git a/milena/mln/labeling/colorize.hh b/milena/mln/labeling/colorize.hh
index ddfbb15..ba876a7 100644
--- a/milena/mln/labeling/colorize.hh
+++ b/milena/mln/labeling/colorize.hh
@@ -198,7 +198,7 @@ namespace mln
// mlc_is_a(mln_value(L), mln::value::Symbolic)::check();
(void) value;
- unsigned label_count = value::next(nlabels);
+ unsigned label_count = value::succ(nlabels);
static fun::i2v::array<V> f(0);
int diff_size = f.size() - label_count;
if (diff_size < 0)
diff --git a/milena/mln/labeling/compute.hh b/milena/mln/labeling/compute.hh
index a9dc791..4ad48b5 100644
--- a/milena/mln/labeling/compute.hh
+++ b/milena/mln/labeling/compute.hh
@@ -211,7 +211,7 @@ namespace mln
const A& a = exact(a_);
const L& label = exact(label_);
- util::array<A> accus(value::next(nlabels), a);
+ util::array<A> accus(value::succ(nlabels), a);
mln_piter(L) p(label.domain());
for_all(p)
@@ -245,12 +245,12 @@ namespace mln
trace::entering("labeling::impl::generic::compute");
internal::compute_tests(A(), label_, nlabels);
- if (value::next(nlabels) != accus.size())
+ if (value::succ(nlabels) != accus.size())
{
accus.resize(0); // Make sure all the accumulators are
// re-initialized when resizing on next
// line.
- accus.resize(value::next(nlabels));
+ accus.resize(value::succ(nlabels));
}
const L& label = exact(label_);
@@ -292,7 +292,7 @@ namespace mln
const I& input = exact(input_);
const L& label = exact(label_);
- util::array<A> accus(value::next(nlabels), a);
+ util::array<A> accus(value::succ(nlabels), a);
mln_piter(I) p(input.domain());
for_all(p)
@@ -331,12 +331,12 @@ namespace mln
const L& label = exact(label_);
(void) nlabels;
- if (value::next(nlabels) != accus.size())
+ if (value::succ(nlabels) != accus.size())
{
accus.resize(0); // Make sure all the accumulators are
// re-initialized when resizing on next
// line.
- accus.resize(value::next(nlabels));
+ accus.resize(value::succ(nlabels));
}
mln_piter(I) p(input.domain());
@@ -384,7 +384,7 @@ namespace mln
// FIXME: check image properties + add doc.
- util::array<A> accus(value::next(nlabels), a);
+ util::array<A> accus(value::succ(nlabels), a);
unsigned ncols = geom::ncols(label);
@@ -439,12 +439,12 @@ namespace mln
const L& label = exact(label_);
(void) nlabels;
- if (value::next(nlabels) != accus.size())
+ if (value::succ(nlabels) != accus.size())
{
accus.resize(0); // Make sure all the accumulators are
// re-initialized when resizing on next
// line.
- accus.resize(value::next(nlabels));
+ accus.resize(value::succ(nlabels));
}
unsigned ncols = geom::ncols(label);
@@ -757,7 +757,7 @@ namespace mln
typedef util::array<mln_result(A)> R;
R res = internal::compute_dispatch(accus, label, nlabels);
- mln_postcondition(res.nelements() == value::next(nlabels));
+ mln_postcondition(res.nelements() == value::succ(nlabels));
trace::exiting("labeling::compute");
return res;
@@ -779,7 +779,7 @@ namespace mln
typedef util::array<mln_result(A)> R;
R res = internal::compute_dispatch(a, label, nlabels);
- mln_postcondition(res.nelements() == value::next(nlabels));
+ mln_postcondition(res.nelements() == value::succ(nlabels));
trace::exiting("labeling::compute");
return res;
diff --git a/milena/mln/labeling/superpose.hh b/milena/mln/labeling/superpose.hh
index 1df647c..e063912 100644
--- a/milena/mln/labeling/superpose.hh
+++ b/milena/mln/labeling/superpose.hh
@@ -98,7 +98,7 @@ namespace mln
mln_concrete(I) output = duplicate(lhs);
util::array<mln_value(J)>
- rebase_lbl(value::next(rhs_nlabels));
+ rebase_lbl(value::succ(rhs_nlabels));
rebase_lbl(0) = 0;
for (unsigned i = 1; i <= rhs_nlabels; ++i)
diff --git a/milena/mln/make/relabelfun.hh b/milena/mln/make/relabelfun.hh
index bc423fb..3ec38cb 100644
--- a/milena/mln/make/relabelfun.hh
+++ b/milena/mln/make/relabelfun.hh
@@ -88,7 +88,7 @@ namespace mln
const F& fv2b = exact(fv2b_);
- unsigned nlabels_i = value::next(nlabels);
+ unsigned nlabels_i = value::succ(nlabels);
V tmp_nlabels = literal::zero;
fun::i2v::array<V> fi2v(nlabels_i, literal::zero);
for (V i = 1; i < nlabels_i; ++i)
@@ -111,7 +111,7 @@ namespace mln
const F& fv2v = exact(fv2v_);
- unsigned nlabels_i = value::next(nlabels);
+ unsigned nlabels_i = value::succ(nlabels);
util::array<V> new_labels(nlabels_i, mln_max(V));
new_labels(0) = literal::zero;
diff --git a/milena/mln/set/compute_with_weights.hh b/milena/mln/set/compute_with_weights.hh
index 24da256..2612498 100644
--- a/milena/mln/set/compute_with_weights.hh
+++ b/milena/mln/set/compute_with_weights.hh
@@ -189,7 +189,7 @@ namespace mln
internal::compute_with_weights_tests(a, w, label);
- util::array<A> accus(value::next(nlabels), a);
+ util::array<A> accus(value::succ(nlabels), a);
mln_piter(I) p(w.domain());
for_all(p)
diff --git a/milena/mln/value/next.hh b/milena/mln/value/dec.hh
similarity index 68%
copy from milena/mln/value/next.hh
copy to milena/mln/value/dec.hh
index b9bc06e..7b0e05b 100644
--- a/milena/mln/value/next.hh
+++ b/milena/mln/value/dec.hh
@@ -24,15 +24,15 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef MLN_VALUE_NEXT_HH
-# define MLN_VALUE_NEXT_HH
+#ifndef MLN_VALUE_DEC_HH
+# define MLN_VALUE_DEC_HH
/// \file
///
-/// Return the next value.
+/// Return the dec value.
+# include <mln/value/iota.hh>
# include <mln/value/label.hh>
-# include <mln/value/unsignedh.hh>
namespace mln
@@ -42,8 +42,8 @@ namespace mln
{
template <typename V>
- V
- next(const V&);
+ void
+ dec(V&);
# ifndef MLN_INCLUDE_ONLY
@@ -58,30 +58,20 @@ namespace mln
{
template <typename V>
- inline
- V
- next(const V& v)
+ void
+ dec(V& v)
{
- return v + 1;
+ v -= mln::value::iota<V>::value();
}
} // end of namespace mln::value::implementation::generic
- template <unsigned n>
- inline
- mln::value::label<n>
- next_label(const mln::value::label<n>& v)
- {
- return v.next();
- }
-
-
- inline
- mln::value::unsignedh
- next_unsignedh(const mln::value::unsignedh& v)
+ template <typename V>
+ void
+ dec_label(V& v)
{
- return mln::value::succ(v);
+ --v;
}
} // end of namespace mln::value::implementation
@@ -94,26 +84,17 @@ namespace mln
{
template <unsigned n>
- inline
- label<n>
- next_dispatch(const label<n>& v)
- {
- return implementation::next_label(v);
- }
-
- inline
- unsignedh
- next_dispatch(const unsignedh& v)
+ void
+ dec_dispatch(label<n>& v)
{
- return implementation::next_unsignedh(v);
+ implementation::dec_label(v);
}
template <typename V>
- inline
- V
- next_dispatch(const V& v)
+ void
+ dec_dispatch(V& v)
{
- return implementation::generic::next(v);
+ implementation::generic::dec(v);
}
} // end of namespace mln::value::internal
@@ -123,11 +104,10 @@ namespace mln
// Facade
template <typename V>
- inline
- V
- next(const V& v)
+ void
+ dec(V& v)
{
- return internal::next_dispatch(v);
+ internal::dec_dispatch(v);
}
@@ -138,4 +118,4 @@ namespace mln
} // end of namespace mln
-#endif // ! MLN_VALUE_NEXT_HH
+#endif // ! MLN_VALUE_DEC_HH
diff --git a/milena/mln/value/next.hh b/milena/mln/value/inc.hh
similarity index 68%
copy from milena/mln/value/next.hh
copy to milena/mln/value/inc.hh
index b9bc06e..80fc625 100644
--- a/milena/mln/value/next.hh
+++ b/milena/mln/value/inc.hh
@@ -24,15 +24,15 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef MLN_VALUE_NEXT_HH
-# define MLN_VALUE_NEXT_HH
+#ifndef MLN_VALUE_INC_HH
+# define MLN_VALUE_INC_HH
/// \file
///
-/// Return the next value.
+/// Return the inc value.
+# include <mln/value/iota.hh>
# include <mln/value/label.hh>
-# include <mln/value/unsignedh.hh>
namespace mln
@@ -42,8 +42,8 @@ namespace mln
{
template <typename V>
- V
- next(const V&);
+ void
+ inc(V&);
# ifndef MLN_INCLUDE_ONLY
@@ -58,30 +58,20 @@ namespace mln
{
template <typename V>
- inline
- V
- next(const V& v)
+ void
+ inc(V& v)
{
- return v + 1;
+ v += mln::value::iota<V>::value();
}
} // end of namespace mln::value::implementation::generic
- template <unsigned n>
- inline
- mln::value::label<n>
- next_label(const mln::value::label<n>& v)
- {
- return v.next();
- }
-
-
- inline
- mln::value::unsignedh
- next_unsignedh(const mln::value::unsignedh& v)
+ template <typename V>
+ void
+ inc_label(V& v)
{
- return mln::value::succ(v);
+ ++v;
}
} // end of namespace mln::value::implementation
@@ -94,26 +84,17 @@ namespace mln
{
template <unsigned n>
- inline
- label<n>
- next_dispatch(const label<n>& v)
- {
- return implementation::next_label(v);
- }
-
- inline
- unsignedh
- next_dispatch(const unsignedh& v)
+ void
+ inc_dispatch(label<n>& v)
{
- return implementation::next_unsignedh(v);
+ implementation::inc_label(v);
}
template <typename V>
- inline
- V
- next_dispatch(const V& v)
+ void
+ inc_dispatch(V& v)
{
- return implementation::generic::next(v);
+ implementation::generic::inc(v);
}
} // end of namespace mln::value::internal
@@ -123,11 +104,10 @@ namespace mln
// Facade
template <typename V>
- inline
- V
- next(const V& v)
+ void
+ inc(V& v)
{
- return internal::next_dispatch(v);
+ internal::inc_dispatch(v);
}
@@ -138,4 +118,4 @@ namespace mln
} // end of namespace mln
-#endif // ! MLN_VALUE_NEXT_HH
+#endif // ! MLN_VALUE_INC_HH
diff --git a/milena/mln/world/k1/is_0_or_1_face.hh b/milena/mln/value/iota.hh
similarity index 64%
copy from milena/mln/world/k1/is_0_or_1_face.hh
copy to milena/mln/value/iota.hh
index 6f3f47a..bdad60c 100644
--- a/milena/mln/world/k1/is_0_or_1_face.hh
+++ b/milena/mln/value/iota.hh
@@ -23,49 +23,58 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
+#ifndef MLN_VALUE_IOTA_HH
+# define MLN_VALUE_IOTA_HH
+
/// \file
///
-/// \brief Check if site is a 1 face.
-
-#ifndef MLN_WORLD_K1_IS_0_OR_1_FACE_HH
-# define MLN_WORLD_K1_IS_0_OR_1_FACE_HH
-
-# include <mln/core/alias/point2d.hh>
-# include <mln/world/k1/internal/face_dim.hh>
-
+/// Define a functor returning the smallest next value in a given
+/// type.
namespace mln
{
- namespace world
+ namespace value
{
- namespace k1
+ /// Define a functor returning the smallest next value in a
+ /// given type.
+ template <typename T>
+ struct iota;
+
+ /// Specialization of \ref mln::value::internal::iota for unsigned.
+ template <>
+ struct iota<unsigned>
{
+ static unsigned value();
+ };
- /// \brief Check if site is a 1 face
- bool is_0_or_1_face(const point2d& p);
+ /// Specialization of \ref mln::value::internal::iota for int.
+ template <>
+ struct iota<int>
+ {
+ static int value();
+ };
# ifndef MLN_INCLUDE_ONLY
+ unsigned
+ iota<unsigned>::value()
+ {
+ return 1u;
+ }
- // Facade
-
- inline
- bool is_0_or_1_face(const point2d& p)
- {
- unsigned dim = internal::face_dim(p);
- return dim == 0 || dim == 1;
- }
-
+ int
+ iota<int>::value()
+ {
+ return 1;
+ }
# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace mln::world::k1
-
- } // end of namespace mln::world
+ } // end of namespace mln::value
} // end of namespace mln
-#endif // ! MLN_WORLD_K1_IS_0_OR_1_FACE_HH
+#endif // MLN_VALUE_IOTA_HH
diff --git a/milena/mln/value/label.hh b/milena/mln/value/label.hh
index dd0f924..a28889f 100644
--- a/milena/mln/value/label.hh
+++ b/milena/mln/value/label.hh
@@ -136,8 +136,8 @@ namespace mln
/// Self decrement.
label<n>& operator--();
- /// Return the next value.
- label<n> next() const;
+ /// Return the successive value.
+ label<n> succ() const;
/// Return the previous value.
label<n> prev() const;
@@ -260,7 +260,7 @@ namespace mln
template <unsigned n>
inline
label<n>
- label<n>::next() const
+ label<n>::succ() const
{
return label<n>(this->v_ + 1);
}
diff --git a/milena/mln/value/next.hh b/milena/mln/value/prev.hh
similarity index 69%
copy from milena/mln/value/next.hh
copy to milena/mln/value/prev.hh
index b9bc06e..93221c5 100644
--- a/milena/mln/value/next.hh
+++ b/milena/mln/value/prev.hh
@@ -1,5 +1,4 @@
-// Copyright (C) 2010, 2012 EPITA Research and Development Laboratory
-// (LRDE)
+// Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -24,15 +23,15 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef MLN_VALUE_NEXT_HH
-# define MLN_VALUE_NEXT_HH
+#ifndef MLN_VALUE_PREV_HH
+# define MLN_VALUE_PREV_HH
/// \file
///
-/// Return the next value.
+/// Return the prev value.
+# include <mln/value/iota.hh>
# include <mln/value/label.hh>
-# include <mln/value/unsignedh.hh>
namespace mln
@@ -43,7 +42,7 @@ namespace mln
template <typename V>
V
- next(const V&);
+ prev(const V&);
# ifndef MLN_INCLUDE_ONLY
@@ -60,28 +59,20 @@ namespace mln
template <typename V>
inline
V
- next(const V& v)
+ prev(const V& v)
{
- return v + 1;
+ return v - mln::value::iota<V>::value();
}
} // end of namespace mln::value::implementation::generic
- template <unsigned n>
- inline
- mln::value::label<n>
- next_label(const mln::value::label<n>& v)
- {
- return v.next();
- }
-
-
+ template <typename V>
inline
- mln::value::unsignedh
- next_unsignedh(const mln::value::unsignedh& v)
+ V
+ prev_method(const V& v)
{
- return mln::value::succ(v);
+ return v.prev();
}
} // end of namespace mln::value::implementation
@@ -96,24 +87,17 @@ namespace mln
template <unsigned n>
inline
label<n>
- next_dispatch(const label<n>& v)
- {
- return implementation::next_label(v);
- }
-
- inline
- unsignedh
- next_dispatch(const unsignedh& v)
+ prev_dispatch(const label<n>& v)
{
- return implementation::next_unsignedh(v);
+ return implementation::prev_method(v);
}
template <typename V>
inline
V
- next_dispatch(const V& v)
+ prev_dispatch(const V& v)
{
- return implementation::generic::next(v);
+ return implementation::generic::prev(v);
}
} // end of namespace mln::value::internal
@@ -125,9 +109,9 @@ namespace mln
template <typename V>
inline
V
- next(const V& v)
+ prev(const V& v)
{
- return internal::next_dispatch(v);
+ return internal::prev_dispatch(v);
}
@@ -138,4 +122,4 @@ namespace mln
} // end of namespace mln
-#endif // ! MLN_VALUE_NEXT_HH
+#endif // ! MLN_VALUE_PREV_HH
diff --git a/milena/mln/value/range.hh b/milena/mln/value/range.hh
index ca8f2f4..5c90de7 100644
--- a/milena/mln/value/range.hh
+++ b/milena/mln/value/range.hh
@@ -233,7 +233,7 @@ namespace mln
{
unsigned n = 1;
T v = lower_;
- for (; v != upper_; v = value::next(v))
+ for (; v != upper_; v = value::succ(v))
n += 1;
return n;
@@ -323,7 +323,7 @@ namespace mln
are_adjacent(const range<T>& r1, const range<T>& r2)
{
return span(r1, r2).length() == r1.length() + r2.length()
- + (value::next(r2.lower()) - r2.lower());
+ + (value::succ(r2.lower()) - r2.lower());
}
template <typename T>
diff --git a/milena/mln/value/next.hh b/milena/mln/value/succ.hh
similarity index 72%
rename from milena/mln/value/next.hh
rename to milena/mln/value/succ.hh
index b9bc06e..4877727 100644
--- a/milena/mln/value/next.hh
+++ b/milena/mln/value/succ.hh
@@ -24,15 +24,15 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef MLN_VALUE_NEXT_HH
-# define MLN_VALUE_NEXT_HH
+#ifndef MLN_VALUE_SUCC_HH
+# define MLN_VALUE_SUCC_HH
/// \file
///
-/// Return the next value.
+/// Return the succ value.
+# include <mln/value/iota.hh>
# include <mln/value/label.hh>
-# include <mln/value/unsignedh.hh>
namespace mln
@@ -43,7 +43,7 @@ namespace mln
template <typename V>
V
- next(const V&);
+ succ(const V&);
# ifndef MLN_INCLUDE_ONLY
@@ -60,28 +60,20 @@ namespace mln
template <typename V>
inline
V
- next(const V& v)
+ succ(const V& v)
{
- return v + 1;
+ return v + mln::value::iota<V>::value();
}
} // end of namespace mln::value::implementation::generic
- template <unsigned n>
- inline
- mln::value::label<n>
- next_label(const mln::value::label<n>& v)
- {
- return v.next();
- }
-
-
+ template <typename V>
inline
- mln::value::unsignedh
- next_unsignedh(const mln::value::unsignedh& v)
+ V
+ succ_method(const V& v)
{
- return mln::value::succ(v);
+ return v.succ();
}
} // end of namespace mln::value::implementation
@@ -96,24 +88,17 @@ namespace mln
template <unsigned n>
inline
label<n>
- next_dispatch(const label<n>& v)
- {
- return implementation::next_label(v);
- }
-
- inline
- unsignedh
- next_dispatch(const unsignedh& v)
+ succ_dispatch(const label<n>& v)
{
- return implementation::next_unsignedh(v);
+ return implementation::succ_method(v);
}
template <typename V>
inline
V
- next_dispatch(const V& v)
+ succ_dispatch(const V& v)
{
- return implementation::generic::next(v);
+ return implementation::generic::succ(v);
}
} // end of namespace mln::value::internal
@@ -125,9 +110,9 @@ namespace mln
template <typename V>
inline
V
- next(const V& v)
+ succ(const V& v)
{
- return internal::next_dispatch(v);
+ return internal::succ_dispatch(v);
}
@@ -138,4 +123,4 @@ namespace mln
} // end of namespace mln
-#endif // ! MLN_VALUE_NEXT_HH
+#endif // ! MLN_VALUE_SUCC_HH
--
1.7.2.5
1
0
* mln/value/unsignedh.hh,
* tests/value/unsignedh.cc: Remove.
* mln/value/intsub.hh,
* tests/value/intsub.cc: New.
* tests/value/Makefile.am: Change target name.
---
milena/ChangeLog | 12 +
milena/mln/value/intsub.hh | 569 ++++++++++++++++++++++++
milena/mln/value/unsignedh.hh | 415 -----------------
milena/tests/value/Makefile.am | 4 +-
milena/tests/value/{unsignedh.cc => intsub.cc} | 46 ++-
5 files changed, 623 insertions(+), 423 deletions(-)
create mode 100644 milena/mln/value/intsub.hh
delete mode 100644 milena/mln/value/unsignedh.hh
rename milena/tests/value/{unsignedh.cc => intsub.cc} (65%)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 26ffbf2..3f2a4c2 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,17 @@
2012-10-03 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Replace unsignedh type by intsub.
+
+ * mln/value/unsignedh.hh,
+ * tests/value/unsignedh.cc: Remove.
+
+ * mln/value/intsub.hh,
+ * tests/value/intsub.cc: New.
+
+ * tests/value/Makefile.am: Change target name.
+
+2012-10-03 Guillaume Lazzara <z(a)lrde.epita.fr>
+
New routines to browse values into a value set.
* mln/accu/label_used.hh,
diff --git a/milena/mln/value/intsub.hh b/milena/mln/value/intsub.hh
new file mode 100644
index 0000000..fc269a8
--- /dev/null
+++ b/milena/mln/value/intsub.hh
@@ -0,0 +1,569 @@
+// Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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_VALUE_INTSUB_HH
+# define MLN_VALUE_INTSUB_HH
+
+/// \file
+///
+/// Define a subdivided integer value class.
+
+# include <cstdlib>
+# include <iostream>
+# include <sstream>
+# include <mln/value/internal/value_like.hh>
+# include <mln/value/internal/encoding.hh>
+# include <mln/value/internal/limits.hh>
+# include <mln/value/concept/integer.hh>
+# include <mln/value/iota.hh>
+# include <mln/value/prev.hh>
+# include <mln/value/succ.hh>
+
+
+namespace mln
+{
+
+ // Forward declaration
+ namespace value {
+ template <unsigned n> class intsub;
+ }
+
+ namespace trait
+ {
+
+ template <unsigned n>
+ struct set_precise_unary_< op::uminus, mln::value::intsub<n> >
+ {
+ typedef mln::value::intsub<n> ret;
+ };
+
+
+ template <unsigned n>
+ struct value_< mln::value::intsub<n> >
+ {
+ private:
+ typedef mln::value::intsub<n> self_;
+ typedef typename mln::value::internal::encoding_signed_<32>::ret enc_;
+ public:
+
+ enum constants_ {
+ dim = 1,
+ nbits = 32,
+ card = mln_value_card_from_(32/n) // FIXME: Really?
+ };
+
+ typedef trait::value::nature::integer nature;
+ typedef trait::value::kind::data kind;
+ typedef mln_value_quant_from_(card) quant;
+
+ static const self_ max() { return mln::value::internal::limits<int>::max() / n; }
+ static const self_ min() { return - max(); }
+ static const self_ epsilon() { return 0; }
+
+ typedef mln::value::intsub<n> comp;
+
+ typedef mln::value::intsub<n> sum;
+
+ static const char* name()
+ {
+ static std::string
+ s = mln::value::internal::make_generic_name("intsub", n);
+ return s.c_str();
+ }
+
+ };
+
+ } // end of namespace mln::trait
+
+
+
+ namespace value
+ {
+
+ template <unsigned n>
+ class intsub
+ : public Integer< intsub<n> >,
+ public internal::value_like_< int, // Equivalent.
+ typename internal::encoding_signed_<32>::ret, // Enc.
+ int, // Interoperation.
+ intsub<n> > // Exact.
+ {
+ public:
+ intsub();
+ intsub(const intsub<n>& rhs);
+ /// Construct an intsub with value : \p int_part + 1 / \p denominator.
+ intsub(int int_part, unsigned denominator);
+ intsub(int i);
+
+ intsub<n>& operator=(const intsub<n>& rhs);
+ intsub<n>& operator=(int i);
+
+ /// Is an integer value.
+ bool is_integer() const;
+
+ /// Convert this intsub to a larger intsub type.
+ template <unsigned m>
+ operator intsub<m>();
+
+ /*! \internal Increment by value::iota::value() the
+ value to the next one.
+ */
+ void inc_();
+ /*! \internal Decrement by value::iota::value() the
+ value to the next one.
+ */
+ void dec_();
+
+ /*!\internal Return the integer part of this value.
+ */
+ int to_int() const;
+
+ /*!\internal Construct a intsub using an encoding value. */
+ static intsub<n> make_from_enc_(int enc);
+
+ /// Unary operator minus.
+ intsub<n> operator-() const;
+
+ };
+
+
+ // Safety
+ template <> struct intsub<0>;
+
+// rounding
+
+ template <unsigned n>
+ intsub<n> floor(const intsub<n>& i);
+ template <unsigned n>
+ intsub<n> ceil(const intsub<n>& i);
+
+
+// comparison
+
+ template <unsigned n>
+ bool operator==(const intsub<n>& l, const intsub<n>& r);
+ template <unsigned n, typename V>
+ bool operator==(const intsub<n>& l, const V& r);
+ template <unsigned n>
+ bool operator<=(const intsub<n>& l, const intsub<n>& r);
+ template <unsigned n>
+ bool operator!=(const intsub<n>& l, const intsub<n>& r);
+ template <unsigned n>
+ bool operator>=(const intsub<n>& l, const intsub<n>& r);
+ template <unsigned n>
+ bool operator>(const intsub<n>& l, const intsub<n>& r);
+ template <unsigned n>
+ bool operator<(const intsub<n>& l, const intsub<n>& r);
+
+// arithmetics
+
+ template <unsigned n>
+ intsub<n> operator+(const intsub<n>& l, const intsub<n>& r);
+ template <unsigned n, typename O>
+ intsub<n> operator+(const intsub<n>& l, const O& r);
+ template <typename O, unsigned n>
+ intsub<n> operator+(const O& r, const intsub<n>& l);
+ template <unsigned n>
+ void operator+=(intsub<n>& l, const intsub<n>& r);
+ template <unsigned n, typename O>
+ void operator+=(intsub<n>& l, const O& r);
+
+ template <unsigned n>
+ intsub<n> operator-(const intsub<n>& l, const intsub<n>& r);
+ template <unsigned n, typename O>
+ intsub<n> operator-(const intsub<n>& l, const O& r);
+ template <typename O, unsigned n>
+ intsub<n> operator-(const O& r, const intsub<n>& l);
+ template <unsigned n>
+ void operator-=(intsub<n>& l, const intsub<n>& r);
+ template <unsigned n, typename O>
+ void operator-=(intsub<n>& l, const O& r);
+
+ template <unsigned n>
+ intsub<n> operator*(const intsub<n>& l, const intsub<n>& r);
+ template <unsigned n, typename O>
+ intsub<n> operator*(const intsub<n>& l, const O& r);
+ template <typename O, unsigned n>
+ intsub<n> operator*(const O& r, const intsub<n>& l);
+ template <unsigned n>
+ void operator*=(intsub<n>& l, const intsub<n>& r);
+ template <unsigned n, typename O>
+ void operator*=(intsub<n>& l, const O& r);
+
+// other ops
+
+ template <unsigned n>
+ intsub<n> min(const intsub<n>& u1, const intsub<n>& u2);
+ template <unsigned n>
+ intsub<n> max(const intsub<n>& u1, const intsub<n>& u2);
+ template <unsigned n>
+ intsub<n> mean(const intsub<n>& v1, const intsub<n>& v2);
+ template <unsigned n>
+ intsub<n> mean(const intsub<n>& v1, const intsub<n>& v2,
+ const intsub<n>& v3, const intsub<n>& v4);
+
+// <<
+
+ template <unsigned n>
+ std::ostream&
+ operator<<(std::ostream& ostr, const intsub<n>& i);
+
+ template <unsigned n>
+ struct iota<intsub<n> >
+ {
+ static intsub<n> value();
+ };
+
+ } // end of namespace mln::value
+
+ extern const value::intsub<2> half;
+ extern const value::intsub<4> quarter;
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ // half
+
+# ifndef MLN_WO_GLOBAL_VARS
+
+ const value::intsub<2> half = value::intsub<2>(0, 2);
+ const value::intsub<4> quarter = value::intsub<4>(0, 4);
+
+# endif // ! MLN_WO_GLOBAL_VARS
+
+
+
+ namespace value
+ {
+
+ template <unsigned n>
+ intsub<n>::intsub()
+ {
+ }
+
+ template <unsigned n>
+ intsub<n>::intsub(const intsub<n>& rhs)
+ {
+ this->v_ = rhs.v_;
+ }
+
+ template <unsigned n>
+ intsub<n>::intsub(int i)
+ {
+ this->v_ = n * i;
+ }
+
+ template <unsigned n>
+ intsub<n>::intsub(int int_part, unsigned denominator)
+ {
+ // FIXME: better error handling ?
+ if (denominator > n)
+ std::abort();
+
+ this->v_ = int_part * n + denominator / n;
+ }
+
+
+ template <unsigned n>
+ intsub<n>&
+ intsub<n>::operator=(const intsub<n>& rhs)
+ {
+ this->v_ = rhs.v_;
+ return *this;
+ }
+
+ template <unsigned n>
+ intsub<n>&
+ intsub<n>::operator=(int i)
+ {
+ this->v_ = n * i;
+ return *this;
+ }
+
+ template <unsigned n>
+ intsub<n> intsub<n>::make_from_enc_(int enc)
+ {
+ intsub<n> i;
+ i.v_ = enc;
+ return i;
+ }
+
+ template <unsigned n>
+ bool
+ intsub<n>::is_integer() const
+ {
+ return this->v_ % n == 0;
+ }
+
+ template <unsigned n>
+ template <unsigned m>
+ intsub<n>::operator intsub<m>()
+ {
+ // FIXME: better error handling ?
+ if (n > m)
+ std::abort();
+ return intsub<m>::make_from_enc_(this->v_ * (m / n));
+ }
+
+ template <unsigned n>
+ void
+ intsub<n>::inc_()
+ {
+ this->v_ += iota<intsub<n> >::value().to_enc();
+ }
+
+ template <unsigned n>
+ void
+ intsub<n>::dec_()
+ {
+ this->v_ -= iota<intsub<n> >::value().to_enc();
+ }
+
+ template <unsigned n>
+ int
+ intsub<n>::to_int() const
+ {
+ return this->v_ / n;
+ }
+
+ template <unsigned n>
+ intsub<n>
+ intsub<n>::operator-() const
+ {
+ return intsub<n>::make_from_enc_(this->v_ * -1);
+ }
+
+ // Iota
+ template <unsigned n>
+ intsub<n>
+ iota<intsub<n> >::value()
+ {
+ return intsub<n>(0,n);
+ }
+
+
+// rounding
+
+
+ template <unsigned n>
+ intsub<n> floor(const intsub<n>& i)
+ {
+ return i.is_integer() ? i : value::prev(i);
+ }
+
+ template <unsigned n>
+ intsub<n> ceil(const intsub<n>& i)
+ {
+ return i.is_integer() ? i : value::succ(i);
+ }
+
+
+
+// comparison
+
+ template <unsigned n>
+ bool operator==(const intsub<n>& l, const intsub<n>& r)
+ {
+ return l.to_enc() == r.to_enc();
+ }
+
+ template <unsigned n>
+ bool operator==(const intsub<n>& l, const int& r)
+ {
+ return l == intsub<n>(r);
+ }
+
+ template <unsigned n>
+ bool operator<=(const intsub<n>& l, const intsub<n>& r)
+ {
+ return l.to_enc() <= r.to_enc();
+ }
+
+ template <unsigned n>
+ bool operator!=(const intsub<n>& l, const intsub<n>& r)
+ {
+ return ! (l == r);
+ }
+
+ template <unsigned n>
+ bool operator>=(const intsub<n>& l, const intsub<n>& r)
+ {
+ return r <= l;
+ }
+
+ template <unsigned n>
+ bool operator>(const intsub<n>& l, const intsub<n>& r)
+ {
+ return ! (l <= r);
+ }
+
+ template <unsigned n>
+ bool operator<(const intsub<n>& l, const intsub<n>& r)
+ {
+ return r > l;
+ }
+
+
+// arithmetics
+
+ template <unsigned n>
+ intsub<n> operator+(const intsub<n>& l, const intsub<n>& r)
+ {
+ return intsub<n>::make_from_enc_(l.to_enc() + r.to_enc());
+ }
+
+ template <unsigned n>
+ intsub<n> operator+(const intsub<n>& l, int r)
+ {
+ return l + intsub<n>(r);
+ }
+
+ template <unsigned n>
+ intsub<n> operator+(int l, const intsub<n>& r)
+ {
+ return r + l;
+ }
+
+ template <unsigned n>
+ void operator+=(intsub<n>& l, const intsub<n>& r)
+ {
+ l = l + r;
+ }
+
+ template <unsigned n>
+ void operator+=(intsub<n>& l, int r)
+ {
+ l = l + intsub<n>(r);
+ }
+
+ template <unsigned n>
+ intsub<n> operator-(const intsub<n>& l, const intsub<n>& r)
+ {
+ return intsub<n>::make_from_enc_(l.to_enc() - r.to_enc());
+ }
+
+ template <unsigned n>
+ intsub<n> operator-(const intsub<n>& l, int r)
+ {
+ return l - intsub<n>(r);
+ }
+
+ template <unsigned n>
+ intsub<n> operator-(int l, const intsub<n>& r)
+ {
+ return - r + l;
+ }
+
+ template <unsigned n>
+ void operator-=(intsub<n>& l, const intsub<n>& r)
+ {
+ l = l - r;
+ }
+
+ template <unsigned n>
+ void operator-=(intsub<n>& l, int r)
+ {
+ l = l - intsub<n>(r);
+ }
+
+ template <unsigned n>
+ intsub<n> operator*(const intsub<n>& l, const intsub<n>& r)
+ {
+ return intsub<n>::make_from_enc_(l.to_enc() * r.to_enc() / n);
+ }
+
+ template <unsigned n>
+ intsub<n> operator*(const intsub<n>& l, int r)
+ {
+ return l * intsub<n>(r);
+ }
+
+ template <unsigned n>
+ intsub<n> operator*(int l, const intsub<n>& r)
+ {
+ return r * l;
+ }
+
+ template <unsigned n>
+ void operator*=(intsub<n>& l, const intsub<n>& r)
+ {
+ l = l * r;
+ }
+
+ template <unsigned n>
+ void operator*=(intsub<n>& l, int r)
+ {
+ l = l * intsub<n>(r);
+ }
+
+
+// other ops
+
+ template <unsigned n>
+ intsub<n> min(const intsub<n>& v1, const intsub<n>& v2)
+ {
+ return intsub<n>::make_from_enc_(v1.to_enc() < v2.to_enc() ? v1.to_enc() : v2.to_enc());
+ }
+
+ template <unsigned n>
+ intsub<n> max(const intsub<n>& v1, const intsub<n>& v2)
+ {
+ return intsub<n>::make_from_enc_(v1.to_enc() > v2.to_enc() ? v1.to_enc() : v2.to_enc());
+ }
+
+ template <unsigned n>
+ intsub<n> mean(const intsub<n>& v1, const intsub<n>& v2)
+ {
+ return intsub<n>::make_from_enc_((v1.to_enc() + v2.to_enc()) / 2);
+ }
+
+ template <unsigned n>
+ intsub<n> mean(const intsub<n>& v1, const intsub<n>& v2,
+ const intsub<n>& v3, const intsub<n>& v4)
+ {
+ return intsub<n>::make_from_enc_((v1.to_enc() + v2.to_enc()
+ + v3.to_enc() + v4.to_enc()) / 4);
+ }
+
+
+// <<
+
+ template <unsigned n>
+ std::ostream&
+ operator<<(std::ostream& ostr, const intsub<n>& i)
+ {
+ if (i.is_integer())
+ return ostr << i.to_int();
+ else
+ return ostr << floor(i).to_int() << ".5";
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::value
+
+} // end of namespace mln
+
+#endif // ! MLN_VALUE_INTSUB_HH
diff --git a/milena/mln/value/unsignedh.hh b/milena/mln/value/unsignedh.hh
deleted file mode 100644
index 1f0281c..0000000
--- a/milena/mln/value/unsignedh.hh
+++ /dev/null
@@ -1,415 +0,0 @@
-// Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)
-//
-// This file is part of Olena.
-//
-// Olena is free software: you can redistribute it and/or modify it under
-// the terms of the GNU General Public License as published by the Free
-// Software Foundation, version 2 of the License.
-//
-// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
-//
-// As a special exception, you may use this file as part of a free
-// software project 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_VALUE_UNSIGNEDH_HH
-# define MLN_VALUE_UNSIGNEDH_HH
-
-/// \file
-///
-/// Define a semi-unsigned value class.
-
-# include <cstdlib>
-# include <iostream>
-# include <sstream>
-
-// FIXME: parameterize unsignedh so that we also can have
-// Z/4 and so on...
-
-namespace mln
-{
-
- namespace value
- {
-
-
- class unsignedh
- {
- public:
- unsignedh();
- unsignedh(const unsignedh& rhs);
- unsignedh(unsigned i);
- unsignedh(int i);
-
- unsignedh& operator=(const unsignedh& rhs);
- unsignedh& operator=(unsigned i);
- unsignedh& operator=(int i);
-
- unsigned enc() const;
-
- /// Construct an unsignedh with value v
- static unsignedh make(unsigned v);
- /// Construct an unsignedh with value v. The given value is
- /// rounded to the closest integer or half value.
-// static unsignedh make(float v);
-
- bool is_integer() const;
-
- unsigned to_unsigned() const;
-
- /// Set this unsignedh to its next value and return itself.
- unsignedh& goto_succ();
-
- /// Set this unsignedh to its previous value and return itself.
- unsignedh& goto_pred();
-
- operator std::string() const;
-
- private:
- unsigned enc_;
- };
-
-
- extern const unsignedh half;
-
-
-// next
-
- unsignedh succ(unsignedh i);
- unsignedh pred(unsignedh i);
-
-// rounding
-
- unsignedh floor(unsignedh i);
- unsignedh ceil(unsignedh i);
-
-
-// comparison
-
- bool operator==(unsignedh l, unsignedh r);
- bool operator<=(unsignedh l, unsignedh r);
- bool operator!=(unsignedh l, unsignedh r);
- bool operator>=(unsignedh l, unsignedh r);
- bool operator>(unsignedh l, unsignedh r);
- bool operator<(unsignedh l, unsignedh r);
-
-// arithmetics
-
- unsignedh operator+(unsignedh l, unsignedh r);
- void operator+=(unsignedh& l, unsignedh r);
- unsignedh operator-(unsignedh l, unsignedh r);
- void operator-=(unsignedh& l, unsignedh r);
- unsignedh operator/(unsignedh l, unsigned r);
-
-// other ops
-
- unsignedh min(unsignedh u1, unsignedh u2);
- unsignedh max(unsignedh u1, unsignedh u2);
- unsignedh mean(unsignedh u1, unsignedh u2);
-
-// for a transparent use of both unsigned and unsignedh
-// FIXME: is it useful?
-
- unsigned decode(unsigned u);
- void encode(unsigned u, unsigned& dst);
- unsigned decode(unsignedh u);
- void encode(unsigned u, unsignedh& dst);
-
-// <<
-
- std::ostream&
- operator<<(std::ostream& ostr, const unsignedh& i);
-
-
-# ifndef MLN_INCLUDE_ONLY
-
- inline
- unsignedh::unsignedh()
- {
- }
-
- inline
- unsignedh::unsignedh(const unsignedh& rhs)
- : enc_(rhs.enc_)
- {
- }
-
-
- inline
- unsignedh::unsignedh(unsigned i)
- {
- enc_ = 2 * i;
- }
-
- inline
- unsignedh::unsignedh(int i)
- {
- if (i < 0)
- std::abort();
- enc_ = 2 * i;
- }
-
- inline
- unsignedh&
- unsignedh::operator=(const unsignedh& rhs)
- {
- enc_ = rhs.enc_;
- return *this;
- }
-
- inline
- unsignedh&
- unsignedh::operator=(unsigned i)
- {
- enc_ = 2 * i;
- return *this;
- }
-
- inline
- unsignedh&
- unsignedh::operator=(int i)
- {
- if (i < 0)
- std::abort();
- enc_ = 2 * i;
- return *this;
- }
-
- inline
- unsigned
- unsignedh::enc() const
- {
- return enc_;
- }
-
- inline
- unsignedh unsignedh::make(unsigned enc)
- {
- unsignedh i;
- i.enc_ = enc;
- return i;
- }
-
- inline
- bool
- unsignedh::is_integer() const
- {
- return enc_ % 2 == 0;
- }
-
- inline
- unsigned
- unsignedh::to_unsigned() const
- {
- if (! this->is_integer())
- std::abort();
- return enc_ / 2;
- }
-
- inline
- unsignedh&
- unsignedh::goto_succ()
- {
- enc_ += 1;
- return *this;
- }
-
- inline
- unsignedh&
- unsignedh::goto_pred()
- {
- if (enc_ == 0)
- std::abort();
- enc_ -= 1;
- return *this;
- }
-
- inline
- unsignedh::operator std::string() const
- {
- std::stringstream s;
- s << *this;
- return s.str();
- }
-
-
-
-// half
-
-# ifndef MLN_WO_GLOBAL_VARS
-
- const unsignedh half = unsignedh::make(1u);
-
-# endif // ! MLN_WO_GLOBAL_VARS
-
-
-// next
-
- unsignedh succ(unsignedh i)
- {
- return unsignedh::make(i.enc() + 1);
- }
-
- unsignedh pred(unsignedh i)
- {
- if (i.enc() == 0)
- std::abort();
- return unsignedh::make(i.enc() - 1);
- }
-
-
-
-// rounding
-
- unsignedh floor(unsignedh i)
- {
- return i.is_integer() ? i : pred(i);
- }
-
- unsignedh ceil(unsignedh i)
- {
- return i.is_integer() ? i : succ(i);
- }
-
-
-
-// comparison
-
- bool operator==(unsignedh l, unsignedh r)
- {
- return l.enc() == r.enc();
- }
-
- bool operator<=(unsignedh l, unsignedh r)
- {
- return l.enc() <= r.enc();
- }
-
- bool operator!=(unsignedh l, unsignedh r)
- {
- return ! (l == r);
- }
-
- bool operator>=(unsignedh l, unsignedh r)
- {
- return r <= l;
- }
-
- bool operator>(unsignedh l, unsignedh r)
- {
- return ! (l <= r);
- }
-
- bool operator<(unsignedh l, unsignedh r)
- {
- return r > l;
- }
-
-
-
-// arithmetics
-
- unsignedh operator+(unsignedh l, unsignedh r)
- {
- return unsignedh::make(l.enc() + r.enc());
- }
-
- void operator+=(unsignedh& l, unsignedh r)
- {
- l = l + r;
- }
-
- unsignedh operator-(unsignedh l, unsignedh r)
- {
- if (r > l)
- std::abort();
- return unsignedh::make(l.enc() - r.enc());
- }
-
- void operator-=(unsignedh& l, unsignedh r)
- {
- if (r > l)
- std::abort();
- l = l - r;
- }
-
- unsignedh operator/(unsignedh l, unsigned r)
- {
- if (l.enc() % r != 0)
- std::abort();
- return unsignedh::make(l.enc() / r);
- }
-
-
-
-// other ops
-
- unsignedh min(unsignedh u1, unsignedh u2)
- {
- return unsignedh::make(u1.enc() < u2.enc() ? u1.enc() : u2.enc());
- }
-
- unsignedh max(unsignedh u1, unsignedh u2)
- {
- return unsignedh::make(u1.enc() > u2.enc() ? u1.enc() : u2.enc());
- }
-
- unsignedh mean(unsignedh u1, unsignedh u2)
- {
- return (u1 + u2) / 2;
- }
-
-
-// for a transparent use of both unsigned and unsignedh
-// FIXME: is it useful?
-
- unsigned decode(unsigned u)
- {
- return u;
- }
-
- void encode(unsigned u, unsigned& dst)
- {
- dst = u;
- }
-
- unsigned decode(unsignedh u)
- {
- return u.enc();
- }
-
- void encode(unsigned u, unsignedh& dst)
- {
- dst = unsignedh::make(u);
- }
-
-
-// <<
-
- std::ostream&
- operator<<(std::ostream& ostr, const unsignedh& i)
- {
- if (i.is_integer())
- return ostr << i.to_unsigned();
- else
- return ostr << floor(i).to_unsigned() << ".5";
- }
-
-# endif // ! MLN_INCLUDE_ONLY
-
- } // end of namespace mln::value
-
-} // end of namespace mln
-
-#endif // ndef UNSIGNEDH_HH
diff --git a/milena/tests/value/Makefile.am b/milena/tests/value/Makefile.am
index fb654fa..8d6718f 100644
--- a/milena/tests/value/Makefile.am
+++ b/milena/tests/value/Makefile.am
@@ -36,7 +36,7 @@ check_PROGRAMS = \
scalar \
set \
sign \
- unsignedh
+ intsub
# float01
# float01_bis
# float01_f
@@ -61,7 +61,7 @@ rgb8_SOURCES = rgb8.cc
scalar_SOURCES = scalar.cc
set_SOURCES = set.cc
sign_SOURCES = sign.cc
-unsignedh_SOURCES = unsignedh.cc
+intsub_SOURCES = intsub.cc
#<<lrde
# FIXME: Not distributed (yet).
diff --git a/milena/tests/value/unsignedh.cc b/milena/tests/value/intsub.cc
similarity index 65%
rename from milena/tests/value/unsignedh.cc
rename to milena/tests/value/intsub.cc
index ca98a59..e324fe3 100644
--- a/milena/tests/value/unsignedh.cc
+++ b/milena/tests/value/intsub.cc
@@ -26,19 +26,53 @@
/// \file
#include <cassert>
-#include <mln/value/unsignedh.hh>
-
+#include <mln/value/intsub.hh>
+#include <mln/value/inc.hh>
+#include <mln/value/dec.hh>
+#include <mln/value/succ.hh>
+#include <mln/value/prev.hh>
+#include <mln/math/mean.hh>
int main()
{
+ using namespace mln;
using namespace mln::value;
- unsignedh i = 2;
- i.goto_succ();
+ // i == 2
+ intsub<2> i = 2;
+ inc(i);
// i == 2.5
- assert(i == 2 + half);
+ mln_assertion(i == half + 2);
// (2.5 + 0.5) / 2 == 1.5
- assert(mean(i, half) == 1 + half);
+ mln_assertion(mean(i, half) == 1 + half);
+
+ // i == 3
+ inc(i);
+ mln_assertion(i == intsub<2>(3));
+
+ // i == 2.5
+ dec(i);
+ mln_assertion(i == intsub<2>(2,2));
+ dec(i);
+
+ // i == 2.5
+ mln_assertion(succ(i) == 2 + half);
+
+ // i == 1.5
+ mln_assertion(prev(i) == 2 - half);
+
+ // i == 6
+ i *= 3;
+ mln_assertion(i == 6);
+
+ // j = 6
+ intsub<4> j = i;
+ mln_assertion(j == 6);
+
+ // j = 6.25
+ inc(j);
+ mln_assertion(j == 6 + quarter);
+
}
--
1.7.2.5
1
0
19 Oct '12
---
milena/ChangeLog | 4 ++++
milena/tests/world/k1/Makefile.am | 2 +-
2 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 3f2a4c2..0b2e2cf 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,9 @@
2012-10-03 Guillaume Lazzara <z(a)lrde.epita.fr>
+ * tests/world/k1/Makefile.am: Fix target names.
+
+2012-10-03 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Replace unsignedh type by intsub.
* mln/value/unsignedh.hh,
diff --git a/milena/tests/world/k1/Makefile.am b/milena/tests/world/k1/Makefile.am
index 0027267..598d8dd 100644
--- a/milena/tests/world/k1/Makefile.am
+++ b/milena/tests/world/k1/Makefile.am
@@ -38,7 +38,7 @@ check_PROGRAMS = \
un_immerse
display_enlarged_SOURCES = display_enlarged.cc
-fill_0_1_faces_border_SOURCES = fill_0_1_faces_border.cc
+fill_0_1_faces_internal_border_SOURCES = fill_0_1_faces_internal_border.cc
fill_0_from_1_faces_SOURCES = fill_0_from_1_faces.cc
fill_0_from_2_faces_SOURCES = fill_0_from_2_faces.cc
fill_0_from_primary_faces_SOURCES = fill_0_from_primary_faces.cc
--
1.7.2.5
1
0
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Olena, a generic and efficient image processing platform".
The branch unstable/scribo has been updated
via f46deddccad811cc836aca7917a6cfbd6a5d12cc (commit)
via 6412c07f5e375f1bc8a22ae3d42288e601b3471d (commit)
via ba481b8ad2a28420b170e8e5f8a4890b2f6bd9cf (commit)
via 2ac2f4b257f2c7cdf521a100c047a828b39f39f4 (commit)
from 39c49007646f0a4b5ca021af14ee039220865935 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
No new revisions were added by this update.
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 5 +++++
scribo/ChangeLog | 16 ++++++++++++++++
scribo/demo/viewer/main.cc | 14 --------------
scribo/scribo/text/recognition.hh | 21 ++++++++++++++++++++-
4 files changed, 41 insertions(+), 15 deletions(-)
hooks/post-receive
--
Olena, a generic and efficient image processing platform
1
0
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Olena, a generic and efficient image processing platform".
The branch exp/khalimsky has been updated
discards 0ee6ca936752310d487231054017dbfe2685dbcf (commit)
discards 63a31e89870d37a1cabe9f2185ea37755d40cfa4 (commit)
discards 1a5b21fe7b038b69f458c5eff9470cf9a297d062 (commit)
discards df0ecc75bbd147bb9bd3733217189879aafe1221 (commit)
discards acb3c05ba9f4d806c74604c440533ff5d7db3014 (commit)
discards 6b05452c6453e2114d063aef6c53078159c793ff (commit)
discards f81a760ac268c88667aa3d9f51f19b968640d308 (commit)
discards 61eef32bf34aa5d7b65ce8f27405ae16bed66d30 (commit)
discards 027f767ead3b99a0b564cf5723b6acac18dc3716 (commit)
discards cbf3fe229ced061e0a6b9aa590593c91fced0d10 (commit)
discards be35e3941a0a8bb5ec44a7be4e55a0142c734430 (commit)
discards 1cde74522f42b4cfdd260df9e3d2f46c50510eb1 (commit)
discards bbd4359f6eda38f4c6f04a0c69203ad4d5120d9b (commit)
discards b52230fdd12773c58aceb1e8a9d3d28c584f5a50 (commit)
discards 378bb80be1f173841b2358c47b15be1ce87add88 (commit)
discards c709c0740a7690c450763f5fe2e13bde69795f31 (commit)
discards 0c9847ecc8e97564ab24fc23dd2aee7ace9aa072 (commit)
discards 841c962c69fee0d982dbdae5b155c479bdd73c99 (commit)
discards d2cc34cb2d84e990fce7f03ecc130cb3cbe86e2b (commit)
discards 3ce4ce1dc14779f0ce244fef70a6fa984f494d59 (commit)
discards e5977cbc87ffe43c37e74e83f36eee278f15ce13 (commit)
discards 25a6947e13ca488b5f1b0601f2333d113c85d2d7 (commit)
discards 91b3fcb92cb20730dc0c3b29a6e8ea1462eec7f7 (commit)
discards d0d18bf100fa99b288d55dd025055c1c79ada3cc (commit)
discards b0be295569b332dfffbeb4313ff208726ca01794 (commit)
discards f669bdcced156e0cbf9307a77515860911ad17bd (commit)
discards cb1593cc1781f87210c01db60ac8cd138121fa2b (commit)
discards 39e1152eceddabf1c61e368c2f7bd477dbc2c46e (commit)
discards 1a7b4fcf3f2e141a6b59bc39db3ae2298329b379 (commit)
discards 0a1c1c9af1b82c13146555ce8caca89030e7af58 (commit)
discards 287d09bba75106e59f22e1a313225481cf7f9bd8 (commit)
discards cc2c4ef347d9a8fdce6fc6bbf29213f14e366131 (commit)
via c8699b912ad6e68f3ead87f6165612c8fe7ed067 (commit)
via c680fc72f05286ea1875e0eb3adac770afd8c96c (commit)
via 4bae71d7d231b34e2db0ec358a146b2f96b1073d (commit)
via 995652fc46f68950a7c0b3e24ffa14282b24929b (commit)
via 1b1c0afd99678c36cbdb118a7b43895cbfe7725d (commit)
via 253edef48d8dcb2d2696a362543866be852041f3 (commit)
via 318c0f779abc51062e0bbf57fb61bb75cec3e81c (commit)
via 3e7e4f92950eba72a5e6d78ccb9a8e0bf5ab1401 (commit)
via b96d7cc9a2f10653fdaaf81ffe233da62810e1ab (commit)
via 81ed289d3056035e658a6c6f7faff0f33a94b1b4 (commit)
via e242c846a5f0385c93c0d5fbc487034e1e80e50e (commit)
via d61b69f1285c177ef4a4fe3d2fa819cb3fc6900e (commit)
via a42ca7ea8a3cb38c1aee89eea4cc3e299f4b4802 (commit)
via 3d34eb099ffc8e71bd8c8540283c96015521f3b8 (commit)
via cc965b2b677c5f3d7e6e10b8a4c55fe87cfebe5a (commit)
via 06d861d159a4cc3783f28465f883f6539cfaa058 (commit)
via e0efc4408d2274f91e82ceccd49b2ee75efcfc5a (commit)
via ed21680bd937412edb5edc9af255dc0c3322d656 (commit)
via dbc709fd9b4e968f4d9b7663815f22881244717d (commit)
via 12b51e718856528402a9dc8937cb031440e57e8a (commit)
via 7cbca2dfd04d1848bc9fb9372324094fc8b42b75 (commit)
via 4a735fd7e0aed4a1901659e242a41e5f24925a9d (commit)
via 64344919991cdcaef004d295f727888c13de0aac (commit)
via 82a0e36765d634513cff57997a97afc8f7ad2ae8 (commit)
via 759954227486a5ef88810bd8f2368f89fc50bb27 (commit)
via 7aacabf8927300b389ee6b4c70c3340d4063c23a (commit)
via 99ee8c8080a11b9c547f2ca12d9f20bd6b566f22 (commit)
via 9d4bc6a3cca30b47451090bade9cfa27e7b56be0 (commit)
via 539ff65ac5534696410e3642eaea0fa35a6e5cf5 (commit)
via 1f96c87d44e8ec5b5d06b15954a9aec5ed2888ae (commit)
via f46deddccad811cc836aca7917a6cfbd6a5d12cc (commit)
via 6412c07f5e375f1bc8a22ae3d42288e601b3471d (commit)
via ba481b8ad2a28420b170e8e5f8a4890b2f6bd9cf (commit)
via 2ac2f4b257f2c7cdf521a100c047a828b39f39f4 (commit)
via 39c49007646f0a4b5ca021af14ee039220865935 (commit)
via 4b68faa4d9d1d5895d02886babfa882daacfff34 (commit)
via 100a5de1c32ce7239ed7516e695f73039d34c197 (commit)
via a0009d29906b8d09acfec883cb0525a744af261c (commit)
via 4e2298d2cb279e72733a1623e6df1bc913d8df2d (commit)
via 3388ab1a99b95859e0ee2f8645195904d8825eff (commit)
via 031310f04de779261c2d1c947639fd26a977aa61 (commit)
via c6498e5c0810332d9df1f36eacd18c71f49bb84a (commit)
via 3ce08d0601400cc731547fb4787a721be550f253 (commit)
via 0c8e07f9d1f011558bd12f93d3cd8f4f3f268d40 (commit)
via 378f3533e395702eaf862094eb2a6efbd7b28562 (commit)
via cf88d225eedfd2b1171d7d682e41b8d058022896 (commit)
via 3a65b8d103648386c782e6ffd7e6c6f9d4d31876 (commit)
via 9aec99882d259af348743be9789cf7ed1048fa2a (commit)
via 8c4e2dd61bf3a218b8d74a3d404ac031148f1fba (commit)
via e1b3bd773168c12df5dba50ec1f51800099f680e (commit)
via 183d8311bb8ebc4f50368d5b514d146eb140dece (commit)
via 9846847b09170222664d4bc855138c413867687a (commit)
via 13097b17352c352b39d2aa6c3db44247bf5a7e05 (commit)
via b7cf120ad8026ef2ab94a4bf72f0b1cf75ee8659 (commit)
via 6bc3a11973ec08c060943988bf96e1155d66c387 (commit)
via 03eaf1cd586c489ec0ef5e1353c5752aed78a4a7 (commit)
via 962ceb9b1aa6da7d0b2a1278d375c52e94095279 (commit)
via f3c06f65c794685bb17d73b321afcda9f70b05af (commit)
via c471618c68f0572f188c1851e2a016d92ca42855 (commit)
via e9bb20fdca74a67c31321df1050a0937d69600e8 (commit)
via 9a738ad40e072fa940b1745b7843d89b9d9c09f5 (commit)
via a20c0650f91295e50e8913ecd9f8bf0516747318 (commit)
via 4f0a66f09045818f9b9bb16dc315ca7691e30c03 (commit)
via d5207270e354bb9317c6339ab1ada1bc7e88f701 (commit)
via ae6f6e5e98ec7c589cadc60ac8547639c36e45d8 (commit)
via 876593557f34e3a78366a5aa9322fec0afae8af3 (commit)
via 54defbbea0f22afc1413698b007cd6457d245f40 (commit)
via d5de13336922ea9fe734e176b0f25a22e895d302 (commit)
via 7307887029d66c125b3fc70de134e40913814c30 (commit)
via e916a0335fe6e931a87fb8de965948ae7674f10c (commit)
via 85d28da864d15cf517e3857141d802c411f21047 (commit)
via 923296ed8b82d64c6cba045374136c12f8d4d685 (commit)
via 6b6f7a188e2a850f405bec64e81f2000e848cfe9 (commit)
via ef341a251501dd4c232dfb6ac0f85e41086c4d4f (commit)
via 317c7bee067b7bd678eb55e5ed866861ac892274 (commit)
via b926dc165dc73387115470edbbba0b6b2e0964d1 (commit)
via 0c44c4c4c9b5e9112cde2b58e0131d09153e046f (commit)
via 91bcd8b415ad22099a16cd941b54f459968b348b (commit)
via 19c45fe85a90403b06454eab85b2a1e628f8d617 (commit)
via b77d84adbfa931b4b6685b5069ad15b8cd447056 (commit)
via ec7416a0b0021f1b53482c04a5854cdb8c182832 (commit)
via b340c526ae583ce7be9ea28b63bf98f25aae1add (commit)
via 3b03179e7f4d5bd9354bdfbcc897dfd47968fe05 (commit)
via 6982d67f5d2c708ed42648e039ad0b1cfcc959ab (commit)
via 520e734397bbc288a76bfba987f23b13614d540d (commit)
via 8cef82347f1de7ee16f351e8536b9ebc34227ffc (commit)
via 481bcb1c9eac10beda96f0e176b2481fd5e4c86c (commit)
via 80d159955caf5c547a844c660c45984bcdb8d880 (commit)
via 0461de7a9a2d473326a09fa6d09fda03df9b6fd9 (commit)
via ad194b5f069f035d7624f748b6063baf2525cbde (commit)
via fc1b111887113926a038df4cc292561bf1d5f31e (commit)
via 674e43ac4187e2adf6a4826c9bc77c886d0cec89 (commit)
via 699326af505c203e1eeb4a2d67d2a0d85d5cd6d1 (commit)
via f31589e55f08e02a6b3f450015c892600024ec15 (commit)
This update added new revisions after undoing existing revisions. That is
to say, the old revision is not a strict subset of the new revision. This
situation occurs when you --force push a change and generate a repository
containing something like this:
* -- * -- B -- O -- O -- O (0ee6ca936752310d487231054017dbfe2685dbcf)
\
N -- N -- N (c8699b912ad6e68f3ead87f6165612c8fe7ed067)
When this happens we assume that you've already had alert emails for all
of the O revisions, and so we here report only the revisions in the N
branch from the common base, B.
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
c8699b9 New comparison functions.
c680fc7 Force abort() on unsafe conversions.
4bae71d Refine util::level operators.
995652f Let the user specify conversion functions in K2 immersion.
1b1c0af mln/core/routine/ops.hh: Update comments.
253edef tests/value/interval.cc: Add more tests.
318c0f7 Introduce level tag.
3e7e4f9 Fix accu::stat::median_interval.
b96d7cc Introduce K2 and Kn spaces.
81ed289 Some fixes.
e242c84 New span accumulator.
d61b69f Add functions.
a42ca7e Improve accu::median_interval.
3d34eb0 mln/value/intsub.hh: Add more constructors.
cc965b2 mln/value/concept/interval.hh: New. Add value::Interval concept.
06d861d Add an accumulator median based on intervals.
e0efc44 Rename interval::nelements() to interval::nvalues().
ed21680 Replace range class with interval and improve it.
dbc709f Improve value::intsub class.
12b51e7 mln/value/builtin/ops.hh: Handle all the comparison operators.
7cbca2d Add mathematical tools.
4a735fd tests/world/k1/Makefile.am: Fix target names.
6434491 Replace unsignedh type by intsub.
82a0e36 New routines to browse values into a value set.
7599542 New value types.
7aacabf New routine for filling internal border in K1.
99ee8c8 mln/world/k1/neighb2d.hh: New neighborhoods.
9d4bc6a More routines working on images immersed in K1.
539ff65 configure.ac: Configure milena/tests/world/k1/Makefile.am.
1f96c87 Initial commit of tools to work in K1.
f46dedd scribo/text/recognition.hh: Restore previous locale.
6412c07 Ensure current locale is C while calling Tesseract.
ba481b8 m4/oln-with-lib.m4: Lookup for multiple AND single libraries while checking Tesseract availability.
2ac2f4b scribo/text/recognition.hh: Fix code for Tesseract 3.01 compatibility.
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 14 +
NEWS | 19 +
distrib/macports/Portfile.in | 7 +-
milena/ChangeLog | 371 ++++++++++++++++-
milena/apps/papers/levillain.09.ismm/graph.cc | 7 +-
.../examples/tuto4_genericity_and_algorithms.cc | 7 +-
milena/headers.mk | 5 +-
milena/mln/accu/count_labels.hh | 4 +-
milena/mln/accu/line.hh | 6 +-
milena/mln/accu/math/sumpow.hh | 201 +++++++++
milena/mln/accu/transform_line.hh | 26 +-
milena/mln/algebra/vec.hh | 165 +++++++-
milena/mln/binarization/threshold.hh | 7 +-
milena/mln/border/duplicate.hh | 8 +-
milena/mln/border/fill.hh | 8 +-
milena/mln/canvas/browsing/diagonal2d.hh | 7 +-
milena/mln/canvas/labeling/sorted.hh | 2 +-
milena/mln/convert/from_to.hh | 130 +++---
milena/mln/convert/from_to.hxx | 441 +-------------------
milena/mln/convert/impl/from_double_to_value.hh | 159 ++++----
milena/mln/convert/impl/from_float_to_value.hh | 179 ++++----
milena/mln/convert/impl/from_image_to_site_set.hh | 8 +-
milena/mln/convert/impl/from_int_to_value.hh | 101 ++---
milena/mln/convert/impl/from_unsigned_to_value.hh | 140 +++----
milena/mln/convert/impl/from_value_to_value.hh | 7 +-
milena/mln/convert/to.hh | 1 -
milena/mln/convert/to_qimage.hh | 9 +-
milena/mln/core/alias/neighb2d.hh | 75 ++--
milena/mln/core/alias/neighb3d.hh | 65 ++--
milena/mln/core/alias/point1d.hh | 5 +-
milena/mln/core/alias/point2d.hh | 5 +-
milena/mln/core/alias/point3d.hh | 5 +-
milena/mln/core/alias/window1d.hh | 51 +--
milena/mln/core/alias/window2d.hh | 100 ++---
milena/mln/core/alias/window3d.hh | 56 +--
milena/mln/core/concept/accumulator.hh | 81 ++---
milena/mln/core/concept/box.hh | 7 +-
milena/mln/core/concept/doc/image_fastest.hh | 9 +-
milena/mln/core/concept/gdpoint.hh | 61 +--
milena/mln/core/concept/generalized_pixel.hh | 9 +-
milena/mln/core/concept/gpoint.hh | 123 ++----
milena/mln/core/concept/graph.hh | 34 +-
milena/mln/core/concept/image.hh | 108 +++---
milena/mln/core/concept/iterator.hh | 11 +-
milena/mln/core/concept/neighborhood.hh | 9 +-
milena/mln/core/concept/proxy.hh | 56 +--
milena/mln/core/concept/pseudo_site.hh | 7 +-
milena/mln/core/concept/site_iterator.hh | 15 +-
milena/mln/core/concept/site_proxy.hh | 7 +-
milena/mln/core/concept/site_set.hh | 132 +++---
milena/mln/core/concept/value_iterator.hh | 5 +-
milena/mln/core/concept/value_set.hh | 8 +-
milena/mln/core/concept/weighted_window.hh | 7 +-
milena/mln/core/concept/window.hh | 136 +++----
milena/mln/core/dpoint.hh | 1 -
milena/mln/core/dpoints_pixter.hh | 8 +-
milena/mln/core/image/dmorph/slice_image.hh | 16 +-
milena/mln/core/image/graph_window_if_piter.hh | 4 +-
milena/mln/core/image/image1d.hh | 99 +----
milena/mln/core/image/image2d.hh | 27 +-
milena/mln/core/image/image3d.hh | 16 +-
milena/mln/core/image/imorph/decorated_image.hh | 4 +-
milena/mln/core/internal/check/image_fastest.hh | 37 +-
milena/mln/core/internal/image_identity.hh | 11 +-
milena/mln/core/internal/neighborhood_base.hh | 9 +-
milena/mln/core/internal/pixel_impl.hh | 6 +-
.../core/internal/site_relative_iterator_base.hh | 10 +-
milena/mln/core/mixed_neighb.hh | 72 ++--
milena/mln/core/neighb.hh | 76 ++---
milena/mln/core/pixel.hh | 5 +-
milena/mln/core/point.hh | 172 ++-------
milena/mln/core/site_set/operators.hh | 13 +-
milena/mln/core/site_set/p_centered.hh | 5 +-
milena/mln/core/site_set/p_vaccess.hh | 4 +-
milena/mln/core/w_window.hh | 191 +++------
milena/mln/data/compute_in_window.hh | 248 +++++++++++
milena/mln/data/fill_with_value.spe.hh | 5 +-
milena/mln/data/memset_.hh | 4 +-
milena/mln/debug/draw_graph.hh | 66 +++-
milena/mln/draw/box_plain.hh | 9 +-
milena/mln/fun/i2v/array.hh | 154 +++----
milena/mln/fun/v2b/all.hh | 6 +-
milena/mln/fun/v2b/compare.hh | 84 ++++
milena/mln/fun/v2b/essential.hh | 6 +-
milena/mln/fun/v2b/threshold.hh | 84 ----
milena/mln/fun/v2b/threshold_ge.hh | 88 ++++
milena/mln/fun/v2b/threshold_gt.hh | 88 ++++
milena/mln/fun/v2b/threshold_le.hh | 88 ++++
milena/mln/fun/v2b/threshold_lt.hh | 87 ++++
milena/mln/fun/v2v/hsl_to_rgb.hh | 10 +-
milena/mln/fun/v2v/rgb_to_hsl.hh | 4 +-
milena/mln/geom/crop.hh | 73 ++++
milena/mln/geom/crop_without_localization.hh | 81 ++++
milena/mln/histo/array.hh | 34 ++-
milena/mln/io/dicom/load.hh | 4 +-
milena/mln/io/magick/load.hh | 6 +-
milena/mln/io/magick/save.hh | 274 ++++++++++++-
milena/mln/io/off/load.hh | 6 +-
milena/mln/io/off/save.hh | 2 +-
milena/mln/io/plot/save.hh | 5 +-
milena/mln/labeling/blobs_and_compute.hh | 5 +-
milena/mln/labeling/value_and_compute.hh | 7 +-
milena/mln/linear/gaussian_directional_2d.hh | 9 +-
milena/mln/make/w_window2d.hh | 5 +-
.../morpho/reconstruction/by_erosion/union_find.hh | 5 +-
milena/mln/morpho/watershed/topological.hh | 4 +-
milena/mln/registration/icp.hh | 2 +-
milena/mln/subsampling/antialiased.hh | 8 +-
.../internal/complex_relative_iterator_base.hh | 7 +-
milena/mln/trait/image/props.hh | 11 +-
.../transform/internal/closest_point_functor.hh | 5 +-
milena/mln/util/array.hh | 138 ++++---
milena/mln/util/level.hh | 79 ++--
milena/mln/util/object_id.hh | 46 +--
milena/mln/value/hsl.hh | 104 +++---
milena/mln/value/int_u.hh | 162 ++++----
milena/mln/value/interval.hh | 3 +-
milena/mln/value/label.hh | 150 +++----
milena/mln/value/qt/rgb32.hh | 78 +---
milena/mln/value/rgb.hh | 196 ++++------
milena/mln/win/multiple.hh | 5 +-
milena/mln/win/multiple_size.hh | 3 +-
milena/mln/world/binary_2d/enlarge.hh | 6 +-
milena/mln/world/binary_2d/subsample.hh | 6 +-
milena/mln/world/k2/converters.hh | 9 +-
milena/tests/accu/site_set/rectangularity.cc | 4 +-
milena/tests/algebra/h_vec.cc | 1 +
milena/tests/core/alias/point1d.cc | 4 +-
milena/tests/core/other/graph_elt_neighborhood.cc | 3 +-
milena/tests/core/other/graph_elt_window.cc | 5 +-
milena/tests/core/other/point_set_compatibility.cc | 4 +-
milena/tests/data/Makefile.am | 2 +
milena/tests/data/compute_in_window.cc | 79 ++++
milena/tests/draw/graph.cc | 4 +-
milena/tests/io/dump/Makefile.am | 4 +-
milena/tests/io/dump/dump.cc | 20 +-
milena/tests/labeling/n_max.cc | 4 +-
milena/tests/literal/Makefile.am | 12 +-
milena/tests/literal/colors.cc | 77 ++++
milena/tests/literal/identity.cc | 47 ++
milena/tests/literal/max.cc | 45 ++
milena/tests/literal/medium_gray.cc | 25 +-
milena/tests/literal/min.cc | 45 ++
milena/tests/literal/origin.cc | 42 ++
milena/tests/metal/unconst.cc | 9 +-
milena/tests/morpho/complex_image_wst.cc | 2 +
milena/tests/trait/super.cc | 1 +
milena/tests/unit_test/unit-tests.mk | 10 +-
milena/tests/util/level.cc | 63 +++-
scribo/ChangeLog | 249 +++++++++++-
scribo/demo/Makefile.am | 8 +-
scribo/demo/xml2doc/templates/html/main.xsl | 31 +-
scribo/demo/xml2doc/templates/html/main_base64.xsl | 31 +-
scribo/demo/xml2doc/templates/pdf/line.xsl | 157 ++++----
scribo/headers.mk | 12 +-
scribo/scribo/binarization/all.hh | 5 +-
scribo/scribo/binarization/global_threshold.hh | 4 +-
.../internal/compute_local_threshold.hh | 224 ++++++++++
.../internal/compute_sauvola_threshold.hh | 285 -------------
.../binarization/internal/first_pass_functor.hh | 24 +-
.../binarization/internal/local_threshold_debug.hh | 88 ++++
.../binarization/internal/niblack_formula.hh | 105 +++++
.../scribo/binarization/internal/sauvola_debug.hh | 87 ----
.../binarization/internal/sauvola_formula.hh | 121 ++++++
scribo/scribo/binarization/niblack.hh | 218 ++++++++++
scribo/scribo/binarization/niblack_threshold.hh | 299 +++++++++++++
scribo/scribo/binarization/otsu.hh | 85 ++++
scribo/scribo/binarization/otsu_threshold.hh | 132 ++++++
scribo/scribo/binarization/sauvola.hh | 24 +-
scribo/scribo/binarization/sauvola_ms.hh | 49 +--
scribo/scribo/binarization/sauvola_ms_split.hh | 5 +-
scribo/scribo/binarization/sauvola_threshold.hh | 296 +++++++++++++
.../scribo/binarization/sauvola_threshold_image.hh | 301 -------------
scribo/scribo/canvas/integral_browsing.hh | 6 +-
scribo/scribo/core/line_info.hh | 21 +-
scribo/scribo/debug/logger.hh | 252 +++++++++++-
scribo/scribo/debug/option_check.hh | 19 +-
scribo/scribo/debug/option_parser.hh | 19 +-
scribo/scribo/draw/line_components.hh | 8 +-
scribo/scribo/filter/object_groups_with_holes.hh | 2 +-
scribo/scribo/filter/objects_with_holes.hh | 2 +-
.../io/xml/internal/extended_page_xml_visitor.hh | 1 +
scribo/scribo/io/xml/internal/full_xml_visitor.hh | 1 +
scribo/scribo/io/xml/load.hh | 1 +
scribo/scribo/postprocessing/fill_object_holes.hh | 2 +-
scribo/scribo/preprocessing/rotate_90.hh | 10 +-
scribo/scribo/primitive/extract/internal/union.hh | 6 +-
.../primitive/extract/lines_h_thick_and_thin.hh | 8 +-
scribo/scribo/primitive/extract/lines_pattern.hh | 2 +-
.../primitive/extract/separators_nonvisible.hh | 16 +-
scribo/scribo/primitive/internal/rd.hh | 2 +-
.../link/merge_double_link_closest_aligned.hh | 4 +-
scribo/scribo/subsampling/integral.hh | 8 +-
scribo/scribo/subsampling/integral_single_image.hh | 28 +-
scribo/scribo/text/clean.hh | 7 +-
scribo/scribo/text/clean_inplace.hh | 6 +-
scribo/scribo/text/merging.hh | 4 +-
scribo/scribo/text/merging_hdoc.hh | 4 +-
scribo/scribo/text/recognition.hh | 204 +++++++--
scribo/scribo/toolchain/text_in_doc_preprocess.hh | 13 +-
scribo/src/Makefile.am | 15 +-
scribo/src/afp/components.hh | 4 +-
scribo/src/binarization/Makefile.am | 49 ++-
scribo/src/binarization/global_threshold.cc | 104 +++++
scribo/src/binarization/niblack.cc | 106 +++++
scribo/src/binarization/otsu.cc | 99 +++++
scribo/src/binarization/pgm_sauvola.cc | 80 ----
scribo/src/binarization/pgm_sauvola_ms.cc | 111 -----
.../binarization/pgm_sauvola_threshold_image.cc | 77 ----
scribo/src/binarization/ppm_sauvola.cc | 88 ----
scribo/src/binarization/ppm_sauvola_ms.cc | 123 ------
scribo/src/binarization/ppm_sauvola_ms_fg.cc | 134 ------
scribo/src/binarization/ppm_sauvola_ms_split.cc | 128 ------
scribo/src/content_in_doc.cc | 8 +-
scribo/src/content_in_hdoc.cc | 7 +-
scribo/src/contest/DAE-2011/README | 23 +
scribo/src/contest/DAE-2011/content_in_doc_dae.cc | 5 +-
scribo/src/contest/DAE-2011/content_in_hdoc_dae.cc | 5 +-
scribo/src/contest/hdibco-2010/README | 21 +
scribo/src/contest/hdlac-2011/README | 26 ++
.../contest/hdlac-2011/content_in_hdoc_hdlac.cc | 10 +-
scribo/src/non_text_components.cc | 5 +-
scribo/src/text_in_picture_dual.cc | 146 +++++++
scribo/src/text_in_picture_neg.cc | 197 ---------
scribo/tests/binarization/Makefile.am | 8 +-
scribo/tests/binarization/global_threshold.cc | 7 +-
scribo/tests/binarization/niblack.cc | 52 +++
scribo/tests/binarization/niblack.ref.pbm | Bin 0 -> 32884 bytes
scribo/tests/binarization/otsu.cc | 52 +++
scribo/tests/binarization/otsu.ref.pbm | Bin 0 -> 32884 bytes
scribo/tests/unit_test/unit-tests.mk | 24 +-
231 files changed, 7379 insertions(+), 4924 deletions(-)
create mode 100644 milena/mln/accu/math/sumpow.hh
create mode 100644 milena/mln/data/compute_in_window.hh
create mode 100644 milena/mln/fun/v2b/compare.hh
delete mode 100644 milena/mln/fun/v2b/threshold.hh
create mode 100644 milena/mln/fun/v2b/threshold_ge.hh
create mode 100644 milena/mln/fun/v2b/threshold_gt.hh
create mode 100644 milena/mln/fun/v2b/threshold_le.hh
create mode 100644 milena/mln/fun/v2b/threshold_lt.hh
create mode 100644 milena/mln/geom/crop.hh
create mode 100644 milena/mln/geom/crop_without_localization.hh
create mode 100644 milena/tests/data/compute_in_window.cc
create mode 100644 milena/tests/literal/colors.cc
create mode 100644 milena/tests/literal/identity.cc
create mode 100644 milena/tests/literal/max.cc
create mode 100644 milena/tests/literal/min.cc
create mode 100644 milena/tests/literal/origin.cc
create mode 100644 scribo/scribo/binarization/internal/compute_local_threshold.hh
delete mode 100644 scribo/scribo/binarization/internal/compute_sauvola_threshold.hh
create mode 100644 scribo/scribo/binarization/internal/local_threshold_debug.hh
create mode 100644 scribo/scribo/binarization/internal/niblack_formula.hh
delete mode 100644 scribo/scribo/binarization/internal/sauvola_debug.hh
create mode 100644 scribo/scribo/binarization/internal/sauvola_formula.hh
create mode 100644 scribo/scribo/binarization/niblack.hh
create mode 100644 scribo/scribo/binarization/niblack_threshold.hh
create mode 100644 scribo/scribo/binarization/otsu.hh
create mode 100644 scribo/scribo/binarization/otsu_threshold.hh
create mode 100644 scribo/scribo/binarization/sauvola_threshold.hh
delete mode 100644 scribo/scribo/binarization/sauvola_threshold_image.hh
create mode 100644 scribo/src/binarization/global_threshold.cc
create mode 100644 scribo/src/binarization/niblack.cc
create mode 100644 scribo/src/binarization/otsu.cc
delete mode 100644 scribo/src/binarization/pgm_sauvola.cc
delete mode 100644 scribo/src/binarization/pgm_sauvola_ms.cc
delete mode 100644 scribo/src/binarization/pgm_sauvola_threshold_image.cc
delete mode 100644 scribo/src/binarization/ppm_sauvola.cc
delete mode 100644 scribo/src/binarization/ppm_sauvola_ms.cc
delete mode 100644 scribo/src/binarization/ppm_sauvola_ms_fg.cc
delete mode 100644 scribo/src/binarization/ppm_sauvola_ms_split.cc
create mode 100644 scribo/src/contest/DAE-2011/README
create mode 100644 scribo/src/contest/hdibco-2010/README
create mode 100644 scribo/src/contest/hdlac-2011/README
create mode 100644 scribo/src/text_in_picture_dual.cc
delete mode 100644 scribo/src/text_in_picture_neg.cc
create mode 100644 scribo/tests/binarization/niblack.cc
create mode 100644 scribo/tests/binarization/niblack.ref.pbm
create mode 100644 scribo/tests/binarization/otsu.cc
create mode 100644 scribo/tests/binarization/otsu.ref.pbm
hooks/post-receive
--
Olena, a generic and efficient image processing platform
1
0
* mln/fun/v2b/compare.hh,
* mln/fun/v2b/threshold_gt.hh,
* mln/fun/v2b/threshold_lt.hh: New.
---
milena/ChangeLog | 8 ++++
milena/mln/fun/v2b/{lnot.hh => compare.hh} | 35 +++++++++++++-------
.../fun/v2b/{threshold_ge.hh => threshold_gt.hh} | 18 +++++-----
.../fun/v2b/{threshold_ge.hh => threshold_lt.hh} | 21 ++++++------
4 files changed, 50 insertions(+), 32 deletions(-)
copy milena/mln/fun/v2b/{lnot.hh => compare.hh} (73%)
copy milena/mln/fun/v2b/{threshold_ge.hh => threshold_gt.hh} (84%)
copy milena/mln/fun/v2b/{threshold_ge.hh => threshold_lt.hh} (81%)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 6433185..7052b67 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,13 @@
2012-10-19 Guillaume Lazzara <z(a)lrde.epita.fr>
+ New comparison functions.
+
+ * mln/fun/v2b/compare.hh,
+ * mln/fun/v2b/threshold_gt.hh,
+ * mln/fun/v2b/threshold_lt.hh: New.
+
+2012-10-19 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Force abort() on unsafe conversions.
* mln/value/interval.hh,
diff --git a/milena/mln/fun/v2b/lnot.hh b/milena/mln/fun/v2b/compare.hh
similarity index 73%
copy from milena/mln/fun/v2b/lnot.hh
copy to milena/mln/fun/v2b/compare.hh
index 73d9ecf..22f5d88 100644
--- a/milena/mln/fun/v2b/lnot.hh
+++ b/milena/mln/fun/v2b/compare.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -23,12 +23,12 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef MLN_FUN_V2B_LNOT_HH
-# define MLN_FUN_V2B_LNOT_HH
+#ifndef MLN_FUN_V2B_COMPARE_HH
+# define MLN_FUN_V2B_COMPARE_HH
/// \file
///
-/// Functor that computes "logical not" on a value.
+/// FIXME.
# include <mln/core/concept/function.hh>
@@ -42,12 +42,16 @@ namespace mln
namespace v2b
{
- /// Functor computing logical-not on a value.
+ /// Comparison function.
+ /// f(v) = (v == ref).
template <typename V>
- struct lnot : public Function_v2b< lnot<V> >
+ struct compare : public Function_v2b< compare<V> >
{
- typedef V result;
- V operator()(const V& v) const;
+ typedef bool result;
+ bool operator()(const V& v) const;
+
+ compare(const V& a);
+ V a;
};
@@ -55,10 +59,17 @@ namespace mln
template <typename V>
inline
- V
- lnot<V>::operator()(const V& v) const
+ compare<V>::compare(const V& a)
+ : a(a)
+ {
+ }
+
+ template <typename V>
+ inline
+ bool
+ compare<V>::operator()(const V& v) const
{
- return ! v;
+ return v == a;
}
# endif // ! MLN_INCLUDE_ONLY
@@ -70,4 +81,4 @@ namespace mln
} // end of namespace mln
-#endif // ! MLN_FUN_V2B_LNOT_HH
+#endif // ! MLN_FUN_V2B_COMPARE_HH
diff --git a/milena/mln/fun/v2b/threshold_ge.hh b/milena/mln/fun/v2b/threshold_gt.hh
similarity index 84%
copy from milena/mln/fun/v2b/threshold_ge.hh
copy to milena/mln/fun/v2b/threshold_gt.hh
index c5fef9e..05edd97 100644
--- a/milena/mln/fun/v2b/threshold_ge.hh
+++ b/milena/mln/fun/v2b/threshold_gt.hh
@@ -24,8 +24,8 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef MLN_FUN_V2B_THRESHOLD_GE_HH
-# define MLN_FUN_V2B_THRESHOLD_GE_HH
+#ifndef MLN_FUN_V2B_THRESHOLD_GT_HH
+# define MLN_FUN_V2B_THRESHOLD_GT_HH
/// \file
///
@@ -44,14 +44,14 @@ namespace mln
{
/// Threshold function.
- /// f(v) = (v >= threshold).
+ /// f(v) = (v > threshold).
template <typename V>
- struct threshold_ge : public Function_v2b< threshold_ge<V> >
+ struct threshold_gt : public Function_v2b< threshold_gt<V> >
{
typedef bool result;
bool operator()(const V& v) const;
- threshold_ge(const V& a);
+ threshold_gt(const V& a);
V a;
};
@@ -60,7 +60,7 @@ namespace mln
template <typename V>
inline
- threshold_ge<V>::threshold_ge(const V& a)
+ threshold_gt<V>::threshold_gt(const V& a)
: a(a)
{
}
@@ -68,12 +68,12 @@ namespace mln
template <typename V>
inline
bool
- threshold_ge<V>::operator()(const V& v) const
+ threshold_gt<V>::operator()(const V& v) const
{
// Here the test seems to be inversed compared to the usual
// use. Indeed, we want to preserve the following convention:
// True for foreground and False for background.
- return v >= a;
+ return v > a;
}
# endif // ! MLN_INCLUDE_ONLY
@@ -85,4 +85,4 @@ namespace mln
} // end of namespace mln
-#endif // ! MLN_FUN_V2B_THRESHOLD_GE_HH
+#endif // ! MLN_FUN_V2B_THRESHOLD_GT_HH
diff --git a/milena/mln/fun/v2b/threshold_ge.hh b/milena/mln/fun/v2b/threshold_lt.hh
similarity index 81%
copy from milena/mln/fun/v2b/threshold_ge.hh
copy to milena/mln/fun/v2b/threshold_lt.hh
index c5fef9e..dd82305 100644
--- a/milena/mln/fun/v2b/threshold_ge.hh
+++ b/milena/mln/fun/v2b/threshold_lt.hh
@@ -1,5 +1,4 @@
-// Copyright (C) 2008, 2009, 2011 EPITA Research and Development
-// Laboratory (LRDE)
+// Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -24,8 +23,8 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef MLN_FUN_V2B_THRESHOLD_GE_HH
-# define MLN_FUN_V2B_THRESHOLD_GE_HH
+#ifndef MLN_FUN_V2B_THRESHOLD_LT_HH
+# define MLN_FUN_V2B_THRESHOLD_LT_HH
/// \file
///
@@ -44,14 +43,14 @@ namespace mln
{
/// Threshold function.
- /// f(v) = (v >= threshold).
+ /// f(v) = (v < threshold).
template <typename V>
- struct threshold_ge : public Function_v2b< threshold_ge<V> >
+ struct threshold_lt : public Function_v2b< threshold_lt<V> >
{
typedef bool result;
bool operator()(const V& v) const;
- threshold_ge(const V& a);
+ threshold_lt(const V& a);
V a;
};
@@ -60,7 +59,7 @@ namespace mln
template <typename V>
inline
- threshold_ge<V>::threshold_ge(const V& a)
+ threshold_lt<V>::threshold_lt(const V& a)
: a(a)
{
}
@@ -68,12 +67,12 @@ namespace mln
template <typename V>
inline
bool
- threshold_ge<V>::operator()(const V& v) const
+ threshold_lt<V>::operator()(const V& v) const
{
// Here the test seems to be inversed compared to the usual
// use. Indeed, we want to preserve the following convention:
// True for foreground and False for background.
- return v >= a;
+ return v < a;
}
# endif // ! MLN_INCLUDE_ONLY
@@ -85,4 +84,4 @@ namespace mln
} // end of namespace mln
-#endif // ! MLN_FUN_V2B_THRESHOLD_GE_HH
+#endif // ! MLN_FUN_V2B_THRESHOLD_LT_HH
--
1.7.2.5
1
0
19 Oct '12
* mln/value/interval.hh,
* mln/world/k2/converters.hh: Here.
---
milena/ChangeLog | 14 ++++++++++++++
milena/mln/value/interval.hh | 3 ++-
milena/mln/world/k2/converters.hh | 9 ++++++---
3 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index b248164..6433185 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,19 @@
2012-10-19 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Force abort() on unsafe conversions.
+
+ * mln/value/interval.hh,
+ * mln/world/k2/converters.hh: Here.
+
+2012-10-19 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Force abort() on unsafe conversions.
+
+ mln/value/interval.hh,
+ mln/world/k2/converters.hh: Here.
+
+2012-10-19 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Refine util::level operators.
* mln/util/level.hh: Add comparison operators with images.
diff --git a/milena/mln/value/interval.hh b/milena/mln/value/interval.hh
index d3cbbdd..a7cafc7 100644
--- a/milena/mln/value/interval.hh
+++ b/milena/mln/value/interval.hh
@@ -313,7 +313,8 @@ namespace mln
void
interval<T>::self_open()
{
- mln_precondition(! is_degenerated());
+ if (is_degenerated())
+ abort();
mln_precondition(nvalues_ > 2);
first += iota<T>::value();
diff --git a/milena/mln/world/k2/converters.hh b/milena/mln/world/k2/converters.hh
index de76087..0988326 100644
--- a/milena/mln/world/k2/converters.hh
+++ b/milena/mln/world/k2/converters.hh
@@ -166,7 +166,8 @@ namespace mln
int
interval_intsub_n_to_int<n>::operator()(const interval<intsub<n> >& from) const
{
- mln_precondition(from.is_degenerated());
+ if (!from.is_degenerated())
+ abort();
return from.first();
}
@@ -181,7 +182,8 @@ namespace mln
value::int_u8
interval_intsub_n_to_int_u8<n>::operator()(const interval<intsub<n> >& from) const
{
- mln_precondition(from.is_degenerated());
+ if (!from.is_degenerated())
+ abort();
return from.first().to_interop();
}
@@ -196,7 +198,8 @@ namespace mln
intsub<n/2>
interval_intsub_n_to_intsub_n_2<n>::operator()(const interval<intsub<n> >& from) const
{
- mln_precondition(from.is_degenerated());
+ if (!from.is_degenerated())
+ abort();
return from.first().to_interop();
}
--
1.7.2.5
1
0