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
November 2007
- 9 participants
- 147 discussions
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-11-22 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Subdirectory logical ready for rereading.
* mln/logical/all.hh,
* mln/logical/and.hh,
* mln/logical/and_not.hh,
* mln/logical/not.hh,
* mln/logical/or.hh: Check typo.
---
all.hh | 8 +++++++-
and.hh | 3 +++
and_not.hh | 1 +
not.hh | 6 ++++++
or.hh | 4 ++++
5 files changed, 21 insertions(+), 1 deletion(-)
Index: trunk/milena/mln/logical/and.hh
===================================================================
--- trunk/milena/mln/logical/and.hh (revision 1514)
+++ trunk/milena/mln/logical/and.hh (revision 1515)
@@ -37,6 +37,7 @@
# include <mln/core/concept/image.hh>
+
// Specializations are in:
# include <mln/logical/and.spe.hh>
@@ -105,6 +106,7 @@
mln_concrete(L) and_(const Image<L>& lhs, const Image<R>& rhs)
{
trace::entering("logical::and_");
+
mln_precondition(exact(rhs).domain() == exact(lhs).domain());
mln_concrete(L) output;
@@ -120,6 +122,7 @@
void and_inplace(Image<L>& lhs, const Image<R>& rhs)
{
trace::entering("logical::and_inplace");
+
mln_precondition(exact(rhs).domain() >= exact(lhs).domain());
impl::and__(mln_trait_image_speed(L)(), exact(lhs),
Index: trunk/milena/mln/logical/and_not.hh
===================================================================
--- trunk/milena/mln/logical/and_not.hh (revision 1514)
+++ trunk/milena/mln/logical/and_not.hh (revision 1515)
@@ -37,6 +37,7 @@
# include <mln/core/concept/image.hh>
+
// Specializations are in:
# include <mln/logical/and_not.spe.hh>
Index: trunk/milena/mln/logical/all.hh
===================================================================
--- trunk/milena/mln/logical/all.hh (revision 1514)
+++ trunk/milena/mln/logical/all.hh (revision 1515)
@@ -41,7 +41,13 @@
namespace logical
{
/// Implementation namespace of logical namespace.
- namespace impl {}
+ namespace impl {
+
+ /// Generic implementation namespace of logical namespace.
+ namespace generic {}
+
+ }
+
}
}
Index: trunk/milena/mln/logical/or.hh
===================================================================
--- trunk/milena/mln/logical/or.hh (revision 1514)
+++ trunk/milena/mln/logical/or.hh (revision 1515)
@@ -37,9 +37,11 @@
# include <mln/core/concept/image.hh>
+
// Specializations are in:
# include <mln/logical/or.spe.hh>
+
namespace mln
{
@@ -102,6 +104,7 @@
mln_concrete(L) or_(const Image<L>& lhs, const Image<R>& rhs)
{
trace::entering("logical::or_");
+
mln_precondition(exact(rhs).domain() == exact(lhs).domain());
mln_concrete(L) output;
@@ -117,6 +120,7 @@
void or_inplace(Image<L>& lhs, const Image<R>& rhs)
{
trace::entering("logical::or_inplace");
+
mln_precondition(exact(rhs).domain() >= exact(lhs).domain());
impl::or__(mln_trait_image_speed(L)(), exact(lhs),
Index: trunk/milena/mln/logical/not.hh
===================================================================
--- trunk/milena/mln/logical/not.hh (revision 1514)
+++ trunk/milena/mln/logical/not.hh (revision 1515)
@@ -37,6 +37,7 @@
# include <mln/core/concept/image.hh>
+
// Specializations are in:
# include <mln/logical/not.spe.hh>
@@ -65,6 +66,8 @@
* It performs: \n
* for all p of input.domain \n
* input(p) = not input(p)
+ *
+ * \pre \p input.has_data
*/
template <typename I>
void not_inplace(Image<I>& input);
@@ -99,6 +102,7 @@
mln_concrete(I) not_(const Image<I>& input)
{
trace::entering("logical::not");
+
mln_precondition(exact(input).has_data());
mln_concrete(I) output;
@@ -113,8 +117,10 @@
void not_inplace(Image<I>& input)
{
trace::entering("logical::not_inplace");
+
mln_precondition(exact(input).has_data());
impl::not__(mln_trait_image_speed(I)(), exact(input), exact(input));
+
trace::exiting("logical::not_inplace");
}
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-11-22 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Subdirectory arith ready for rereading.
* mln/arith/all.hh,
* mln/arith/min.hh,
* mln/arith/min.spe.hh,
* mln/arith/minus.hh,
* mln/arith/plus.hh,
* mln/arith/times.hh: + fix tracing,
* mln/arith/revert.hh: Check typo.
* tests/arith/plus.cc: Update test for not display.
---
mln/arith/all.hh | 14 ++++++--
mln/arith/min.hh | 2 -
mln/arith/min.spe.hh | 1
mln/arith/minus.hh | 15 ++++++---
mln/arith/plus.hh | 12 +++++++
mln/arith/revert.hh | 2 +
mln/arith/times.hh | 16 ++++++++++
tests/arith/plus.cc | 81 +++++++++++++++++++++++++++++++++++----------------
8 files changed, 108 insertions(+), 35 deletions(-)
Index: trunk/milena/tests/arith/plus.cc
===================================================================
--- trunk/milena/tests/arith/plus.cc (revision 1513)
+++ trunk/milena/tests/arith/plus.cc (revision 1514)
@@ -31,18 +31,9 @@
*/
#include <mln/core/image2d.hh>
-#include <mln/core/clone.hh>
-#include <mln/value/int_u8.hh>
-
+#include <mln/debug/iota.hh>
#include <mln/arith/plus.hh>
-#include <mln/arith/times.hh>
#include <mln/level/compare.hh>
-#include <mln/fun/v2v/cast.hh>
-
-#include <mln/debug/iota.hh>
-#include <mln/debug/println.hh>
-
-
int main()
{
@@ -51,29 +42,69 @@
// trace::quiet = false;
{
- image2d<int> ref(3,3);
- debug::iota(ref);
+ image2d<int> ima(3,3);
+ debug::iota(ima);
- image2d<int> ima_i = clone(ref);
- ima_i += ima_i;
- mln_assertion(ima_i == 2 * ref);
-
- debug::println(ima_i);
- ima_i += 1;
- debug::println(ima_i);
-
- image2d<float> ima_f(3,3);
- debug::iota(ima_f);
- debug::println(ima_i + ima_f);
+ int vs[3][3] = {
+ { 4, 5, 6},
+ { 7, 8, 9},
+ {10, 11, 12}
+ };
- point2d p(0, 0);
- std::cout << arith::plus<float>(ima_i, ima_i)(p) / 5 << std::endl;
+ ima += 2;
+ image2d<int> ref(make::image2d(vs));
+
+ mln_assertion (ima + 1 == ref);
}
}
+// #include <mln/core/image2d.hh>
+// #include <mln/core/clone.hh>
+// #include <mln/value/int_u8.hh>
+
+// #include <mln/arith/plus.hh>
+// #include <mln/arith/times.hh>
+// #include <mln/level/compare.hh>
+// #include <mln/fun/v2v/cast.hh>
+
+// #include <mln/debug/iota.hh>
+// #include <mln/debug/println.hh>
+
+
+
+// int main()
+// {
+// using namespace mln;
+
+// // trace::quiet = false;
+
+// {
+// image2d<int> ref(3,3);
+// debug::iota(ref);
+
+// image2d<int> ima_i = clone(ref);
+// ima_i += ima_i;
+// mln_assertion(ima_i == 2 * ref);
+
+// debug::println(ima_i);
+// ima_i += 1;
+// debug::println(ima_i);
+
+// image2d<float> ima_f(3,3);
+// debug::iota(ima_f);
+// debug::println(ima_i + ima_f);
+
+// point2d p(0, 0);
+// std::cout << arith::plus<float>(ima_i, ima_i)(p) / 5 << std::endl;
+// }
+
+// }
+
+
+
// Bench:
// {
Index: trunk/milena/mln/arith/times.hh
===================================================================
--- trunk/milena/mln/arith/times.hh (revision 1513)
+++ trunk/milena/mln/arith/times.hh (revision 1514)
@@ -221,35 +221,51 @@
template <typename L, typename R, typename O>
void times(const Image<L>& lhs, const Image<R>& rhs, Image<O>& output)
{
+ trace::entering("arith::times");
+
mln_precondition(exact(rhs).domain() == exact(lhs).domain());
mln_precondition(exact(output).domain() == exact(lhs).domain());
impl::times_(mln_trait_image_speed(L)(), exact(lhs),
mln_trait_image_speed(R)(), exact(rhs),
mln_trait_image_speed(O)(), exact(output));
+
+ trace::exiting("arith::times");
}
template <typename I, typename V, typename O>
void times_cst(const Image<I>& input, const V& val, Image<O>& output)
{
+ trace::entering("arith::times_cst");
+
mln_precondition(exact(output).domain() == exact(input).domain());
times(input, pw::cst(val) | exact(input).domain(), output);
// Calls the previous version.
+
+ trace::exiting("arith::times_cst");
}
template <typename L, typename R>
void times_inplace(Image<L>& lhs, const Image<R>& rhs)
{
+ trace::entering("arith::times_inplace");
+
mln_precondition(exact(rhs).domain() <= exact(lhs).domain());
impl::times_inplace_(mln_trait_image_speed(L)(), exact(lhs),
mln_trait_image_speed(R)(), exact(rhs));
+
+ trace::exiting("arith::times_inplace");
}
template <typename I, typename V>
void times_cst_inplace(Image<I>& input, const V& val)
{
+ trace::entering("arith::times_cst_inplace");
+
mln_precondition(exact(input).has_data());
times_inplace(input, pw::cst(val) | exact(input).domain());
// Calls the previous version.
+
+ trace::exiting("arith::times_cst_inplace");
}
} // end of namespace mln::arith
Index: trunk/milena/mln/arith/plus.hh
===================================================================
--- trunk/milena/mln/arith/plus.hh (revision 1513)
+++ trunk/milena/mln/arith/plus.hh (revision 1514)
@@ -211,6 +211,7 @@
operator+(const Image<L>& lhs, const Image<R>& rhs)
{
trace::entering("operator::plus");
+
mln_precondition(exact(rhs).domain() == exact(lhs).domain());
mln_trait_op_plus(L,R) output = arith::plus(lhs, rhs);
@@ -224,6 +225,7 @@
operator+=(Image<L>& lhs, const Image<R>& rhs)
{
trace::entering("operator::plus_eq");
+
mln_precondition(exact(rhs).domain() == exact(lhs).domain());
arith::plus_inplace(lhs, rhs);
@@ -238,6 +240,7 @@
operator+(const Image<I>& ima, const value::Scalar<S>& s)
{
trace::entering("operator::plus");
+
mln_precondition(exact(ima).has_data());
mln_trait_op_plus(I,S) output = arith::plus_cst(ima, exact(s));
@@ -251,6 +254,7 @@
operator+=(Image<I>& ima, const value::Scalar<S>& s)
{
trace::entering("operator::plus_eq");
+
mln_precondition(exact(ima).has_data());
arith::plus_cst_inplace(ima, exact(s));
@@ -337,6 +341,7 @@
plus(const Image<L>& lhs, const Image<R>& rhs)
{
trace::entering("arith::plus");
+
mln_precondition(exact(rhs).domain() == exact(lhs).domain());
mln_trait_op_plus(L, R) output;
@@ -354,6 +359,7 @@
plus(const Image<L>& lhs, const Image<R>& rhs, const Function_v2v<F>& f)
{
trace::entering("arith::plus");
+
mln_precondition(exact(rhs).domain() == exact(lhs).domain());
mln_ch_value(L, mln_result(F)) output;
@@ -371,6 +377,7 @@
plus(const Image<L>& lhs, const Image<R>& rhs)
{
trace::entering("arith::plus");
+
mln_precondition(exact(rhs).domain() == exact(lhs).domain());
// Calls the previous version.
@@ -387,6 +394,7 @@
plus_cst(const Image<I>& input, const V& val)
{
trace::entering("arith::plus_cst");
+
mln_precondition(exact(input).has_data());
// Calls the previous version.
@@ -403,6 +411,7 @@
plus_cst(const Image<I>& input, const V& val, const Function_v2v<F>& f)
{
trace::entering("arith::plus_cst");
+
mln_precondition(exact(input).has_data());
// Calls the previous version.
@@ -420,6 +429,7 @@
plus_cst(const Image<I>& input, const V& val)
{
trace::entering("arith::plus_cst");
+
mln_precondition(exact(input).has_data());
// Calls the previous version.
@@ -436,6 +446,7 @@
plus_inplace(Image<L>& lhs, const Image<R>& rhs)
{
trace::entering("arith::plus_inplace");
+
mln_precondition(exact(rhs).domain() == exact(lhs).domain());
impl::plus_inplace_(mln_trait_image_speed(L)(), exact(lhs),
@@ -450,6 +461,7 @@
plus_cst_inplace(Image<I>& input, const V& val)
{
trace::entering("arith::plus_cst_inplace");
+
mln_precondition(exact(input).has_data());
// Calls the previous version.
Index: trunk/milena/mln/arith/min.hh
===================================================================
--- trunk/milena/mln/arith/min.hh (revision 1513)
+++ trunk/milena/mln/arith/min.hh (revision 1514)
@@ -127,8 +127,8 @@
void min_inplace(Image<L>& lhs, const Image<R>& rhs)
{
trace::entering("arith::min_inplace");
- mln_precondition(exact(rhs).domain() == exact(lhs).domain());
+ mln_precondition(exact(rhs).domain() == exact(lhs).domain());
impl::min_inplace_(mln_trait_image_speed(L)(), exact(lhs),
mln_trait_image_speed(R)(), exact(rhs));
Index: trunk/milena/mln/arith/revert.hh
===================================================================
--- trunk/milena/mln/arith/revert.hh (revision 1513)
+++ trunk/milena/mln/arith/revert.hh (revision 1514)
@@ -113,6 +113,7 @@
mln_concrete(I) revert(const Image<I>& input)
{
trace::entering("arith::revert");
+
mln_precondition(exact(input).has_data());
mln_concrete(I) output;
@@ -127,6 +128,7 @@
void revert_inplace(Image<I>& input)
{
trace::entering("arith::revert_inplace");
+
mln_precondition(exact(input).has_data());
impl::revert_(mln_trait_image_speed(I)(), exact(input), exact(input));
Index: trunk/milena/mln/arith/all.hh
===================================================================
--- trunk/milena/mln/arith/all.hh (revision 1513)
+++ trunk/milena/mln/arith/all.hh (revision 1514)
@@ -41,18 +41,24 @@
namespace arith
{
/// Implementation namespace of arith namespace.
- namespace impl {}
+ namespace impl {
+
+ /// Generic implementation namespace of arith namespace.
+ namespace generic {
+
}
}
+ }
-# include <mln/arith/plus.hh>
-# include <mln/arith/minus.hh>
-# include <mln/arith/times.hh>
+}
# include <mln/arith/min.hh>
+# include <mln/arith/minus.hh>
+# include <mln/arith/plus.hh>
# include <mln/arith/revert.hh>
+# include <mln/arith/times.hh>
#endif // ! MLN_ARITH_ALL_HH
Index: trunk/milena/mln/arith/min.spe.hh
===================================================================
--- trunk/milena/mln/arith/min.spe.hh (revision 1513)
+++ trunk/milena/mln/arith/min.spe.hh (revision 1514)
@@ -53,7 +53,6 @@
template <typename L, typename R>
void min_inplace_(L& lhs, const R& rhs);
-
}
template <typename L, typename R, typename O>
Index: trunk/milena/mln/arith/minus.hh
===================================================================
--- trunk/milena/mln/arith/minus.hh (revision 1513)
+++ trunk/milena/mln/arith/minus.hh (revision 1514)
@@ -197,8 +197,8 @@
operator-(const Image<L>& lhs, const Image<R>& rhs)
{
trace::entering("operator::minus");
- mln_precondition(exact(rhs).domain() == exact(lhs).domain());
+ mln_precondition(exact(rhs).domain() == exact(lhs).domain());
mln_trait_op_minus(L,R) output = arith::minus(lhs, rhs);
trace::exiting("operator::minus");
@@ -210,8 +210,8 @@
operator-=(Image<L>& lhs, const Image<R>& rhs)
{
trace::entering("operator::minus_eq");
- mln_precondition(exact(rhs).domain() == exact(lhs).domain());
+ mln_precondition(exact(rhs).domain() == exact(lhs).domain());
arith::minus_inplace(lhs, rhs);
trace::exiting("operator::minus_eq");
@@ -224,8 +224,8 @@
operator-(const Image<I>& ima, const value::Scalar<S>& s)
{
trace::entering("operator::minus");
- mln_precondition(exact(ima).has_data());
+ mln_precondition(exact(ima).has_data());
mln_trait_op_minus(I,S) output = arith::minus_cst(ima, exact(s));
trace::exiting("operator::minus");
@@ -237,8 +237,8 @@
operator-=(Image<I>& ima, const value::Scalar<S>& s)
{
trace::entering("operator::minus_eq");
- mln_precondition(exact(ima).has_data());
+ mln_precondition(exact(ima).has_data());
arith::minus_cst_inplace(ima, exact(s));
trace::exiting("operator::minus_eq");
@@ -323,6 +323,7 @@
minus(const Image<L>& lhs, const Image<R>& rhs)
{
trace::entering("arith::minus");
+
mln_precondition(exact(rhs).domain() == exact(lhs).domain());
mln_trait_op_minus(L, R) output;
@@ -340,6 +341,7 @@
minus(const Image<L>& lhs, const Image<R>& rhs, const Function_v2v<F>& f)
{
trace::entering("arith::minus");
+
mln_precondition(exact(rhs).domain() == exact(lhs).domain());
mln_ch_value(L, mln_result(F)) output;
@@ -357,6 +359,7 @@
minus(const Image<L>& lhs, const Image<R>& rhs)
{
trace::entering("arith::minus");
+
mln_precondition(exact(rhs).domain() == exact(lhs).domain());
// Calls the previous version.
@@ -373,6 +376,7 @@
minus_cst(const Image<I>& input, const V& val)
{
trace::entering("arith::minus_cst");
+
mln_precondition(exact(input).has_data());
// Calls the previous version.
@@ -389,6 +393,7 @@
minus_cst(const Image<I>& input, const V& val, const Function_v2v<F>& f)
{
trace::entering("arith::minus_cst");
+
mln_precondition(exact(input).has_data());
// Calls the previous version.
@@ -406,6 +411,7 @@
minus_inplace(Image<L>& lhs, const Image<R>& rhs)
{
trace::entering("arith::minus_inplace");
+
mln_precondition(exact(rhs).domain() == exact(lhs).domain());
impl::minus_inplace_(mln_trait_image_speed(L)(), exact(lhs),
@@ -420,6 +426,7 @@
minus_cst_inplace(Image<I>& input, const V& val)
{
trace::entering("arith::minus_cst_inplace");
+
mln_precondition(exact(input).has_data());
// Calls the previous version.
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-11-22 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Review seeds2tiling and fix chamfer.
* mln/geom/seeds2tiling.hh: Add doc and tracing, fix typo and
update code.
* mln/geom/seeds2tiling_with_chamfer.hh: Remove ...
* mln/geom/seeds2tiling_roundness.hh: ... rename it and like
seeds2tiling.
* mln/geom/chamfer.hh,
* mln/canvas/chamfer.hh: Fix headers.
Tests
* tests/seed2tiling.cc: Update tests.
* tests/geom/seed2tiling.cc,
* tests/geom/seed2tiling_roundness.cc: New unit tests for these
algorithms.
---
mln/geom/chamfer.hh | 4 -
mln/geom/seeds2tiling.hh | 30 +++++++
mln/geom/seeds2tiling_roundness.hh | 144 ++++++++++++++++++++++++++++++++++++
tests/geom/seed2tiling.cc | 85 +++++++++++++++++++++
tests/geom/seed2tiling_roundness.cc | 90 ++++++++++++++++++++++
tests/seed2tiling.cc | 6 -
6 files changed, 355 insertions(+), 4 deletions(-)
Index: trunk/milena/tests/geom/seed2tiling_roundness.cc
===================================================================
--- trunk/milena/tests/geom/seed2tiling_roundness.cc (revision 0)
+++ trunk/milena/tests/geom/seed2tiling_roundness.cc (revision 1513)
@@ -0,0 +1,90 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/geom/seed2tiling_roundness.cc
+ *
+ * \brief Tests on mln::geom::seed2tiling_roundness.
+ */
+
+# include <mln/core/image2d.hh>
+# include <mln/core/neighb2d.hh>
+# include <mln/core/w_window2d_int.hh>
+# include <mln/make/win_chamfer.hh>
+# include <mln/geom/seeds2tiling_roundness.hh>
+# include <mln/level/compare.hh>
+# include <mln/debug/println.hh>
+
+int main()
+{
+ using namespace mln;
+ unsigned max = 2048;
+ const w_window2d_int& w_win = make::mk_chamfer_3x3_int<2,3> ();
+
+ unsigned vs [16][16] = {
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ };
+
+ unsigned ws [16][16] = {
+ {1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2},
+ {1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2},
+ {1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2},
+ {1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2},
+ {1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2},
+ {1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2},
+ {1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2},
+ {1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2},
+ {1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3},
+ {1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3},
+ {1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3},
+ {1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3},
+ {1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3},
+ {1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3},
+ {1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3},
+ {1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3}
+ };
+
+ image2d<unsigned> ima (make::image2d(vs));
+ image2d<unsigned> out = geom::seeds2tiling_roundness(ima, w_win, max, c4());
+ image2d<unsigned> ref (make::image2d(ws));
+
+ mln_assertion (ref == out);
+}
Index: trunk/milena/tests/geom/seed2tiling.cc
===================================================================
--- trunk/milena/tests/geom/seed2tiling.cc (revision 0)
+++ trunk/milena/tests/geom/seed2tiling.cc (revision 1513)
@@ -0,0 +1,85 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/geom/seed2tiling.cc
+ *
+ * \brief Tests on mln::geom::seed2tiling.
+ */
+
+
+# include <mln/core/image2d.hh>
+# include <mln/core/neighb2d.hh>
+# include <mln/geom/seeds2tiling.hh>
+# include <mln/level/compare.hh>
+
+int main()
+{
+ using namespace mln;
+
+ unsigned vs [16][16] = {
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ };
+
+ unsigned ws [16][16] = {
+ {1 ,1 ,1 ,1 ,1 ,1 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,2},
+ {1 ,1 ,1 ,1 ,1 ,1 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,2},
+ {1 ,1 ,1 ,1 ,1 ,1 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,2},
+ {1 ,1 ,1 ,1 ,1 ,1 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,2},
+ {1 ,1 ,1 ,1 ,1 ,1 ,1 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,2},
+ {1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,2},
+ {1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,2 ,2 ,2 ,2 ,2 ,2 ,2},
+ {1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,2 ,2 ,2 ,2 ,2 ,2},
+ {1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,3 ,3 ,3 ,3 ,3 ,3},
+ {1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,3 ,3 ,3 ,3 ,3 ,3},
+ {1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,3 ,3 ,3 ,3 ,3 ,3 ,3},
+ {1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,3 ,3 ,3 ,3 ,3 ,3 ,3 ,3},
+ {1 ,1 ,1 ,1 ,1 ,1 ,1 ,3 ,3 ,3 ,3 ,3 ,3 ,3 ,3 ,3},
+ {1 ,1 ,1 ,1 ,1 ,1 ,3 ,3 ,3 ,3 ,3 ,3 ,3 ,3 ,3 ,3},
+ {1 ,1 ,1 ,1 ,1 ,1 ,3 ,3 ,3 ,3 ,3 ,3 ,3 ,3 ,3 ,3},
+ {1 ,1 ,1 ,1 ,1 ,1 ,3 ,3 ,3 ,3 ,3 ,3 ,3 ,3 ,3 ,3}
+ };
+
+ image2d<unsigned> ima (make::image2d(vs));
+ image2d<unsigned> out = geom::seeds2tiling(ima, c4());
+ image2d<unsigned> ref (make::image2d(ws));
+ mln_assertion (ref == out);
+}
Index: trunk/milena/tests/seed2tiling.cc
===================================================================
--- trunk/milena/tests/seed2tiling.cc (revision 1512)
+++ trunk/milena/tests/seed2tiling.cc (revision 1513)
@@ -44,7 +44,7 @@
# include <mln/debug/println.hh>
# include <mln/draw/mesh.hh>
# include <mln/geom/seeds2tiling.hh>
-# include <mln/geom/seeds2tiling_with_chamfer.hh>
+# include <mln/geom/seeds2tiling_roundness.hh>
# include <mln/make/voronoi.hh>
#include <mln/core/image2d.hh>
@@ -85,13 +85,13 @@
std::cout << "ima1 generate with seeds2tiling"
<< std::endl;
- inte = geom::seeds2tiling_with_chamfer(lab, w_win, max, c4 ());
+ inte = geom::seeds2tiling_roundness(lab, w_win, max, c4 ());
border::fill(inte, 0);
level::stretch(inte, inte2);
io::pgm::save(inte2, "ima2.pgm");
- std::cout << "ima2 generate with seeds2tiling_with_chamfer"
+ std::cout << "ima2 generate with seeds2tiling_roundness"
<< std::endl;
}
Index: trunk/milena/mln/geom/seeds2tiling_with_chamfer.hh (deleted)
===================================================================
Index: trunk/milena/mln/geom/seeds2tiling_roundness.hh
===================================================================
--- trunk/milena/mln/geom/seeds2tiling_roundness.hh (revision 0)
+++ trunk/milena/mln/geom/seeds2tiling_roundness.hh (revision 1513)
@@ -0,0 +1,144 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_GEOM_SEEDS2TILING_ROUNDNESS_HH
+# define MLN_GEOM_SEEDS2TILING_ROUNDNESS_HH
+
+/*! \file mln/geom/seeds2tiling_roundness.hh
+ *
+ * \brief seeds2tiling with a method which makes tiles more roundness.
+ */
+
+# include <map>
+
+
+# include <mln/core/p_priority_queue_fast.hh>
+# include <mln/core/clone.hh>
+# include <mln/accu/mean.hh>
+# include <mln/estim/min_max.hh>
+# include <mln/metal/vec.hh>
+# include <mln/geom/chamfer.hh>
+
+
+namespace mln
+{
+ namespace geom
+ {
+
+
+ /*! Take a labeled image \p ima_ with seeds and extend them until
+ * creating tiles nore roundness that the primary version.
+ *
+ * \param[in,out] ima The labeled image with seed.
+ * \param[in] win_w The weight window using by geom::chamfer to compute distance.
+ * \param[in] max Unsigned using by geom::chamfer to compute distance.
+ * \param[in] nbh The neighborhood to use on this algorithm.
+ *
+ * \pre \p ima has to be initialized.
+ *
+ */
+ template <typename I, typename N>
+ I
+ seeds2tiling_roundness (Image<I>& ima_, const w_window2d_int& w_win, unsigned max,
+ const Neighborhood<N>& nbh);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace impl
+ {
+
+ template <typename I, typename N>
+ I
+ seeds2tiling_roundness(Image<I>& ima_, const w_window2d_int& w_win, unsigned max,
+ const Neighborhood<N>& nbh)
+ {
+ trace::entering("geom::impl::seed2tiling_roundness");
+
+ I& ima = exact(ima_);
+ image2d<unsigned> dist = geom::chamfer(ima, w_win, max);
+ I out = clone(ima_);
+ p_priority_queue_fast<mln_psite(I), unsigned> q;
+
+ // Init.
+ {
+ mln_piter(I) p(ima.domain());
+
+ for_all(p)
+ q.push_force(p, max - dist(p));
+ }
+
+
+ // Body: alternative version.
+ {
+ while (! q.is_empty())
+ {
+ mln_psite(I) p = q.front();
+ q.pop();
+ if (out(p) != 0) // p has already been processed so ignore
+ continue;
+ mln_niter(N) n(nbh, p);
+
+ for_all(n) if (ima.has(n))
+ if (out(n) != 0)
+ out(p) = out(n);
+ }
+ }
+
+ trace::exiting("geom::impl::seed2tiling_roundness");
+ return out;
+ }
+
+ } // end of namespace mln::geom::impl
+
+
+ /// Facade
+ template <typename I, typename N>
+ I
+ seeds2tiling_roundness(Image<I>& ima_, const w_window2d_int& w_win, unsigned max,
+ const Neighborhood<N>& nbh)
+ {
+ trace::entering("geom::seed2tiling_roundness");
+
+ mln_precondition(exact(ima_).has_data());
+ I output = impl::seeds2tiling_roundness(ima_, w_win, max, nbh);
+
+ trace::exiting("geom::seed2tiling_roundness");
+ return output;
+ }
+
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::geom
+
+} // end of namespace mln
+
+
+#endif // ! MLN_GEOM_SEEDS2TILING_ROUNDNESS_HH
Index: trunk/milena/mln/geom/seeds2tiling.hh
===================================================================
--- trunk/milena/mln/geom/seeds2tiling.hh (revision 1512)
+++ trunk/milena/mln/geom/seeds2tiling.hh (revision 1513)
@@ -47,17 +47,30 @@
namespace geom
{
+ /*! Take a labeled image \p ima_ with seeds and extend them
+ * until creating tiles.
+ *
+ * \param[in,out] ima The labeled image with seed.
+ * \param[in] nbh The neighborhood to use on this algorithm.
+ *
+ * \pre \p ima has to be initialized.
+ *
+ */
template <typename I, typename N>
I seeds2tiling (Image<I>& ima_, const Neighborhood<N>& nbh);
# ifndef MLN_INCLUDE_ONLY
+ namespace impl
+ {
template <typename I, typename N>
I
seeds2tiling (Image<I>& ima_,
const Neighborhood<N>& nbh)
{
+ trace::entering("geom::impl::seed2tiling");
+
I& ima = exact(ima_);
I out = clone(ima_);
p_queue<mln_psite(I)> q;
@@ -94,9 +107,26 @@
}
}
+ trace::exiting("geom::impl::seed2tiling");
return out;
}
+ } // end of namespace mln::geom::impl
+
+
+ /// Facade
+ template <typename I, typename N>
+ I seeds2tiling(Image<I>& ima_, const Neighborhood<N>& nbh)
+ {
+ trace::entering("geom::seed2tiling");
+
+ mln_precondition(exact(ima_).has_data());
+ I output = impl::seeds2tiling(ima_, nbh);
+
+ trace::exiting("geom::seed2tiling");
+ return output;
+ }
+
# endif // ! MLN_INCLUDE_ONLY
Index: trunk/milena/mln/geom/chamfer.hh
===================================================================
--- trunk/milena/mln/geom/chamfer.hh (revision 1512)
+++ trunk/milena/mln/geom/chamfer.hh (revision 1513)
@@ -36,7 +36,9 @@
# include <mln/level/fill.hh>
# include <mln/core/w_window2d_int.hh>
# include <mln/core/w_window2d_float.hh>
-
+# include <mln/core/sub_image.hh>
+# include <mln/core/image_if_value.hh>
+# include <mln/core/inplace.hh>
# include <mln/canvas/chamfer.hh>
namespace mln
Index: trunk/milena/mln/canvas/chamfer.hh
===================================================================
1
0
22 Nov '07
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Get rid of the former property mechanism for value types.
Start cleaning the histogram-related test.
* tests/histo_compute.cc: Rename as...
* tests/histo/compute.cc: ...this.
Activate the test with int_s<5>.
* tests/accu_all.cc: Inactivate tests on
"median< value::set<bool> >" and
"min_h< value::set<bool> >" since traits for bool are not
equiped with min() and max().
* tests/Makefile.am (SUBDIRS): Sort,
Add histo.
(histo_compute_SOURCES): Remove.
* tests/io_pbm.cc: Simplify.
* tests/histo/Makefile.am (check_PROGRAMS): New.
(compute_SOURCES, TESTS): New.
Preparing to get rid of former property mechanism for value types.
* mln/value/props.hh (mln_card_): Move...
* mln/trait/value_.hh: ...here and rename as...
(mln_card): ...this.
* mln/value/props.hh
(mln_value_sum, mln_value_kind, mln_value_card_): Remove.
(mln_is_lowq): Remove.
(mln_min, mln_max): Move...
* mln/trait/value_.hh: ...here.
* mln/trait/value_.hh (mln_trait_value_card): Rename as...
(mln_card): ...this.
(mln_value_quant_from_card): Rename as...
(mln_value_quant_from_): ...this.
(mln_value_card_from_): New macro.
(mln_nbits, mln_epsilon): New.
* mln/trait/value/nature.hh (matrix): New.
Now get rid of value "props".
* mln/value/props.hh: Remove.
(convert_): Move into...
* mln/value/internal/convert.hh: ...this new file.
(convert_<bool>): New specialization.
Propagate changes.
* tests/value_bool.cc,
* mln/trait/images.hh,
* mln/trait/value/print.hh,
* mln/core/macros.hh,
* mln/math/round_sat.hh,
* mln/metal/mat.hh,
* mln/metal/vec.hh,
* mln/arith/revert.hh,
* mln/arith/revert.spe.hh,
* mln/level/sort_points.hh,
* mln/level/transform.spe.hh,
* mln/level/transform.hh,
* mln/level/stretch.hh,
* mln/accu/min.hh,
* mln/accu/max.hh,
* mln/accu/min_max.hh,
* mln/accu/sum.hh,
* mln/value/proxy.hh,
* mln/value/graylevel.hh,
* mln/value/lut_vec.hh,
* mln/value/ops.hh,
* mln/value/gray.hh,
* mln/value/float01_.hh,
* mln/value/all.hh,
* mln/value/quat.hh,
* mln/value/int_s.hh,
* mln/value/int_u.hh,
* mln/value/int_u_sat.hh,
* mln/value/set.hh,
* mln/value/float01.hh,
* mln/value/builtin/symbolics.hh,
* mln/value/builtin/floatings.hh,
* mln/value/builtin/integers.hh,
* mln/value/rgb.hh,
* mln/value/float01_f.hh,
* mln/value/label.hh,
* mln/fun/v2v/saturate.hh,
* mln/morpho/Rd.hh,
* mln/norm/l1.hh,
* mln/norm/l2.hh: Update.
Misc.
* mln/metal/math/pow.hh (mlc_pow, mlc_pow_int): New macros.
* mln/value/internal/iterable_set.hh: .
* mln/io/pnm/save_header.hh (save_max_val): New specialization
for bool.
* mln/io/pnm/load.hh: Fix.
* mln/io/pbm/save.hh: Fix.
mln/accu/max.hh | 2
mln/accu/min.hh | 2
mln/accu/min_max.hh | 2
mln/accu/sum.hh | 2
mln/arith/revert.hh | 2
mln/arith/revert.spe.hh | 2
mln/core/macros.hh | 3 -
mln/fun/v2v/saturate.hh | 2
mln/io/pbm/save.hh | 35 ++++++------
mln/io/pnm/load.hh | 4 -
mln/io/pnm/save_header.hh | 10 +++
mln/level/sort_points.hh | 16 +++--
mln/level/stretch.hh | 2
mln/level/transform.hh | 2
mln/level/transform.spe.hh | 4 -
mln/math/round_sat.hh | 2
mln/metal/mat.hh | 46 ++++++++++------
mln/metal/math/pow.hh | 5 +
mln/metal/vec.hh | 48 +++++++++-------
mln/morpho/Rd.hh | 2
mln/norm/l1.hh | 24 ++++----
mln/norm/l2.hh | 24 ++++----
mln/trait/images.hh | 7 +-
mln/trait/value/nature.hh | 1
mln/trait/value/print.hh | 4 +
mln/trait/value_.hh | 49 ++++++++++++++---
mln/value/all.hh | 2
mln/value/builtin/floatings.hh | 50 ++++++++++++++++-
mln/value/builtin/integers.hh | 54 +++++++++----------
mln/value/builtin/symbolics.hh | 7 +-
mln/value/float01.hh | 2
mln/value/float01_.hh | 57 +++++++++++++-------
mln/value/float01_f.hh | 52 ++++++++++++------
mln/value/gray.hh | 65 ++++++++++++++++++++++
mln/value/graylevel.hh | 41 +++++++++-----
mln/value/int_s.hh | 41 ++++++++------
mln/value/int_u.hh | 37 +++++++------
mln/value/int_u_sat.hh | 2
mln/value/internal/convert.hh | 105 +++++++++++++++++++++++++++++++++++++
mln/value/internal/iterable_set.hh | 5 -
mln/value/label.hh | 65 +++++++++++++---------
mln/value/lut_vec.hh | 2
mln/value/ops.hh | 6 +-
mln/value/proxy.hh | 37 +++++++++----
mln/value/quat.hh | 31 +++++++++-
mln/value/rgb.hh | 39 +++++++++----
mln/value/set.hh | 11 ++-
tests/Makefile.am | 16 ++---
tests/accu_all.cc | 4 -
tests/histo/Makefile.am | 7 ++
tests/histo/compute.cc | 104 ++++++++++++++++++++++++++++++++++++
tests/io_pbm.cc | 48 ++++------------
tests/value_bool.cc | 4 -
53 files changed, 848 insertions(+), 348 deletions(-)
Index: tests/accu_all.cc
--- tests/accu_all.cc (revision 1511)
+++ tests/accu_all.cc (working copy)
@@ -46,9 +46,9 @@
histo< value::set<bool> > h;
max_<int> ma;
mean_<int> me;
- median< value::set<bool> > med;
+ // median< value::set<bool> > med; // FIXME: bool has no min so workaround!
min_<int> mi;
- min_h< value::set<bool> > mh;
+ // min_h< value::set<bool> > mh; // OK: do not work since bool has no min/max :)
min_max_<int> mm;
nil n;
pair_< min_<int>, max_<int> > p;
Index: tests/Makefile.am
--- tests/Makefile.am (revision 1511)
+++ tests/Makefile.am (working copy)
@@ -2,15 +2,17 @@
include $(top_srcdir)/milena/tests/tests.mk
-SUBDIRS = norm \
- level \
+SUBDIRS = \
arith \
- logical \
- draw \
border \
canvas \
- win \
- set
+ draw \
+ histo \
+ level \
+ logical \
+ norm \
+ set \
+ win
check_PROGRAMS = \
accu_all \
@@ -57,7 +59,6 @@
fun_x2x_translation \
\
hexa \
- histo_compute \
histo_to_image1d \
h_vec \
\
@@ -210,7 +211,6 @@
fun_x2x_translation_SOURCES = fun_x2x_translation.cc
hexa_SOURCES = hexa.cc
-histo_compute_SOURCES = histo_compute.cc
histo_to_image1d_SOURCES = histo_to_image1d.cc
h_vec_SOURCES = h_vec.cc
Index: tests/io_pbm.cc
--- tests/io_pbm.cc (revision 1511)
+++ tests/io_pbm.cc (working copy)
@@ -27,53 +27,29 @@
/*! \file tests/io_pbm.cc
*
- * \brief Test on mln::io::pbm::load and mln::io::pbm::save.
+ * \brief Test on mln::io::pbm::.
*/
#include <mln/core/image2d.hh>
-
-#include <mln/value/int_u8.hh>
-#include <mln/pw/all.hh>
-
-#include <mln/io/pgm/load.hh>
#include <mln/io/pbm/load.hh>
#include <mln/io/pbm/save.hh>
-#include <mln/level/compare.hh>
-#include <mln/level/fill.hh>
-
-#include <mln/display/show.hh>
-#include <mln/display/save.hh>
-
-#include <mln/border/thickness.hh>
int main()
{
using namespace mln;
- using typename value::int_u8;
-
- typedef image2d< bool > I;
-
- border::thickness = 0;
- image2d< int_u8 >
- lena = io::pgm::load("../img/lena.pgm");
-
- I out(lena.domain());
- level::fill(out, pw::value(lena) > pw::cst(127));
- io::pbm::save(out, "out.pbm");
-
- {
- I lena = io::pbm::load("out.pbm");
- image2d<bool> out(lena.domain());
-
- io::pbm::save(lena, "out2.pbm");
+ image2d<bool> pic = io::pbm::load("../img/picasso.pbm");
+ io::pbm::save(pic, "pic.pbm");
+}
- I lena2 = io::pbm::load("out2.pbm");
- io::pbm::save(lena2, "out3.pbm");
+// sample binary image to test with xv, imview, and display
+// to bring into the fore the binary image bug with raw pbm.
- mln_assertion(lena.domain() = lena2.domain());
- mln_assertion(lena = lena2);
- }
-}
+// | | | | -
+// | | - - -
+// | - - - -
+// - - - - -
+// - - - - -
+// - - - - -
Index: tests/histo/compute.cc
--- tests/histo/compute.cc (revision 0)
+++ tests/histo/compute.cc (revision 0)
@@ -0,0 +1,104 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/histo/compute.cc
+ *
+ * \brief Tests on mln::accu::histo and mln::histo::data.
+ */
+
+#include <iterator>
+#include <sstream>
+
+#include <mln/core/image2d.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/value/int_s.hh>
+
+#include <mln/debug/iota.hh>
+#include <mln/debug/println.hh>
+#include <mln/accu/histo.hh>
+#include <mln/histo/compute.hh>
+
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+
+// // Test on 'bool'.
+// {
+// accu::histo< value::set<bool> > h;
+
+// for (unsigned i = 0; i < 5; ++i)
+// h.take(false);
+// for (unsigned i = 0; i < 2; ++i)
+// h.take(true);
+// h.untake(true);
+
+// mln_assertion(h[0] * 10 + h[1] = 51);
+// mln_assertion(h(false) * 10 + h(true) = 51);
+// }
+
+// // Test on 'int_u8'.
+// {
+// image2d<int_u8> ima(3, 3);
+// debug::iota(ima);
+// ima.at(0,0) = 2;
+
+// histo::data< value::set<int_u8> > h = histo::compute(ima);
+// std::ostringstream oss;
+// oss << h;
+// mln_assertion(oss.str() = "2:2 3:1 4:1 5:1 6:1 7:1 8:1 9:1 ");
+
+// int_u8 i = 2;
+// mln_assertion(h(i) = 2);
+// }
+
+ // Test on 'int_s5'.
+ {
+ typedef value::int_s<5> int_s5;
+ image2d<int_s5> ima(3, 3);
+ debug::iota(ima);
+ ima.at(0,0) = 2;
+
+ std::cout << "int_s5: "
+ << value::props< int_s5 >::min() << ' '
+ << value::props< int_s5 >::max() << ' '
+ << value::props< int_s5 >::card_ << std::endl;
+
+ debug::println(ima);
+
+
+ histo::data< value::set<int_s5> > h = histo::compute(ima);
+ std::cout << "nvalues = " << h.vset().nvalues() << std::endl;
+ std::cout << h << std::endl;
+
+ for (unsigned i = 0; i < h.vset().nvalues(); ++i)
+ std::cout << i << ':' << h[i] << ' ';
+ std::cout << std::endl;
+ }
+
+}
Index: tests/histo/Makefile.am
--- tests/histo/Makefile.am (revision 1511)
+++ tests/histo/Makefile.am (working copy)
@@ -1,3 +1,10 @@
## Process this file through Automake to create Makefile.in -*- Makefile -*-
include $(top_srcdir)/milena/tests/tests.mk
+
+check_PROGRAMS = \
+ compute
+
+compute_SOURCES = compute.cc
+
+TESTS = $(check_PROGRAMS)
Index: tests/value_bool.cc
--- tests/value_bool.cc (revision 1511)
+++ tests/value_bool.cc (working copy)
@@ -30,7 +30,7 @@
* \brief Tests on mln::value::set.
*/
-#include <mln/value/props.hh>
+#include <mln/trait/value_.hh>
#include <mln/value/set.hh>
@@ -38,7 +38,7 @@
{
using namespace mln;
- mln_assertion(mln::trait::value_<bool>::card::value = 2);
+ mln_assertion(mln_card(bool) = 2);
value::set<bool> B;
std::cout << B << std::endl;
Index: mln/trait/images.hh
--- mln/trait/images.hh (revision 1511)
+++ mln/trait/images.hh (working copy)
@@ -40,7 +40,7 @@
# include <mln/trait/undef.hh>
# include <mln/trait/image/props.hh>
-# include <mln/value/props.hh>
+# include <mln/trait/value_.hh>
# include <mln/metal/bexpr.hh>
# include <mln/metal/equal.hh>
@@ -148,9 +148,10 @@
struct default_image_ : undefined_image_<I>
{
private:
- typedef metal::bool_<( mln_value_card_(T) = 0 )> is_high_quant_;
+ typedef mlc_equal(mln_trait_value_quant(T),
+ trait::value::quant::high) is_high_quant_;
public:
- typedef mln_value_kind(T) kind;
+ typedef mln_trait_value_kind(T) kind;
typedef mlc_if( is_high_quant_,
trait::image::quant::high,
trait::image::quant::low ) quant;
Index: mln/trait/value_.hh
--- mln/trait/value_.hh (revision 1511)
+++ mln/trait/value_.hh (working copy)
@@ -41,19 +41,38 @@
# include <mln/metal/if.hh>
# include <mln/trait/value/all.hh>
+# include <mln/metal/math/pow.hh>
# define mln_trait_value_nature(V) typename mln::trait::value_< V >::nature
# define mln_trait_value_kind(V) typename mln::trait::value_< V >::kind
# define mln_trait_value_quant(V) typename mln::trait::value_< V >::quant
-# define mln_trait_value_card(V) typename mln::trait::value_< V >::card
-# define mln_value_quant_from_card(C) \
- mlc_if(mln::metal::bool_<( C::value > 65536 || C::value = 0 )>, \
+# define mln_nbits(V) mln::trait::value_< V >::nbits
+# define mln_card(V) mln::trait::value_< V >::card
+# define mln_min(V) mln::trait::value_< V >::min()
+# define mln_max(V) mln::trait::value_< V >::max()
+# define mln_epsilon(V) mln::trait::value_< V >::epsilon()
+
+
+/// Give the summation type for values of type \c T.
+# define mln_trait_value_sum(V) typename mln::trait::value_< V >::sum
+# define mln_sum(V) mln_trait_value_sum(V)
+
+
+
+# define mln_value_quant_from_(C) \
+ mlc_if(mln::metal::bool_<( C > 65536 || C = 0 )>, \
mln::trait::value::quant::high, \
mln::trait::value::quant::low)
+# define mln_value_card_from_(N) \
+ N <= 16 \
+ ? mlc_pow_int((N <= 16 ? 2 : 1), \
+ (N <= 16 ? N : 1)) \
+ : 0
+
namespace mln
@@ -68,24 +87,38 @@
typedef undef nature;
typedef undef kind;
typedef undef quant;
- typedef undef card;
+
+ /*
+ * enum {
+ * nbits = ?,
+ * card = ?
+ * };
+ *
+ * static const E min();
+ * static const E max();
+ * static const E epsilon();
+ */
+
typedef undef sum;
// FIXME: signed or not, with zero or not, centered or not, etc.
};
- struct default_value_
+ struct default_value_ : undefined_value_
{
+ enum {
+ nbits = 0,
+ card = 0
+ };
+
typedef trait::value::nature::unknown nature;
typedef trait::value::kind::data kind;
typedef trait::value::quant::high quant;
- typedef metal::int_<0> card;
- typedef undef sum;
};
template <typename V>
- struct value_ : undefined_value_
+ struct value_ : default_value_
{
};
Index: mln/trait/value/print.hh
--- mln/trait/value/print.hh (revision 1511)
+++ mln/trait/value/print.hh (working copy)
@@ -70,7 +70,9 @@
<< typename the::nature().name() << ", "
<< typename the::kind() .name() << ", "
<< typename the::quant() .name() << ", "
- << typename the::card() .name() << " }" << std::endl;
+ << "nbits=" << the::nbits << ", "
+ << "card=" << the::card << ", "
+ << " }" << std::endl;
}
template <typename V>
Index: mln/trait/value/nature.hh
--- mln/trait/value/nature.hh (revision 1511)
+++ mln/trait/value/nature.hh (working copy)
@@ -54,6 +54,7 @@
struct floating : scalar { std::string name() const { return "nature::floating"; } };
struct vectorial : any { std::string name() const { return "nature::vectorial"; } };
+ struct matrix : any { std::string name() const { return "nature::matrix"; } };
struct symbolic : any { std::string name() const { return "nature::symbolic"; } };
struct structured : any { std::string name() const { return "nature::structured"; } };
Index: mln/core/macros.hh
--- mln/core/macros.hh (revision 1511)
+++ mln/core/macros.hh (working copy)
@@ -173,9 +173,6 @@
# define mln_value(T) typename T::value
# define mln_value_(T) T::value
-/// Shortcut to test if the values of an image with type \c I are lowly quantifized.
-# define mln_is_value_lowq(I) mln_is_lowq( mln_value(I) )
-
/// Shortcut to access the type of value set (vset) associated to T.
# define mln_vset(T) typename T::vset
Index: mln/math/round_sat.hh
--- mln/math/round_sat.hh (revision 1511)
+++ mln/math/round_sat.hh (working copy)
@@ -36,7 +36,7 @@
# include <cmath>
# include <mln/core/concept/function.hh>
-# include <mln/value/props.hh>
+# include <mln/trait/value_.hh>
Index: mln/metal/mat.hh
--- mln/metal/mat.hh (revision 1511)
+++ mln/metal/mat.hh (working copy)
@@ -40,7 +40,7 @@
# include <mln/core/concept/function.hh>
# include <mln/core/contract.hh>
# include <mln/trait/all.hh>
-# include <mln/value/props.hh>
+# include <mln/trait/value_.hh>
# include <mln/metal/vec.hh>
@@ -51,6 +51,35 @@
namespace mln
{
+
+ // Fwd decl.
+ namespace metal {
+ template <unsigned n, unsigned m, typename T> class mat;
+ }
+
+
+ namespace trait
+ {
+
+ template <unsigned n, unsigned m, typename T>
+ struct value_< metal::mat<n,m,T> >
+ {
+ typedef trait::value::nature::matrix nature;
+ typedef trait::value::kind::data kind;
+
+ enum {
+ nbits = n * m * mln_nbits(T),
+ card = n * m * mln_card(T)
+ };
+ typedef mln_value_quant_from_(card) quant;
+
+ typedef metal::mat<n, m, mln_sum(T)> sum;
+ };
+
+ } // end of namespace mln::trait
+
+
+
namespace metal
{
@@ -166,21 +195,6 @@
- namespace value
- {
-
- template <unsigned n, unsigned m, typename T>
- struct props< metal::mat<n,m,T> >
- {
- typedef trait::value::kind::data kind;
- static const std::size_t card_ = n * m * mln_card_(T);
- typedef metal::mat<n,m, mln_value_sum(T)> sum;
- };
-
- } // end of namespace mln::value
-
-
-
namespace metal
{
Index: mln/metal/math/pow.hh
--- mln/metal/math/pow.hh (revision 1511)
+++ mln/metal/math/pow.hh (working copy)
@@ -37,6 +37,11 @@
# include <mln/metal/int.hh>
+# define mlc_pow(X, N) typename mln::metal::math::pow< X, N >::ret
+# define mlc_pow_int(x, n) mln::metal::math::pow_int< x, n >::value
+
+
+
namespace mln
{
Index: mln/metal/vec.hh
--- mln/metal/vec.hh (revision 1511)
+++ mln/metal/vec.hh (working copy)
@@ -40,7 +40,7 @@
# include <mln/core/concept/object.hh>
# include <mln/trait/all.hh>
-# include <mln/value/props.hh>
+# include <mln/trait/value_.hh>
# include <mln/fun/i2v/all_to.hh>
# include <mln/debug/format.hh>
@@ -54,18 +54,41 @@
{
// Fwd decls.
- namespace literal { struct zero_t; }
+ namespace metal {
+ template <unsigned n, typename T> class vec;
+ }
+ namespace literal {
+ struct zero_t;
+ }
template <unsigned d, typename C> struct h_vec;
- namespace metal
+ namespace trait
{
- // Fwd decl.
- template <unsigned n, typename T> class vec;
+ template <unsigned n, typename T>
+ struct value_< mln::metal::vec<n,T> >
+ {
+ typedef trait::value::nature::vectorial nature;
+ typedef trait::value::kind::data kind;
+
+ enum {
+ nbits = n * mln_nbits(T),
+ card = n * mln_card(T)
+ };
+ typedef mln_value_quant_from_(card) quant;
+
+ typedef metal::vec<n, mln_sum(T)> sum;
+ };
+
+ } // end of namespace mln::trait
+
+ namespace metal
+ {
+
namespace internal
{
@@ -253,21 +276,6 @@
- namespace value
- {
-
- template <unsigned n, typename T>
- struct props< metal::vec<n,T> >
- {
- typedef trait::value::kind::data kind;
- static const std::size_t card_ = n * mln_card_(T);
- typedef metal::vec<n, mln_value_sum(T)> sum;
- };
-
- } // end of namespace mln::value
-
-
-
namespace metal
{
Index: mln/arith/revert.hh
--- mln/arith/revert.hh (revision 1511)
+++ mln/arith/revert.hh (working copy)
@@ -36,7 +36,7 @@
*/
# include <mln/core/concept/image.hh>
-# include <mln/value/props.hh>
+# include <mln/trait/value_.hh>
// Specializations are in:
# include <mln/arith/revert.spe.hh>
Index: mln/arith/revert.spe.hh
--- mln/arith/revert.spe.hh (revision 1511)
+++ mln/arith/revert.spe.hh (working copy)
@@ -35,7 +35,7 @@
*/
# include <mln/core/concept/image.hh>
-# include <mln/value/props.hh>
+# include <mln/trait/value_.hh>
# ifndef MLN_INCLUDE_ONLY
Index: mln/level/sort_points.hh
--- mln/level/sort_points.hh (revision 1511)
+++ mln/level/sort_points.hh (working copy)
@@ -107,7 +107,8 @@
template <typename I>
p_array<mln_point(I)>
- sort_points_increasing_(metal::false_, const I& input) // general case
+ sort_points_increasing_(trait::image::quant::any, // general case
+ const I& input)
{
p_array<mln_point(I)> v = convert::to_p_array(input.domain());
std::sort(v.hook_().begin(), v.hook_().end(),
@@ -117,7 +118,8 @@
template <typename I>
p_array<mln_point(I)>
- sort_points_increasing_(metal::true_, const I& input) // low quantization
+ sort_points_increasing_(trait::image::quant::low, // low quantization
+ const I& input)
{
typedef mln_vset(I) S;
const S& vset = input.values();
@@ -148,7 +150,8 @@
template <typename I>
p_array<mln_point(I)>
- sort_points_decreasing_(metal::false_, const I& input) // general case
+ sort_points_decreasing_(trait::image::quant::any, // general case
+ const I& input)
{
p_array<mln_point(I)> v = convert::to_p_array(input.domain());
std::sort(v.hook_().begin(), v.hook_().end(),
@@ -158,7 +161,8 @@
template <typename I>
p_array<mln_point(I)>
- sort_points_decreasing_(metal::true_, const I& input) // low quantization
+ sort_points_decreasing_(trait::image::quant::low, // low quantization
+ const I& input)
{
typedef mln_vset(I) S;
const S& vset = input.values();
@@ -195,7 +199,7 @@
sort_points_increasing(const Image<I>& input)
{
mln_precondition(exact(input).has_data());
- return impl::sort_points_increasing_(mln_is_value_lowq(I)(), exact(input));
+ return impl::sort_points_increasing_(mln_trait_image_quant(I)(), exact(input));
}
template <typename I>
@@ -203,7 +207,7 @@
sort_points_decreasing(const Image<I>& input)
{
mln_precondition(exact(input).has_data());
- return impl::sort_points_decreasing_(mln_is_value_lowq(I)(), exact(input));
+ return impl::sort_points_decreasing_(mln_trait_image_quant(I)(), exact(input));
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/level/transform.spe.hh
--- mln/level/transform.spe.hh (revision 1511)
+++ mln/level/transform.spe.hh (working copy)
@@ -62,7 +62,7 @@
}
template <typename I, typename F, typename O>
- void transform_(metal::false_, // general case
+ void transform_(mln::trait::image::quant::any, // general case
const Image<I>& input_, const Function_v2v<F>& f_, Image<O>& output_)
{
generic::transform_(input_, f_, output_);
@@ -70,7 +70,7 @@
template <typename I, typename F, typename O>
- void transform_(metal::true_, // low quantization
+ void transform_(mln::trait::image::quant::low, // low quantization
const Image<I>& input_, const Function_v2v<F>& f_, Image<O>& output_)
{
trace::entering("level::impl::transform");
Index: mln/level/transform.hh
--- mln/level/transform.hh (revision 1511)
+++ mln/level/transform.hh (working copy)
@@ -110,7 +110,7 @@
trace::entering("level::transform");
mln_precondition(exact(output).domain() >= exact(input).domain());
- impl::transform_(mln_is_value_lowq(I)(),
+ impl::transform_(mln_trait_image_quant(I)(),
exact(input), exact(f), exact(output));
trace::exiting("level::transform");
Index: mln/level/stretch.hh
--- mln/level/stretch.hh (revision 1511)
+++ mln/level/stretch.hh (working copy)
@@ -73,7 +73,7 @@
if (max_ = min_)
return; // FIXME
float min = float(min_), max = float(max_);
- const float epsilon = value::props<float>::epsilon();
+ const float epsilon = mln_epsilon(float);
float m = 0.0f - 0.5f + epsilon;
float M = mln_max(value::int_u<n>) + 0.5f - epsilon;
float a = (M - m) / (max - min);
Index: mln/accu/min.hh
--- mln/accu/min.hh (revision 1511)
+++ mln/accu/min.hh (working copy)
@@ -35,7 +35,7 @@
# include <mln/accu/internal/base.hh>
# include <mln/core/concept/meta_accumulator.hh>
-# include <mln/value/props.hh>
+# include <mln/trait/value_.hh>
# include <mln/util/pix.hh>
Index: mln/accu/max.hh
--- mln/accu/max.hh (revision 1511)
+++ mln/accu/max.hh (working copy)
@@ -34,7 +34,7 @@
*/
# include <mln/core/concept/meta_accumulator.hh>
-# include <mln/value/props.hh>
+# include <mln/trait/value_.hh>
# include <mln/util/pix.hh>
Index: mln/accu/min_max.hh
--- mln/accu/min_max.hh (revision 1511)
+++ mln/accu/min_max.hh (working copy)
@@ -40,7 +40,7 @@
# include <mln/accu/pair.hh>
# include <mln/accu/min.hh>
# include <mln/accu/max.hh>
-# include <mln/value/props.hh>
+# include <mln/trait/value_.hh>
# include <mln/util/pix.hh>
Index: mln/accu/sum.hh
--- mln/accu/sum.hh (revision 1511)
+++ mln/accu/sum.hh (working copy)
@@ -36,7 +36,7 @@
# include <mln/core/concept/meta_accumulator.hh>
# include <mln/accu/internal/base.hh>
-# include <mln/value/props.hh>
+# include <mln/trait/value_.hh>
# include <mln/util/pix.hh>
# include <mln/literal/zero.hh>
Index: mln/value/proxy.hh
--- mln/value/proxy.hh (revision 1511)
+++ mln/value/proxy.hh (working copy)
@@ -34,16 +34,41 @@
*/
# include <mln/core/concept/value.hh>
-# include <mln/value/props.hh>
+# include <mln/trait/value_.hh>
# include <mln/metal/unconst.hh>
namespace mln
{
- namespace value
+ // Fwd decl.
+ namespace value {
+ template <typename I> class proxy;
+ }
+
+
+ namespace trait
+ {
+
+ template <typename I>
+ struct value_< mln::value::proxy<I> >
+ :
+ value_< mln_value(I) >
+ {
+ };
+
+ template <typename I>
+ struct value_< mln::value::proxy<const I> >
+ :
+ value_< mln_value(I) >
{
+ };
+
+ } // end of namespace trait
+
+ namespace value
+ {
/*! \brief Generic proxy class for an image pixel value.
*
@@ -156,14 +181,6 @@
- template <typename I>
- struct props< proxy<I> > : public props< mln_value(I) >
- {
- // Contents is inherited.
- };
-
-
-
/*! \brief Print a value proxy \p x into the output stream \p ostr.
*
* \param[in,out] ostr An output stream.
Index: mln/value/graylevel.hh
--- mln/value/graylevel.hh (revision 1511)
+++ mln/value/graylevel.hh (working copy)
@@ -44,7 +44,7 @@
# include <mln/value/int_u.hh>
# include <mln/value/gray.hh>
-# include <mln/value/props.hh>
+# include <mln/trait/value_.hh>
namespace mln
@@ -144,6 +144,33 @@
mln::value::scalar_<S>) ret;
};
+
+ // 'graylevel<n>' as a value.
+
+ template <unsigned n>
+ struct value_< mln::value::graylevel<n> >
+ {
+ private:
+ typedef mln::value::graylevel<n> self_;
+ public:
+
+ enum {
+ nbits = n,
+ card = mln_value_card_from_(n)
+ };
+
+ typedef trait::value::nature::integer nature; // FIXME: Or scalar?
+ typedef trait::value::kind::gray kind;
+ typedef mln_value_quant_from_(card) quant;
+
+ static const self_ min() { return 0; }
+ static const self_ max() { return card - 1; }
+ static const self_ epsilon() { return 0; }
+
+ typedef float sum;
+ };
+
+
} // end of namespace mln::trait
@@ -219,18 +246,6 @@
};
- template <unsigned n>
- struct props< graylevel<n> >
- {
- static const std::size_t card_ = metal::math::pow_int<2, n>::value;
- static const graylevel<n> min() { return 0; }
- static const graylevel<n> max() { return card_ - 1; }
- static const unsigned nbits = n;
- typedef trait::value::kind::data kind;
- typedef float sum;
- typedef int interop;
- };
-
/// Op<<.
template <unsigned n>
Index: mln/value/lut_vec.hh
--- mln/value/lut_vec.hh (revision 1511)
+++ mln/value/lut_vec.hh (working copy)
@@ -37,7 +37,7 @@
# include <mln/core/concept/value_set.hh>
# include <mln/core/concept/function.hh>
-# include <mln/value/props.hh>
+# include <mln/trait/value_.hh>
namespace mln
Index: mln/value/ops.hh
--- mln/value/ops.hh (revision 1511)
+++ mln/value/ops.hh (working copy)
@@ -37,14 +37,16 @@
# include <mln/value/builtin/all.hh>
# include <mln/value/concept/all.hh>
# include <mln/value/equiv.hh>
-# include <mln/value/props.hh>
+# include <mln/trait/value_.hh>
# include <mln/literal/zero.hh>
# include <mln/literal/one.hh>
# include <mln/literal/ops.hh>
# include <mln/metal/ret.hh>
-# define mln_sum_x(T, U) typename mln::value::props< mln_trait_op_times(T,U) >::sum
+# define mln_trait_value_sum_x(T, U) typename mln::trait::value_< mln_trait_op_times(T,U) >::sum
+
+# define mln_sum_x(T, U) mln_trait_value_sum_x(T, U)
Index: mln/value/gray.hh
--- mln/value/gray.hh (revision 1511)
+++ mln/value/gray.hh (working copy)
@@ -69,9 +69,36 @@
typedef mln::value::gray ret;
};
+
+ // 'gray' as a value.
+
+ template <>
+ struct value_< mln::value::gray >
+ {
+ private:
+ typedef mln::value::gray self_;
+ public:
+
+ enum {
+ nbits = 8 * (sizeof(unsigned) + sizeof(long)),
+ card = 0
+ };
+
+ typedef trait::value::nature::integer nature; // FIXME: Or scalar?
+ typedef trait::value::kind::gray kind;
+ typedef trait::value::quant::high quant;
+
+ static const self_ min();
+ static const self_ max();
+ static const self_ epsilon();
+
+ typedef self_ sum; // FIXME: OK?
+ };
+
} // end of namespace mln::trait
+
namespace value
{
@@ -131,7 +158,7 @@
unsigned nbits_;
/// Value.
- long val_;
+ long val_; // FIXME: Why not int?
};
@@ -151,10 +178,15 @@
gray operator/(const gray& lhs, int s);
+ } // end of namespace mln::value
+
# ifndef MLN_INCLUDE_ONLY
+ namespace value
+ {
+
// Gray.
gray::gray()
@@ -513,10 +545,39 @@
return internal::helper_gray_op_<ret>::div(lhs, rhs);
}
-# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::value
+
+
+ namespace trait
+ {
+
+ // 'gray' as a value.
+
+ const mln::value::gray
+ value_< mln::value::gray >::min()
+ {
+ return mln::value::gray(1, 0);
+ }
+
+ const mln::value::gray
+ value_< mln::value::gray >::max()
+ {
+ return mln::value::gray(1, 1);
+ }
+
+ const mln::value::gray
+ value_< mln::value::gray >::epsilon()
+ {
+ return mln::value::gray(1, 0); // Means '0'.
+ }
+
+ } // end of namespace mln::trait
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
} // end of namespace mln
Index: mln/value/float01_.hh
--- mln/value/float01_.hh (revision 1511)
+++ mln/value/float01_.hh (working copy)
@@ -40,20 +40,49 @@
# include <mln/value/int_u.hh>
# include <mln/value/concept/floating.hh>
+# include <mln/value/internal/convert.hh>
# include <mln/value/float01.hh>
-# include <mln/value/props.hh>
+# include <mln/trait/value_.hh>
namespace mln
{
- namespace value
+ // Fwd decls.
+ namespace value {
+ class float01;
+ template <unsigned n> struct float01_;
+ }
+
+
+ namespace trait
{
- /// Fwd decl.
- class float01;
+ template <unsigned n>
+ struct value_< mln::value::float01_<n> >
+ {
+ enum {
+ nbits = n,
+ card = mln_value_card_from_(nbits)
+ };
+ typedef trait::value::nature::floating nature;
+ typedef trait::value::kind::data kind;
+ typedef mln_value_quant_from_(card) quant;
+
+ static const float min() { return 0.f; }
+ static const float max() { return 1.f; }
+ static const float epsilon() { return 0.f; }
+
+ typedef float sum;
+ };
+
+ } // end of namespace trait
+
+
+ namespace value
+ {
/// General class for the interval [0,1] of |R made discrete (quantized with n bits).
template <unsigned n>
@@ -106,18 +135,6 @@
};
}
- template <unsigned n>
- struct props< float01_<n> >
- {
- static const std::size_t card_ = metal::math::pow_int<2, n>::value;
- static const float min() { return 0.f; }
- static const float max() { return 1.f; }
- static const unsigned nbits = n;
- typedef trait::value::kind::data kind;
- typedef float sum;
- typedef float interop;
- };
-
/// Op<<.
template <unsigned n>
@@ -146,14 +163,14 @@
{
mln_precondition(val >= 0);
mln_precondition(val <= 1);
- this->v_ = int(val * (mln_card_(float01_<n>) - 1)); // FIXME
+ this->v_ = int(val * (mln_card(float01_<n>) - 1)); // FIXME
}
template <unsigned n>
float
float01_<n>::value() const
{
- return float(this->v_) / (mln_card_(float01_<n>) - 1); // FIXME
+ return float(this->v_) / (mln_card(float01_<n>) - 1); // FIXME
}
template <unsigned n>
@@ -169,14 +186,14 @@
{
mln_precondition(val >= 0);
mln_precondition(val <= 1);
- this->v_ = int(val * (mln_card_(float01_<n>) - 1)); // FIXME
+ this->v_ = int(val * (mln_card(float01_<n>) - 1)); // FIXME
return *this;
}
template <unsigned n>
float01_<n>::operator float() const
{
- return float(this->v_) / (mln_card_(float01_<n>) - 1);
+ return float(this->v_) / (mln_card(float01_<n>) - 1);
}
Index: mln/value/all.hh
--- mln/value/all.hh (revision 1511)
+++ mln/value/all.hh (working copy)
@@ -49,7 +49,7 @@
# include <mln/value/aliases.hh>
# include <mln/value/label.hh>
-# include <mln/value/props.hh>
+# include <mln/trait/value_.hh>
# include <mln/value/proxy.hh>
# include <mln/value/interval.hh>
Index: mln/value/quat.hh
--- mln/value/quat.hh (revision 1511)
+++ mln/value/quat.hh (working copy)
@@ -39,7 +39,7 @@
# include <mln/value/concept/vectorial.hh>
# include <mln/value/internal/value_like.hh>
-# include <mln/value/props.hh>
+# include <mln/trait/value_.hh>
# include <mln/metal/vec.hh>
# include <mln/norm/l2.hh>
@@ -90,6 +90,26 @@
typedef mln::value::quat ret;
};
+
+ // 'quat' as a value.
+
+
+ template <>
+ struct value_< mln::value::quat >
+ {
+ typedef trait::value::nature::vectorial nature;
+ typedef trait::value::kind::data kind;
+ typedef trait::value::quant::high quant;
+
+ enum {
+ nbits = 4 * sizeof(float),
+ card = 0
+ };
+
+ typedef mln::value::quat sum;
+ };
+
+
} // end of namespace mln::trait
@@ -376,8 +396,8 @@
{
static const float pi = 3.14159265358979323846;
- mln_precondition(theta > - pi - props<float>::epsilon()
- && theta < pi + props<float>::epsilon());
+ mln_precondition(theta > - pi - mln_epsilon(float)
+ && theta < pi + mln_epsilon(float));
mln_precondition(about_equal(norm::l2(uv), 1.f));
this->v_[0] = cos(theta);
@@ -496,9 +516,10 @@
template <typename T>
bool about_equal(const T& f, const T& q)
{
+ // FIXME: Use abs!
if (f > q)
- return (f - q ) < props<T>::epsilon();
- return (q - f) < props<T>::epsilon();
+ return (f - q ) < mln_epsilon(T);
+ return (q - f) < mln_epsilon(T);
}
bool about_equal(const quat& p, const quat& q)
Index: mln/value/int_s.hh
--- mln/value/int_s.hh (revision 1511)
+++ mln/value/int_s.hh (working copy)
@@ -39,7 +39,7 @@
# include <mln/value/internal/value_like.hh>
# include <mln/value/concept/integer.hh>
# include <mln/value/internal/encoding.hh>
-# include <mln/value/props.hh>
+# include <mln/trait/value_.hh>
# include <mln/trait/all.hh>
# include <mln/debug/format.hh>
@@ -69,8 +69,26 @@
{
template <unsigned n>
- struct value_< mln::value::int_s<n> > : mln::trait::value_integer_<n>
+ struct value_< mln::value::int_s<n> >
{
+ private:
+ typedef mln::value::int_s<n> self_;
+ public:
+
+ enum {
+ nbits = n,
+ card = mln_value_card_from_(n)
+ };
+
+ typedef trait::value::nature::integer nature;
+ typedef trait::value::kind::data kind;
+ typedef mln_value_quant_from_(card) quant;
+
+ static const self_ max() { return card / 2 - 1; }
+ static const self_ min() { return - max(); }
+ static const self_ epsilon() { return 0; }
+
+ typedef float sum;
};
} // end of namespace mln::trait
@@ -88,8 +106,10 @@
template <unsigned n>
struct int_s
:
- public Integer< int_s<n> >,
-
+ private metal::bool_<(n <= 32)>::check_t
+ ,
+ public Integer< int_s<n> >
+ ,
public internal::value_like_< int, // Equivalent.
typename internal::encoding_signed_<n>::ret, // Enc.
int, // Interoperation.
@@ -129,19 +149,6 @@
- template <unsigned n>
- struct props< int_s<n> >
- {
- static const std::size_t card_ = metal::math::pow_int<2, n>::value - 1;
- static const int_s<n> max() { return metal::math::pow_int<2, n-1>::value - 1; }
- static const int_s<n> min() { return - max(); }
- static const unsigned nbits = n;
- typedef trait::value::kind::data kind;
- typedef float sum;
- };
-
-
-
/*! \brief Print an signed integer \p i into the output stream \p ostr.
*
* \param[in,out] ostr An output stream.
Index: mln/value/int_u.hh
--- mln/value/int_u.hh (revision 1511)
+++ mln/value/int_u.hh (working copy)
@@ -39,7 +39,7 @@
# include <mln/value/internal/value_like.hh>
# include <mln/value/internal/encoding.hh>
# include <mln/value/concept/integer.hh>
-# include <mln/value/props.hh>
+# include <mln/trait/value_.hh>
# include <mln/trait/all.hh> // FIXME!
# include <mln/trait/value_.hh>
# include <mln/debug/format.hh>
@@ -74,9 +74,28 @@
typedef int ret;
};
+
template <unsigned n>
- struct value_< mln::value::int_u<n> > : mln::trait::value_integer_<n>
+ struct value_< mln::value::int_u<n> >
{
+ private:
+ typedef mln::value::int_u<n> self_;
+ public:
+
+ enum {
+ nbits = n,
+ card = mln_value_card_from_(n)
+ };
+
+ typedef trait::value::nature::integer nature;
+ typedef trait::value::kind::data kind;
+ typedef mln_value_quant_from_(card) quant;
+
+ static const self_ min() { return 0; }
+ static const self_ max() { return card - 1; }
+ static const self_ epsilon() { return 0; }
+
+ typedef float sum;
};
} // end of namespace mln::trait
@@ -136,20 +155,6 @@
- template <unsigned n>
- struct props< int_u<n> >
- {
- static const std::size_t card_ = metal::math::pow_int<2, n>::value;
- static const int_u<n> min() { return 0; }
- static const int_u<n> max() { return card_ - 1; }
- static const unsigned nbits = n;
- typedef trait::value::kind::data kind;
- typedef float sum;
- typedef int interop;
- };
-
-
-
/*! \brief Print an unsigned integer \p i into the output stream \p ostr.
*
* \param[in,out] ostr An output stream.
Index: mln/value/internal/iterable_set.hh
--- mln/value/internal/iterable_set.hh (revision 1511)
+++ mln/value/internal/iterable_set.hh (working copy)
@@ -34,9 +34,9 @@
*/
# include <mln/core/concept/value_set.hh>
-# include <mln/value/props.hh>
# include <mln/trait/value_.hh>
# include <mln/value/builtin/all.hh>
+# include <mln/value/internal/convert.hh>
namespace mln
@@ -112,8 +112,7 @@
unsigned
iterable_set<T,E>::nvalues() const
{
- typedef mln_trait_value_card(T) card_;
- return card_::value;
+ return mln_card(T);
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/value/internal/convert.hh
--- mln/value/internal/convert.hh (revision 0)
+++ mln/value/internal/convert.hh (revision 0)
@@ -0,0 +1,105 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_VALUE_INTERNAL_CONVERT_HH
+# define MLN_VALUE_INTERNAL_CONVERT_HH
+
+/*! \file mln/value/internal/convert.hh
+ *
+ * \brief Define a conversion between an index and an iterable value.
+ */
+
+# include <mln/trait/value_.hh>
+
+
+namespace mln
+{
+
+ namespace value
+ {
+
+ namespace internal
+ {
+
+ template <typename T>
+ struct convert_
+ {
+ // FIXME: Check that we have a type T compatible with 'int'.
+
+ static T value_at_index(unsigned i);
+ static unsigned index_of_value(const T& v);
+ };
+
+ template <>
+ struct convert_<bool>
+ {
+ static bool value_at_index(unsigned i);
+ static unsigned index_of_value(bool v);
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename T>
+ T
+ convert_<T>::value_at_index(unsigned i)
+ {
+ return T( int(mln_min(T)) + int(i) );
+ }
+
+ template <typename T>
+ unsigned
+ convert_<T>::index_of_value(const T& v)
+ {
+ return unsigned( int(v) - int(mln_min(T)) );
+ }
+
+ // Case of 'bool'.
+
+ bool
+ convert_<bool>::value_at_index(unsigned i)
+ {
+ mln_precondition(i < 2);
+ return i = 1 ? true : false;
+ }
+
+ unsigned
+ convert_<bool>::index_of_value(bool v)
+ {
+ return v ? 1 : 0;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::value::internal
+
+ } // end of namespace mln::value
+
+} // end of namespace mln
+
+
+#endif // ! MLN_VALUE_INTERNAL_CONVERT_HH
Index: mln/value/int_u_sat.hh
--- mln/value/int_u_sat.hh (revision 1511)
+++ mln/value/int_u_sat.hh (working copy)
@@ -38,7 +38,7 @@
# include <mln/value/internal/value_like.hh>
# include <mln/value/concept/integer.hh>
# include <mln/value/internal/encoding.hh>
-# include <mln/value/props.hh>
+# include <mln/trait/value_.hh>
# include <mln/debug/format.hh>
Index: mln/value/set.hh
--- mln/value/set.hh (revision 1511)
+++ mln/value/set.hh (working copy)
@@ -34,7 +34,7 @@
*/
# include <mln/value/internal/iterable_set.hh>
-# include <mln/value/props.hh>
+# include <mln/trait/value_.hh>
namespace mln
@@ -46,12 +46,12 @@
namespace internal
{
- template <typename T, typename E, typename is_lowq = metal::false_>
+ template <typename T, typename E, bool is_lowq = false>
struct set_selector_ // no inheritance
{};
template <typename T, typename E>
- struct set_selector_< T, E, metal::true_ > // lowq so iterable
+ struct set_selector_< T, E, true > // lowq so iterable
:
public iterable_set< T, E >
{};
@@ -65,7 +65,10 @@
* This is the exhaustive set of values obtainable from type \c T.
*/
template <typename T>
- struct set : public internal::set_selector_< T, set<T>, mln_is_lowq(T) >
+ struct set : public internal::set_selector_< T, set<T>,
+ mlc_equal( mln_trait_value_quant(T),
+ mln::trait::value::quant::low )::value
+ >
{
/// Return a singleton.
static const set<T>& the();
Index: mln/value/float01.hh
--- mln/value/float01.hh (revision 1511)
+++ mln/value/float01.hh (working copy)
@@ -38,7 +38,7 @@
# include <mln/core/concept/value.hh>
# include <mln/value/float01_.hh>
-# include <mln/value/props.hh>
+# include <mln/trait/value_.hh>
# include <mln/trait/all.hh> // FIXME!
# include <mln/trait/value_.hh>
Index: mln/value/builtin/symbolics.hh
--- mln/value/builtin/symbolics.hh (revision 1511)
+++ mln/value/builtin/symbolics.hh (working copy)
@@ -56,11 +56,14 @@
template <>
struct value_< bool>
{
- typedef metal::int_<1> nbits;
typedef value::nature::symbolic nature;
typedef value::kind::binary kind;
+
+ enum {
+ nbits = 1,
+ card = 2
+ };
typedef value::quant::low quant;
- typedef metal::int_<2> card;
};
} // end of namespace mln::trait
Index: mln/value/builtin/floatings.hh
--- mln/value/builtin/floatings.hh (revision 1511)
+++ mln/value/builtin/floatings.hh (working copy)
@@ -33,6 +33,8 @@
* \brief Some definitions about built-in floating types.
*/
+# include <limits>
+
# include <mln/value/concept/built_in.hh>
# include <mln/value/concept/floating.hh>
# include <mln/trait/value_.hh>
@@ -63,22 +65,62 @@
template <>
struct value_< float >
{
- typedef metal::int_<8*sizeof(float)> nbits;
+ enum {
+ nbits = 8 * sizeof(float),
+ card = 0
+ };
+
typedef value::nature::floating nature;
typedef value::kind::data kind;
- typedef metal::int_<0> card;
typedef value::quant::high quant;
+
+ static const float min()
+ {
+ static const float min_ = std::numeric_limits<float>::min();
+ return min_;
+ }
+ static const float max()
+ {
+ static const float max_ = std::numeric_limits<float>::max();
+ return max_;
+ }
+ static const float epsilon()
+ {
+ static const float epsilon_ = std::numeric_limits<float>::epsilon();
+ return epsilon_;
+ }
+
typedef float sum;
};
template <>
struct value_< double >
{
- typedef metal::int_<8*sizeof(double)> nbits;
+ enum {
+ nbits = 8 * sizeof(double),
+ card = 0
+ };
+
typedef value::nature::floating nature;
typedef value::kind::data kind;
- typedef metal::int_<0> card;
typedef value::quant::high quant;
+
+ static const double min()
+ {
+ static const double min_ = std::numeric_limits<double>::min();
+ return min_;
+ }
+ static const double max()
+ {
+ static const double max_ = std::numeric_limits<double>::max();
+ return max_;
+ }
+ static const double epsilon()
+ {
+ static const double epsilon_ = std::numeric_limits<double>::epsilon();
+ return epsilon_;
+ }
+
typedef double sum;
};
Index: mln/value/builtin/integers.hh
--- mln/value/builtin/integers.hh (revision 1511)
+++ mln/value/builtin/integers.hh (working copy)
@@ -33,6 +33,8 @@
* \brief Some definitions about built-in integer types.
*/
+# include <limits>
+
# include <mln/value/concept/built_in.hh>
# include <mln/value/concept/integer.hh>
# include <mln/trait/value_.hh>
@@ -63,43 +65,39 @@
namespace internal
{
- template < bool small_n /* = true */, unsigned n_bits >
- struct helper_card_
- {
- typedef metal::math::pow_int<2, n_bits> pow_;
- typedef metal::int_<pow_::value> card;
- };
-
- template < unsigned n_bits >
- struct helper_card_< false, n_bits >
- {
- typedef metal::int_<0> card;
- };
-
- } // end of namespace mln::trait::internal
-
-
- template <unsigned n_bits>
+ template <typename E>
struct value_integer_
{
- typedef typename internal::helper_card_<(n_bits <= 16), n_bits>::card card;
+ private:
+ enum { n = 8 * sizeof(E) };
+ public:
+
+ enum {
+ nbits = n,
+ card = mln_value_card_from_(n)
+ };
- typedef metal::int_<n_bits> nbits;
typedef trait::value::nature::integer nature;
typedef trait::value::kind::data kind;
- typedef mln_value_quant_from_card(card) quant;
+ typedef mln_value_quant_from_(card) quant;
+
+ static const E min() { return std::numeric_limits<E>::min(); }
+ static const E max() { return std::numeric_limits<E>::max(); }
+
typedef float sum;
};
+ } // end of namespace mln::trait::internal
+
- template <> struct value_< unsigned char > : value_integer_< 8 * sizeof(unsigned char) > {};
- template <> struct value_< signed char > : value_integer_< 8 * sizeof( signed char) > {};
- template <> struct value_< unsigned short > : value_integer_< 8 * sizeof(unsigned short) > {};
- template <> struct value_< signed short > : value_integer_< 8 * sizeof( signed short) > {};
- template <> struct value_< unsigned int > : value_integer_< 8 * sizeof(unsigned int) > {};
- template <> struct value_< signed int > : value_integer_< 8 * sizeof( signed int) > {};
- template <> struct value_< unsigned long > : value_integer_< 8 * sizeof(unsigned long) > {};
- template <> struct value_< signed long > : value_integer_< 8 * sizeof( signed long) > {};
+ template <> struct value_< unsigned char > : internal::value_integer_< unsigned char > {};
+ template <> struct value_< signed char > : internal::value_integer_< signed char > {};
+ template <> struct value_< unsigned short > : internal::value_integer_< unsigned short > {};
+ template <> struct value_< signed short > : internal::value_integer_< signed short > {};
+ template <> struct value_< unsigned int > : internal::value_integer_< unsigned int > {};
+ template <> struct value_< signed int > : internal::value_integer_< signed int > {};
+ template <> struct value_< unsigned long > : internal::value_integer_< unsigned long > {};
+ template <> struct value_< signed long > : internal::value_integer_< signed long > {};
} // end of namespace mln::trait
Index: mln/value/rgb.hh
--- mln/value/rgb.hh (revision 1511)
+++ mln/value/rgb.hh (working copy)
@@ -57,6 +57,34 @@
}
+ // Fwd decl.
+ namespace value {
+ template <unsigned n> struct rgb;
+ }
+
+
+ namespace trait
+ {
+
+ template <unsigned n>
+ struct value_< mln::value::rgb<n> >
+ {
+ enum {
+ nbits = 3 * n,
+ card = mln_value_card_from_(nbits)
+ };
+
+ typedef trait::value::nature::vectorial nature;
+ typedef trait::value::kind::color kind;
+ typedef mln_value_quant_from_(card) quant;
+
+ typedef metal::vec<3, float> sum;
+ };
+
+ } // end of namespace trait
+
+
+
namespace value
{
@@ -129,17 +157,6 @@
- template <unsigned n>
- struct props< rgb<n> >
- {
- static const unsigned nbits = 3 * n;
- static const std::size_t card_ = 0; // FIXME: was: metal::math::pow_int<2, nbits>::value;
- typedef trait::value::kind::color kind;
- typedef metal::vec<3, float> sum;
- typedef metal::vec<3, int> interop;
- };
-
-
/*! \brief Print an rgb \p c into the output stream \p ostr.
*
* \param[in,out] ostr An output stream.
Index: mln/value/float01_f.hh
--- mln/value/float01_f.hh (revision 1511)
+++ mln/value/float01_f.hh (working copy)
@@ -36,18 +36,49 @@
# include <iostream>
# include <mln/value/internal/value_like.hh>
# include <mln/value/concept/floating.hh>
-# include <mln/value/props.hh>
+# include <mln/value/builtin/floatings.hh>
+# include <mln/trait/value_.hh>
+
namespace mln
{
- namespace value
+ // Fwd decls.
+ namespace value {
+ struct float01;
+ struct float01_f;
+ }
+
+
+ namespace trait
{
- /// Fwd decl.
- struct float01;
+ template <>
+ struct value_< mln::value::float01_f >
+ {
+ typedef trait::value::nature::floating nature;
+ typedef trait::value::kind::data kind;
+ typedef trait::value::quant::high quant;
+
+ enum {
+ nbits = 8 * sizeof(float),
+ card = 0
+ };
+
+ static const float min() { return 0; }
+ static const float max() { return 1; }
+ static const float epsilon() { return mln_epsilon(float); }
+
+ typedef float sum;
+ };
+
+ } // end of namespace trait
+
+ namespace value
+ {
+
/// Class for floating values restricted to the interval [0..1].
struct float01_f
:
@@ -75,19 +106,6 @@
};
- template <>
- struct props< float01_f >
- {
- static const std::size_t card_ = 0;
- static const float min() { return 0; }
- static const float max() { return 1; }
- //static const unsigned nbits = n;
- typedef trait::value::kind::data kind;
- typedef float sum;
- typedef float interop;
- };
-
-
# ifndef MLN_INCLUDE_ONLY
// Float01_F.
Index: mln/value/label.hh
--- mln/value/label.hh (revision 1511)
+++ mln/value/label.hh (working copy)
@@ -34,19 +34,53 @@
*/
# include <mln/metal/math/pow.hh>
-# include <mln/value/internal/value_like.hh>
# include <mln/value/concept/symbolic.hh>
+# include <mln/value/internal/value_like.hh>
+# include <mln/value/internal/convert.hh>
# include <mln/value/internal/encoding.hh>
-# include <mln/value/props.hh>
+# include <mln/trait/value_.hh>
namespace mln
{
- namespace value
+ // Fwd decl.
+ namespace value {
+ template <unsigned n> struct label;
+ }
+
+
+
+ namespace trait
+ {
+
+ template <unsigned n>
+ struct value_< mln::value::label<n> >
{
+ private:
+ typedef mln::value::label<n> self_;
+ public:
+
+ enum {
+ nbits = n,
+ card = mln_value_card_from_(n)
+ };
+
+ typedef trait::value::nature::symbolic nature;
+ typedef trait::value::kind::label kind;
+ typedef mln_value_quant_from_(card) quant;
+
+ static const self_ min() { return 0; }
+ static const self_ max() { return card - 1; }
+ };
+
+ } // end of namespace trait
+
+ namespace value
+ {
+
/*! \brief Label value class.
*
@@ -125,23 +159,6 @@
-
- template <unsigned n>
- struct props< label<n> >
- {
- static const std::size_t card_ = metal::math::pow_int<2, n>::value;
- static const label<n> min; // = 0
- static const label<n> max; // = card_ - 1
- static const unsigned nbits = n;
- typedef trait::value::kind::label kind;
- };
-
-
-
-
-
-
-
/*! \brief Print a label \p l into the output stream \p ostr.
*
* \param[in,out] ostr An output stream.
@@ -217,14 +234,6 @@
}
template <unsigned n>
- const label<n>
- props< label<n> >::min = 0;
-
- template <unsigned n>
- const label<n>
- props< label<n> >::max = metal::math::pow_int<2, n>::value - 1;
-
- template <unsigned n>
std::ostream& operator<<(std::ostream& ostr, const label<n>& i)
{
return ostr << i.to_enc();
Index: mln/fun/v2v/saturate.hh
--- mln/fun/v2v/saturate.hh (revision 1511)
+++ mln/fun/v2v/saturate.hh (working copy)
@@ -35,7 +35,7 @@
# include <mln/core/concept/function.hh>
# include <mln/metal/converts_to.hh>
-# include <mln/value/props.hh>
+# include <mln/trait/value_.hh>
namespace mln
Index: mln/morpho/Rd.hh
--- mln/morpho/Rd.hh (revision 1511)
+++ mln/morpho/Rd.hh (working copy)
@@ -39,7 +39,7 @@
# include <mln/core/concept/image.hh>
# include <mln/core/concept/neighborhood.hh>
-# include <mln/value/props.hh>
+# include <mln/trait/value_.hh>
# include <mln/level/fill.hh>
# include <mln/level/compare.hh>
Index: mln/io/pnm/save_header.hh
--- mln/io/pnm/save_header.hh (revision 1511)
+++ mln/io/pnm/save_header.hh (working copy)
@@ -61,6 +61,10 @@
file << unsigned(mln_max(V)) << std::endl;
}
+ void save_max_val(bool&, std::ofstream& file)
+ {
+ }
+
template <unsigned int n>
void save_max_val(value::rgb<n>&, std::ofstream& file)
{
@@ -80,7 +84,11 @@
abort();
}
file << "P" << type << std::endl;
- file << "# milena" << std::endl;
+ file << "# Generated by milena 1.0 http://olena.lrde.epita.fr" << std::endl;
+ file << "# EPITA Research and Development Laboratory (LRDE)" << std::endl;
+ // We have a two-line comment because xv is buggy for some
+ // tiny binary images and their workaround is to have such a
+ // two-line comment...
file << geom::ncols(ima) << ' ' << geom::nrows(ima) << std::endl;
mln_value(I) i;
Index: mln/io/pnm/load.hh
--- mln/io/pnm/load.hh (revision 1511)
+++ mln/io/pnm/load.hh (working copy)
@@ -189,9 +189,9 @@
read_header(type_ - 3, type_, file, type,
nrows, ncols, maxval);
- if (value::props< mln_value(I) >::max() != maxval)
+ if (mln_max(mln_value(I)) != maxval)
{
- std::cerr << "max ref : " << value::props< mln_value(I) >::max()
+ std::cerr << "max ref : " << mln_max(mln_value(I))
<< "max image : " << maxval
<< std::endl;
Index: mln/io/pbm/save.hh
--- mln/io/pbm/save.hh (revision 1511)
+++ mln/io/pbm/save.hh (working copy)
@@ -80,29 +80,30 @@
io::pnm::save_header(PBM, ima, filename, file);
- const int
- min_row = geom::min_row(ima),
- max_row = geom::max_row(ima),
- min_col = geom::min_col(ima),
- max_col = geom::max_col(ima);
- point2d p;
-
+ int ncols = geom::ncols(ima);
+ int col = 0;
+ int stride = 0;
unsigned char c = 0;
- int i = 0;
- mln_piter(I) it(ima.domain());
- for_all(it)
+ mln_fwd_piter(I) p(ima.domain());
+ for_all(p)
+ {
+ c <<= 1;
+ c += (ima(p) = true ? 1 : 0); // FIXME: Swap.
+ if (++col >= ncols)
{
- if (i && (i = 8))
+ c <<= (8 - stride - 1);
+ file << c;
+ c = col = stride = 0;
+ }
+ else
+ if (++stride >= 8)
{
- file.write((char*)(&c), 1);
- i = 0;
+ file << c;
+ c = stride = 0;
}
- c = c * 2;
- c += ima(it);
- ++i;
}
- file.write((char*)(&c), 1);
+ mln_postcondition(stride = 0);
}
} // end of namespace mln::io::impl
Index: mln/norm/l1.hh
--- mln/norm/l1.hh (revision 1511)
+++ mln/norm/l1.hh (working copy)
@@ -47,19 +47,19 @@
/// L1-norm of a vector \a vec.
/// \{
template <unsigned n, typename C>
- mln_value_sum(C) l1(const C (&vec)[n]);
+ mln_sum(C) l1(const C (&vec)[n]);
template <unsigned n, typename C>
- mln_value_sum(C) l1(const metal::vec<n,C>& vec);
+ mln_sum(C) l1(const metal::vec<n,C>& vec);
/// \}
/// L1-norm distance between vectors \a vec1 and \a vec2.
/// \{
template <unsigned n, typename C>
- mln_value_sum(C) l1_distance(const C (&vec1)[n], const C (&vec2)[n]);
+ mln_sum(C) l1_distance(const C (&vec1)[n], const C (&vec2)[n]);
template <unsigned n, typename C>
- mln_value_sum(C) l1_distance(const metal::vec<n,C>& vec1,
+ mln_sum(C) l1_distance(const metal::vec<n,C>& vec1,
const metal::vec<n,C>& vec2);
/// \}
@@ -69,20 +69,20 @@
namespace impl
{
template <unsigned n, typename C, typename V>
- mln_value_sum(C)
+ mln_sum(C)
l1_(const V& vec)
{
- mln_value_sum(C) m = 0;
+ mln_sum(C) m = 0;
for (unsigned i = 0; i < n; ++i)
m += mln::math::abs (vec[i]);
return m;
}
template <unsigned n, typename C, typename V>
- mln_value_sum(C)
+ mln_sum(C)
l1_distance_(const V& vec1, const V& vec2)
{
- mln_value_sum(C) d = 0;
+ mln_sum(C) d = 0;
for (unsigned i = 0; i < n; ++i)
d += mln::math::abs (vec1[i] - vec2[i]);
return d;
@@ -96,28 +96,28 @@
`----------*/
template <unsigned n, typename C>
- mln_value_sum(C)
+ mln_sum(C)
l1(const C (&vec)[n])
{
return impl::l1_<n, C>(vec);
}
template <unsigned n, typename C>
- mln_value_sum(C)
+ mln_sum(C)
l1(const metal::vec<n,C>& vec)
{
return impl::l1_<n, C>(vec);
}
template <unsigned n, typename C>
- mln_value_sum(C)
+ mln_sum(C)
l1_distance(const C (&vec1)[n], const C (&vec2)[n])
{
return impl::l1_distance_<n, C>(vec1, vec2);
}
template <unsigned n, typename C>
- mln_value_sum(C)
+ mln_sum(C)
l1_distance(const metal::vec<n,C>& vec1, const metal::vec<n,C>& vec2)
{
return impl::l1_distance_<n, C>(vec1, vec2);
Index: mln/norm/l2.hh
--- mln/norm/l2.hh (revision 1511)
+++ mln/norm/l2.hh (working copy)
@@ -48,19 +48,19 @@
/// L2-norm of a vector \a vec.
/// \{
template <unsigned n, typename C>
- mln_value_sum(C) l2(const C (&vec)[n]);
+ mln_sum(C) l2(const C (&vec)[n]);
template <unsigned n, typename C>
- mln_value_sum(C) l2(const metal::vec<n,C>& vec);
+ mln_sum(C) l2(const metal::vec<n,C>& vec);
/// \}
/// L2-norm distance between vectors \a vec1 and \p vec2.
/// \{
template <unsigned n, typename C>
- mln_value_sum(C) l2_distance(const C (&vec1)[n], const C (&vec2)[n]);
+ mln_sum(C) l2_distance(const C (&vec1)[n], const C (&vec2)[n]);
template <unsigned n, typename C>
- mln_value_sum(C) l2_distance(const metal::vec<n,C>& vec1,
+ mln_sum(C) l2_distance(const metal::vec<n,C>& vec1,
const metal::vec<n,C>& vec2);
/// \}
@@ -71,20 +71,20 @@
{
template <unsigned n, typename C, typename V>
- mln_value_sum(C)
+ mln_sum(C)
l2_(const V& vec)
{
- mln_value_sum(C) m = 0;
+ mln_sum(C) m = 0;
for (unsigned i = 0; i < n; ++i)
m += mln::math::sqr(vec[i]);
return mln::math::sqrt(m);
}
template <unsigned n, typename C, typename V>
- mln_value_sum(C)
+ mln_sum(C)
l2_distance_(const V& vec1, const V& vec2)
{
- mln_value_sum(C) d = 0;
+ mln_sum(C) d = 0;
for (unsigned i = 0; i < n; ++i)
d += mln::math::sqr(vec1[i] - vec2[i]);
return mln::math::sqrt(d);
@@ -98,28 +98,28 @@
`----------*/
template <unsigned n, typename C>
- mln_value_sum(C)
+ mln_sum(C)
l2(const C (&vec)[n])
{
return impl::l2_<n, C>(vec);
}
template <unsigned n, typename C>
- mln_value_sum(C)
+ mln_sum(C)
l2(const metal::vec<n,C>& vec)
{
return impl::l2_<n, C>(vec);
}
template <unsigned n, typename C>
- mln_value_sum(C)
+ mln_sum(C)
l2_distance(const C (&vec1)[n], const C (&vec2)[n])
{
return impl::l2_distance_<n, C>(vec1, vec2);
}
template <unsigned n, typename C>
- mln_value_sum(C)
+ mln_sum(C)
l2_distance(const metal::vec<n,C>& vec1, const metal::vec<n,C>& vec2)
{
return impl::l2_distance_<n, C>(vec1, vec2);
1
0
22 Nov '07
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-11-22 Simon Nivault <simon.nivault(a)lrde.epita.fr>
Review the set directory and add tests.
* mln/set/all.hh,
* mln/set/diff.hh,
* mln/set/inter.hh,
* mln/set/is_subset_of.hh,
* mln/set/sym_diff.hh,
* mln/set/uni.hh: Review.
* tests/Makefile.am,
* tests/set/Makefile.am,
* tests/set/diff.cc,
* tests/set/inter.cc,
* tests/set/is_subset_of.cc,
* tests/set/sym_diff.cc,
* tests/set/uni.cc: Add tests.
* mln/make/pix.hh: Doc.
---
mln/make/pix.hh | 8 +++
mln/set/all.hh | 1
mln/set/diff.hh | 15 +++++--
mln/set/inter.hh | 4 +
mln/set/is_subset_of.hh | 13 ++++++
mln/set/sym_diff.hh | 14 +++++-
mln/set/uni.hh | 4 +
tests/Makefile.am | 3 -
tests/set/Makefile.am | 15 +++++++
tests/set/diff.cc | 93 +++++++++++++++++++++++++++++++++++++++++++++
tests/set/inter.cc | 94 ++++++++++++++++++++++++++++++++++++++++++++++
tests/set/is_subset_of.cc | 79 ++++++++++++++++++++++++++++++++++++++
tests/set/sym_diff.cc | 93 +++++++++++++++++++++++++++++++++++++++++++++
tests/set/uni.cc | 93 +++++++++++++++++++++++++++++++++++++++++++++
14 files changed, 522 insertions(+), 7 deletions(-)
Index: trunk/milena/tests/Makefile.am
===================================================================
--- trunk/milena/tests/Makefile.am (revision 1510)
+++ trunk/milena/tests/Makefile.am (revision 1511)
@@ -9,7 +9,8 @@
draw \
border \
canvas \
- win
+ win \
+ set
check_PROGRAMS = \
accu_all \
Index: trunk/milena/tests/set/uni.cc
===================================================================
--- trunk/milena/tests/set/uni.cc (revision 0)
+++ trunk/milena/tests/set/uni.cc (revision 1511)
@@ -0,0 +1,93 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/set/uni.cc
+ *
+ * \brief Tests on mln::set::uni.
+ */
+
+#include <mln/set/uni.hh>
+#include <mln/core/dpoint2d.hh>
+
+int main()
+{
+ using namespace mln;
+
+ {
+ window<dpoint2d> win1;
+ win1
+ .insert( 2, 7)
+ .insert( 2, 1)
+ .insert(-4, 0)
+ .insert( 0, 0)
+ .insert( 1, 1)
+ .insert( 6, 5);
+ window<dpoint2d> win2;
+ win2
+ .insert( 2, 7)
+ .insert(-2, 1)
+ .insert(-4, 0)
+ .insert( 1,-1)
+ .insert( 6, 5);
+ window<dpoint2d> win3 = set::uni(win1, win2);
+ mln_assertion(win3.has(dpoint2d( 2, 1)));
+ mln_assertion(win3.has(dpoint2d( 0, 0)));
+ mln_assertion(win3.has(dpoint2d( 1, 1)));
+ mln_assertion(win3.has(dpoint2d( 2, 7)));
+ mln_assertion(win3.has(dpoint2d(-2, 1)));
+ mln_assertion(win3.has(dpoint2d(-4, 0)));
+ mln_assertion(win3.has(dpoint2d( 1,-1)));
+ mln_assertion(win3.has(dpoint2d( 6, 5)));
+ }
+
+ {
+ p_set<point2d> pst1;
+ pst1
+ .insert(point2d( 2, 7))
+ .insert(point2d( 2, 1))
+ .insert(point2d(-4, 0))
+ .insert(point2d( 0, 0))
+ .insert(point2d( 1, 1))
+ .insert(point2d( 6, 5));
+ p_set<point2d> pst2;
+ pst2
+ .insert(point2d( 2, 7))
+ .insert(point2d(-2, 1))
+ .insert(point2d(-4, 0))
+ .insert(point2d( 1,-1))
+ .insert(point2d( 6, 5));
+ p_set<point2d> pst3 = set::uni(pst1, pst2);
+ mln_assertion(pst3.has(point2d( 2, 1)));
+ mln_assertion(pst3.has(point2d( 0, 0)));
+ mln_assertion(pst3.has(point2d( 1, 1)));
+ mln_assertion(pst3.has(point2d( 2, 7)));
+ mln_assertion(pst3.has(point2d(-2, 1)));
+ mln_assertion(pst3.has(point2d(-4, 0)));
+ mln_assertion(pst3.has(point2d( 1,-1)));
+ mln_assertion(pst3.has(point2d( 6, 5)));
+ }
+}
Index: trunk/milena/tests/set/sym_diff.cc
===================================================================
--- trunk/milena/tests/set/sym_diff.cc (revision 0)
+++ trunk/milena/tests/set/sym_diff.cc (revision 1511)
@@ -0,0 +1,93 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/set/sym_diff.cc
+ *
+ * \brief Tests on mln::set::sym_diff.
+ */
+
+#include <mln/set/sym_diff.hh>
+#include <mln/core/dpoint2d.hh>
+
+int main()
+{
+ using namespace mln;
+
+ {
+ window<dpoint2d> win1;
+ win1
+ .insert( 2, 7)
+ .insert( 2, 1)
+ .insert(-4, 0)
+ .insert( 0, 0)
+ .insert( 1, 1)
+ .insert( 6, 5);
+ window<dpoint2d> win2;
+ win2
+ .insert( 2, 7)
+ .insert(-2, 1)
+ .insert(-4, 0)
+ .insert( 1,-1)
+ .insert( 6, 5);
+ window<dpoint2d> win3 = set::sym_diff(win1, win2);
+ mln_assertion(win3.has(dpoint2d( 2, 1)));
+ mln_assertion(win3.has(dpoint2d( 0, 0)));
+ mln_assertion(win3.has(dpoint2d( 1, 1)));
+ mln_assertion(!win3.has(dpoint2d( 2, 7)));
+ mln_assertion(win3.has(dpoint2d(-2, 1)));
+ mln_assertion(!win3.has(dpoint2d(-4, 0)));
+ mln_assertion(win3.has(dpoint2d( 1,-1)));
+ mln_assertion(!win3.has(dpoint2d( 6, 5)));
+ }
+
+ {
+ p_set<point2d> pst1;
+ pst1
+ .insert(point2d( 2, 7))
+ .insert(point2d( 2, 1))
+ .insert(point2d(-4, 0))
+ .insert(point2d( 0, 0))
+ .insert(point2d( 1, 1))
+ .insert(point2d( 6, 5));
+ p_set<point2d> pst2;
+ pst2
+ .insert(point2d( 2, 7))
+ .insert(point2d(-2, 1))
+ .insert(point2d(-4, 0))
+ .insert(point2d( 1,-1))
+ .insert(point2d( 6, 5));
+ p_set<point2d> pst3 = set::sym_diff(pst1, pst2);
+ mln_assertion(pst3.has(point2d( 2, 1)));
+ mln_assertion(pst3.has(point2d( 0, 0)));
+ mln_assertion(pst3.has(point2d( 1, 1)));
+ mln_assertion(!pst3.has(point2d( 2, 7)));
+ mln_assertion(pst3.has(point2d(-2, 1)));
+ mln_assertion(!pst3.has(point2d(-4, 0)));
+ mln_assertion(pst3.has(point2d( 1,-1)));
+ mln_assertion(!pst3.has(point2d( 6, 5)));
+ }
+}
Index: trunk/milena/tests/set/inter.cc
===================================================================
--- trunk/milena/tests/set/inter.cc (revision 0)
+++ trunk/milena/tests/set/inter.cc (revision 1511)
@@ -0,0 +1,94 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/set/inter.cc
+ *
+ * \brief Tests on mln::set::inter.
+ */
+
+#include <mln/set/inter.hh>
+#include <mln/core/dpoint2d.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ {
+ window<dpoint2d> win1;
+ win1
+ .insert( 2, 7)
+ .insert( 2, 1)
+ .insert(-4, 0)
+ .insert( 0, 0)
+ .insert( 1, 1)
+ .insert( 6, 5);
+ window<dpoint2d> win2;
+ win2
+ .insert( 2, 7)
+ .insert(-2, 1)
+ .insert(-4, 0)
+ .insert( 1,-1)
+ .insert( 6, 5);
+ window<dpoint2d> win3 = set::inter(win1, win2);
+ mln_assertion(!win3.has(dpoint2d( 2, 1)));
+ mln_assertion(!win3.has(dpoint2d( 0, 0)));
+ mln_assertion(!win3.has(dpoint2d( 1, 1)));
+ mln_assertion(win3.has(dpoint2d( 2, 7)));
+ mln_assertion(!win3.has(dpoint2d(-2, 1)));
+ mln_assertion(win3.has(dpoint2d(-4, 0)));
+ mln_assertion(!win3.has(dpoint2d( 1,-1)));
+ mln_assertion(win3.has(dpoint2d( 6, 5)));
+ }
+
+ {
+ p_set<point2d> pst1;
+ pst1
+ .insert(point2d( 2, 7))
+ .insert(point2d( 2, 1))
+ .insert(point2d(-4, 0))
+ .insert(point2d( 0, 0))
+ .insert(point2d( 1, 1))
+ .insert(point2d( 6, 5));
+ p_set<point2d> pst2;
+ pst2
+ .insert(point2d( 2, 7))
+ .insert(point2d(-2, 1))
+ .insert(point2d(-4, 0))
+ .insert(point2d( 1,-1))
+ .insert(point2d( 6, 5));
+ p_set<point2d> pst3 = set::inter(pst1, pst2);
+ mln_assertion(!pst3.has(point2d( 2, 1)));
+ mln_assertion(!pst3.has(point2d( 0, 0)));
+ mln_assertion(!pst3.has(point2d( 1, 1)));
+ mln_assertion(pst3.has(point2d( 2, 7)));
+ mln_assertion(!pst3.has(point2d(-2, 1)));
+ mln_assertion(pst3.has(point2d(-4, 0)));
+ mln_assertion(!pst3.has(point2d( 1,-1)));
+ mln_assertion(pst3.has(point2d( 6, 5)));
+ }
+}
Index: trunk/milena/tests/set/is_subset_of.cc
===================================================================
--- trunk/milena/tests/set/is_subset_of.cc (revision 0)
+++ trunk/milena/tests/set/is_subset_of.cc (revision 1511)
@@ -0,0 +1,79 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/set/is_subset_of.cc
+ *
+ * \brief Tests on mln::set::is_subset_of.
+ */
+
+#include <mln/set/is_subset_of.hh>
+#include <mln/core/p_set.hh>
+#include <mln/core/point2d.hh>
+
+int main()
+{
+ using namespace mln;
+
+ {
+ p_set<point2d> pst1;
+ p_set<point2d> pst2;
+ p_set<point2d> pst3;
+ p_set<point2d> pst4;
+ pst1
+ .insert(point2d( 2, 7))
+ .insert(point2d( 2, 1))
+ .insert(point2d(-4, 0))
+ .insert(point2d( 0, 0))
+ .insert(point2d( 1, 1))
+ .insert(point2d( 6, 5));
+ pst2
+ .insert(point2d( 2, 7))
+ .insert(point2d(-2, 1))
+ .insert(point2d(-4, 0))
+ .insert(point2d( 1,-1))
+ .insert(point2d( 6, 5));
+ pst3
+ .insert(point2d( 2, 7))
+ .insert(point2d( 2, 1))
+ .insert(point2d(-4, 0))
+ .insert(point2d( 0, 0))
+ .insert(point2d( 1, 1))
+ .insert(point2d( 6, 5))
+ .insert(point2d(-2, 1))
+ .insert(point2d( 1,-1));
+
+ mln_assertion(set::is_subset_of(pst1, pst3));
+ mln_assertion(set::is_subset_of(pst2, pst3));
+ mln_assertion(!set::is_subset_of(pst3, pst1));
+ mln_assertion(!set::is_subset_of(pst3, pst2));
+ mln_assertion(set::is_subset_of(pst3, pst3));
+ mln_assertion(set::is_subset_of(pst4, pst1));
+ mln_assertion(set::is_subset_of(pst4, pst2));
+ mln_assertion(set::is_subset_of(pst4, pst3));
+ mln_assertion(set::is_subset_of(pst4, pst4));
+ }
+}
Index: trunk/milena/tests/set/Makefile.am
===================================================================
--- trunk/milena/tests/set/Makefile.am (revision 1510)
+++ trunk/milena/tests/set/Makefile.am (revision 1511)
@@ -1,3 +1,18 @@
## Process this file through Automake to create Makefile.in -*- Makefile -*-
include $(top_srcdir)/milena/tests/tests.mk
+
+check_PROGRAMS = \
+ diff \
+ inter \
+ is_subset_of \
+ sym_diff \
+ uni
+
+diff_SOURCES = diff.cc
+inter_SOURCES = inter.cc
+is_subset_SOURCES = is_subset.cc
+sym_diff_SOURCES = sym_diff.cc
+uni_SOURCES = uni.cc
+
+TESTS = $(check_PROGRAMS)
Index: trunk/milena/tests/set/diff.cc
===================================================================
--- trunk/milena/tests/set/diff.cc (revision 0)
+++ trunk/milena/tests/set/diff.cc (revision 1511)
@@ -0,0 +1,93 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/set/diff.cc
+ *
+ * \brief Tests on mln::set::diff.
+ */
+
+#include <mln/set/diff.hh>
+#include <mln/core/dpoint2d.hh>
+
+int main()
+{
+ using namespace mln;
+
+ {
+ window<dpoint2d> win1;
+ win1
+ .insert( 2, 7)
+ .insert( 2, 1)
+ .insert(-4, 0)
+ .insert( 0, 0)
+ .insert( 1, 1)
+ .insert( 6, 5);
+ window<dpoint2d> win2;
+ win2
+ .insert( 2, 7)
+ .insert(-2, 1)
+ .insert(-4, 0)
+ .insert( 1,-1)
+ .insert( 6, 5);
+ window<dpoint2d> win3 = set::diff(win1, win2);
+ mln_assertion(win3.has(dpoint2d( 2, 1)));
+ mln_assertion(win3.has(dpoint2d( 0, 0)));
+ mln_assertion(win3.has(dpoint2d( 1, 1)));
+ mln_assertion(!win3.has(dpoint2d( 2, 7)));
+ mln_assertion(!win3.has(dpoint2d(-2, 1)));
+ mln_assertion(!win3.has(dpoint2d(-4, 0)));
+ mln_assertion(!win3.has(dpoint2d( 1,-1)));
+ mln_assertion(!win3.has(dpoint2d( 6, 5)));
+ }
+
+ {
+ p_set<point2d> pst1;
+ pst1
+ .insert(point2d( 2, 7))
+ .insert(point2d( 2, 1))
+ .insert(point2d(-4, 0))
+ .insert(point2d( 0, 0))
+ .insert(point2d( 1, 1))
+ .insert(point2d( 6, 5));
+ p_set<point2d> pst2;
+ pst2
+ .insert(point2d( 2, 7))
+ .insert(point2d(-2, 1))
+ .insert(point2d(-4, 0))
+ .insert(point2d( 1,-1))
+ .insert(point2d( 6, 5));
+ p_set<point2d> pst3 = set::diff(pst1, pst2);
+ mln_assertion(pst3.has(point2d( 2, 1)));
+ mln_assertion(pst3.has(point2d( 0, 0)));
+ mln_assertion(pst3.has(point2d( 1, 1)));
+ mln_assertion(!pst3.has(point2d( 2, 7)));
+ mln_assertion(!pst3.has(point2d(-2, 1)));
+ mln_assertion(!pst3.has(point2d(-4, 0)));
+ mln_assertion(!pst3.has(point2d( 1,-1)));
+ mln_assertion(!pst3.has(point2d( 6, 5)));
+ }
+}
Index: trunk/milena/mln/make/pix.hh
===================================================================
--- trunk/milena/mln/make/pix.hh (revision 1510)
+++ trunk/milena/mln/make/pix.hh (revision 1511)
@@ -42,7 +42,13 @@
namespace make
{
- /// Create an mln::pix from an image \p ima and a psite \p p.
+ /*! \brief Create an mln::util::pix from an image \p ima and a psite \p p.
+ *
+ * \param[in] ima The input image.
+ * \param[in] p The point site.
+ *
+ * \return An mln::util::pix.
+ */
template <typename I>
mln::util::pix<I> pix(const Image<I>& ima, const mln_psite(I)& p);
Index: trunk/milena/mln/set/inter.hh
===================================================================
--- trunk/milena/mln/set/inter.hh (revision 1510)
+++ trunk/milena/mln/set/inter.hh (revision 1511)
@@ -69,6 +69,7 @@
window<mln_dpoint(Wl)>
inter(const Window<Wl>& lhs, const Window<Wr>& rhs)
{
+ trace::entering("set::inter");
mln::metal::equal<mln_dpoint(Wl), mln_dpoint(Wr)>::check();
typedef mln_dpoint(Wl) D;
std::set<D>
@@ -79,12 +80,14 @@
sr.begin(), sr.end(),
std::inserter(s, s.begin()));
return convert::to_window(s);
+ trace::exiting("set::inter");
}
template <typename Wl, typename Wr>
p_set<mln_point(Wl)>
inter(const Point_Set<Wl>& lhs, const Point_Set<Wr>& rhs)
{
+ trace::entering("set::inter");
mln::metal::equal<mln_point(Wl), mln_point(Wr)>::check();
typedef mln_point(Wl) P;
std::set<P>
@@ -95,6 +98,7 @@
sr.begin(), sr.end(),
std::inserter(s, s.begin()));
return convert::to_p_set(s);
+ trace::exiting("set::inter");
}
# endif // ! MLN_INCLUDE_ONLY
Index: trunk/milena/mln/set/is_subset_of.hh
===================================================================
--- trunk/milena/mln/set/is_subset_of.hh (revision 1510)
+++ trunk/milena/mln/set/is_subset_of.hh (revision 1511)
@@ -28,6 +28,11 @@
#ifndef MLN_SET_IS_SUBSET_OF_HH
# define MLN_SET_IS_SUBSET_OF_HH
+/*! \file mln/set/is_subset_of.hh
+ *
+ * \brief Routine to test if a set is a subset of another.
+ */
+
# include <mln/core/concept/point_set.hh>
namespace mln
@@ -49,18 +54,26 @@
bool
is_subset_of(const Point_Set<Pl>& lhs_, const Point_Set<Pr>& rhs_)
{
+ trace::entering("set::is_subset_of");
Pl lhs = exact(lhs_);
Pr rhs = exact(rhs_);
if (lhs.npoints() > rhs.npoints())
+ {
+ trace::exiting("set::is_subset_of");
return false;
+ }
mln_piter(Pl) p(lhs);
for_all(p)
{
if (!rhs.has(p))
+ {
+ trace::exiting("set::is_subset_of");
return false;
}
+ }
+ trace::exiting("set::is_subset_of");
return true;
}
Index: trunk/milena/mln/set/all.hh
===================================================================
--- trunk/milena/mln/set/all.hh (revision 1510)
+++ trunk/milena/mln/set/all.hh (revision 1511)
@@ -44,6 +44,7 @@
# include <mln/set/diff.hh>
# include <mln/set/inter.hh>
+# include <mln/set/is_subset_of.hh>
# include <mln/set/sym_diff.hh>
# include <mln/set/union.hh>
Index: trunk/milena/mln/set/diff.hh
===================================================================
--- trunk/milena/mln/set/diff.hh (revision 1510)
+++ trunk/milena/mln/set/diff.hh (revision 1511)
@@ -49,12 +49,18 @@
namespace set
{
- /// Set theoretic difference of \p lhs and \p rhs.
+ /*! \brief Set theoretic difference of \p lhs and \p rhs.
+ *
+ * \relates mln::Window
+ */
template <typename Wl, typename Wr>
window<mln_dpoint(Wl)>
diff(const Window<Wl>& lhs, const Window<Wr>& rhs);
- /// Set theoretic difference of \p lhs and \p rhs.
+ /*! \brief Set theoretic difference of \p lhs and \p rhs.
+ *
+ * \relates mln::Point_Set
+ */
template <typename Wl, typename Wr>
p_set<mln_point(Wl)>
diff(const Point_Set<Wl>& lhs, const Point_Set<Wr>& rhs);
@@ -66,6 +72,7 @@
window<mln_dpoint(Wl)>
diff(const Window<Wl>& lhs, const Window<Wr>& rhs)
{
+ trace::entering("set::diff");
mln::metal::equal<mln_dpoint(Wl), mln_dpoint(Wr)>::check();
typedef mln_dpoint(Wl) D;
std::set<D>
@@ -75,14 +82,15 @@
std::set_difference(sl.begin(), sl.end(),
sr.begin(), sr.end(),
std::inserter(s, s.begin()));
+ trace::exiting("set::diff");
return convert::to_window(s);
}
- /// Set theoretic difference of \p lhs and \p rhs.
template <typename Wl, typename Wr>
p_set<mln_point(Wl)>
diff(const Point_Set<Wl>& lhs, const Point_Set<Wr>& rhs)
{
+ trace::entering("set::diff");
mln::metal::equal<mln_point(Wl), mln_point(Wr)>::check();
typedef mln_point(Wl) P;
std::set<P>
@@ -92,6 +100,7 @@
std::set_difference(sl.begin(), sl.end(),
sr.begin(), sr.end(),
std::inserter(s, s.begin()));
+ trace::exiting("set::diff");
return convert::to_p_set(s);
}
Index: trunk/milena/mln/set/uni.hh
===================================================================
--- trunk/milena/mln/set/uni.hh (revision 1510)
+++ trunk/milena/mln/set/uni.hh (revision 1511)
@@ -69,6 +69,7 @@
window<mln_dpoint(Wl)>
uni(const Window<Wl>& lhs, const Window<Wr>& rhs)
{
+ trace::entering("set::uni");
mln::metal::equal<mln_dpoint(Wl), mln_dpoint(Wr)>::check();
typedef mln_dpoint(Wl) D;
std::set<D>
@@ -78,6 +79,7 @@
std::set_union(sl.begin(), sl.end(),
sr.begin(), sr.end(),
std::inserter(s, s.begin()));
+ trace::exiting("set::uni");
return convert::to_window(s);
}
@@ -85,6 +87,7 @@
p_set<mln_point(Wl)>
uni(const Point_Set<Wl>& lhs, const Point_Set<Wr>& rhs)
{
+ trace::entering("set::uni");
mln::metal::equal<mln_point(Wl), mln_point(Wr)>::check();
typedef mln_point(Wl) P;
std::set<P>
@@ -94,6 +97,7 @@
std::set_union(sl.begin(), sl.end(),
sr.begin(), sr.end(),
std::inserter(s, s.begin()));
+ trace::exiting("set::uni");
return convert::to_p_set(s);
}
Index: trunk/milena/mln/set/sym_diff.hh
===================================================================
--- trunk/milena/mln/set/sym_diff.hh (revision 1510)
+++ trunk/milena/mln/set/sym_diff.hh (revision 1511)
@@ -46,12 +46,18 @@
namespace set
{
- /// Set theoretic symmetrical difference of \p lhs and \p rhs.
+ /*! \brief Set theoretic symmetrical difference of \p lhs and \p rhs.
+ *
+ * \relates mln::Window
+ */
template <typename Wl, typename Wr>
window<mln_dpoint(Wl)>
sym_diff(const Window<Wl>& lhs, const Window<Wr>& rhs);
- /// Set theoretic symmetrical difference of \p lhs and \p rhs.
+ /*! \brief Set theoretic symmetrical difference of \p lhs and \p rhs.
+ *
+ * \relates mln::Point_Set
+ */
template <typename Wl, typename Wr>
p_set<mln_point(Wl)>
sym_diff(const Point_Set<Wl>& lhs, const Point_Set<Wr>& rhs);
@@ -62,6 +68,7 @@
window<mln_dpoint(Wl)>
sym_diff(const Window<Wl>& lhs, const Window<Wr>& rhs)
{
+ trace::entering("set::sym_diff");
mln::metal::equal<mln_dpoint(Wl), mln_dpoint(Wr)>::check();
typedef mln_dpoint(Wl) D;
std::set<D>
@@ -71,6 +78,7 @@
std::set_symmetric_difference(sl.begin(), sl.end(),
sr.begin(), sr.end(),
std::inserter(s, s.begin()));
+ trace::exiting("set::sym_diff");
return convert::to_window(s);
}
@@ -78,6 +86,7 @@
p_set<mln_point(Wl)>
sym_diff(const Point_Set<Wl>& lhs, const Point_Set<Wr>& rhs)
{
+ trace::entering("set::sym_diff");
mln::metal::equal<mln_point(Wl), mln_point(Wr)>::check();
typedef mln_point(Wl) P;
std::set<P>
@@ -87,6 +96,7 @@
std::set_symmetric_difference(sl.begin(), sl.end(),
sr.begin(), sr.end(),
std::inserter(s, s.begin()));
+ trace::exiting("set::sym_diff");
return convert::to_p_set(s);
}
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-11-21 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Replace the default viewer by "display".
* mln/display/save_and_show.hh,
* mln/display/show.hh,
* tests/display/save_and_show.cc,
* tests/display/show.cc: Replace "xv" by "display" for the
default viewer.
---
mln/display/save_and_show.hh | 6 +++---
mln/display/show.hh | 8 ++++----
tests/display/save_and_show.cc | 4 ++--
tests/display/show.cc | 4 ++--
4 files changed, 11 insertions(+), 11 deletions(-)
Index: trunk/milena/tests/display/show.cc
===================================================================
--- trunk/milena/tests/display/show.cc (revision 1509)
+++ trunk/milena/tests/display/show.cc (revision 1510)
@@ -69,7 +69,7 @@
{
image_if_value<image2d<unsigned> > t = inplace (tmp | i);
display::save (t);
- display::show (t, "xv", 1);
+ display::show (t, "display", 1);
}
// image2d<value::rgb8> color_image (16, 16);
@@ -77,7 +77,7 @@
// for (int j = 0; j < 16; ++j)
// color_image(point2d(i, j)) = value::rgb8(0,0,255);
// display::save (color_image);
-// display::show (color_image, "xv");
+// display::show (color_image, "display");
display::remove ();
}
Index: trunk/milena/tests/display/save_and_show.cc
===================================================================
--- trunk/milena/tests/display/save_and_show.cc (revision 1509)
+++ trunk/milena/tests/display/save_and_show.cc (revision 1510)
@@ -65,11 +65,11 @@
for (unsigned i = 2; i < 6; i += 2)
{
image_if_value<image2d<unsigned> > t = inplace (tmp | i);
- display::save_and_show (t, "xv", 1);
+ display::save_and_show (t, "display", 1);
}
/// FIXME: Uncomment this ASAP
// image2d<value::rgb8> ima (100, 100);
// level::fill(ima, value::rgb8 (0, 0, 255));
-// display::save_and_show (ima, "xv", 1);
+// display::save_and_show (ima, "display", 1);
}
Index: trunk/milena/mln/display/save_and_show.hh
===================================================================
--- trunk/milena/mln/display/save_and_show.hh (revision 1509)
+++ trunk/milena/mln/display/save_and_show.hh (revision 1510)
@@ -49,7 +49,7 @@
* \param[in] input_ the image to show.
* \param[in] cmd The string which contains the programm of the
* viewer which the user want to display with. By default its
- * value is "xv".
+ * value is "display".
* \param[in] time The number of second of
* display, 0 display permanently. By default the value is 0.
*
@@ -58,7 +58,7 @@
*/
template <typename I>
void
- save_and_show(const Image<I>& input_, std::string cmd = "xv", int time = 0);
+ save_and_show(const Image<I>& input_, std::string cmd = "display", int time = 0);
# ifndef MLN_INCLUDE_ONLY
@@ -82,7 +82,7 @@
/// Facade.
template <typename I>
void
- save_and_show(const Image<I>& input_, std::string cmd = "xv", int time = 0)
+ save_and_show(const Image<I>& input_, std::string cmd = "display", int time = 0)
{
trace::entering("display::save_and_show");
Index: trunk/milena/mln/display/show.hh
===================================================================
--- trunk/milena/mln/display/show.hh (revision 1509)
+++ trunk/milena/mln/display/show.hh (revision 1510)
@@ -31,7 +31,7 @@
/*! \file mln/display/show.hh
*
* \brief Display the temporary image which has just been saved with
- * given viewer (default xv).
+ * given viewer (default display).
*/
# include <mln/trait/image_from_mesh.hh>
@@ -53,7 +53,7 @@
* \param[in] input_ the image to show.
* \param[in] cmd The string which contains the programm of the
* viewer which the user want to display with. By default its
- * value is "xv".
+ * value is "display".
* \param[in] time The number of second of
* display, 0 display permanently. By default the value is 0.
*
@@ -62,7 +62,7 @@
*/
template <typename I>
void
- show(const Image<I>& input_, std::string cmd = "xv", int time = 0);
+ show(const Image<I>& input_, std::string cmd = "display", int time = 0);
# ifndef MLN_INCLUDE_ONLY
@@ -114,7 +114,7 @@
/// Facade.
template <typename I>
void
- show(const Image<I>& input_, std::string cmd = "xv", int time = 0)
+ show(const Image<I>& input_, std::string cmd = "display", int time = 0)
{
trace::entering("display::show");
1
0
Re: [Olena-patches] milena r1509: Review display directory and add tests.
by Guillaume Duhamel 21 Nov '07
by Guillaume Duhamel 21 Nov '07
21 Nov '07
Guillaume Duhamel wrote:
> URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
>
> ChangeLog:
> 2007-11-21 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
>
> Review.
>
> * mln/display/color_pretty.hh,
> * mln/display/remove.hh,
> * mln/display/save.hh,
> * mln/display/save_and_show.hh,
> * mln/display/show.hh: Fix enhancement, add doc and tracing,
> check typo.
>
> * tests/display/color_pretty.cc,
> * tests/display/save_and_show.cc,
> * tests/display/show.cc: Tests for display routines.
>
> Typo
> * mln/level/transform.hh: Fix typo.
>
> ---
> mln/display/color_pretty.hh | 56 +++++++++++++++++++++++++++++--
> mln/display/remove.hh | 15 +++++++-
> mln/display/save.hh | 38 ++++++++++++++-------
> mln/display/save_and_show.hh | 44 +++++++++++++++---------
> mln/display/show.hh | 62 ++++++++++++++++++++++++++++++----
> tests/display/color_pretty.cc | 73 ++++++++++++++++++++++-------------------
> tests/display/save_and_show.cc | 13 +++----
> tests/display/show.cc | 12 +++++-
> 8 files changed, 229 insertions(+), 84 deletions(-)
>
> Index: trunk/milena/tests/display/show.cc
> ===================================================================
> --- trunk/milena/tests/display/show.cc (revision 1508)
> +++ trunk/milena/tests/display/show.cc (revision 1509)
> @@ -25,7 +25,7 @@
> // reasons why the executable file might be covered by the GNU General
> // Public License.
>
> -/*! \file tests/show.cc
> +/*! \file tests/display/show.cc
> *
> * \brief Tests on mln::display::show.
> */
> @@ -69,7 +69,15 @@
> {
> image_if_value<image2d<unsigned> > t = inplace (tmp | i);
> display::save (t);
> - display::show (t, "xv");
> + display::show (t, "xv", 1);
> }
> +
> +// image2d<value::rgb8> color_image (16, 16);
> +// for (int i = 0; i < 16; ++i)
> +// for (int j = 0; j < 16; ++j)
> +// color_image(point2d(i, j)) = value::rgb8(0,0,255);
> +// display::save (color_image);
> +// display::show (color_image, "xv");
> +
> display::remove ();
> }
> Index: trunk/milena/tests/display/save_and_show.cc
> ===================================================================
> --- trunk/milena/tests/display/save_and_show.cc (revision 1508)
> +++ trunk/milena/tests/display/save_and_show.cc (revision 1509)
> @@ -25,9 +25,9 @@
> // reasons why the executable file might be covered by the GNU General
> // Public License.
>
> -/*! \file tests/save_and_show.cc
> +/*! \file tests/display/save_and_show.cc
> *
> - * \brief Tests on mln::display::show.
> + * \brief Tests on mln::display::save_and_show.
> */
>
> # include <mln/core/image2d.hh>
> @@ -42,7 +42,7 @@
> # include <mln/display/show.hh>
> # include <mln/io/ppm/save.hh>
> # include <mln/display/save_and_show.hh>
> -
> +# include <mln/level/fill.hh>
>
> int main()
> {
> @@ -50,7 +50,6 @@
>
> unsigned max = 51;
>
> -
> image2d<bool> input = io::pbm::load("../../img/toto.pbm");
>
> // Create a weighted windows :
> @@ -66,9 +65,11 @@
> for (unsigned i = 2; i < 6; i += 2)
> {
> image_if_value<image2d<unsigned> > t = inplace (tmp | i);
> - display::save_and_show (t, "xv");
> + display::save_and_show (t, "xv", 1);
> }
>
> + /// FIXME: Uncomment this ASAP
> // image2d<value::rgb8> ima (100, 100);
> -// display::save_and_show (ima, "xv");
> +// level::fill(ima, value::rgb8 (0, 0, 255));
> +// display::save_and_show (ima, "xv", 1);
> }
> Index: trunk/milena/tests/display/color_pretty.cc
> ===================================================================
> --- trunk/milena/tests/display/color_pretty.cc (revision 1508)
> +++ trunk/milena/tests/display/color_pretty.cc (revision 1509)
> @@ -31,56 +31,63 @@
> */
>
> # include <mln/core/image2d.hh>
> -# include <mln/io/pbm/load.hh>
> -# include <mln/make/win_chamfer.hh>
> -# include <mln/geom/chamfer.hh>
> -# include <mln/value/rgb8.hh>
> +# include <mln/value/int_u8.hh>
> +# include <mln/level/fill.hh>
> +# include <mln/core/p_set.hh>
> # include <mln/core/sub_image.hh>
> -# include <mln/core/image_if_value.hh>
> # include <mln/core/inplace.hh>
> -# include <mln/core/w_window2d_int.hh>
> +# include <mln/value/rgb8.hh>
> # include <mln/display/color_pretty.hh>
> -# include <mln/io/ppm/save.hh>
> -# include <mln/core/p_set.hh>
> +# include <mln/level/compare.hh>
>
>
> int main()
> {
> using namespace mln;
> + using value::int_u8;
>
> - unsigned max = 51;
> + /// Test on color_pretty.
> + {
> + image2d<int_u8> ima (2, 2);
> + level::fill (ima, 51);
>
> + p_set<point2d > s;
> + s.insert(point2d(0, 0));
> + s.insert(point2d(1, 1));
> +
> + sub_image<image2d<int_u8>, p_set<point2d > > input = inplace(ima | s);
> + image2d<value::rgb8> out = display::color_pretty(input);
> +
> + value::rgb8 vs[2][2] = {
> + {value::rgb8(51, 51, 51), value::rgb8(255, 0, 0) },
> + {value::rgb8(255, 0, 0), value::rgb8(51, 51, 51)}
> + };
>
> - image2d<bool> input = io::pbm::load("../../img/toto.pbm");
> + image2d<value::rgb8> ref (make::image2d(vs));
> + mln_assertion (ref == out);
> + }
>
> - // Create a weighted windows :
> - // 0 2 0
> - // 2 p 2
> - // 0 2 0
> - const w_window2d_int& w_win = make::mk_chamfer_3x3_int<2, 0> ();
>
> - // Call chamfer for a distance image.
> - image2d<unsigned> tmp = geom::chamfer(input, w_win, max);
> + /// Test on color_pretty_rgb.
> + {
> + image2d<value::rgb8> ima (2, 2);
>
> p_set<point2d > s1;
> p_set<point2d > s2;
> p_set<point2d > s3;
>
> - for (int i = 200; i < 300; ++i)
> - for (int j = 0; j < 100; ++j)
> - s2.insert(point2d(i, j));
> + s1.insert(point2d(0, 0));
> + s2.insert(point2d(0, 1));
> + s3.insert(point2d(1, 0));
> +
> + image2d<value::rgb8> out = display::color_pretty_rgb(ima, s1, s2, s3);
> +
> + value::rgb8 vs[2][2] = {
> + {value::rgb8(255, 0, 0), value::rgb8(0, 255, 0) },
> + {value::rgb8(0, 0, 255), value::rgb8(0, 0, 0)}
> + };
>
> - for (int i = 0; i < 100; ++i)
> - for (int j = 200; j < 300; ++j)
> - s3.insert(point2d(i, j));
> -
> -
> -
> -// // Call color_pretty for sub_image.
> -// image2d<value::rgb8> out = display::color_pretty_rgb(tmp, s1, s2, s3);
> -
> -// // Save output image from color in out.ppm.
> -// io::ppm::save(out, "out.ppm");
> -
> -// std::cout << "out.ppm generate" << std::endl;
> + image2d<value::rgb8> ref (make::image2d(vs));
> + mln_assertion (ref == out);
> + }
> }
> Index: trunk/milena/mln/level/transform.hh
> ===================================================================
> Index: trunk/milena/mln/display/color_pretty.hh
> ===================================================================
> --- trunk/milena/mln/display/color_pretty.hh (revision 1508)
> +++ trunk/milena/mln/display/color_pretty.hh (revision 1509)
> @@ -41,6 +41,7 @@
> # include <mln/level/fill.hh>
> # include <mln/level/paste.hh>
> # include <mln/core/p_set.hh>
> +# include <mln/metal/is_not.hh>
>
> namespace mln
> {
> @@ -48,10 +49,36 @@
> namespace display
> {
>
> + /*! Return new image colored from an image \p input_. with the
> + * color red for the pixels not in the domain of \p input_.
> + *
> + * \param[in] ima The image in gray level to color.
> + *
> + * \return colored image from \p input_ in rgb8 with red for the
> + * color filled when the point is in bounding box of \p input_ but
> + * not defined.
> + *
> + * \pre \p input_ has to be initialized.
> + * \pre \p input_ values isn't color.
> + *
> + */
> template <typename I>
> typename trait::image_from_mesh < mln_mesh(I), value::rgb8 >::ret
> color_pretty(const Image<I>& input_);
>
> +
> + /*! Return new image colored from an image \p input_. with the
> + * color red for the pixels not in the domain of \p input_.
> + *
> + * \param[in] ima The image whose domain let to define the domain
> + * of the returned image.
> + * \param[in] s1_ The p_set where the points will be colored in red.
> + * \param[in] s2_ The p_set where the points will be colored in green.
> + * \param[in] s3_ The p_set where the points will be colored in blue.
> + *
> + * \return colored image from \p input_ domain which be filled in rgb8.
> + *
> + */
> template <typename I>
> typename trait::image_from_mesh < mln_mesh(I), value::rgb8 >::ret
> color_pretty_rgb(const Image<I>& input_,
> @@ -67,7 +94,6 @@
> value::rgb8
> color_value(V v)
> {
> - //r = v * (mln_max(V) / mln_max(value::int_u8) );
> return value::rgb8(v, v, v);
> }
>
> @@ -90,6 +116,8 @@
> typename trait::image_from_mesh < mln_mesh(I), value::rgb8 >::ret
> color_pretty(const Image<I>& input_)
> {
> + trace::entering("display::impl::color_pretty");
> +
> const I& input = exact (input_);
>
> image2d<value::rgb8> output(input.domain().bbox());
> @@ -101,6 +129,8 @@
> for_all(p)
> output(p) = value::rgb8(color_value(input(p)));
> }
> +
> + trace::exiting("display::impl::color_pretty");
> return output;
> }
>
> @@ -142,12 +172,25 @@
>
> } // end of namespace mln::display::impl
>
> +
> /// Facade.
> +
> template <typename I>
> typename trait::image_from_mesh < mln_mesh(I), value::rgb8 >::ret
> color_pretty(const Image<I>& input_)
> {
> - return impl::color_pretty(input_);
> + trace::entering("display::color_pretty");
> +
> + const I& input = exact(input_);
> + mln_precondition(input.has_data());
> +
> + mlc_is_not(mln_trait_value_kind(mln_value(I)) (),
> + trait::value::kind::color)::check();
> +
> + image2d<value::rgb8> output = impl::color_pretty(input);
> +
> + trace::exiting("display::color_pretty");
> + return output;
> }
>
> template <typename I>
> @@ -157,7 +200,14 @@
> const p_set<mln_point(I) >& s2_,
> const p_set<mln_point(I) >& s3_)
> {
> - return impl::color_pretty_rgb(input_, s1_, s2_, s3_);
> + trace::entering("display::color_pretty_rgb");
> +
> + const I& input = exact(input_);
> +
> + image2d<value::rgb8> output = impl::color_pretty_rgb(input_, s1_, s2_, s3_);
> +
> + trace::exiting("display::color_pretty_rgb");
> + return output;
> }
>
> # endif // !MLN_INCLUDE_ONLY
> Index: trunk/milena/mln/display/remove.hh
> ===================================================================
> --- trunk/milena/mln/display/remove.hh (revision 1508)
> +++ trunk/milena/mln/display/remove.hh (revision 1509)
> @@ -30,7 +30,7 @@
>
> /*! \file mln/display/remove.hh
> *
> - * \brief Remove all temporary files creat by display::save.
> + * \brief Remove all temporary files create by display::save.
> *
> */
>
> @@ -47,6 +47,10 @@
> namespace display
> {
>
> + /*! Remove all temporary images which are created by the routine
> + * save.
> + *
> + */
> void
> remove();
>
> @@ -58,6 +62,7 @@
> void
> remove()
> {
> + trace::entering("display::impl::remove");
>
> for (std::map<void*, std::string>::const_iterator it = map_saved_image_tmp_.begin ();
> it != map_saved_image_tmp_.end ();
> @@ -66,6 +71,8 @@
> std::string s = "rm -f " + (*it).second;
> system (s.c_str ());
> }
> +
> + trace::exiting("display::impl::remove");
> }
>
> } // end of namespace mln::display::impl
> @@ -74,7 +81,11 @@
> void
> remove()
> {
> - return impl::remove();
> + trace::entering("display::remove");
> +
> + impl::remove();
> +
> + trace::exiting("display::remove");
> }
>
> # endif // !MLN_INCLUDE_ONLY
> Index: trunk/milena/mln/display/save.hh
> ===================================================================
> --- trunk/milena/mln/display/save.hh (revision 1508)
> +++ trunk/milena/mln/display/save.hh (revision 1509)
> @@ -49,24 +49,31 @@
> namespace display
> {
>
> + /*! Map which stocks the location of the saved file by the id of
> + * the image.
> + *
> + */
> std::map<void*, std::string> map_saved_image_tmp_;
>
> + /*! Save an image in a temporary file in ppm format.
> + *
> + * \param[in] input_ the image to save.
> + *
> + */
> template <typename I>
> void
> save(const Image<I>& input_);
>
> - template <typename I>
> - void
> - save_color(const Image<I>& input_);
> -
> # ifndef MLN_INCLUDE_ONLY
>
> namespace impl
> {
> template <typename I>
> void
> - save(const Image<I>& input_)
> + save(trait::value::kind::any, const Image<I>& input_)
> {
> + trace::entering("display::impl::save");
> +
> const I& input = exact (input_);
> image2d<value::rgb8> out = display::color_pretty(input);
>
> @@ -80,12 +87,16 @@
> io::ppm::save(out, path_tmp);
>
> map_saved_image_tmp_[(void*)input.id_ ()] = path_tmp;
> +
> + trace::exiting("display::impl::save");
> }
>
> template <typename I>
> void
> - save_color(const Image<I>& input_)
> + save(trait::value::kind::color, const Image<I>& input_)
> {
> + trace::entering("display::impl::save");
> +
> const I& input = exact (input_);
>
> /// Use of mkstemp instead tempmap.
> @@ -98,6 +109,8 @@
> io::ppm::save(input, path_tmp);
>
> map_saved_image_tmp_[(void*)input.id_ ()] = path_tmp;
> +
> + trace::exiting("display::impl::save");
> }
>
> } // end of namespace mln::display::impl
> @@ -107,14 +120,13 @@
> void
> save(const Image<I>& input_)
> {
> - return impl::save(input_);
> - }
> + trace::entering("display::save");
>
> - template <typename I>
> - void
> - save_color(const Image<I>& input_)
> - {
> - return impl::save_color(input_);
> + const I& input = exact(input_);
> + mln_precondition(input.has_data());
> + impl::save(mln_trait_value_kind(mln_value(I)) (), input);
> +
> + trace::exiting("display::save");
> }
>
> # endif // !MLN_INCLUDE_ONLY
> Index: trunk/milena/mln/display/save_and_show.hh
> ===================================================================
> --- trunk/milena/mln/display/save_and_show.hh (revision 1508)
> +++ trunk/milena/mln/display/save_and_show.hh (revision 1509)
> @@ -43,9 +43,22 @@
> namespace display
> {
>
> + /*! Save and show an image \p input_, which displays whith \p cmd
> + * viewer in \p time seconds.
> + *
> + * \param[in] input_ the image to show.
> + * \param[in] cmd The string which contains the programm of the
> + * viewer which the user want to display with. By default its
> + * value is "xv".
> + * \param[in] time The number of second of
> + * display, 0 display permanently. By default the value is 0.
> + *
> + * \warning This routine doesn't erase the temporary created file.
> + *
> + */
> template <typename I>
> void
> - save_and_show(const Image<I>& input_, std::string cmd);
> + save_and_show(const Image<I>& input_, std::string cmd = "xv", int time = 0);
>
> # ifndef MLN_INCLUDE_ONLY
>
> @@ -53,21 +66,15 @@
> {
> template <typename I>
> void
> - save_and_show_(trait::value::kind::color,
> - const Image<I>& input, std::string cmd)
> + save_and_show_(const Image<I>& input,
> + std::string cmd, int time)
> {
> - save_color(input);
> - show(input, cmd);
> - }
> + trace::entering("display::impl::save_and_show_");
>
> - template <typename I>
> - void
> - save_and_show_(trait::value::kind::any,
> - const Image<I>& input,
> - std::string cmd)
> - {
> - save(input);
> - show(input, cmd);
> + display::save(input);
> + show(input, cmd, time);
> +
> + trace::exiting("display::impl::save_and_show_");
> }
>
> } // end of namespace mln::display::impl
> @@ -75,10 +82,13 @@
> /// Facade.
> template <typename I>
> void
> - save_and_show(const Image<I>& input_, std::string cmd)
> + save_and_show(const Image<I>& input_, std::string cmd = "xv", int time = 0)
> {
> - impl::save_and_show_(mln_trait_value_kind(mln_value(I)) (),
> - input_, cmd);
> + trace::entering("display::save_and_show");
> +
> + impl::save_and_show_(input_, cmd, time);
> +
> + trace::exiting("display::save_and_show");
> }
>
> # endif // !MLN_INCLUDE_ONLY
> Index: trunk/milena/mln/display/show.hh
> ===================================================================
> --- trunk/milena/mln/display/show.hh (revision 1508)
> +++ trunk/milena/mln/display/show.hh (revision 1509)
> @@ -47,9 +47,22 @@
> namespace display
> {
>
> + /*! Show an image \p input_ previously saved by display::save,
> + * which displays whith \p cmd viewer in \p time seconds.
> + *
> + * \param[in] input_ the image to show.
> + * \param[in] cmd The string which contains the programm of the
> + * viewer which the user want to display with. By default its
> + * value is "xv".
> + * \param[in] time The number of second of
> + * display, 0 display permanently. By default the value is 0.
> + *
> + * \pre the image \p input_ is previously saved is map_saved_image_tmp_.
> + *
> + */
> template <typename I>
> void
> - show(const Image<I>& input_, std::string cmd = "xv");
> + show(const Image<I>& input_, std::string cmd = "xv", int time = 0);
>
> # ifndef MLN_INCLUDE_ONLY
>
> @@ -57,15 +70,43 @@
> {
>
> template <typename I>
> + bool
> + check_saved(const Image<I>& input_)
> + {
> + const I& input = exact(input_);
> +
> + typename std::map<void*, std::string>::iterator it = map_saved_image_tmp_.begin();
> +
> + for (; it != map_saved_image_tmp_.end(); ++it)
> + if ((*it).first == input.id_())
> + return true;
> + return false;
> + }
> +
> + template <typename I>
> void
> - show(const Image<I>& input_, std::string cmd)
> + show(const Image<I>& input_, std::string cmd, int time)
> {
> + trace::entering("display::impl::show");
> +
> const I& input = exact (input_);
>
> - std::string s = cmd + " " + map_saved_image_tmp_[(void*)input.id_ ()] + " &";
> - system (s.c_str ());
> - s = "sleep 3 && pkill " + cmd;
> - system (s.c_str ());
> + std::stringstream st;
> + if (time)
> + {
> + st << cmd << " " << map_saved_image_tmp_[(void*)input.id_()] << " &";
> + system(st.str().c_str());
> + st.str("");
> + st << "sleep " << time << " && pkill " << cmd;
> + system(st.str().c_str());
> + }
> + else
> + {
> + st << cmd << " " << map_saved_image_tmp_[(void*)input.id_()];
> + system(st.str().c_str());
> + }
> +
> + trace::exiting("display::impl::show");
> }
>
> } // end of namespace mln::display::impl
> @@ -73,9 +114,14 @@
> /// Facade.
> template <typename I>
> void
> - show(const Image<I>& input_, std::string cmd = "xv")
> + show(const Image<I>& input_, std::string cmd = "xv", int time = 0)
> {
> - return impl::show(input_, cmd);
> + trace::entering("display::show");
> +
> + mln_precondition(impl::check_saved(input_));
> + impl::show(input_, cmd, time);
> +
> + trace::entering("display::show");
> }
>
> # endif // !MLN_INCLUDE_ONLY
>
fix title.
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-11-21 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Review.
* mln/display/color_pretty.hh,
* mln/display/remove.hh,
* mln/display/save.hh,
* mln/display/save_and_show.hh,
* mln/display/show.hh: Fix enhancement, add doc and tracing,
check typo.
* tests/display/color_pretty.cc,
* tests/display/save_and_show.cc,
* tests/display/show.cc: Tests for display routines.
Typo
* mln/level/transform.hh: Fix typo.
---
mln/display/color_pretty.hh | 56 +++++++++++++++++++++++++++++--
mln/display/remove.hh | 15 +++++++-
mln/display/save.hh | 38 ++++++++++++++-------
mln/display/save_and_show.hh | 44 +++++++++++++++---------
mln/display/show.hh | 62 ++++++++++++++++++++++++++++++----
tests/display/color_pretty.cc | 73 ++++++++++++++++++++++-------------------
tests/display/save_and_show.cc | 13 +++----
tests/display/show.cc | 12 +++++-
8 files changed, 229 insertions(+), 84 deletions(-)
Index: trunk/milena/tests/display/show.cc
===================================================================
--- trunk/milena/tests/display/show.cc (revision 1508)
+++ trunk/milena/tests/display/show.cc (revision 1509)
@@ -25,7 +25,7 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/show.cc
+/*! \file tests/display/show.cc
*
* \brief Tests on mln::display::show.
*/
@@ -69,7 +69,15 @@
{
image_if_value<image2d<unsigned> > t = inplace (tmp | i);
display::save (t);
- display::show (t, "xv");
+ display::show (t, "xv", 1);
}
+
+// image2d<value::rgb8> color_image (16, 16);
+// for (int i = 0; i < 16; ++i)
+// for (int j = 0; j < 16; ++j)
+// color_image(point2d(i, j)) = value::rgb8(0,0,255);
+// display::save (color_image);
+// display::show (color_image, "xv");
+
display::remove ();
}
Index: trunk/milena/tests/display/save_and_show.cc
===================================================================
--- trunk/milena/tests/display/save_and_show.cc (revision 1508)
+++ trunk/milena/tests/display/save_and_show.cc (revision 1509)
@@ -25,9 +25,9 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/save_and_show.cc
+/*! \file tests/display/save_and_show.cc
*
- * \brief Tests on mln::display::show.
+ * \brief Tests on mln::display::save_and_show.
*/
# include <mln/core/image2d.hh>
@@ -42,7 +42,7 @@
# include <mln/display/show.hh>
# include <mln/io/ppm/save.hh>
# include <mln/display/save_and_show.hh>
-
+# include <mln/level/fill.hh>
int main()
{
@@ -50,7 +50,6 @@
unsigned max = 51;
-
image2d<bool> input = io::pbm::load("../../img/toto.pbm");
// Create a weighted windows :
@@ -66,9 +65,11 @@
for (unsigned i = 2; i < 6; i += 2)
{
image_if_value<image2d<unsigned> > t = inplace (tmp | i);
- display::save_and_show (t, "xv");
+ display::save_and_show (t, "xv", 1);
}
+ /// FIXME: Uncomment this ASAP
// image2d<value::rgb8> ima (100, 100);
-// display::save_and_show (ima, "xv");
+// level::fill(ima, value::rgb8 (0, 0, 255));
+// display::save_and_show (ima, "xv", 1);
}
Index: trunk/milena/tests/display/color_pretty.cc
===================================================================
--- trunk/milena/tests/display/color_pretty.cc (revision 1508)
+++ trunk/milena/tests/display/color_pretty.cc (revision 1509)
@@ -31,56 +31,63 @@
*/
# include <mln/core/image2d.hh>
-# include <mln/io/pbm/load.hh>
-# include <mln/make/win_chamfer.hh>
-# include <mln/geom/chamfer.hh>
-# include <mln/value/rgb8.hh>
+# include <mln/value/int_u8.hh>
+# include <mln/level/fill.hh>
+# include <mln/core/p_set.hh>
# include <mln/core/sub_image.hh>
-# include <mln/core/image_if_value.hh>
# include <mln/core/inplace.hh>
-# include <mln/core/w_window2d_int.hh>
+# include <mln/value/rgb8.hh>
# include <mln/display/color_pretty.hh>
-# include <mln/io/ppm/save.hh>
-# include <mln/core/p_set.hh>
+# include <mln/level/compare.hh>
int main()
{
using namespace mln;
+ using value::int_u8;
- unsigned max = 51;
+ /// Test on color_pretty.
+ {
+ image2d<int_u8> ima (2, 2);
+ level::fill (ima, 51);
+ p_set<point2d > s;
+ s.insert(point2d(0, 0));
+ s.insert(point2d(1, 1));
+
+ sub_image<image2d<int_u8>, p_set<point2d > > input = inplace(ima | s);
+ image2d<value::rgb8> out = display::color_pretty(input);
+
+ value::rgb8 vs[2][2] = {
+ {value::rgb8(51, 51, 51), value::rgb8(255, 0, 0) },
+ {value::rgb8(255, 0, 0), value::rgb8(51, 51, 51)}
+ };
- image2d<bool> input = io::pbm::load("../../img/toto.pbm");
+ image2d<value::rgb8> ref (make::image2d(vs));
+ mln_assertion (ref == out);
+ }
- // Create a weighted windows :
- // 0 2 0
- // 2 p 2
- // 0 2 0
- const w_window2d_int& w_win = make::mk_chamfer_3x3_int<2, 0> ();
- // Call chamfer for a distance image.
- image2d<unsigned> tmp = geom::chamfer(input, w_win, max);
+ /// Test on color_pretty_rgb.
+ {
+ image2d<value::rgb8> ima (2, 2);
p_set<point2d > s1;
p_set<point2d > s2;
p_set<point2d > s3;
- for (int i = 200; i < 300; ++i)
- for (int j = 0; j < 100; ++j)
- s2.insert(point2d(i, j));
+ s1.insert(point2d(0, 0));
+ s2.insert(point2d(0, 1));
+ s3.insert(point2d(1, 0));
+
+ image2d<value::rgb8> out = display::color_pretty_rgb(ima, s1, s2, s3);
+
+ value::rgb8 vs[2][2] = {
+ {value::rgb8(255, 0, 0), value::rgb8(0, 255, 0) },
+ {value::rgb8(0, 0, 255), value::rgb8(0, 0, 0)}
+ };
- for (int i = 0; i < 100; ++i)
- for (int j = 200; j < 300; ++j)
- s3.insert(point2d(i, j));
-
-
-
-// // Call color_pretty for sub_image.
-// image2d<value::rgb8> out = display::color_pretty_rgb(tmp, s1, s2, s3);
-
-// // Save output image from color in out.ppm.
-// io::ppm::save(out, "out.ppm");
-
-// std::cout << "out.ppm generate" << std::endl;
+ image2d<value::rgb8> ref (make::image2d(vs));
+ mln_assertion (ref == out);
+ }
}
Index: trunk/milena/mln/level/transform.hh
===================================================================
Index: trunk/milena/mln/display/color_pretty.hh
===================================================================
--- trunk/milena/mln/display/color_pretty.hh (revision 1508)
+++ trunk/milena/mln/display/color_pretty.hh (revision 1509)
@@ -41,6 +41,7 @@
# include <mln/level/fill.hh>
# include <mln/level/paste.hh>
# include <mln/core/p_set.hh>
+# include <mln/metal/is_not.hh>
namespace mln
{
@@ -48,10 +49,36 @@
namespace display
{
+ /*! Return new image colored from an image \p input_. with the
+ * color red for the pixels not in the domain of \p input_.
+ *
+ * \param[in] ima The image in gray level to color.
+ *
+ * \return colored image from \p input_ in rgb8 with red for the
+ * color filled when the point is in bounding box of \p input_ but
+ * not defined.
+ *
+ * \pre \p input_ has to be initialized.
+ * \pre \p input_ values isn't color.
+ *
+ */
template <typename I>
typename trait::image_from_mesh < mln_mesh(I), value::rgb8 >::ret
color_pretty(const Image<I>& input_);
+
+ /*! Return new image colored from an image \p input_. with the
+ * color red for the pixels not in the domain of \p input_.
+ *
+ * \param[in] ima The image whose domain let to define the domain
+ * of the returned image.
+ * \param[in] s1_ The p_set where the points will be colored in red.
+ * \param[in] s2_ The p_set where the points will be colored in green.
+ * \param[in] s3_ The p_set where the points will be colored in blue.
+ *
+ * \return colored image from \p input_ domain which be filled in rgb8.
+ *
+ */
template <typename I>
typename trait::image_from_mesh < mln_mesh(I), value::rgb8 >::ret
color_pretty_rgb(const Image<I>& input_,
@@ -67,7 +94,6 @@
value::rgb8
color_value(V v)
{
- //r = v * (mln_max(V) / mln_max(value::int_u8) );
return value::rgb8(v, v, v);
}
@@ -90,6 +116,8 @@
typename trait::image_from_mesh < mln_mesh(I), value::rgb8 >::ret
color_pretty(const Image<I>& input_)
{
+ trace::entering("display::impl::color_pretty");
+
const I& input = exact (input_);
image2d<value::rgb8> output(input.domain().bbox());
@@ -101,6 +129,8 @@
for_all(p)
output(p) = value::rgb8(color_value(input(p)));
}
+
+ trace::exiting("display::impl::color_pretty");
return output;
}
@@ -142,12 +172,25 @@
} // end of namespace mln::display::impl
+
/// Facade.
+
template <typename I>
typename trait::image_from_mesh < mln_mesh(I), value::rgb8 >::ret
color_pretty(const Image<I>& input_)
{
- return impl::color_pretty(input_);
+ trace::entering("display::color_pretty");
+
+ const I& input = exact(input_);
+ mln_precondition(input.has_data());
+
+ mlc_is_not(mln_trait_value_kind(mln_value(I)) (),
+ trait::value::kind::color)::check();
+
+ image2d<value::rgb8> output = impl::color_pretty(input);
+
+ trace::exiting("display::color_pretty");
+ return output;
}
template <typename I>
@@ -157,7 +200,14 @@
const p_set<mln_point(I) >& s2_,
const p_set<mln_point(I) >& s3_)
{
- return impl::color_pretty_rgb(input_, s1_, s2_, s3_);
+ trace::entering("display::color_pretty_rgb");
+
+ const I& input = exact(input_);
+
+ image2d<value::rgb8> output = impl::color_pretty_rgb(input_, s1_, s2_, s3_);
+
+ trace::exiting("display::color_pretty_rgb");
+ return output;
}
# endif // !MLN_INCLUDE_ONLY
Index: trunk/milena/mln/display/remove.hh
===================================================================
--- trunk/milena/mln/display/remove.hh (revision 1508)
+++ trunk/milena/mln/display/remove.hh (revision 1509)
@@ -30,7 +30,7 @@
/*! \file mln/display/remove.hh
*
- * \brief Remove all temporary files creat by display::save.
+ * \brief Remove all temporary files create by display::save.
*
*/
@@ -47,6 +47,10 @@
namespace display
{
+ /*! Remove all temporary images which are created by the routine
+ * save.
+ *
+ */
void
remove();
@@ -58,6 +62,7 @@
void
remove()
{
+ trace::entering("display::impl::remove");
for (std::map<void*, std::string>::const_iterator it = map_saved_image_tmp_.begin ();
it != map_saved_image_tmp_.end ();
@@ -66,6 +71,8 @@
std::string s = "rm -f " + (*it).second;
system (s.c_str ());
}
+
+ trace::exiting("display::impl::remove");
}
} // end of namespace mln::display::impl
@@ -74,7 +81,11 @@
void
remove()
{
- return impl::remove();
+ trace::entering("display::remove");
+
+ impl::remove();
+
+ trace::exiting("display::remove");
}
# endif // !MLN_INCLUDE_ONLY
Index: trunk/milena/mln/display/save.hh
===================================================================
--- trunk/milena/mln/display/save.hh (revision 1508)
+++ trunk/milena/mln/display/save.hh (revision 1509)
@@ -49,24 +49,31 @@
namespace display
{
+ /*! Map which stocks the location of the saved file by the id of
+ * the image.
+ *
+ */
std::map<void*, std::string> map_saved_image_tmp_;
+ /*! Save an image in a temporary file in ppm format.
+ *
+ * \param[in] input_ the image to save.
+ *
+ */
template <typename I>
void
save(const Image<I>& input_);
- template <typename I>
- void
- save_color(const Image<I>& input_);
-
# ifndef MLN_INCLUDE_ONLY
namespace impl
{
template <typename I>
void
- save(const Image<I>& input_)
+ save(trait::value::kind::any, const Image<I>& input_)
{
+ trace::entering("display::impl::save");
+
const I& input = exact (input_);
image2d<value::rgb8> out = display::color_pretty(input);
@@ -80,12 +87,16 @@
io::ppm::save(out, path_tmp);
map_saved_image_tmp_[(void*)input.id_ ()] = path_tmp;
+
+ trace::exiting("display::impl::save");
}
template <typename I>
void
- save_color(const Image<I>& input_)
+ save(trait::value::kind::color, const Image<I>& input_)
{
+ trace::entering("display::impl::save");
+
const I& input = exact (input_);
/// Use of mkstemp instead tempmap.
@@ -98,6 +109,8 @@
io::ppm::save(input, path_tmp);
map_saved_image_tmp_[(void*)input.id_ ()] = path_tmp;
+
+ trace::exiting("display::impl::save");
}
} // end of namespace mln::display::impl
@@ -107,14 +120,13 @@
void
save(const Image<I>& input_)
{
- return impl::save(input_);
- }
+ trace::entering("display::save");
- template <typename I>
- void
- save_color(const Image<I>& input_)
- {
- return impl::save_color(input_);
+ const I& input = exact(input_);
+ mln_precondition(input.has_data());
+ impl::save(mln_trait_value_kind(mln_value(I)) (), input);
+
+ trace::exiting("display::save");
}
# endif // !MLN_INCLUDE_ONLY
Index: trunk/milena/mln/display/save_and_show.hh
===================================================================
--- trunk/milena/mln/display/save_and_show.hh (revision 1508)
+++ trunk/milena/mln/display/save_and_show.hh (revision 1509)
@@ -43,9 +43,22 @@
namespace display
{
+ /*! Save and show an image \p input_, which displays whith \p cmd
+ * viewer in \p time seconds.
+ *
+ * \param[in] input_ the image to show.
+ * \param[in] cmd The string which contains the programm of the
+ * viewer which the user want to display with. By default its
+ * value is "xv".
+ * \param[in] time The number of second of
+ * display, 0 display permanently. By default the value is 0.
+ *
+ * \warning This routine doesn't erase the temporary created file.
+ *
+ */
template <typename I>
void
- save_and_show(const Image<I>& input_, std::string cmd);
+ save_and_show(const Image<I>& input_, std::string cmd = "xv", int time = 0);
# ifndef MLN_INCLUDE_ONLY
@@ -53,21 +66,15 @@
{
template <typename I>
void
- save_and_show_(trait::value::kind::color,
- const Image<I>& input, std::string cmd)
+ save_and_show_(const Image<I>& input,
+ std::string cmd, int time)
{
- save_color(input);
- show(input, cmd);
- }
+ trace::entering("display::impl::save_and_show_");
- template <typename I>
- void
- save_and_show_(trait::value::kind::any,
- const Image<I>& input,
- std::string cmd)
- {
- save(input);
- show(input, cmd);
+ display::save(input);
+ show(input, cmd, time);
+
+ trace::exiting("display::impl::save_and_show_");
}
} // end of namespace mln::display::impl
@@ -75,10 +82,13 @@
/// Facade.
template <typename I>
void
- save_and_show(const Image<I>& input_, std::string cmd)
+ save_and_show(const Image<I>& input_, std::string cmd = "xv", int time = 0)
{
- impl::save_and_show_(mln_trait_value_kind(mln_value(I)) (),
- input_, cmd);
+ trace::entering("display::save_and_show");
+
+ impl::save_and_show_(input_, cmd, time);
+
+ trace::exiting("display::save_and_show");
}
# endif // !MLN_INCLUDE_ONLY
Index: trunk/milena/mln/display/show.hh
===================================================================
--- trunk/milena/mln/display/show.hh (revision 1508)
+++ trunk/milena/mln/display/show.hh (revision 1509)
@@ -47,9 +47,22 @@
namespace display
{
+ /*! Show an image \p input_ previously saved by display::save,
+ * which displays whith \p cmd viewer in \p time seconds.
+ *
+ * \param[in] input_ the image to show.
+ * \param[in] cmd The string which contains the programm of the
+ * viewer which the user want to display with. By default its
+ * value is "xv".
+ * \param[in] time The number of second of
+ * display, 0 display permanently. By default the value is 0.
+ *
+ * \pre the image \p input_ is previously saved is map_saved_image_tmp_.
+ *
+ */
template <typename I>
void
- show(const Image<I>& input_, std::string cmd = "xv");
+ show(const Image<I>& input_, std::string cmd = "xv", int time = 0);
# ifndef MLN_INCLUDE_ONLY
@@ -57,15 +70,43 @@
{
template <typename I>
+ bool
+ check_saved(const Image<I>& input_)
+ {
+ const I& input = exact(input_);
+
+ typename std::map<void*, std::string>::iterator it = map_saved_image_tmp_.begin();
+
+ for (; it != map_saved_image_tmp_.end(); ++it)
+ if ((*it).first == input.id_())
+ return true;
+ return false;
+ }
+
+ template <typename I>
void
- show(const Image<I>& input_, std::string cmd)
+ show(const Image<I>& input_, std::string cmd, int time)
{
+ trace::entering("display::impl::show");
+
const I& input = exact (input_);
- std::string s = cmd + " " + map_saved_image_tmp_[(void*)input.id_ ()] + " &";
- system (s.c_str ());
- s = "sleep 3 && pkill " + cmd;
- system (s.c_str ());
+ std::stringstream st;
+ if (time)
+ {
+ st << cmd << " " << map_saved_image_tmp_[(void*)input.id_()] << " &";
+ system(st.str().c_str());
+ st.str("");
+ st << "sleep " << time << " && pkill " << cmd;
+ system(st.str().c_str());
+ }
+ else
+ {
+ st << cmd << " " << map_saved_image_tmp_[(void*)input.id_()];
+ system(st.str().c_str());
+ }
+
+ trace::exiting("display::impl::show");
}
} // end of namespace mln::display::impl
@@ -73,9 +114,14 @@
/// Facade.
template <typename I>
void
- show(const Image<I>& input_, std::string cmd = "xv")
+ show(const Image<I>& input_, std::string cmd = "xv", int time = 0)
{
- return impl::show(input_, cmd);
+ trace::entering("display::show");
+
+ mln_precondition(impl::check_saved(input_));
+ impl::show(input_, cmd, time);
+
+ trace::entering("display::show");
}
# endif // !MLN_INCLUDE_ONLY
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
===================================================================
--- ChangeLog (revision 1507)
+++ ChangeLog (revision 1508)
@@ -32,40 +32,6 @@
* tests/win/cube3d.cc: New tests.
* tests/canvas/Makefile.am: Fix subdirs.
-2007-11-21 Simon Nivault <simon.nivault(a)lrde.epita.fr>
-
- Review win directory and add tests.
- * mln/win/backdiag2d.hh,
- * mln/win/cube3d.hh,
- * mln/win/diag2d.hh,
- * mln/win/disk2d.hh,
- * mln/win/hline2d.hh,
- * mln/win/line.hh,
- * mln/win/octagon2d.hh,
- * mln/win/rectangle2d.hh,
- * mln/win/segment1d.hh,
- * mln/win/vline2d.hh: Review.
-
- * tests/Makefile.am,
- * tests/win/Makefile.am: Update.
-
- * tests/win_backdiag2d.cc,
- * tests/win_diag2d.cc,
- * tests/win_disk2d.cc,
- * tests/win_hline2d.cc,
- * tests/win_octagon2d.cc,
- * tests/win_rectangle2d.cc: Rename as...
- * tests/win/backdiag2d.cc,
- * tests/win/diag2d.cc,
- * tests/win/disk2d.cc,
- * tests/win/hline2d.cc,
- * tests/win/octagon2d.cc,
- * tests/win/rectangle2d.cc: ...this.
- * tests/win/segment1d.cc,
- * tests/win/vline2d.cc,
- * tests/win/cube3d.cc: New tests.
- * tests/canvas/Makefile.am: Fix subdirs.
-
2007-11-21 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Little fix in test/Makefile.am.
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-11-21 Simon Nivault <simon.nivault(a)lrde.epita.fr>
Review win directory and add tests.
* mln/win/backdiag2d.hh,
* mln/win/cube3d.hh,
* mln/win/diag2d.hh,
* mln/win/disk2d.hh,
* mln/win/hline2d.hh,
* mln/win/line.hh,
* mln/win/octagon2d.hh,
* mln/win/rectangle2d.hh,
* mln/win/segment1d.hh,
* mln/win/vline2d.hh: Review.
* tests/Makefile.am,
* tests/win/Makefile.am: Update.
* tests/win_backdiag2d.cc,
* tests/win_diag2d.cc,
* tests/win_disk2d.cc,
* tests/win_hline2d.cc,
* tests/win_octagon2d.cc,
* tests/win_rectangle2d.cc: Rename as...
* tests/win/backdiag2d.cc,
* tests/win/diag2d.cc,
* tests/win/disk2d.cc,
* tests/win/hline2d.cc,
* tests/win/octagon2d.cc,
* tests/win/rectangle2d.cc: ...this.
* tests/win/segment1d.cc,
* tests/win/vline2d.cc,
* tests/win/cube3d.cc: New tests.
* tests/canvas/Makefile.am: Fix subdirs.
---
0 files changed
--
--
Simon NIVAULT aka Pollux
EPITA 2009 - stagiaire LRDE milena
@ : simonnivault(a)hotmail.com
"La derision est l'ultime defi au malheur"
1
0