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
October 2007
- 8 participants
- 229 discussions
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-10-04 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
Rename x variables into t in accumulators.
* mln/accu/count.hh,
* mln/accu/histo.hh,
* mln/accu/max.hh,
* mln/accu/max_h.hh,
* mln/accu/mean.hh,
* mln/accu/median.hh,
* mln/accu/median_alt.hh,
* mln/accu/min.hh,
* mln/accu/min_h.hh,
* mln/accu/p.hh,
* mln/accu/pair.hh,
* mln/accu/sum.hh,
* mln/accu/v.hh,
* mln/core/concept/accumulator.hh,
* mln/core/concept/doc/accumulator.hh: Rename.
* tests/value_float01.cc: Fix warnings.
---
mln/accu/count.hh | 36 +++++++++---------
mln/accu/histo.hh | 20 +++++-----
mln/accu/max.hh | 64 ++++++++++++++++----------------
mln/accu/max_h.hh | 42 ++++++++++-----------
mln/accu/mean.hh | 50 ++++++++++++-------------
mln/accu/median.hh | 32 ++++++++--------
mln/accu/median_alt.hh | 42 ++++++++++-----------
mln/accu/min.hh | 72 ++++++++++++++++++------------------
mln/accu/min_h.hh | 42 ++++++++++-----------
mln/accu/p.hh | 12 +++---
mln/accu/pair.hh | 62 +++++++++++++++----------------
mln/accu/sum.hh | 40 ++++++++++----------
mln/accu/v.hh | 12 +++---
mln/core/concept/accumulator.hh | 2 -
mln/core/concept/doc/accumulator.hh | 4 +-
tests/value_float01.cc | 8 ++--
16 files changed, 270 insertions(+), 270 deletions(-)
Index: trunk/milena/tests/value_float01.cc
===================================================================
--- trunk/milena/tests/value_float01.cc (revision 1247)
+++ trunk/milena/tests/value_float01.cc (revision 1248)
@@ -48,11 +48,11 @@
using namespace mln::value;
using mln::value::int_u8;
-float fi(int x) { return 0.5; }
-int ii(int x) { return 1; }
+float fi(int) { return 0.5; }
+int ii(int) { return 1; }
-float fd(double x) { return 0.5; }
-int id(double x) { return 1; }
+float fd(double) { return 0.5; }
+int id(double) { return 1; }
struct tofloat01 : mln::Function_v2v<tofloat01>
Index: trunk/milena/mln/core/concept/doc/accumulator.hh
===================================================================
--- trunk/milena/mln/core/concept/doc/accumulator.hh (revision 1247)
+++ trunk/milena/mln/core/concept/doc/accumulator.hh (revision 1248)
@@ -50,8 +50,8 @@
/// Initialize the accumulator.
void init();
- /// Take into account a argument \p x (an element).
- void take(const argument& x);
+ /// Take into account a argument \p t (an element).
+ void take(const argument& t);
/// Take into account another accumulator \p other.
void take(const E& other);
Index: trunk/milena/mln/core/concept/accumulator.hh
===================================================================
--- trunk/milena/mln/core/concept/accumulator.hh (revision 1247)
+++ trunk/milena/mln/core/concept/accumulator.hh (revision 1248)
@@ -68,7 +68,7 @@
typedef argument;
typedef result;
void init();
- void take(const argument& x);
+ void take(const argument& t);
void take(const E& other);
result to_result() const;
operator result_() const;
Index: trunk/milena/mln/accu/min.hh
===================================================================
--- trunk/milena/mln/accu/min.hh (revision 1247)
+++ trunk/milena/mln/accu/min.hh (revision 1248)
@@ -48,26 +48,26 @@
/*! Generic min accumulator class.
*
- * The parameter \c V is the type of values.
+ * The parameter \c T is the type of values.
*/
- template <typename V>
- struct min_ : public mln::accu::internal::base_< V, min_<V> >
+ template <typename T>
+ struct min_ : public mln::accu::internal::base_< T, min_<T> >
{
- typedef V argument;
- typedef V result;
+ typedef T argument;
+ typedef T result;
min_();
void init();
- void take_as_init(const argument& x);
- void take(const argument& x);
- void take(const min_<V>& other);
+ void take_as_init(const argument& t);
+ void take(const argument& t);
+ void take(const min_<T>& other);
- V to_result() const;
+ T to_result() const;
protected:
- V x_;
+ T t_;
};
@@ -77,10 +77,10 @@
// FIXME: Doc!
struct min : public Meta_Accumulator< min >
{
- template <typename V>
+ template <typename T>
struct with
{
- typedef min_<V> ret;
+ typedef min_<T> ret;
};
};
@@ -88,17 +88,17 @@
// // FIXME: Sample code.
-// template <typename V>
-// struct p_min_ : public p_< min_<V> >
+// template <typename T>
+// struct p_min_ : public p_< min_<T> >
// {
// };
// struct p_min : public Meta_Accumulator< p_min >
// {
-// template <typename V>
+// template <typename T>
// struct with
// {
-// typedef p_min_<V> ret;
+// typedef p_min_<T> ret;
// };
// };
@@ -106,45 +106,45 @@
# ifndef MLN_INCLUDE_ONLY
- template <typename V>
- min_<V>::min_()
+ template <typename T>
+ min_<T>::min_()
{
init();
}
- template <typename V>
+ template <typename T>
void
- min_<V>::init()
+ min_<T>::init()
{
- x_ = mln_max(V);
+ t_ = mln_max(T);
}
- template <typename V>
- void min_<V>::take_as_init(const argument& x)
+ template <typename T>
+ void min_<T>::take_as_init(const argument& t)
{
- x_ = x;
+ t_ = t;
}
- template <typename V>
- void min_<V>::take(const argument& x)
+ template <typename T>
+ void min_<T>::take(const argument& t)
{
- if (x < x_)
- x_ = x;
+ if (t < t_)
+ t_ = t;
}
- template <typename V>
+ template <typename T>
void
- min_<V>::take(const min_<V>& other)
+ min_<T>::take(const min_<T>& other)
{
- if (other.x_ < x_)
- x_ = other.x_;
+ if (other.t_ < t_)
+ t_ = other.t_;
}
- template <typename V>
- V
- min_<V>::to_result() const
+ template <typename T>
+ T
+ min_<T>::to_result() const
{
- return x_;
+ return t_;
}
# endif // ! MLN_INCLUDE_ONLY
Index: trunk/milena/mln/accu/max.hh
===================================================================
--- trunk/milena/mln/accu/max.hh (revision 1247)
+++ trunk/milena/mln/accu/max.hh (revision 1248)
@@ -47,26 +47,26 @@
/*! Generic max accumulator class.
*
- * The parameter \c V is the type of values.
+ * The parameter \c T is the type of values.
*/
- template <typename V>
- struct max_ : public mln::accu::internal::base_< V , max_<V> >
+ template <typename T>
+ struct max_ : public mln::accu::internal::base_< T , max_<T> >
{
- typedef V argument;
- typedef V result;
+ typedef T argument;
+ typedef T result;
max_();
void init();
- void take_as_init(const argument& x);
- void take(const argument& x);
- void take(const max_<V>& other);
+ void take_as_init(const argument& t);
+ void take(const argument& t);
+ void take(const max_<T>& other);
- V to_result() const;
+ T to_result() const;
protected:
- V x_;
+ T t_;
};
@@ -76,10 +76,10 @@
// FIXME: Doc!
struct max : public Meta_Accumulator< max >
{
- template <typename V>
+ template <typename T>
struct with
{
- typedef max_<V> ret;
+ typedef max_<T> ret;
};
};
@@ -87,47 +87,47 @@
# ifndef MLN_INCLUDE_ONLY
- template <typename V>
- max_<V>::max_()
+ template <typename T>
+ max_<T>::max_()
{
init();
}
- template <typename V>
+ template <typename T>
void
- max_<V>::init()
+ max_<T>::init()
{
- x_ = mln_min(V);
+ t_ = mln_min(T);
}
- template <typename V>
+ template <typename T>
void
- max_<V>::take_as_init(const argument& x)
+ max_<T>::take_as_init(const argument& t)
{
- x_ = x;
+ t_ = t;
}
- template <typename V>
+ template <typename T>
void
- max_<V>::take(const argument& x)
+ max_<T>::take(const argument& t)
{
- if (x > x_)
- x_ = x;
+ if (t > t_)
+ t_ = t;
}
- template <typename V>
+ template <typename T>
void
- max_<V>::take(const max_<V>& other)
+ max_<T>::take(const max_<T>& other)
{
- if (other.x_ > x_)
- x_ = other.x_;
+ if (other.t_ > t_)
+ t_ = other.t_;
}
- template <typename V>
- V
- max_<V>::to_result() const
+ template <typename T>
+ T
+ max_<T>::to_result() const
{
- return x_;
+ return t_;
}
# endif // ! MLN_INCLUDE_ONLY
Index: trunk/milena/mln/accu/histo.hh
===================================================================
--- trunk/milena/mln/accu/histo.hh (revision 1247)
+++ trunk/milena/mln/accu/histo.hh (revision 1248)
@@ -61,12 +61,12 @@
typedef mln_value(S) argument;
typedef const std::vector<std::size_t>& result;
- void take(const argument& x);
+ void take(const argument& t);
void take(const histo<S>& other);
- void untake(const argument& x);
+ void untake(const argument& t);
void init();
- std::size_t operator()(const argument& x) const;
+ std::size_t operator()(const argument& t) const;
std::size_t operator[](std::size_t i) const;
std::size_t nvalues() const;
std::size_t sum() const;
@@ -110,9 +110,9 @@
template <typename S>
void
- histo<S>::take(const argument& x)
+ histo<S>::take(const argument& t)
{
- ++h_[s_.index_of(x)];
+ ++h_[s_.index_of(t)];
++sum_;
}
@@ -127,11 +127,11 @@
template <typename S>
void
- histo<S>::untake(const argument& x)
+ histo<S>::untake(const argument& t)
{
- mln_precondition(h_[s_.index_of(x)] > 0);
+ mln_precondition(h_[s_.index_of(t)] > 0);
mln_precondition(sum_ > 0);
- --h_[s_.index_of(x)];
+ --h_[s_.index_of(t)];
--sum_;
}
@@ -145,9 +145,9 @@
template <typename S>
std::size_t
- histo<S>::operator()(const argument& x) const
+ histo<S>::operator()(const argument& t) const
{
- return h_[s_.index_of(x)];
+ return h_[s_.index_of(t)];
}
template <typename S>
Index: trunk/milena/mln/accu/count.hh
===================================================================
--- trunk/milena/mln/accu/count.hh (revision 1247)
+++ trunk/milena/mln/accu/count.hh (revision 1248)
@@ -46,17 +46,17 @@
/*! Generic counter accumulator class.
*/
- template <typename V>
- struct count_ : public mln::accu::internal::base_< std::size_t , count_<V> >
+ template <typename T>
+ struct count_ : public mln::accu::internal::base_< std::size_t , count_<T> >
{
- typedef V argument;
+ typedef T argument;
typedef std::size_t result; // FIXME: Up in Accumulator.
count_();
void init();
void take(const argument&);
- void take(const count_<V>& other);
+ void take(const count_<T>& other);
std::size_t to_result() const;
void set_value(std::size_t c);
@@ -70,53 +70,53 @@
// FIXME: Doc!
struct count : public Meta_Accumulator< count >
{
- template <typename V>
+ template <typename T>
struct with
{
- typedef count_<V> ret;
+ typedef count_<T> ret;
};
};
# ifndef MLN_INCLUDE_ONLY
- template <typename V>
- count_<V>::count_()
+ template <typename T>
+ count_<T>::count_()
{
init();
}
- template <typename V>
+ template <typename T>
void
- count_<V>::init()
+ count_<T>::init()
{
count__ = 0;
}
- template <typename V>
+ template <typename T>
void
- count_<V>::take(const argument&)
+ count_<T>::take(const argument&)
{
++count__;
}
- template <typename V>
+ template <typename T>
void
- count_<V>::take(const count_<V>& other)
+ count_<T>::take(const count_<T>& other)
{
count__ += other.count__;
}
- template <typename V>
+ template <typename T>
std::size_t
- count_<V>::to_result() const
+ count_<T>::to_result() const
{
return count__;
}
- template <typename V>
+ template <typename T>
void
- count_<V>::set_value(std::size_t c)
+ count_<T>::set_value(std::size_t c)
{
count__ = c;
}
Index: trunk/milena/mln/accu/min_h.hh
===================================================================
--- trunk/milena/mln/accu/min_h.hh (revision 1247)
+++ trunk/milena/mln/accu/min_h.hh (revision 1248)
@@ -57,10 +57,10 @@
min_h();
void init();
- void take(const argument& x);
- void take_as_init(const argument& x);
+ void take(const argument& t);
+ void take_as_init(const argument& t);
void take(const min_h<S>& other);
- void untake(const argument& x);
+ void untake(const argument& t);
unsigned card() const { return h_.sum(); }
@@ -76,7 +76,7 @@
mutable std::size_t sum_;
mutable bool valid_;
mutable std::size_t i_; // the min index
- mutable argument x_; // the min value
+ mutable argument t_; // the min value
// Auxiliary methods
void update_() const;
@@ -105,15 +105,15 @@
template <typename S>
void
- min_h<S>::take(const argument& x)
+ min_h<S>::take(const argument& t)
{
- h_.take(x);
+ h_.take(t);
if (h_.sum() == 1)
{
- this->take_as_init(x);
+ this->take_as_init(t);
return;
}
- if (x < x_)
+ if (t < t_)
{
++sum_;
valid_ = false;
@@ -134,23 +134,23 @@
template <typename S>
void
- min_h<S>::untake(const argument& x)
+ min_h<S>::untake(const argument& t)
{
- mln_precondition(h_(x) != 0);
- h_.untake(x);
+ mln_precondition(h_(t) != 0);
+ h_.untake(t);
if (h_.sum() == 0)
{
init();
return;
}
- if (x < x_)
+ if (t < t_)
{
mln_invariant(sum_ >= 1);
--sum_;
valid_ = false;
}
else
- if (x == x_ && h_[i_] == 0)
+ if (t == t_ && h_[i_] == 0)
valid_ = false;
}
@@ -177,7 +177,7 @@
sum_ -= h_[i_];
}
while (sum_ != 0);
- x_ = s_[i_];
+ t_ = s_[i_];
}
template <typename S>
@@ -187,7 +187,7 @@
do
++i_;
while (h_[i_] == 0);
- x_ = s_[i_];
+ t_ = s_[i_];
}
template <typename S>
@@ -197,18 +197,18 @@
h_.init();
sum_ = 0;
i_ = mln_max(argument);
- x_ = s_[i_];
+ t_ = s_[i_];
valid_ = true;
}
template <typename S>
void
- min_h<S>::take_as_init(const argument& x)
+ min_h<S>::take_as_init(const argument& t)
{
- h_.take(x);
+ h_.take(t);
sum_ = 0;
- i_ = s_.index_of(x);
- x_ = x;
+ i_ = s_.index_of(t);
+ t_ = t;
valid_ = true;
}
@@ -218,7 +218,7 @@
{
if (! valid_)
update_();
- return x_;
+ return t_;
}
template <typename S>
Index: trunk/milena/mln/accu/pair.hh
===================================================================
--- trunk/milena/mln/accu/pair.hh (revision 1247)
+++ trunk/milena/mln/accu/pair.hh (revision 1248)
@@ -51,14 +51,14 @@
/*! Generic pair of accumulators.
*
- * The parameter \c V is the type of values.
+ * The parameter \c T is the type of values.
*
- * \todo Check that, when V is not provided, A1 and A2 have the same value.
+ * \todo Check that, when T is not provided, A1 and A2 have the same value.
*/
- template <typename A1, typename A2, typename V = mln_argument(A1)>
- struct pair_ : public mln::accu::internal::base_< std::pair< mlc_unqualif(mln_result(A1)) , mlc_unqualif(mln_result(A2)) > , pair_<A1,A2,V> >
+ template <typename A1, typename A2, typename T = mln_argument(A1)>
+ struct pair_ : public mln::accu::internal::base_< std::pair< mlc_unqualif(mln_result(A1)) , mlc_unqualif(mln_result(A2)) > , pair_<A1,A2,T> >
{
- typedef V argument;
+ typedef T argument;
typedef mlc_unqualif(mln_result(A1)) result_1;
typedef mlc_unqualif(mln_result(A2)) result_2;
@@ -68,9 +68,9 @@
pair_(const A1& a1, const A2& a2);
void init();
- void take_as_init(const argument& x);
- void take(const argument& x);
- void take(const pair_<A1,A2,V>& other);
+ void take_as_init(const argument& t);
+ void take(const argument& t);
+ void take(const pair_<A1,A2,T>& other);
result to_result() const;
void get_result(result_1& r1, result_2& r2) const;
@@ -87,67 +87,67 @@
template <typename A1, typename A2>
struct pair : public Meta_Accumulator< pair<A1,A2> >
{
- template <typename V>
+ template <typename T>
struct with
{
- typedef mln_accu_with(A1, V) A1_V;
- typedef mln_accu_with(A2, V) A2_V;
- typedef pair_<A1_V, A2_V, V> ret;
+ typedef mln_accu_with(A1, T) A1_T;
+ typedef mln_accu_with(A2, T) A2_T;
+ typedef pair_<A1_T, A2_T, T> ret;
};
};
# ifndef MLN_INCLUDE_ONLY
- template <typename A1, typename A2, typename V>
- pair_<A1,A2,V>::pair_()
+ template <typename A1, typename A2, typename T>
+ pair_<A1,A2,T>::pair_()
{
init();
}
- template <typename A1, typename A2, typename V>
+ template <typename A1, typename A2, typename T>
void
- pair_<A1,A2,V>::init()
+ pair_<A1,A2,T>::init()
{
a1_.init();
a2_.init();
}
- template <typename A1, typename A2, typename V>
+ template <typename A1, typename A2, typename T>
void
- pair_<A1,A2,V>::take_as_init(const argument& x)
+ pair_<A1,A2,T>::take_as_init(const argument& t)
{
- a1_.take_as_init(x);
- a2_.take_as_init(x);
+ a1_.take_as_init(t);
+ a2_.take_as_init(t);
}
- template <typename A1, typename A2, typename V>
+ template <typename A1, typename A2, typename T>
void
- pair_<A1,A2,V>::take(const argument& x)
+ pair_<A1,A2,T>::take(const argument& t)
{
- a1_.take(x);
- a2_.take(x);
+ a1_.take(t);
+ a2_.take(t);
}
- template <typename A1, typename A2, typename V>
+ template <typename A1, typename A2, typename T>
void
- pair_<A1,A2,V>::take(const pair_<A1,A2,V>& other)
+ pair_<A1,A2,T>::take(const pair_<A1,A2,T>& other)
{
a1_.take(other.a1_);
a2_.take(other.a2_);
}
- template <typename A1, typename A2, typename V>
- typename pair_<A1,A2,V>::result
- pair_<A1,A2,V>::to_result() const
+ template <typename A1, typename A2, typename T>
+ typename pair_<A1,A2,T>::result
+ pair_<A1,A2,T>::to_result() const
{
result tmp(a1_.to_result(), a2_.to_result());
return tmp;
}
- template <typename A1, typename A2, typename V>
+ template <typename A1, typename A2, typename T>
void
- pair_<A1,A2,V>::get_result(result_1& r1,
+ pair_<A1,A2,T>::get_result(result_1& r1,
result_2& r2) const
{
r1 = a1_.to_result();
Index: trunk/milena/mln/accu/max_h.hh
===================================================================
--- trunk/milena/mln/accu/max_h.hh (revision 1247)
+++ trunk/milena/mln/accu/max_h.hh (revision 1248)
@@ -57,10 +57,10 @@
max_h();
void init();
- void take(const argument& x);
- void take_as_init(const argument& x);
+ void take(const argument& t);
+ void take_as_init(const argument& t);
void take(const max_h<S>& other);
- void untake(const argument& x);
+ void untake(const argument& t);
unsigned card() const { return h_.sum(); }
@@ -76,7 +76,7 @@
mutable std::size_t sum_;
mutable bool valid_;
mutable std::size_t i_; // the max index
- mutable argument x_; // the max argument
+ mutable argument t_; // the max argument
// Auxiliary methods
void update_() const;
@@ -105,15 +105,15 @@
template <typename S>
void
- max_h<S>::take(const argument& x)
+ max_h<S>::take(const argument& t)
{
- h_.take(x);
+ h_.take(t);
if (h_.sum() == 1)
{
- this->take_as_init(x);
+ this->take_as_init(t);
return;
}
- if (x > x_)
+ if (t > t_)
{
++sum_;
valid_ = false;
@@ -134,23 +134,23 @@
template <typename S>
void
- max_h<S>::untake(const argument& x)
+ max_h<S>::untake(const argument& t)
{
- mln_precondition(h_(x) != 0);
- h_.untake(x);
+ mln_precondition(h_(t) != 0);
+ h_.untake(t);
if (h_.sum() == 0)
{
init();
return;
}
- if (x > x_)
+ if (t > t_)
{
mln_invariant(sum_ >= 1);
--sum_;
valid_ = false;
}
else
- if (x == x_ && h_[i_] == 0)
+ if (t == t_ && h_[i_] == 0)
valid_ = false;
}
@@ -173,7 +173,7 @@
do
--i_;
while (h_[i_] == 0);
- x_ = s_[i_];
+ t_ = s_[i_];
}
template <typename S>
@@ -186,7 +186,7 @@
if (h_[i_] != 0)
sum_ -= h_[i_];
} while (sum_ != 0);
- x_ = s_[i_];
+ t_ = s_[i_];
}
template <typename S>
@@ -196,18 +196,18 @@
h_.init();
sum_ = 0;
i_ = mln_min(argument);
- x_ = s_[i_];
+ t_ = s_[i_];
valid_ = true;
}
template <typename S>
void
- max_h<S>::take_as_init(const argument& x)
+ max_h<S>::take_as_init(const argument& t)
{
- h_.take(x);
+ h_.take(t);
sum_ = 0;
- i_ = s_.index_of(x);
- x_ = x;
+ i_ = s_.index_of(t);
+ t_ = t;
valid_ = true;
}
@@ -217,7 +217,7 @@
{
if (! valid_)
update_();
- return x_;
+ return t_;
}
template <typename S>
Index: trunk/milena/mln/accu/median.hh
===================================================================
--- trunk/milena/mln/accu/median.hh (revision 1247)
+++ trunk/milena/mln/accu/median.hh (revision 1248)
@@ -57,9 +57,9 @@
median();
void init();
- void take(const argument& x);
+ void take(const argument& t);
void take(const median<S>& other);
- void untake(const argument& x);
+ void untake(const argument& t);
unsigned card() const { return h_.sum(); }
@@ -76,7 +76,7 @@
mutable bool valid_;
mutable std::size_t i_; // the median index
- mutable argument x_; // the median value
+ mutable argument t_; // the median value
// Auxiliary methods
void update_() const;
@@ -105,13 +105,13 @@
template <typename S>
void
- median<S>::take(const argument& x)
+ median<S>::take(const argument& t)
{
- h_.take(x);
+ h_.take(t);
- if (x < x_)
+ if (t < t_)
++sum_minus_;
- else if (x > x_)
+ else if (t > t_)
++sum_plus_;
if (valid_)
@@ -139,14 +139,14 @@
template <typename S>
void
- median<S>::untake(const argument& x)
+ median<S>::untake(const argument& t)
{
- mln_precondition(h_(x) != 0);
- h_.untake(x);
+ mln_precondition(h_(t) != 0);
+ h_.untake(t);
- if (x < x_)
+ if (t < t_)
--sum_minus_;
- else if (x > x_)
+ else if (t > t_)
--sum_plus_;
if (valid_)
@@ -191,7 +191,7 @@
sum_minus_ -= h_[i_];
}
while (2 * sum_minus_ > h_.sum());
- x_ = s_[i_];
+ t_ = s_[i_];
}
template <typename S>
@@ -207,7 +207,7 @@
sum_plus_ -= h_[i_];
}
while (2 * sum_plus_ > h_.sum());
- x_ = s_[i_];
+ t_ = s_[i_];
}
template <typename S>
@@ -218,7 +218,7 @@
sum_minus_ = 0;
sum_plus_ = 0;
i_ = (mln_max(argument) - mln_min(argument)) / 2;
- x_ = s_[i_];
+ t_ = s_[i_];
valid_ = true;
}
@@ -228,7 +228,7 @@
{
if (! valid_)
update_();
- return x_;
+ return t_;
}
template <typename S>
Index: trunk/milena/mln/accu/median_alt.hh
===================================================================
--- trunk/milena/mln/accu/median_alt.hh (revision 1247)
+++ trunk/milena/mln/accu/median_alt.hh (revision 1248)
@@ -54,8 +54,8 @@
median_alt(const Value_Set<S>& s);
- void take(const argument& x);
- void untake(const argument& x);
+ void take(const argument& t);
+ void untake(const argument& t);
void init();
argument to_result() const;
@@ -64,7 +64,7 @@
void debug__() const
{
std::cout << " i = " << i_
- << " x = " << x_
+ << " t = " << t_
<< " s = " << sum_minus_ << " ; " << h_[i_] << " ; " << sum_plus_ << " = " << h_.sum()
<< std::endl;
}
@@ -77,7 +77,7 @@
std::size_t sum_minus_, sum_plus_;
std::size_t i_; // the median index
- argument x_; // the median argument
+ argument t_; // the median argument
// Auxiliary methods
void go_minus_();
@@ -109,24 +109,24 @@
template <typename S>
void
- median_alt<S>::take(const argument& x)
+ median_alt<S>::take(const argument& t)
{
// update h_
- h_.take(x);
+ h_.take(t);
// particular case:
// current state was initialization
if (h_[i_] == 0)
{
// std::cout << "init!" << std::endl;
- i_ = s_.index_of(x);
- x_ = x;
+ i_ = s_.index_of(t);
+ t_ = t;
return;
}
// particular case:
// the median does not change
- if (x == x_)
+ if (t == t_)
{
// std::cout << "no change!" << std::endl;
return;
@@ -134,14 +134,14 @@
// general case:
- if (x < x_)
+ if (t < t_)
{
++sum_minus_;
if (2 * sum_minus_ > h_.sum())
go_minus_();
}
else
- // x > x_
+ // t > t_
{
++sum_plus_;
if (2 * sum_plus_ > h_.sum())
@@ -152,12 +152,12 @@
template <typename S>
void
- median_alt<S>::untake(const argument& x)
+ median_alt<S>::untake(const argument& t)
{
- mln_precondition(h_(x) != 0);
+ mln_precondition(h_(t) != 0);
// update h_
- h_.untake(x);
+ h_.untake(t);
// particular case:
// the only value has been removed
@@ -168,20 +168,20 @@
}
// general case:
- if (x < x_)
+ if (t < t_)
{
--sum_minus_;
if (2 * sum_plus_ > h_.sum())
go_plus_();
}
- else if (x > x_)
+ else if (t > t_)
{
--sum_plus_;
if (2 * sum_minus_ > h_.sum())
go_minus_();
}
else
- // x == x_
+ // t == t_
{
if (h_[i_] == 0)
{
@@ -216,7 +216,7 @@
sum_minus_ -= h_[i_];
}
while (2 * sum_minus_ > h_.sum());
- x_ = s_[i_];
+ t_ = s_[i_];
}
@@ -233,7 +233,7 @@
sum_plus_ -= h_[i_];
}
while (2 * sum_plus_ > h_.sum());
- x_ = s_[i_];
+ t_ = s_[i_];
}
@@ -245,14 +245,14 @@
sum_minus_ = 0;
sum_plus_ = 0;
i_ = (mln_max(argument) - mln_min(argument)) / 2;
- x_ = s_[i_];
+ t_ = s_[i_];
}
template <typename S>
typename median_alt<S>::argument
median_alt<S>::to_result() const
{
- return x_;
+ return t_;
}
template <typename S>
Index: trunk/milena/mln/accu/p.hh
===================================================================
--- trunk/milena/mln/accu/p.hh (revision 1247)
+++ trunk/milena/mln/accu/p.hh (revision 1248)
@@ -61,8 +61,8 @@
p_(const A& a);
void init();
- void take_as_init(const argument& x);
- void take(const argument& x);
+ void take_as_init(const argument& t);
+ void take(const argument& t);
void take(const p_<A>& other);
result to_result() const;
@@ -109,16 +109,16 @@
template <typename A>
void
- p_<A>::take_as_init(const argument& x)
+ p_<A>::take_as_init(const argument& t)
{
- a_.take_as_init(x.p()); // FIXME: Generalize with "psite(x)".
+ a_.take_as_init(t.p()); // FIXME: Generalize with "psite(t)".
}
template <typename A>
void
- p_<A>::take(const argument& x)
+ p_<A>::take(const argument& t)
{
- a_.take(x.p());
+ a_.take(t.p());
}
template <typename A>
Index: trunk/milena/mln/accu/sum.hh
===================================================================
--- trunk/milena/mln/accu/sum.hh (revision 1247)
+++ trunk/milena/mln/accu/sum.hh (revision 1248)
@@ -50,21 +50,21 @@
/*! Generic sum accumulator class.
*
- * Parameter \c V is the type of values that we sum. Parameter \c
+ * Parameter \c T is the type of values that we sum. Parameter \c
* S is the type to store the value sum; the default type of
- * \c S is the summation type (property) of \c V.
+ * \c S is the summation type (property) of \c T.
*/
- template <typename V, typename S = mln_sum(V)>
- struct sum_ : public mln::accu::internal::base_< S, sum_<V,S> >
+ template <typename T, typename S = mln_sum(T)>
+ struct sum_ : public mln::accu::internal::base_< S, sum_<T,S> >
{
- typedef V argument;
+ typedef T argument;
typedef S result;
sum_();
void init();
- void take(const argument& x);
- void take(const sum_<V,S>& other);
+ void take(const argument& t);
+ void take(const sum_<T,S>& other);
S to_result() const;
@@ -81,10 +81,10 @@
// FIXME: Doc!
struct sum : public Meta_Accumulator< sum >
{
- template <typename V, typename S = mln_sum(V)>
+ template <typename T, typename S = mln_sum(T)>
struct with
{
- typedef sum_<V, S> ret;
+ typedef sum_<T, S> ret;
};
};
@@ -92,35 +92,35 @@
# ifndef MLN_INCLUDE_ONLY
- template <typename V, typename S>
- sum_<V,S>::sum_()
+ template <typename T, typename S>
+ sum_<T,S>::sum_()
{
init();
}
- template <typename V, typename S>
+ template <typename T, typename S>
void
- sum_<V,S>::init()
+ sum_<T,S>::init()
{
s_ = literal::zero;
}
- template <typename V, typename S>
- void sum_<V,S>::take(const argument& x)
+ template <typename T, typename S>
+ void sum_<T,S>::take(const argument& t)
{
- s_ += x;
+ s_ += t;
}
- template <typename V, typename S>
+ template <typename T, typename S>
void
- sum_<V,S>::take(const sum_<V,S>& other)
+ sum_<T,S>::take(const sum_<T,S>& other)
{
s_ += other.s_;
}
- template <typename V, typename S>
+ template <typename T, typename S>
S
- sum_<V,S>::to_result() const
+ sum_<T,S>::to_result() const
{
return s_;
}
Index: trunk/milena/mln/accu/v.hh
===================================================================
--- trunk/milena/mln/accu/v.hh (revision 1247)
+++ trunk/milena/mln/accu/v.hh (revision 1248)
@@ -57,8 +57,8 @@
val_(const A& a);
void init();
- void take_as_init(const argument& x);
- void take(const argument& x);
+ void take_as_init(const argument& t);
+ void take(const argument& t);
void take(const val_<A>& other);
template <typename I>
@@ -118,16 +118,16 @@
template <typename A>
void
- val_<A>::take_as_init(const argument& x)
+ val_<A>::take_as_init(const argument& t)
{
- a_.take_as_init(x);
+ a_.take_as_init(t);
}
template <typename A>
void
- val_<A>::take(const argument& x)
+ val_<A>::take(const argument& t)
{
- a_.take(x);
+ a_.take(t);
}
template <typename A>
Index: trunk/milena/mln/accu/mean.hh
===================================================================
--- trunk/milena/mln/accu/mean.hh (revision 1247)
+++ trunk/milena/mln/accu/mean.hh (revision 1248)
@@ -49,32 +49,32 @@
/*! Generic mean accumulator class.
*
- * Parameter \c V is the type of values that we sum. Parameter \c
+ * Parameter \c T is the type of values that we sum. Parameter \c
* S is the type to store the sum of values; the default type of
- * \c S is the summation type (property) of \c V. Parameter \c M
+ * \c S is the summation type (property) of \c T. Parameter \c M
* is the type of the mean value; the default type of \c M is \c
* S.
*/
- template <typename V,
- typename S = mln_sum(V),
+ template <typename T,
+ typename S = mln_sum(T),
typename M = S>
- struct mean_ : public mln::accu::internal::base_< M , mean_<V,S,M> >
+ struct mean_ : public mln::accu::internal::base_< M , mean_<T,S,M> >
{
- typedef V argument;
+ typedef T argument;
typedef M result;
mean_();
void init();
- void take(const argument& x);
- void take(const mean_<V,S,M>& other);
+ void take(const argument& t);
+ void take(const mean_<T,S,M>& other);
M to_result() const;
protected:
- accu::count_<V> count_;
- accu::sum_<V,S> sum_;
+ accu::count_<T> count_;
+ accu::sum_<T,S> sum_;
};
@@ -87,50 +87,50 @@
// FIXME: Doc!
struct mean : public Meta_Accumulator< mean >
{
- template < typename V,
- typename S = mln_sum(V),
+ template < typename T,
+ typename S = mln_sum(T),
typename M = S >
struct with
{
- typedef mean_<V,S,M> ret;
+ typedef mean_<T,S,M> ret;
};
};
# ifndef MLN_INCLUDE_ONLY
- template <typename V, typename S, typename M>
- mean_<V,S,M>::mean_()
+ template <typename T, typename S, typename M>
+ mean_<T,S,M>::mean_()
{
init();
}
- template <typename V, typename S, typename M>
+ template <typename T, typename S, typename M>
void
- mean_<V,S,M>::init()
+ mean_<T,S,M>::init()
{
count_.init();
sum_.init();
}
- template <typename V, typename S, typename M>
- void mean_<V,S,M>::take(const argument& x)
+ template <typename T, typename S, typename M>
+ void mean_<T,S,M>::take(const argument& t)
{
- count_.take(x);
- sum_.take(x);
+ count_.take(t);
+ sum_.take(t);
}
- template <typename V, typename S, typename M>
+ template <typename T, typename S, typename M>
void
- mean_<V,S,M>::take(const mean_<V,S,M>& other)
+ mean_<T,S,M>::take(const mean_<T,S,M>& other)
{
count_.take(other.count_);
sum_.take(other.sum_);
}
- template <typename V, typename S, typename M>
+ template <typename T, typename S, typename M>
M
- mean_<V,S,M>::to_result() const
+ mean_<T,S,M>::to_result() const
{
return sum_.to_result() / count_.to_result();
}
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Handle multiple super-categories.
* mln/trait/solve.hh (super_category_): New to handle multiple
super-categories.
* tests/trait_super.cc: New.
* mln/core/w_window.hh (sym): Fix; my fault!
* mln/core/win/hline2d.hh: Add FIXME for Simon.
* mln/accu/min.hh: Add FIXME for Matthieu.
* mln/value/builtin.hh (Integer, Symbolic, Floating): New.
(category): Specialize for some builtins.
mln/accu/min.hh | 19 ++++++
mln/core/w_window.hh | 2
mln/core/win/hline2d.hh | 14 ++++
mln/trait/solve.hh | 52 ++++++++++++++--
mln/value/builtin.hh | 46 ++++++++++++--
tests/trait_super.cc | 152 ++++++++++++++++++++++++++++++++++++++++++++++++
6 files changed, 272 insertions(+), 13 deletions(-)
Index: tests/trait_super.cc
--- tests/trait_super.cc (revision 0)
+++ tests/trait_super.cc (revision 0)
@@ -0,0 +1,152 @@
+// 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/trait_super.cc
+ *
+ * \brief Tests on mln::trait::solve.
+ */
+
+#include <mln/trait/op_uminus.hh>
+#include <mln/core/concept/object.hh>
+#include <mln/value/int_u8.hh>
+
+
+namespace my
+{
+
+
+ // Value.
+
+ template <typename E> struct Value;
+
+ template <> struct Value<void> { typedef mln::Object<void> super; };
+
+ template <typename E>
+ struct Value
+ {
+ typedef Value<void> category;
+ protected:
+ Value() {}
+ };
+
+
+ // Integer.
+
+ template <typename E> struct Integer;
+
+ template <> struct Integer<void> { typedef Value<void> super; };
+
+ template <typename E>
+ struct Integer
+ {
+ typedef Integer<void> category;
+ };
+
+ template <>
+ struct Integer<int>
+ {
+ typedef Integer<void> category;
+ int i;
+ Integer(int i) : i(i) {}
+ };
+
+
+ // Built_In.
+
+ template <typename E> struct Built_In;
+
+ template <> struct Built_In<void> { typedef void* super; }; // cause several posible
+
+
+ // test.
+
+ struct test // like a built-in: no inheritance!
+ {
+ void is_test() {}
+ };
+
+
+// template <typename I>
+// void foo(const Integer<I>&)
+// {
+// std::cout << "Int" << std::endl;
+// }
+
+// template <typename I>
+// void foo(const Value<I>&)
+// {
+// std::cout << "Value" << std::endl;
+// }
+
+} // my
+
+
+
+namespace mln
+{
+
+ template <>
+ struct category< my::test >
+ {
+ typedef my::Built_In<void> ret;
+ typedef my::Integer<void> super;
+ };
+
+// template <>
+// struct category< int >
+// {
+// typedef my::Built_In<void> ret;
+// typedef my::Integer<void> super;
+// };
+
+ namespace trait
+ {
+
+ template <typename T>
+ struct set_unary_< op_uminus, my::Integer, T >
+ {
+ typedef bool ret;
+ };
+
+ } // mln::trait
+
+} // mln
+
+
+int main()
+{
+ using namespace mln;
+
+ mln_trait_op_uminus_(my::test) tmp;
+ tmp = true;
+
+// int i;
+// my::foo<int>(i);
+
+// mln_trait_op_plus_(value::int_u8, int) t;
+// void* v = t;
+}
Index: mln/trait/solve.hh
--- mln/trait/solve.hh (revision 1246)
+++ mln/trait/solve.hh (working copy)
@@ -87,13 +87,37 @@
{
};
+
+ template < template <class> class Category, typename T,
+ typename Super_Category >
+ struct super_category_;
+
+ template < template <class> class Category, typename T,
+ template <class> class Super_Category >
+ struct super_category_< Category, T,
+ Super_Category<void> >
+ {
+ typedef Super_Category<void> ret; // One super category: keep it.
+ };
+
+ template < template <class> class Category, typename T >
+ struct super_category_< Category, T,
+ void* > // Meaning: several super categories exist, depending on T.
+ {
+ typedef typename mln::category< T >::super ret; // Specific call depending on T.
+ };
+
} // end of namespace mln::trait::internal
template < template <class> class Name,
template <class> class Category_T, typename T >
- struct set_unary_ : internal::set_unary_super_< Name,
- typename Category_T<void>::super, T >
+ struct set_unary_
+ :
+ internal::set_unary_super_< Name,
+ typename internal::super_category_< Category_T, T,
+ typename Category_T<void>::super >::ret,
+ T >
{
};
@@ -125,6 +149,14 @@
{
};
+ template < template <class> class Name,
+ template <class> class Category_T, typename T >
+ struct helper_solve_unary_< Name,
+ Category_T<void*>, T > : helper_choose_unary_< Name,
+ Category_T, T >
+ {
+ };
+
} // end of namespace mln::trait::internal
@@ -245,13 +277,21 @@
// Construct a treillis in a static recursive way!
typedef typename internal::set_binary_super_< Name,
- typename Category_L<void>::super, L,
- Category_R<void>, R >::ret
+ typename internal::super_category_< Category_L,
+ L,
+ typename Category_L<void>::super >::ret,
+ L,
+ Category_R<void>,
+ R >::ret
L_ret;
typedef typename internal::set_binary_super_< Name,
- Category_L<void>, L,
- typename Category_R<void>::super, R >::ret
+ Category_L<void>,
+ L,
+ typename internal::super_category_< Category_R,
+ R,
+ typename Category_R<void>::super >::ret,
+ R >::ret
R_ret;
typedef typename internal::merge_binary_ret_< L_ret, R_ret >::ret ret;
Index: mln/core/w_window.hh
--- mln/core/w_window.hh (revision 1246)
+++ mln/core/w_window.hh (working copy)
@@ -257,7 +257,7 @@
{
w_window<D,W> tmp;
for (unsigned i = 0; i < this->ndpoints(); ++i)
- tmp.insert(this->w(i), this->dp(i));
+ tmp.insert(this->w(i), - this->dp(i));
*this = tmp;
return *this;
}
Index: mln/core/win/hline2d.hh
--- mln/core/win/hline2d.hh (revision 1246)
+++ mln/core/win/hline2d.hh (working copy)
@@ -61,6 +61,20 @@
}
};
+
+// // FIXME for Simon
+
+// // Was:
+// struct hline2d : public Window< hline2d >,
+// public internal::dpoints_base_< dpoint2d, hline2d >
+// {};
+
+// // Will be:
+// template <typename M, unsigned i, typename C >
+// struct line : public Window< line<M,i,C> >,
+// public internal::dpoints_base_< dpoint_<M, C>, line<M,i,C> >
+// {};
+
} // end of namespace mln::win
} // end of namespace mln
Index: mln/accu/min.hh
--- mln/accu/min.hh (revision 1246)
+++ mln/accu/min.hh (working copy)
@@ -85,6 +85,25 @@
};
+
+// // FIXME: Sample code.
+
+// template <typename V>
+// struct p_min_ : public p_< min_<V> >
+// {
+// };
+
+// struct p_min : public Meta_Accumulator< p_min >
+// {
+// template <typename V>
+// struct with
+// {
+// typedef p_min_<V> ret;
+// };
+// };
+
+
+
# ifndef MLN_INCLUDE_ONLY
template <typename V>
Index: mln/value/builtin.hh
--- mln/value/builtin.hh (revision 1246)
+++ mln/value/builtin.hh (working copy)
@@ -43,15 +43,49 @@
// The case of built-in types.
template <typename E>
- struct Built_In
+ struct Built_In;
+
+ template <>
+ struct Built_In<void>
+ {
+ typedef void* super; // Every builtin belongs to a sub-category of Value but we do not know which one.
+ };
+
+
+ template <typename E> struct Symbolic;
+
+ template <>
+ struct Symbolic<void>
{
- typedef Value<void> super; // Builtins belong to a sub-category of values.
+ typedef Value<void> super;
};
- template <> struct category< int > { typedef Built_In<void> ret; };
- template <> struct category< unsigned > { typedef Built_In<void> ret; };
- template <> struct category< float > { typedef Built_In<void> ret; };
- template <> struct category< double > { typedef Built_In<void> ret; };
+
+ template <typename E> struct Integer;
+
+ template <>
+ struct Integer<void>
+ {
+ typedef Value<void> super;
+ };
+
+
+ template <typename E> struct Floating;
+
+ template <>
+ struct Floating<void>
+ {
+ typedef Value<void> super;
+ };
+
+
+ template <> struct category< bool > { typedef Built_In<void> ret; typedef Symbolic<void> super; };
+
+ template <> struct category< int > { typedef Built_In<void> ret; typedef Integer<void> super; };
+ template <> struct category< unsigned > { typedef Built_In<void> ret; typedef Integer<void> super; };
+
+ template <> struct category< float > { typedef Built_In<void> ret; typedef Floating<void> super; };
+ template <> struct category< double > { typedef Built_In<void> ret; typedef Floating<void> super; };
// FIXME: ...
1
0
04 Oct '07
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-10-04 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
Rename typedef value by argument in accumulators.
* mln/accu/bbox.hh,
* mln/accu/count.hh,
* mln/accu/histo.hh,
* mln/accu/internal/base.hh,
* mln/accu/max.hh,
* mln/accu/max_h.hh,
* mln/accu/mean.hh,
* mln/accu/median.hh,
* mln/accu/median_alt.hh,
* mln/accu/min.hh,
* mln/accu/min_h.hh,
* mln/accu/nil.hh,
* mln/accu/p.hh,
* mln/accu/pair.hh,
* mln/accu/sum.hh,
* mln/accu/v.hh,
* mln/core/concept/accumulator.hh,
* mln/core/concept/doc/accumulator.hh,
* mln/core/grids.hh,
* mln/core/macros.hh: (typedef value) Rename as...
(typedef argument) ... this.
---
accu/bbox.hh | 2 -
accu/count.hh | 6 ++--
accu/histo.hh | 22 ++++++++--------
accu/max.hh | 26 ++++++++++----------
accu/max_h.hh | 52 ++++++++++++++++++++--------------------
accu/mean.hh | 10 +++----
accu/median.hh | 42 ++++++++++++++++----------------
accu/median_alt.hh | 50 +++++++++++++++++++-------------------
accu/min.hh | 26 ++++++++++----------
accu/min_h.hh | 52 ++++++++++++++++++++--------------------
accu/nil.hh | 10 +++----
accu/p.hh | 14 +++++-----
accu/pair.hh | 20 +++++++--------
accu/sum.hh | 8 +++---
accu/v.hh | 14 +++++-----
core/concept/accumulator.hh | 16 ++++++------
core/concept/doc/accumulator.hh | 8 +++---
core/grids.hh | 6 ++++
core/macros.hh | 4 +++
19 files changed, 199 insertions(+), 189 deletions(-)
Index: trunk/milena/mln/core/macros.hh
===================================================================
--- trunk/milena/mln/core/macros.hh (revision 1245)
+++ trunk/milena/mln/core/macros.hh (revision 1246)
@@ -161,6 +161,10 @@
# define mln_value(T) typename T::value
# define mln_value_(T) T::value
+/// Shortcut to access the argument type associated to T.
+# define mln_argument(T) typename T::argument
+# define mln_argument_(T) T::argument
+
/// 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) )
Index: trunk/milena/mln/core/concept/doc/accumulator.hh
===================================================================
--- trunk/milena/mln/core/concept/doc/accumulator.hh (revision 1245)
+++ trunk/milena/mln/core/concept/doc/accumulator.hh (revision 1246)
@@ -41,8 +41,8 @@
template <typename E>
struct Accumulator
{
- /// The value type of elements to accumulate.
- typedef void value;
+ /// The argument type of elements to accumulate.
+ typedef void argument;
/// The value type to return.
typedef void result_;
@@ -50,8 +50,8 @@
/// Initialize the accumulator.
void init();
- /// Take into account a value \p v (an element).
- void take(const value& v);
+ /// Take into account a argument \p x (an element).
+ void take(const argument& x);
/// Take into account another accumulator \p other.
void take(const E& other);
Index: trunk/milena/mln/core/concept/accumulator.hh
===================================================================
--- trunk/milena/mln/core/concept/accumulator.hh (revision 1245)
+++ trunk/milena/mln/core/concept/accumulator.hh (revision 1246)
@@ -65,10 +65,10 @@
typedef Accumulator<void> category;
/*
- typedef value;
+ typedef argument;
typedef result;
void init();
- void take(const value& v);
+ void take(const argument& x);
void take(const E& other);
result to_result() const;
operator result_() const;
@@ -76,7 +76,7 @@
// Default impl.
template <typename T>
- void take_as_init(const T& t); // 't' is either value or E.
+ void take_as_init(const T& t); // 't' is either argument or E.
protected:
Accumulator();
@@ -89,25 +89,25 @@
template <typename E>
Accumulator<E>::Accumulator()
{
- typedef mln_value(E) value;
+ typedef mln_argument(E) argument;
typedef mln_result(E) result;
void (E::*m1)() = & E::init;
m1 = 0;
- void (E::*m2)(const value&) = & E::take;
+ void (E::*m2)(const argument&) = & E::take;
m2 = 0;
void (E::*m3)(const E&) = & E::take;
m3 = 0;
result (E::*m4)() const = & E::to_result;
m4 = 0;
- result (E::*m5)() const = & E::operator result;
- m5 = 0;
+// result (E::*m5)() const = & E::operator result;
+// m5 = 0;
}
template <typename E>
template <typename T>
void
- Accumulator<E>::take_as_init(const T& t) // either value or E
+ Accumulator<E>::take_as_init(const T& t) // either argument or E
{
exact(this)->init();
exact(this)->take(t);
Index: trunk/milena/mln/core/grids.hh
===================================================================
--- trunk/milena/mln/core/grids.hh (revision 1245)
+++ trunk/milena/mln/core/grids.hh (revision 1246)
@@ -57,6 +57,12 @@
enum { dim = 2 };
};
+ struct hexa : public Regular_Grid< hexa >
+ {
+ typedef metal::false_ aligned;
+ enum { dim = 2 };
+ };
+
struct cube : public Regular_Grid< cube >
{
typedef metal::true_ aligned;
Index: trunk/milena/mln/accu/nil.hh
===================================================================
--- trunk/milena/mln/accu/nil.hh (revision 1245)
+++ trunk/milena/mln/accu/nil.hh (revision 1246)
@@ -52,14 +52,14 @@
template <typename T>
struct nil_ : public mln::accu::internal::base_< util::ignore , nil_<T> >
{
- typedef util::eat value;
+ typedef util::eat argument;
typedef util::ignore result;
nil_();
void init();
- void take_as_init(const value&);
- void take(const value&);
+ void take_as_init(const argument&);
+ void take(const argument&);
void take(const nil_<T>&);
util::ignore to_result() const;
@@ -93,13 +93,13 @@
template <typename T>
void
- nil_<T>::take(const value&)
+ nil_<T>::take(const argument&)
{
}
template <typename T>
void
- nil_<T>::take_as_init(const value&)
+ nil_<T>::take_as_init(const argument&)
{
}
Index: trunk/milena/mln/accu/min.hh
===================================================================
--- trunk/milena/mln/accu/min.hh (revision 1245)
+++ trunk/milena/mln/accu/min.hh (revision 1246)
@@ -53,21 +53,21 @@
template <typename V>
struct min_ : public mln::accu::internal::base_< V, min_<V> >
{
- typedef V value;
+ typedef V argument;
typedef V result;
min_();
void init();
- void take_as_init(const value& v);
- void take(const value& v);
+ void take_as_init(const argument& x);
+ void take(const argument& x);
void take(const min_<V>& other);
V to_result() const;
protected:
- V v_;
+ V x_;
};
@@ -97,35 +97,35 @@
void
min_<V>::init()
{
- v_ = mln_max(V);
+ x_ = mln_max(V);
}
template <typename V>
- void min_<V>::take_as_init(const value& v)
+ void min_<V>::take_as_init(const argument& x)
{
- v_ = v;
+ x_ = x;
}
template <typename V>
- void min_<V>::take(const value& v)
+ void min_<V>::take(const argument& x)
{
- if (v < v_)
- v_ = v;
+ if (x < x_)
+ x_ = x;
}
template <typename V>
void
min_<V>::take(const min_<V>& other)
{
- if (other.v_ < v_)
- v_ = other.v_;
+ if (other.x_ < x_)
+ x_ = other.x_;
}
template <typename V>
V
min_<V>::to_result() const
{
- return v_;
+ return x_;
}
# endif // ! MLN_INCLUDE_ONLY
Index: trunk/milena/mln/accu/max.hh
===================================================================
--- trunk/milena/mln/accu/max.hh (revision 1245)
+++ trunk/milena/mln/accu/max.hh (revision 1246)
@@ -52,21 +52,21 @@
template <typename V>
struct max_ : public mln::accu::internal::base_< V , max_<V> >
{
- typedef V value;
+ typedef V argument;
typedef V result;
max_();
void init();
- void take_as_init(const value& v);
- void take(const value& v);
+ void take_as_init(const argument& x);
+ void take(const argument& x);
void take(const max_<V>& other);
V to_result() const;
protected:
- V v_;
+ V x_;
};
@@ -97,37 +97,37 @@
void
max_<V>::init()
{
- v_ = mln_min(V);
+ x_ = mln_min(V);
}
template <typename V>
void
- max_<V>::take_as_init(const value& v)
+ max_<V>::take_as_init(const argument& x)
{
- v_ = v;
+ x_ = x;
}
template <typename V>
void
- max_<V>::take(const value& v)
+ max_<V>::take(const argument& x)
{
- if (v > v_)
- v_ = v;
+ if (x > x_)
+ x_ = x;
}
template <typename V>
void
max_<V>::take(const max_<V>& other)
{
- if (other.v_ > v_)
- v_ = other.v_;
+ if (other.x_ > x_)
+ x_ = other.x_;
}
template <typename V>
V
max_<V>::to_result() const
{
- return v_;
+ return x_;
}
# endif // ! MLN_INCLUDE_ONLY
Index: trunk/milena/mln/accu/histo.hh
===================================================================
--- trunk/milena/mln/accu/histo.hh (revision 1245)
+++ trunk/milena/mln/accu/histo.hh (revision 1246)
@@ -58,15 +58,15 @@
histo(const Value_Set<S>& s);
histo();
- typedef mln_value(S) value;
+ typedef mln_value(S) argument;
typedef const std::vector<std::size_t>& result;
- void take(const value& v);
+ void take(const argument& x);
void take(const histo<S>& other);
- void untake(const value& v);
+ void untake(const argument& x);
void init();
- std::size_t operator()(const value& v) const;
+ std::size_t operator()(const argument& x) const;
std::size_t operator[](std::size_t i) const;
std::size_t nvalues() const;
std::size_t sum() const;
@@ -110,9 +110,9 @@
template <typename S>
void
- histo<S>::take(const value& v)
+ histo<S>::take(const argument& x)
{
- ++h_[s_.index_of(v)];
+ ++h_[s_.index_of(x)];
++sum_;
}
@@ -127,11 +127,11 @@
template <typename S>
void
- histo<S>::untake(const value& v)
+ histo<S>::untake(const argument& x)
{
- mln_precondition(h_[s_.index_of(v)] > 0);
+ mln_precondition(h_[s_.index_of(x)] > 0);
mln_precondition(sum_ > 0);
- --h_[s_.index_of(v)];
+ --h_[s_.index_of(x)];
--sum_;
}
@@ -145,9 +145,9 @@
template <typename S>
std::size_t
- histo<S>::operator()(const value& v) const
+ histo<S>::operator()(const argument& x) const
{
- return h_[s_.index_of(v)];
+ return h_[s_.index_of(x)];
}
template <typename S>
Index: trunk/milena/mln/accu/count.hh
===================================================================
--- trunk/milena/mln/accu/count.hh (revision 1245)
+++ trunk/milena/mln/accu/count.hh (revision 1246)
@@ -49,13 +49,13 @@
template <typename V>
struct count_ : public mln::accu::internal::base_< std::size_t , count_<V> >
{
- typedef V value;
+ typedef V argument;
typedef std::size_t result; // FIXME: Up in Accumulator.
count_();
void init();
- void take(const value&);
+ void take(const argument&);
void take(const count_<V>& other);
std::size_t to_result() const;
@@ -95,7 +95,7 @@
template <typename V>
void
- count_<V>::take(const value&)
+ count_<V>::take(const argument&)
{
++count__;
}
Index: trunk/milena/mln/accu/bbox.hh
===================================================================
--- trunk/milena/mln/accu/bbox.hh (revision 1245)
+++ trunk/milena/mln/accu/bbox.hh (revision 1246)
@@ -51,7 +51,7 @@
template <typename P>
struct bbox : public mln::accu::internal::base_< const box_<P>& , bbox<P> >
{
- typedef P value;
+ typedef P argument;
typedef const box_<P>& result;
bbox();
Index: trunk/milena/mln/accu/min_h.hh
===================================================================
--- trunk/milena/mln/accu/min_h.hh (revision 1245)
+++ trunk/milena/mln/accu/min_h.hh (revision 1246)
@@ -50,21 +50,21 @@
template <typename S>
struct min_h : public mln::accu::internal::base_< mln_value(S) , min_h<S> >
{
- typedef mln_value(S) value;
- typedef value result;
+ typedef mln_value(S) argument;
+ typedef argument result;
min_h(const Value_Set<S>& s);
min_h();
void init();
- void take(const value& v);
- void take_as_init(const value& v);
+ void take(const argument& x);
+ void take_as_init(const argument& x);
void take(const min_h<S>& other);
- void untake(const value& v);
+ void untake(const argument& x);
unsigned card() const { return h_.sum(); }
- value to_result() const;
+ result to_result() const;
const accu::histo<S>& histo() const;
@@ -76,7 +76,7 @@
mutable std::size_t sum_;
mutable bool valid_;
mutable std::size_t i_; // the min index
- mutable value v_; // the min value
+ mutable argument x_; // the min value
// Auxiliary methods
void update_() const;
@@ -105,15 +105,15 @@
template <typename S>
void
- min_h<S>::take(const value& v)
+ min_h<S>::take(const argument& x)
{
- h_.take(v);
+ h_.take(x);
if (h_.sum() == 1)
{
- this->take_as_init(v);
+ this->take_as_init(x);
return;
}
- if (v < v_)
+ if (x < x_)
{
++sum_;
valid_ = false;
@@ -134,23 +134,23 @@
template <typename S>
void
- min_h<S>::untake(const value& v)
+ min_h<S>::untake(const argument& x)
{
- mln_precondition(h_(v) != 0);
- h_.untake(v);
+ mln_precondition(h_(x) != 0);
+ h_.untake(x);
if (h_.sum() == 0)
{
init();
return;
}
- if (v < v_)
+ if (x < x_)
{
mln_invariant(sum_ >= 1);
--sum_;
valid_ = false;
}
else
- if (v == v_ && h_[i_] == 0)
+ if (x == x_ && h_[i_] == 0)
valid_ = false;
}
@@ -177,7 +177,7 @@
sum_ -= h_[i_];
}
while (sum_ != 0);
- v_ = s_[i_];
+ x_ = s_[i_];
}
template <typename S>
@@ -187,7 +187,7 @@
do
++i_;
while (h_[i_] == 0);
- v_ = s_[i_];
+ x_ = s_[i_];
}
template <typename S>
@@ -196,29 +196,29 @@
{
h_.init();
sum_ = 0;
- i_ = mln_max(value);
- v_ = s_[i_];
+ i_ = mln_max(argument);
+ x_ = s_[i_];
valid_ = true;
}
template <typename S>
void
- min_h<S>::take_as_init(const value& v)
+ min_h<S>::take_as_init(const argument& x)
{
- h_.take(v);
+ h_.take(x);
sum_ = 0;
- i_ = s_.index_of(v);
- v_ = v;
+ i_ = s_.index_of(x);
+ x_ = x;
valid_ = true;
}
template <typename S>
- typename min_h<S>::value
+ typename min_h<S>::argument
min_h<S>::to_result() const
{
if (! valid_)
update_();
- return v_;
+ return x_;
}
template <typename S>
Index: trunk/milena/mln/accu/pair.hh
===================================================================
--- trunk/milena/mln/accu/pair.hh (revision 1245)
+++ trunk/milena/mln/accu/pair.hh (revision 1246)
@@ -55,10 +55,10 @@
*
* \todo Check that, when V is not provided, A1 and A2 have the same value.
*/
- template <typename A1, typename A2, typename V = mln_value(A1)>
+ template <typename A1, typename A2, typename V = mln_argument(A1)>
struct pair_ : public mln::accu::internal::base_< std::pair< mlc_unqualif(mln_result(A1)) , mlc_unqualif(mln_result(A2)) > , pair_<A1,A2,V> >
{
- typedef V value;
+ typedef V argument;
typedef mlc_unqualif(mln_result(A1)) result_1;
typedef mlc_unqualif(mln_result(A2)) result_2;
@@ -68,8 +68,8 @@
pair_(const A1& a1, const A2& a2);
void init();
- void take_as_init(const value& v);
- void take(const value& v);
+ void take_as_init(const argument& x);
+ void take(const argument& x);
void take(const pair_<A1,A2,V>& other);
result to_result() const;
@@ -115,18 +115,18 @@
template <typename A1, typename A2, typename V>
void
- pair_<A1,A2,V>::take_as_init(const value& v)
+ pair_<A1,A2,V>::take_as_init(const argument& x)
{
- a1_.take_as_init(v);
- a2_.take_as_init(v);
+ a1_.take_as_init(x);
+ a2_.take_as_init(x);
}
template <typename A1, typename A2, typename V>
void
- pair_<A1,A2,V>::take(const value& v)
+ pair_<A1,A2,V>::take(const argument& x)
{
- a1_.take(v);
- a2_.take(v);
+ a1_.take(x);
+ a2_.take(x);
}
template <typename A1, typename A2, typename V>
Index: trunk/milena/mln/accu/max_h.hh
===================================================================
--- trunk/milena/mln/accu/max_h.hh (revision 1245)
+++ trunk/milena/mln/accu/max_h.hh (revision 1246)
@@ -50,21 +50,21 @@
template <typename S>
struct max_h : public mln::accu::internal::base_< mln_value(S) , max_h<S> >
{
- typedef mln_value(S) value;
- typedef value result;
+ typedef mln_value(S) argument;
+ typedef argument result;
max_h(const Value_Set<S>& s);
max_h();
void init();
- void take(const value& v);
- void take_as_init(const value& v);
+ void take(const argument& x);
+ void take_as_init(const argument& x);
void take(const max_h<S>& other);
- void untake(const value& v);
+ void untake(const argument& x);
unsigned card() const { return h_.sum(); }
- value to_result() const;
+ argument to_result() const;
const accu::histo<S>& histo() const;
@@ -76,7 +76,7 @@
mutable std::size_t sum_;
mutable bool valid_;
mutable std::size_t i_; // the max index
- mutable value v_; // the max value
+ mutable argument x_; // the max argument
// Auxiliary methods
void update_() const;
@@ -105,15 +105,15 @@
template <typename S>
void
- max_h<S>::take(const value& v)
+ max_h<S>::take(const argument& x)
{
- h_.take(v);
+ h_.take(x);
if (h_.sum() == 1)
{
- this->take_as_init(v);
+ this->take_as_init(x);
return;
}
- if (v > v_)
+ if (x > x_)
{
++sum_;
valid_ = false;
@@ -134,23 +134,23 @@
template <typename S>
void
- max_h<S>::untake(const value& v)
+ max_h<S>::untake(const argument& x)
{
- mln_precondition(h_(v) != 0);
- h_.untake(v);
+ mln_precondition(h_(x) != 0);
+ h_.untake(x);
if (h_.sum() == 0)
{
init();
return;
}
- if (v > v_)
+ if (x > x_)
{
mln_invariant(sum_ >= 1);
--sum_;
valid_ = false;
}
else
- if (v == v_ && h_[i_] == 0)
+ if (x == x_ && h_[i_] == 0)
valid_ = false;
}
@@ -173,7 +173,7 @@
do
--i_;
while (h_[i_] == 0);
- v_ = s_[i_];
+ x_ = s_[i_];
}
template <typename S>
@@ -186,7 +186,7 @@
if (h_[i_] != 0)
sum_ -= h_[i_];
} while (sum_ != 0);
- v_ = s_[i_];
+ x_ = s_[i_];
}
template <typename S>
@@ -195,29 +195,29 @@
{
h_.init();
sum_ = 0;
- i_ = mln_min(value);
- v_ = s_[i_];
+ i_ = mln_min(argument);
+ x_ = s_[i_];
valid_ = true;
}
template <typename S>
void
- max_h<S>::take_as_init(const value& v)
+ max_h<S>::take_as_init(const argument& x)
{
- h_.take(v);
+ h_.take(x);
sum_ = 0;
- i_ = s_.index_of(v);
- v_ = v;
+ i_ = s_.index_of(x);
+ x_ = x;
valid_ = true;
}
template <typename S>
- typename max_h<S>::value
+ typename max_h<S>::argument
max_h<S>::to_result() const
{
if (! valid_)
update_();
- return v_;
+ return x_;
}
template <typename S>
Index: trunk/milena/mln/accu/median.hh
===================================================================
--- trunk/milena/mln/accu/median.hh (revision 1245)
+++ trunk/milena/mln/accu/median.hh (revision 1246)
@@ -50,20 +50,20 @@
template <typename S>
struct median : public mln::accu::internal::base_< mln_value(S), median<S> >
{
- typedef mln_value(S) value;
- typedef value result;
+ typedef mln_value(S) argument;
+ typedef argument result;
median(const Value_Set<S>& s);
median();
void init();
- void take(const value& v);
+ void take(const argument& x);
void take(const median<S>& other);
- void untake(const value& v);
+ void untake(const argument& x);
unsigned card() const { return h_.sum(); }
- value to_result() const;
+ argument to_result() const;
const accu::histo<S>& histo() const;
@@ -76,7 +76,7 @@
mutable bool valid_;
mutable std::size_t i_; // the median index
- mutable value v_; // the median value
+ mutable argument x_; // the median value
// Auxiliary methods
void update_() const;
@@ -105,13 +105,13 @@
template <typename S>
void
- median<S>::take(const value& v)
+ median<S>::take(const argument& x)
{
- h_.take(v);
+ h_.take(x);
- if (v < v_)
+ if (x < x_)
++sum_minus_;
- else if (v > v_)
+ else if (x > x_)
++sum_plus_;
if (valid_)
@@ -139,14 +139,14 @@
template <typename S>
void
- median<S>::untake(const value& v)
+ median<S>::untake(const argument& x)
{
- mln_precondition(h_(v) != 0);
- h_.untake(v);
+ mln_precondition(h_(x) != 0);
+ h_.untake(x);
- if (v < v_)
+ if (x < x_)
--sum_minus_;
- else if (v > v_)
+ else if (x > x_)
--sum_plus_;
if (valid_)
@@ -191,7 +191,7 @@
sum_minus_ -= h_[i_];
}
while (2 * sum_minus_ > h_.sum());
- v_ = s_[i_];
+ x_ = s_[i_];
}
template <typename S>
@@ -207,7 +207,7 @@
sum_plus_ -= h_[i_];
}
while (2 * sum_plus_ > h_.sum());
- v_ = s_[i_];
+ x_ = s_[i_];
}
template <typename S>
@@ -217,18 +217,18 @@
h_.init();
sum_minus_ = 0;
sum_plus_ = 0;
- i_ = (mln_max(value) - mln_min(value)) / 2;
- v_ = s_[i_];
+ i_ = (mln_max(argument) - mln_min(argument)) / 2;
+ x_ = s_[i_];
valid_ = true;
}
template <typename S>
- typename median<S>::value
+ typename median<S>::argument
median<S>::to_result() const
{
if (! valid_)
update_();
- return v_;
+ return x_;
}
template <typename S>
Index: trunk/milena/mln/accu/median_alt.hh
===================================================================
--- trunk/milena/mln/accu/median_alt.hh (revision 1245)
+++ trunk/milena/mln/accu/median_alt.hh (revision 1246)
@@ -50,21 +50,21 @@
template <typename S>
struct median_alt : : public mln::accu::internal::base_< mln_value(S), median_alt<S> >
{
- typedef mln_value(S) value;
+ typedef mln_value(S) argument;
median_alt(const Value_Set<S>& s);
- void take(const value& v);
- void untake(const value& v);
+ void take(const argument& x);
+ void untake(const argument& x);
void init();
- value to_result() const;
+ argument to_result() const;
// FIXME: remove
void debug__() const
{
std::cout << " i = " << i_
- << " v = " << v_
+ << " x = " << x_
<< " s = " << sum_minus_ << " ; " << h_[i_] << " ; " << sum_plus_ << " = " << h_.sum()
<< std::endl;
}
@@ -77,7 +77,7 @@
std::size_t sum_minus_, sum_plus_;
std::size_t i_; // the median index
- value v_; // the median value
+ argument x_; // the median argument
// Auxiliary methods
void go_minus_();
@@ -109,24 +109,24 @@
template <typename S>
void
- median_alt<S>::take(const value& v)
+ median_alt<S>::take(const argument& x)
{
// update h_
- h_.take(v);
+ h_.take(x);
// particular case:
// current state was initialization
if (h_[i_] == 0)
{
// std::cout << "init!" << std::endl;
- i_ = s_.index_of(v);
- v_ = v;
+ i_ = s_.index_of(x);
+ x_ = x;
return;
}
// particular case:
// the median does not change
- if (v == v_)
+ if (x == x_)
{
// std::cout << "no change!" << std::endl;
return;
@@ -134,14 +134,14 @@
// general case:
- if (v < v_)
+ if (x < x_)
{
++sum_minus_;
if (2 * sum_minus_ > h_.sum())
go_minus_();
}
else
- // v > v_
+ // x > x_
{
++sum_plus_;
if (2 * sum_plus_ > h_.sum())
@@ -152,12 +152,12 @@
template <typename S>
void
- median_alt<S>::untake(const value& v)
+ median_alt<S>::untake(const argument& x)
{
- mln_precondition(h_(v) != 0);
+ mln_precondition(h_(x) != 0);
// update h_
- h_.untake(v);
+ h_.untake(x);
// particular case:
// the only value has been removed
@@ -168,20 +168,20 @@
}
// general case:
- if (v < v_)
+ if (x < x_)
{
--sum_minus_;
if (2 * sum_plus_ > h_.sum())
go_plus_();
}
- else if (v > v_)
+ else if (x > x_)
{
--sum_plus_;
if (2 * sum_minus_ > h_.sum())
go_minus_();
}
else
- // v == v_
+ // x == x_
{
if (h_[i_] == 0)
{
@@ -216,7 +216,7 @@
sum_minus_ -= h_[i_];
}
while (2 * sum_minus_ > h_.sum());
- v_ = s_[i_];
+ x_ = s_[i_];
}
@@ -233,7 +233,7 @@
sum_plus_ -= h_[i_];
}
while (2 * sum_plus_ > h_.sum());
- v_ = s_[i_];
+ x_ = s_[i_];
}
@@ -244,15 +244,15 @@
h_.init();
sum_minus_ = 0;
sum_plus_ = 0;
- i_ = (mln_max(value) - mln_min(value)) / 2;
- v_ = s_[i_];
+ i_ = (mln_max(argument) - mln_min(argument)) / 2;
+ x_ = s_[i_];
}
template <typename S>
- typename median_alt<S>::value
+ typename median_alt<S>::argument
median_alt<S>::to_result() const
{
- return v_;
+ return x_;
}
template <typename S>
Index: trunk/milena/mln/accu/p.hh
===================================================================
--- trunk/milena/mln/accu/p.hh (revision 1245)
+++ trunk/milena/mln/accu/p.hh (revision 1246)
@@ -53,7 +53,7 @@
template <typename A>
struct p_ : public mln::accu::internal::base_< mln_result(A) , p_<A> >
{
- typedef mln_value(A) value;
+ typedef mln_value(A) argument;
typedef mln_result(A) result;
@@ -61,8 +61,8 @@
p_(const A& a);
void init();
- void take_as_init(const value& v);
- void take(const value& v);
+ void take_as_init(const argument& x);
+ void take(const argument& x);
void take(const p_<A>& other);
result to_result() const;
@@ -109,16 +109,16 @@
template <typename A>
void
- p_<A>::take_as_init(const value& v)
+ p_<A>::take_as_init(const argument& x)
{
- a_.take_as_init(v.p()); // FIXME: Generalize with "psite(v)".
+ a_.take_as_init(x.p()); // FIXME: Generalize with "psite(x)".
}
template <typename A>
void
- p_<A>::take(const value& v)
+ p_<A>::take(const argument& x)
{
- a_.take(v.p());
+ a_.take(x.p());
}
template <typename A>
Index: trunk/milena/mln/accu/sum.hh
===================================================================
--- trunk/milena/mln/accu/sum.hh (revision 1245)
+++ trunk/milena/mln/accu/sum.hh (revision 1246)
@@ -57,13 +57,13 @@
template <typename V, typename S = mln_sum(V)>
struct sum_ : public mln::accu::internal::base_< S, sum_<V,S> >
{
- typedef V value;
+ typedef V argument;
typedef S result;
sum_();
void init();
- void take(const value& v);
+ void take(const argument& x);
void take(const sum_<V,S>& other);
S to_result() const;
@@ -106,9 +106,9 @@
}
template <typename V, typename S>
- void sum_<V,S>::take(const value& v)
+ void sum_<V,S>::take(const argument& x)
{
- s_ += v;
+ s_ += x;
}
template <typename V, typename S>
Index: trunk/milena/mln/accu/v.hh
===================================================================
--- trunk/milena/mln/accu/v.hh (revision 1245)
+++ trunk/milena/mln/accu/v.hh (revision 1246)
@@ -50,15 +50,15 @@
template <typename A>
struct val_ : public mln::accu::internal::base_< mln_result(A) , val_<A> >
{
- typedef mln_value(A) value;
+ typedef mln_argument(A) argument;
typedef mln_result(A) result;
val_();
val_(const A& a);
void init();
- void take_as_init(const value& v);
- void take(const value& v);
+ void take_as_init(const argument& x);
+ void take(const argument& x);
void take(const val_<A>& other);
template <typename I>
@@ -118,16 +118,16 @@
template <typename A>
void
- val_<A>::take_as_init(const value& v)
+ val_<A>::take_as_init(const argument& x)
{
- a_.take_as_init(v);
+ a_.take_as_init(x);
}
template <typename A>
void
- val_<A>::take(const value& v)
+ val_<A>::take(const argument& x)
{
- a_.take(v);
+ a_.take(x);
}
template <typename A>
Index: trunk/milena/mln/accu/internal/base.hh
===================================================================
Index: trunk/milena/mln/accu/mean.hh
===================================================================
--- trunk/milena/mln/accu/mean.hh (revision 1245)
+++ trunk/milena/mln/accu/mean.hh (revision 1246)
@@ -60,13 +60,13 @@
typename M = S>
struct mean_ : public mln::accu::internal::base_< M , mean_<V,S,M> >
{
- typedef V value;
+ typedef V argument;
typedef M result;
mean_();
void init();
- void take(const value& v);
+ void take(const argument& x);
void take(const mean_<V,S,M>& other);
M to_result() const;
@@ -114,10 +114,10 @@
}
template <typename V, typename S, typename M>
- void mean_<V,S,M>::take(const value& v)
+ void mean_<V,S,M>::take(const argument& x)
{
- count_.take(v);
- sum_.take(v);
+ count_.take(x);
+ sum_.take(x);
}
template <typename V, typename S, typename M>
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-10-04 Simon Nivault <simon.nivault(a)lrde.epita.fr>
Add generic line.
* mln/core/win/line.hh: New.
* mln/core/win/hline2d.hh,
* mln/core/win/vline2d.hh: Now inherit of line.
* tests/win_hline2d.cc: New.
---
mln/core/win/hline2d.hh | 125 +-------------------------------
mln/core/win/line.hh | 185 ++++++++++++++++++++++++++++++++++++++++++++++++
mln/core/win/vline2d.hh | 125 +-------------------------------
tests/win_hline2d.cc | 48 ++++++++++++
4 files changed, 247 insertions(+), 236 deletions(-)
Index: trunk/milena/tests/win_hline2d.cc
===================================================================
--- trunk/milena/tests/win_hline2d.cc (revision 0)
+++ trunk/milena/tests/win_hline2d.cc (revision 1245)
@@ -0,0 +1,48 @@
+// 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/win_diag2d.cc
+ *
+ * \brief Tests on mln::win::diag2d.
+ */
+
+#include <mln/core/win/hline2d.hh>
+
+#include <mln/convert/to_image.hh>
+
+#include <mln/debug/println.hh>
+
+int main()
+{
+ using namespace mln;
+
+ const unsigned l = 5;
+ win::hline2d hline(l);
+
+ debug::println(convert::to_image(hline));
+}
+
Index: trunk/milena/mln/core/win/vline2d.hh
===================================================================
--- trunk/milena/mln/core/win/vline2d.hh (revision 1244)
+++ trunk/milena/mln/core/win/vline2d.hh (revision 1245)
@@ -33,10 +33,8 @@
* \brief Definition of the mln::win::vline2d window.
*/
-# include <mln/core/concept/window.hh>
-# include <mln/core/internal/dpoints_base.hh>
-# include <mln/core/dpoint2d.hh>
-# include <mln/core/dpoints_piter.hh>
+# include <mln/core/win/line.hh>
+# include <mln/core/grids.hh>
namespace mln
@@ -56,123 +54,14 @@
* o \n
* is defined with length = 5.
*/
- struct vline2d : public Window< vline2d >,
- public internal::dpoints_base_< dpoint2d, vline2d >
+ struct vline2d : public line<grid::square, 0, vline2d>
{
- /// Point associated type.
- typedef point2d point;
-
- /// Dpoint associated type.
- typedef dpoint2d dpoint;
-
- /*! \brief Point_Iterator type to browse a vline such as: "for each row
- * (increasing), for each column (increasing)."
- */
- typedef dpoints_fwd_piter<dpoint2d> fwd_qiter;
-
- /*! \brief Point_Iterator type to browse a vline such as: "for each row
- * (decreasing), for each column (decreasing)."
- */
- typedef dpoints_bkd_piter<dpoint2d> bkd_qiter;
-
- /*! \brief Same as fwd_qiter.
- */
- typedef fwd_qiter qiter;
-
- /*! \brief Constructor.
- *
- * \param[in] length Length, thus height, of the vertical line.
- *
- * \pre \p length is odd.
- */
- vline2d(unsigned length);
-
- /*! \brief Test if the window is centered.
- *
- * \return True.
- */
- bool is_centered() const;
-
- /*! \brief Test if the window is symmetric.
- *
- * \return true.
- */
- bool is_symmetric() const;
-
- /*! \brief Give the vline length, that is, its height.
- */
- unsigned length() const;
-
- /*! \brief Give the maximum coordinate gap between the window
- * center and a window point.
- */
- unsigned delta() const;
-
- /// Apply a central symmetry to the target window.
- vline2d& sym();
-
- protected:
- unsigned length_;
- };
-
-
- /*! \brief Print a vertical 2D line window \p win into the output
- * stream \p ostr.
- *
- * \param[in,out] ostr An output stream.
- * \param[in] win A vertical 2D line window.
- *
- * \return The modified output stream \p ostr.
- *
- * \relates mln::win::vline2d
- */
- std::ostream& operator<<(std::ostream& ostr, const vline2d& win);
-
-
-
-# ifndef MLN_INCLUDE_ONLY
-
- vline2d::vline2d(unsigned length)
- : length_(length)
+ // Ctor.
+ vline2d(unsigned length)
+ : line<grid::square, 0, vline2d>(length)
{
- mln_precondition(length % 2 == 1);
- const int drow = length / 2;
- for (int row = - drow; row <= drow; ++row)
- insert(make::dpoint2d(row, 0));
}
-
- bool vline2d::is_centered() const
- {
- return true;
- }
-
- bool vline2d::is_symmetric() const
- {
- return true;
- }
-
- unsigned vline2d::length() const
- {
- return length_;
- }
-
- unsigned vline2d::delta() const
- {
- return length_ / 2;
- }
-
- vline2d& vline2d::sym()
- {
- return *this;
- }
-
- std::ostream& operator<<(std::ostream& ostr, const vline2d& win)
- {
- ostr << "[line2d: length=" << win.length() << ']';
- return ostr;
- }
-
-# endif // ! MLN_INCLUDE_ONLY
+ };
} // end of namespace mln::win
Index: trunk/milena/mln/core/win/hline2d.hh
===================================================================
--- trunk/milena/mln/core/win/hline2d.hh (revision 1244)
+++ trunk/milena/mln/core/win/hline2d.hh (revision 1245)
@@ -33,10 +33,8 @@
* \brief Definition of the mln::win::hline2d window.
*/
-# include <mln/core/concept/window.hh>
-# include <mln/core/internal/dpoints_base.hh>
-# include <mln/core/dpoint2d.hh>
-# include <mln/core/dpoints_piter.hh>
+# include <mln/core/win/line.hh>
+# include <mln/core/grids.hh>
namespace mln
@@ -54,123 +52,14 @@
* o o x o o \n
* is defined with length = 5.
*/
- struct hline2d : public Window< hline2d >,
- public internal::dpoints_base_< dpoint2d, hline2d >
+ struct hline2d : public line<grid::square, 1, hline2d>
{
- /// Point associated type.
- typedef point2d point;
-
- /// Dpoint associated type.
- typedef dpoint2d dpoint;
-
- /*! \brief Point_Iterator type to browse a hline such as: "for each row
- * (increasing), for each column (increasing)."
- */
- typedef dpoints_fwd_piter<dpoint2d> fwd_qiter;
-
- /*! \brief Point_Iterator type to browse a hline such as: "for each row
- * (decreasing), for each column (decreasing)."
- */
- typedef dpoints_bkd_piter<dpoint2d> bkd_qiter;
-
- /*! \brief Same as fwd_qiter.
- */
- typedef fwd_qiter qiter;
-
- /*! \brief Constructor.
- *
- * \param[in] length Length, thus width, of the horizontal line.
- *
- * \pre \p length is odd.
- */
- hline2d(unsigned length);
-
- /*! \brief Test if the window is centered.
- *
- * \return True.
- */
- bool is_centered() const;
-
- /*! \brief Test if the window is symmetric.
- *
- * \return true.
- */
- bool is_symmetric() const;
-
- /*! \brief Give the hline length, that is, its width.
- */
- unsigned length() const;
-
- /*! \brief Give the maximum coordinate gap between the window
- * center and a window point.
- */
- unsigned delta() const;
-
- /// Apply a central symmetry to the target window.
- hline2d& sym();
-
- protected:
- unsigned length_;
- };
-
-
- /*! \brief Print an horizontal 2D line window \p win into the output
- * stream \p ostr.
- *
- * \param[in,out] ostr An output stream.
- * \param[in] win An horizontal 2D line window.
- *
- * \return The modified output stream \p ostr.
- *
- * \relates mln::win::hline2d
- */
- std::ostream& operator<<(std::ostream& ostr, const hline2d& win);
-
-
-
-# ifndef MLN_INCLUDE_ONLY
-
- hline2d::hline2d(unsigned length)
- : length_(length)
+ // Ctor.
+ hline2d(unsigned length)
+ : line<grid::square, 1, hline2d>(length)
{
- mln_precondition(length % 2 == 1);
- const int dcol = length / 2;
- for (int col = - dcol; col <= dcol; ++col)
- insert(make::dpoint2d(0, col));
}
-
- bool hline2d::is_centered() const
- {
- return true;
- }
-
- bool hline2d::is_symmetric() const
- {
- return true;
- }
-
- unsigned hline2d::length() const
- {
- return length_;
- }
-
- unsigned hline2d::delta() const
- {
- return length_ / 2;
- }
-
- hline2d& hline2d::sym()
- {
- return *this;
- }
-
- std::ostream& operator<<(std::ostream& ostr, const hline2d& win)
- {
- ostr << "[line2d: length=" << win.length() << ']';
- return ostr;
- }
-
-# endif // ! MLN_INCLUDE_ONLY
+ };
} // end of namespace mln::win
Index: trunk/milena/mln/core/win/line.hh
===================================================================
--- trunk/milena/mln/core/win/line.hh (revision 0)
+++ trunk/milena/mln/core/win/line.hh (revision 1245)
@@ -0,0 +1,185 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_WIN_LINE_HH
+# define MLN_CORE_WIN_LINE_HH
+
+/*! \file mln/core/win/line.hh
+ *
+ * \brief Definition of the mln::win::line window.
+ */
+
+# include <mln/core/concept/window.hh>
+# include <mln/core/internal/dpoints_base.hh>
+# include <mln/core/dpoint.hh>
+# include <mln/core/dpoints_piter.hh>
+
+
+namespace mln
+{
+
+ namespace win
+ {
+
+ template <typename M, unsigned i, typename E>
+ struct line : public Window<E>,
+ public internal::dpoints_base_
+ <dpoint_
+ <M, int>, point_
+ <M, int> >
+ {
+ /// Point associated type.
+ typedef point_<M, int> point;
+
+ /// Dpoint associated type.
+ typedef dpoint_<M, int> dpoint;
+
+ /// Point_Iterator type to browse a line forward
+ typedef dpoints_fwd_piter<dpoint> fwd_qiter;
+
+ /// Point_Iterator type to browse a line backward
+ typedef dpoints_bkd_piter<dpoint> bkd_qiter;
+
+ /// Same as fwd_qiter
+ typedef fwd_qiter qiter;
+
+ /*! \brief Constructor.
+ *
+ * \param[in] length Length of the line.
+ *
+ * \pre \p length is odd.
+ */
+ line(unsigned length);
+
+ /*! \brief Test if the window is centered.
+ *
+ * \return True.
+ */
+ bool is_centered() const;
+
+ /*! \brief Test if the window is symmetric.
+ *
+ * \return true.
+ */
+ bool is_symmetric() const;
+
+ /*! \brief Give the hline length, that is, its width.
+ */
+ unsigned length() const;
+
+ /*! \brief Give the maximum coordinate gap between the window
+ * center and a window point.
+ */
+ unsigned delta() const;
+
+ /// Apply a central symmetry to the target window.
+ E& sym();
+
+ protected:
+ unsigned length_;
+ };
+
+
+ /*! \brief Print an line window \p win into the output
+ * stream \p ostr.
+ *
+ * \param[in,out] ostr An output stream.
+ * \param[in] win An line window.
+ *
+ * \return The modified output stream \p ostr.
+ *
+ * \relates mln::win::line
+ */
+ template <typename M, unsigned i, typename E>
+ std::ostream& operator<<(std::ostream& ostr, const line<M,i,E>& win);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ template <typename M, unsigned i, typename E>
+ line<M,i,E>::line(unsigned length)
+ : length_(length)
+ {
+ mln_precondition(i < M::dim);
+ mln_precondition(length % 2 == 1);
+ const int dcol = length / 2;
+ for (int col = - dcol; col <= dcol; ++col)
+ {
+ dpoint n;
+ n[i] = col;
+ insert(n);
+ }
+ }
+
+ template <typename M, unsigned i, typename E>
+ bool line<M,i,E>::is_centered() const
+ {
+ return true;
+ }
+
+ template <typename M, unsigned i, typename E>
+ bool line<M,i,E>::is_symmetric() const
+ {
+ return true;
+ }
+
+ template <typename M, unsigned i, typename E>
+ unsigned line<M,i,E>::length() const
+ {
+ return length_;
+ }
+
+ template <typename M, unsigned i, typename E>
+ unsigned line<M,i,E>::delta() const
+ {
+ return length_ / 2;
+ }
+
+ template <typename M, unsigned i, typename E>
+ E& line<M,i,E>::sym()
+ {
+ return exact(*this);
+ }
+
+ template <typename M, unsigned i, typename E>
+ std::ostream& operator<<(std::ostream& ostr, const line<M,i,E>& win)
+ {
+ ostr << "[line: length=" << win.length() << ']';
+ return ostr;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::win
+
+} // end of namespace mln
+
+
+
+#endif // ! MLN_CORE_WIN_LINE_HH
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-10-04 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Fix chamfer.
* chamfer.hh: Update.
---
chamfer.hh | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
Index: trunk/milena/sandbox/duhamel/chamfer.hh
===================================================================
--- trunk/milena/sandbox/duhamel/chamfer.hh (revision 1243)
+++ trunk/milena/sandbox/duhamel/chamfer.hh (revision 1244)
@@ -27,6 +27,7 @@
# include <mln/core/image_if_interval.hh>
# include <mln/core/dpoint2d.hh>
+# include <math.h>
namespace mln
{
@@ -50,7 +51,7 @@
{
int ws[] = { 0, d21, 0, d21, 0,
d21, d11, d10, d11, d21,
- 0, d10, 0, d10, 0,
+ 0, d10, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0 };
@@ -72,13 +73,24 @@
{
float ws[] = { 0, d21, 0, d21, 0,
d21, d11, d10, d11, d21,
- 0, d10, 0, d10, 0,
+ 0, d10, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0 };
return (make::w_window2d(ws));
}
+ const w_window2d_float
+ mk_chamfer_exact()
+ {
+ float r2 = sqrt(2);
+ float ws[] = { r2, 1, r2,
+ 1, 0, 0,
+ 0, 0, 0 };
+
+ return (make::w_window2d(ws));
+ }
+
} // end of mln::win_chamfer
template <typename I, typename W>
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-10-04 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Update chamfer.
* chamfer.cc: Test for chamfer.
* chamfer.hh: New split of old version.
* color_sub.cc,
* color_sub.hh,
* main.cc: Update.
---
chamfer.cc | 121 ++++++++++++------------------------------------------
chamfer.hh | 131 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
color_sub.cc | 3 -
color_sub.hh | 23 +++++-----
main.cc | 1
5 files changed, 173 insertions(+), 106 deletions(-)
Index: trunk/milena/sandbox/duhamel/main.cc
===================================================================
--- trunk/milena/sandbox/duhamel/main.cc (revision 1242)
+++ trunk/milena/sandbox/duhamel/main.cc (revision 1243)
@@ -26,6 +26,7 @@
{
}
+
int
main (void)
{
Index: trunk/milena/sandbox/duhamel/color_sub.cc
===================================================================
--- trunk/milena/sandbox/duhamel/color_sub.cc (revision 1242)
+++ trunk/milena/sandbox/duhamel/color_sub.cc (revision 1243)
@@ -57,8 +57,7 @@
image2d_b<value::int_u8> ima(3,3);
debug::iota(ima);
std::cout << ima.domain() << std::endl;
- image2d_b<value::rgb8> out(ima.domain ().bbox ());
- color(inplace (ima | 6), out);
+ image2d_b<value::rgb8> out = color(inplace (ima | 6));
io::ppm::save(out, "out.ppm");
debug::println(out);
}
Index: trunk/milena/sandbox/duhamel/chamfer.cc
===================================================================
--- trunk/milena/sandbox/duhamel/chamfer.cc (revision 1242)
+++ trunk/milena/sandbox/duhamel/chamfer.cc (revision 1243)
@@ -1,6 +1,9 @@
#include <mln/core/image2d_b.hh>
#include <mln/core/sub_image.hh>
+#include <mln/core/image_if_value.hh>
#include <mln/core/neighb2d.hh>
+#include <mln/core/inplace.hh>
+
#include <mln/value/int_u8.hh>
#include <mln/level/fill.hh>
#include <mln/level/stretch.hh>
@@ -12,6 +15,7 @@
# include <mln/labeling/base.hh>
# include <mln/debug/println.hh>
# include <mln/core/window2d.hh>
+# include <mln/core/w_window2d_int.hh>
# include <mln/convert/to_window.hh>
# include <mln/core/concept/dpoint.hh>
# include <mln/core/concept/neighborhood.hh>
@@ -20,114 +24,43 @@
# include <mln/pw/cst.hh>
# include <mln/metal/is_a.hh>
+# include <mln/core/image_if_interval.hh>
+#include "chamfer.hh"
-namespace mln
-{
- namespace convert
- {
-// template <typename N>
-// window<mln_dpoint(N)> to_upper_window(const Neighborhood<N>& nbh_)
-// {
-// const N& nbh = exact(nbh_);
-// typedef mln_dpoint(N) D;
-// typedef mln_point(D) P;
-// window<D> win;
-// mln_niter(N) n(nbh, P::zero);
-// for_all(n)
-// if (n > P::zero)
-// win.insert(n - P::zero);
-// return win;
-// }
- template <typename N>
- window<mln_dpoint(N)> to_lower_window(const Neighborhood<N>& nbh_)
- {
- const N& nbh = exact(nbh_);
- typedef mln_dpoint(N) D;
- typedef mln_point(D) P;
- window<D> win;
- mln_niter(N) n(nbh, P::zero);
- for_all(n)
- if (n < P::zero)
- win.insert(n - P::zero);
- return win;
- }
-
- } // end of namespace convert
-
- template <typename I, typename N, typename J>
- void
- chamfer (Image<I>& ima_, const Neighborhood<N>& nbh_,
- mln_point(I)& point, unsigned max, Image<J>& out_)
+int main()
{
- I& ima = exact (ima_);
- J& out = exact (out_);
+ using namespace mln;
+ unsigned max = 51;
- typedef window<mln_dpoint(I)> W;
+ image2d_b<bool> ima(9, 9);
- /// Init.
{
- level::fill (out, max);
- out(point) = 0;
+ level::fill(ima, false);
+ ima.at(4,4) = true;
+ const w_window2d_int& w_win = win_chamfer::mk_chamfer_3x3_int<2, 0> ();
+ image2d_b<unsigned> out = chamfer(ima, w_win, max);
+ debug::println(out | value::interval(0, 8));
}
- /// Fwd pass.
{
- mln_fwd_piter (I) p (ima.domain ());
- W win = convert::to_upper_window(nbh_);
- mln_qiter(W) n(win, p);
-
- for_all (p)
- {
- for_all (n)
- {
- if (out(n) > out(p) + 1)
- out(n) = out(p) + 1;
- }
- }
+ level::fill(ima, false);
+ ima.at(4,4) = true;
+ const w_window2d_int& w_win = win_chamfer::mk_chamfer_3x3_int<2, 3> ();
+ image2d_b<unsigned> out = chamfer(ima, w_win, max);
+ debug::println(out | value::interval(0, 8));
}
- /// Bkd pass.
{
- mln_bkd_piter (I) p (ima.domain ());
- W win = convert::to_lower_window(nbh_);
- mln_qiter(W) n( win, p);
-
+ level::fill(ima, false);
+ ima.at(4,4) = true;
+ const w_window2d_int& w_win = win_chamfer::mk_chamfer_5x5_int<4, 6, 9> ();
+ image2d_b<unsigned> out = chamfer(ima, w_win, max);
+ image2d_b<unsigned>::fwd_piter p(out.domain());
for_all (p)
- {
- for_all (n)
- {
- if (out(n) > out(p) + 1)
- out(n) = out(p) + 1;
- }
- }
+ out(p) = out(p) / 2;
+ debug::println(out | value::interval(0, 8));
}
- }
-} // end of mln
-int main ()
-{
- using namespace mln;
- using value::int_u8;
-
- {
- image2d_b<int_u8> ima (9, 9);
- image2d_b<unsigned> out (ima.domain ());
- point2d p = make::point2d(4,4);
-
- chamfer (ima, c4(), p, 255, out);
- debug::println (out);
- }
-
-
-
- {
- image2d_b<int_u8> ima (1000, 1000);
- image2d_b<unsigned> out (ima.domain ());
- point2d p = make::point2d(4,4);
-
- chamfer (ima, c4(), p, 255, out);
- }
- // debug::println (out);
}
Index: trunk/milena/sandbox/duhamel/color_sub.hh
===================================================================
--- trunk/milena/sandbox/duhamel/color_sub.hh (revision 1242)
+++ trunk/milena/sandbox/duhamel/color_sub.hh (revision 1243)
@@ -37,24 +37,27 @@
namespace mln
{
- template <typename I, typename J>
- void
- color (Image<I>& ima_ , Image<J>& out_)
+ template <typename I>
+ mln_ch_value (I, value::rgb8)
+ color (const Image<I>& input_)
{
- I& ima = exact (ima_);
- J& out = exact (out_);
- // image2d_b<value::rgb8> out(ima.domain ().bbox ());
+ const I& input = exact (input_);
- level::fill (out, value::rgb8(255, 0, 0));
+ mln_ch_value(I, value::rgb8) output;
+ initialize(output, input);
+
+ // image2d_b<value::rgb8> output(ima.domain ().bbox ());
+
+ level::fill (output, value::rgb8(255, 0, 0));
{
- mln_piter(I) p (ima.domain ());
+ mln_piter(I) p (input.domain ());
for_all (p)
{
- out(p) = value::rgb8(ima(p));
+ output(p) = value::rgb8(input(p));
}
}
- // return out;
+ return output;
}
}
Index: trunk/milena/sandbox/duhamel/chamfer.hh
===================================================================
--- trunk/milena/sandbox/duhamel/chamfer.hh (revision 0)
+++ trunk/milena/sandbox/duhamel/chamfer.hh (revision 1243)
@@ -0,0 +1,131 @@
+#include <mln/core/image2d_b.hh>
+#include <mln/core/sub_image.hh>
+#include <mln/core/image_if_value.hh>
+#include <mln/core/neighb2d.hh>
+#include <mln/core/inplace.hh>
+
+#include <mln/value/int_u8.hh>
+#include <mln/level/fill.hh>
+#include <mln/level/stretch.hh>
+#include <mln/io/pbm/load.hh>
+#include <mln/io/pgm/save.hh>
+#include <mln/io/pgm/save.hh>
+#include <mln/io/pgm/save.hh>
+#include <mln/core/mesh_image.hh>
+# include <mln/labeling/base.hh>
+# include <mln/debug/println.hh>
+# include <mln/core/window2d.hh>
+# include <mln/core/w_window2d_int.hh>
+# include <mln/core/w_window2d_float.hh>
+# include <mln/convert/to_window.hh>
+# include <mln/core/concept/dpoint.hh>
+# include <mln/core/concept/neighborhood.hh>
+# include <mln/core/window.hh>
+# include <mln/pw/image.hh>
+# include <mln/pw/cst.hh>
+# include <mln/metal/is_a.hh>
+
+# include <mln/core/image_if_interval.hh>
+# include <mln/core/dpoint2d.hh>
+
+namespace mln
+{
+ namespace win_chamfer
+ {
+
+ template<int d10, int d11>
+ const w_window2d_int
+ mk_chamfer_3x3_int()
+ {
+ int ws[] = { d11, d10, d11,
+ d10, 0, 0,
+ 0, 0, 0 };
+
+ return (make::w_window2d(ws));
+ }
+
+ template<int d10, int d11, int d21>
+ const w_window2d_int
+ mk_chamfer_5x5_int()
+ {
+ int ws[] = { 0, d21, 0, d21, 0,
+ d21, d11, d10, d11, d21,
+ 0, d10, 0, d10, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0 };
+
+ return (make::w_window2d(ws));
+ }
+
+ const w_window2d_float
+ mk_chamfer_3x3_float(float d10, float d11)
+ {
+ float ws[] = { d11, d10, d11,
+ d10, 0, 0,
+ 0, 0, 0 };
+
+ return (make::w_window2d(ws));
+ }
+
+ const w_window2d_float
+ mk_chamfer_5x5_float(float d10, float d11, float d21)
+ {
+ float ws[] = { 0, d21, 0, d21, 0,
+ d21, d11, d10, d11, d21,
+ 0, d10, 0, d10, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0 };
+
+ return (make::w_window2d(ws));
+ }
+
+ } // end of mln::win_chamfer
+
+ template <typename I, typename W>
+ mln_ch_value(I, unsigned)
+ chamfer(const Image<I>& input_, const Weighted_Window<W>& w_win_,
+ unsigned max = mln_max(unsigned))
+ {
+ const I& input = exact(input_);
+ const W& w_win = exact(w_win_);
+
+ mln_ch_value(I, unsigned) output;
+ initialize(output, input);
+
+ /// Init.
+ {
+ level::fill(inplace(output | (input | true).domain()), 0);
+ level::fill(inplace(output | (input | false).domain()), max);
+ }
+
+ /// Fwd pass.
+ {
+ mln_fwd_piter(I) p(input.domain());
+ mln_qiter(W) q(w_win, p);
+
+ for_all(p) if (input(p) == false)
+ for_all(q) if (input.has(q))
+ if (output(q) != max
+ && output(q) + q.w() < output(p))
+ output(p) = output(q) + q.w();
+ }
+
+ /// Bkd pass.
+ {
+
+ W w_win_b = geom::sym(w_win);
+
+ mln_bkd_piter(I) p(input.domain());
+ mln_qiter(W) q(w_win_b, p);
+
+ for_all(p) if (input(p) == false)
+ for_all(q) if (input.has(q))
+ if (output(q) != max
+ && output(q) + q.w() < output(p))
+ output(p) = output(q) + q.w();
+ }
+
+ return output;
+ }
+
+} // end of mln
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-10-04 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Fix chamfer.
* chamfer.cc: .
---
chamfer.cc | 1 -
1 file changed, 1 deletion(-)
Index: trunk/milena/sandbox/duhamel/chamfer.cc
===================================================================
--- trunk/milena/sandbox/duhamel/chamfer.cc (revision 1241)
+++ trunk/milena/sandbox/duhamel/chamfer.cc (revision 1242)
@@ -75,7 +75,6 @@
/// Fwd pass.
{
mln_fwd_piter (I) p (ima.domain ());
- p = point;
W win = convert::to_upper_window(nbh_);
mln_qiter(W) n(win, p);
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-10-04 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Add chamfer in sadbox.
* chamfer.cc: New.
* color_sub.cc: .
* color_sub.hh: New : split ols version.
* labeling_algo.cc: .
* labeling_level_fast.cc: .
---
chamfer.cc | 134 +++++++++++++++++++++++++++++++++++++++++++++++++
color_sub.cc | 23 --------
color_sub.hh | 60 +++++++++++++++++++++
labeling_algo.cc | 20 ++-----
labeling_level_fast.cc | 11 +---
5 files changed, 205 insertions(+), 43 deletions(-)
Index: trunk/milena/sandbox/duhamel/labeling_algo.cc
===================================================================
--- trunk/milena/sandbox/duhamel/labeling_algo.cc (revision 1240)
+++ trunk/milena/sandbox/duhamel/labeling_algo.cc (revision 1241)
@@ -36,15 +36,14 @@
# include <mln/value/int_u8.hh>
# include <mln/level/fill.hh>
# include <mln/level/stretch.hh>
-# include <mln/level/saturate.hh>
# include <mln/border/fill.hh>
# include <mln/io/pbm/load.hh>
# include <mln/io/pgm/save.hh>
# include <mln/labeling/foreground.hh>
# include <mln/debug/println.hh>
-# include <mln/debug/println_with_border.hh>
# include <mln/draw/mesh.hh>
-# include "labeling_algo.hh"
+# include <mln/geom/seeds2tiling.hh>
+# include <mln/make/voronoi.hh>
int main()
{
@@ -52,7 +51,7 @@
using value::int_u8;
// image2d_b<bool> in = io::pbm::load("../../img/toto.pbm");
- image2d_b<bool> in = io::pbm::load("test.pbm");
+ image2d_b<bool> in = io::pbm::load("toto.pbm");
image2d_b<int_u8> lab(in.domain());
image2d_b<int_u8> inte(in.domain());
@@ -64,28 +63,21 @@
std::vector<int_u8> vec;
image2d_b<int> input(in.domain());
- // debug::println (in | make::box2d (100,100));
level::fill(input, lab);
lab(make::point2d (0,0)) = 0;
- inte = make_algo(lab, c4 ());
+ inte = geom::seeds2tiling(lab, c4 ());
border::fill (inte, 0);
image2d_b<int_u8> inte2(inte.domain());
level::stretch (inte, inte2);
- io::pgm::save(inte, "inte.pgm");
- io::pgm::save(inte2, "inte2.pgm");
-
- debug::println(lab | make::box2d (30,30) );
-
- // mesh_p<point2d> m = make::graph_with_no_border(inte, c4());
+ io::pgm::save(inte2, "inte.pgm");
mesh_p<point2d> m = make::voronoi(inte, lab, c4());
- std::cout << "OK" << std::endl;
+ std::cout << "OK : generate inte.pgm and out.pgm" << std::endl;
draw::mesh (out, m, 255, 128);
- // debug::println(out);
io::pgm::save(out, "out.pgm");
}
Index: trunk/milena/sandbox/duhamel/color_sub.cc
===================================================================
--- trunk/milena/sandbox/duhamel/color_sub.cc (revision 1240)
+++ trunk/milena/sandbox/duhamel/color_sub.cc (revision 1241)
@@ -48,26 +48,7 @@
#include <mln/core/image_if_value.hh>
#include <mln/debug/iota.hh>
-namespace mln
-{
- template <typename I, typename J>
- void
- color (Image<I>& ima_, Image<J>& out_)
- {
- I& ima = exact (ima_);
- J& out = exact (out_);
-
- level::fill (out, value::rgb8(255, 0, 0));
-
- {
- mln_piter(I) p (ima.domain ());
- for_all (p)
- {
- out(p) = value::rgb8(ima(p));
- }
- }
- }
-}
+#include "color_sub.hh"
int main()
{
@@ -75,8 +56,8 @@
image2d_b<value::int_u8> ima(3,3);
debug::iota(ima);
- image2d_b<value::rgb8> out(ima.domain ().bbox ());
std::cout << ima.domain() << std::endl;
+ image2d_b<value::rgb8> out(ima.domain ().bbox ());
color(inplace (ima | 6), out);
io::ppm::save(out, "out.ppm");
debug::println(out);
Index: trunk/milena/sandbox/duhamel/chamfer.cc
===================================================================
--- trunk/milena/sandbox/duhamel/chamfer.cc (revision 0)
+++ trunk/milena/sandbox/duhamel/chamfer.cc (revision 1241)
@@ -0,0 +1,134 @@
+#include <mln/core/image2d_b.hh>
+#include <mln/core/sub_image.hh>
+#include <mln/core/neighb2d.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/level/fill.hh>
+#include <mln/level/stretch.hh>
+#include <mln/io/pbm/load.hh>
+#include <mln/io/pgm/save.hh>
+#include <mln/io/pgm/save.hh>
+#include <mln/io/pgm/save.hh>
+#include <mln/core/mesh_image.hh>
+# include <mln/labeling/base.hh>
+# include <mln/debug/println.hh>
+# include <mln/core/window2d.hh>
+# include <mln/convert/to_window.hh>
+# include <mln/core/concept/dpoint.hh>
+# include <mln/core/concept/neighborhood.hh>
+# include <mln/core/window.hh>
+# include <mln/pw/image.hh>
+# include <mln/pw/cst.hh>
+# include <mln/metal/is_a.hh>
+
+
+
+namespace mln
+{
+ namespace convert
+ {
+// template <typename N>
+// window<mln_dpoint(N)> to_upper_window(const Neighborhood<N>& nbh_)
+// {
+// const N& nbh = exact(nbh_);
+// typedef mln_dpoint(N) D;
+// typedef mln_point(D) P;
+// window<D> win;
+// mln_niter(N) n(nbh, P::zero);
+// for_all(n)
+// if (n > P::zero)
+// win.insert(n - P::zero);
+// return win;
+// }
+
+ template <typename N>
+ window<mln_dpoint(N)> to_lower_window(const Neighborhood<N>& nbh_)
+ {
+ const N& nbh = exact(nbh_);
+ typedef mln_dpoint(N) D;
+ typedef mln_point(D) P;
+ window<D> win;
+ mln_niter(N) n(nbh, P::zero);
+ for_all(n)
+ if (n < P::zero)
+ win.insert(n - P::zero);
+ return win;
+ }
+
+ } // end of namespace convert
+
+ template <typename I, typename N, typename J>
+ void
+ chamfer (Image<I>& ima_, const Neighborhood<N>& nbh_,
+ mln_point(I)& point, unsigned max, Image<J>& out_)
+ {
+ I& ima = exact (ima_);
+ J& out = exact (out_);
+
+ typedef window<mln_dpoint(I)> W;
+
+ /// Init.
+ {
+ level::fill (out, max);
+ out(point) = 0;
+ }
+
+ /// Fwd pass.
+ {
+ mln_fwd_piter (I) p (ima.domain ());
+ p = point;
+ W win = convert::to_upper_window(nbh_);
+ mln_qiter(W) n(win, p);
+
+ for_all (p)
+ {
+ for_all (n)
+ {
+ if (out(n) > out(p) + 1)
+ out(n) = out(p) + 1;
+ }
+ }
+ }
+
+ /// Bkd pass.
+ {
+ mln_bkd_piter (I) p (ima.domain ());
+ W win = convert::to_lower_window(nbh_);
+ mln_qiter(W) n( win, p);
+
+ for_all (p)
+ {
+ for_all (n)
+ {
+ if (out(n) > out(p) + 1)
+ out(n) = out(p) + 1;
+ }
+ }
+ }
+ }
+} // end of mln
+
+int main ()
+{
+ using namespace mln;
+ using value::int_u8;
+
+ {
+ image2d_b<int_u8> ima (9, 9);
+ image2d_b<unsigned> out (ima.domain ());
+ point2d p = make::point2d(4,4);
+
+ chamfer (ima, c4(), p, 255, out);
+ debug::println (out);
+ }
+
+
+
+ {
+ image2d_b<int_u8> ima (1000, 1000);
+ image2d_b<unsigned> out (ima.domain ());
+ point2d p = make::point2d(4,4);
+
+ chamfer (ima, c4(), p, 255, out);
+ }
+ // debug::println (out);
+}
Index: trunk/milena/sandbox/duhamel/labeling_level_fast.cc
===================================================================
--- trunk/milena/sandbox/duhamel/labeling_level_fast.cc (revision 1240)
+++ trunk/milena/sandbox/duhamel/labeling_level_fast.cc (revision 1241)
@@ -40,11 +40,7 @@
#include <mln/io/pgm/save.hh>
#include <mln/labeling/level.hh>
#include <mln/debug/iota.hh>
-#include <mln/debug/println_with_border.hh>
-
-#include "paste.hh"
-#include "fill.hh"
-
+#include <mln/debug/println.hh>
int main()
{
@@ -56,12 +52,11 @@
image2d_b<value::int_u8> i1(5, 5, border);
debug::iota(i1);
i1[10] = i1[17] = i1[18] = i1[25] = i1[26] = i1[22] = i1[29] = 2;
- // i1[5] = i1[6] = 2;
- debug::println_with_border(i1);
+ debug::println(i1);
unsigned n;
image2d_b<value::int_u8> out(i1.domain(), border);
- labeling_level_fast(i1, 2, c4(), out, n);
+ labeling::level_fast(i1, 2, c4(), out, n);
std::cout << "n = " << n << std::endl;
debug::println(out);
Index: trunk/milena/sandbox/duhamel/color_sub.hh
===================================================================
--- trunk/milena/sandbox/duhamel/color_sub.hh (revision 0)
+++ trunk/milena/sandbox/duhamel/color_sub.hh (revision 1241)
@@ -0,0 +1,60 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/sub_image.hh
+ *
+ * \brief .
+ */
+
+#include <mln/core/image_if_value.hh>
+#include <mln/core/image2d_b.hh>
+#include <mln/value/rgb8.hh>
+#include <mln/level/fill.hh>
+
+namespace mln
+{
+ template <typename I, typename J>
+ void
+ color (Image<I>& ima_ , Image<J>& out_)
+ {
+ I& ima = exact (ima_);
+ J& out = exact (out_);
+ // image2d_b<value::rgb8> out(ima.domain ().bbox ());
+
+ level::fill (out, value::rgb8(255, 0, 0));
+
+ {
+ mln_piter(I) p (ima.domain ());
+
+ for_all (p)
+ {
+ out(p) = value::rgb8(ima(p));
+ }
+ }
+ // return out;
+ }
+}
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-10-04 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
Update doc of accus. Update Accumulator.
* mln/core/concept/accumulator.hh: Test if the convertion operator
exist.
* mln/core/concept/doc/accumulator.hh: Add operator result().
---
accumulator.hh | 3 +++
doc/accumulator.hh | 7 +++++++
2 files changed, 10 insertions(+)
Index: trunk/milena/mln/core/concept/doc/accumulator.hh
===================================================================
--- trunk/milena/mln/core/concept/doc/accumulator.hh (revision 1239)
+++ trunk/milena/mln/core/concept/doc/accumulator.hh (revision 1240)
@@ -44,6 +44,9 @@
/// The value type of elements to accumulate.
typedef void value;
+ /// The value type to return.
+ typedef void result_;
+
/// Initialize the accumulator.
void init();
@@ -52,6 +55,10 @@
/// Take into account another accumulator \p other.
void take(const E& other);
+
+ /// Convert the accumulator into the result.
+ operator result_() const;
+
};
} // end of namespace mln::doc
Index: trunk/milena/mln/core/concept/accumulator.hh
===================================================================
--- trunk/milena/mln/core/concept/accumulator.hh (revision 1239)
+++ trunk/milena/mln/core/concept/accumulator.hh (revision 1240)
@@ -71,6 +71,7 @@
void take(const value& v);
void take(const E& other);
result to_result() const;
+ operator result_() const;
*/
// Default impl.
@@ -99,6 +100,8 @@
m3 = 0;
result (E::*m4)() const = & E::to_result;
m4 = 0;
+ result (E::*m5)() const = & E::operator result;
+ m5 = 0;
}
template <typename E>
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-10-04 Simon Nivault <simon.nivault(a)lrde.epita.fr>
Add best canvas and make median_dir use it.
* mln/canvas/browsing/dir_ricard51.hh: New canvas.
* mln/canvas/browsing/directional.hh: Fix some names.
* mln/level/median.hh: Use new canvas.
* tests/level_median_dir.cc: New.
---
mln/canvas/browsing/dir_ricard51.hh | 173 ++++++++++++++++++++++++++++++++++++
mln/canvas/browsing/directional.hh | 8 -
mln/level/median.hh | 63 +++----------
tests/level_median_dir.cc | 55 +++++++++++
4 files changed, 248 insertions(+), 51 deletions(-)
Index: trunk/milena/tests/level_median_dir.cc
===================================================================
--- trunk/milena/tests/level_median_dir.cc (revision 0)
+++ trunk/milena/tests/level_median_dir.cc (revision 1239)
@@ -0,0 +1,55 @@
+// 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/level_median.cc
+ *
+ * \brief Test on mln::level::median.
+ */
+
+#include <mln/core/image2d_b.hh>
+
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+
+#include <mln/value/int_u8.hh>
+#include <mln/level/median.hh>
+
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+
+ border::thickness = 7;
+
+ image2d_b<int_u8>
+ lena = io::pgm::load("../img/lena.pgm"),
+ out(lena.domain());
+
+ level::median_dir(lena, 1, 15, out);
+ io::pgm::save(out, "out.pgm");
+}
Index: trunk/milena/mln/level/median.hh
===================================================================
--- trunk/milena/mln/level/median.hh (revision 1238)
+++ trunk/milena/mln/level/median.hh (revision 1239)
@@ -41,7 +41,7 @@
# include <mln/set/diff.hh>
# include <mln/canvas/browsing/snake_fwd.hh>
-# include <mln/canvas/browsing/directional.hh>
+# include <mln/canvas/browsing/dir_ricard51.hh>
# include <mln/accu/median.hh>
@@ -190,11 +190,6 @@
// aux data
mln_point(I) p;
- const mln_point(I)
- pmin, pmax;
- const mln_coord(I)
- pmin_dir, pmax_dir,
- pmin_dir_plus, pmax_dir_minus;
accu::median<mln_vset(I)> med;
// ctor
@@ -206,12 +201,6 @@
output(exact(output)),
// aux data
p(),
- pmin(input.domain().pmin()),
- pmax(input.domain().pmax()),
- pmin_dir(pmin[dir]),
- pmax_dir(pmax[dir]),
- pmin_dir_plus (pmin[dir] + length / 2),
- pmax_dir_minus(pmax[dir] - length / 2),
med(input.values())
{
}
@@ -220,55 +209,26 @@
{
}
- void next()
+ void init_line()
{
- mln_point(I)
- p = this->p,
- pt = p,
- pu = p;
-
- typedef mln_coord(I)& coord_ref;
- coord_ref
- ct = pt[dir],
- cu = pu[dir],
- p_dir = p[dir];
-
- // initialization (before first point of the row)
med.init();
- for (ct = pmin_dir; ct < pmin_dir_plus; ++ct)
- if (input.has(pt))
- med.take(input(pt));
+ }
- // left columns (just take new points)
- for (p_dir = pmin_dir; p_dir <= pmin_dir_plus; ++p_dir, ++ct)
+ void add_point(mln_point(I) pt)
{
- if (input.has(pt))
med.take(input(pt));
- if (output.has(p))
- output(p) = med.to_result();
}
- // middle columns (both take and untake)
- cu = pmin[dir];
- for (; p_dir <= pmax_dir_minus; ++cu, ++p_dir, ++ct)
+ void remove_point(mln_point(I) pu)
{
- if (input.has(pt))
- med.take(input(pt));
- if (input.has(pu))
med.untake(input(pu));
- if (output.has(p))
- output(p) = med.to_result();
}
- // right columns (now just untake old points)
- for (; p_dir <= pmax_dir; ++cu, ++p_dir)
+ void next()
{
- if (input.has(pu))
- med.untake(input(pu));
if (output.has(p))
output(p) = med.to_result();
}
- }
void final()
{
@@ -282,7 +242,7 @@
void median_dir_(const Image<I>& input, unsigned dir, unsigned length, O& output)
{
median_dir_t<I,O> f(exact(input), dir, length, output);
- canvas::browsing::directional(f);
+ canvas::browsing::dir_ricard51(f);
}
@@ -330,11 +290,20 @@
void median_dir(const Image<I>& input, unsigned dir, unsigned length,
Image<O>& output)
{
+ trace::entering("level::median_dir");
+
+ mlc_is(mln_trait_image_io(O), trait::io::write)::check();
+ mlc_is(mln_trait_image_support(I), trait::support::aligned)::check();
+ mlc_converts_to(mln_value(I), mln_value(O))::check();
+
mln_precondition(exact(output).domain() == exact(input).domain());
typedef mln_point(I) P;
mln_precondition(dir < P::dim);
mln_precondition(length % 2 == 1);
+
impl::median_dir_(exact(input), dir, length, exact(output));
+
+ trace::exiting("level::median_dir");
}
# endif // ! MLN_INCLUDE_ONLY
Index: trunk/milena/mln/canvas/browsing/dir_ricard51.hh
===================================================================
--- trunk/milena/mln/canvas/browsing/dir_ricard51.hh (revision 0)
+++ trunk/milena/mln/canvas/browsing/dir_ricard51.hh (revision 1239)
@@ -0,0 +1,173 @@
+// 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_CANVAS_DIR_RICARD51_HH
+# define MLN_CANVAS_DIR_RICARD51_HH
+
+/*! \file mln/canvas/dir_ricard51.hh
+ *
+ * \brief Dir_Ricard51 browsing of an image.
+ */
+
+# include <mln/core/concept/browsing.hh>
+# include <mln/core/concept/image.hh>
+
+namespace mln
+{
+
+ namespace canvas
+ {
+
+ namespace browsing
+ {
+
+ /*! FIXME : DOC
+ * F shall features : \n
+ * { \n
+ * --- as types: \n
+ * I; \n
+ * --- as attributes: \n
+ * dim; \n
+ * dir; // and test dir < dim \n
+ * input; \n
+ * p; \n
+ * length; \n
+ * --- as methods: \n
+ * void init(); \n
+ * void init_line(); \n
+ * void add_point(p) \n
+ * void remove_point(p) \n
+ * void next(); \n
+ * void final(); \n
+ * } \n
+ *
+ */
+ struct dir_ricard51_t : public Browsing< dir_ricard51_t >
+ {
+ template <typename F>
+ void operator()(F& f) const;
+ }
+
+ dir_ricard51;
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename F>
+ void
+ dir_ricard51_t::operator()(F& f) const
+ {
+ mln_precondition(f.dir < f.dim);
+ typedef typename F::I I;
+
+ const mln_point(I)
+ pmin = f.input.domain().pmin(),
+ pmax = f.input.domain().pmax();
+
+ const mln_coord(I)
+ pmin_dir = pmin[f.dir],
+ pmax_dir = pmax[f.dir],
+ pmin_dir_plus_half_length = pmin_dir + f.length / 2,
+ pmax_dir_minus_half_length = pmax_dir - f.length / 2;
+
+ mln_point(I) pt, pu;
+
+ typedef mln_coord(I)& coord_ref;
+ coord_ref
+ ct = pt[f.dir],
+ cu = pu[f.dir],
+ p_dir = f.p[f.dir];
+
+ f.p = pmin;
+
+ f.init();
+
+ do
+ {
+ pt = f.p;
+ pu = f.p;
+
+ f.init_line();
+
+ // initialization (before first point of the line)
+ for (ct = pmin_dir; ct < pmin_dir_plus_half_length; ++ ct)
+ if (f.input.has(pt))
+ f.add_point(pt);
+
+ // left columns (just take new points)
+ for (p_dir = pmin_dir; p_dir <= pmin_dir_plus_half_length; ++p_dir, ++ct)
+ {
+ if (f.input.has(pt))
+ f.add_point(pt);
+ f.next();
+ }
+
+ // middle columns (both take and untake)
+ cu = pmin_dir;
+ for (; p_dir <= pmax_dir_minus_half_length; ++cu, ++p_dir, ++ct)
+ {
+ if (f.input.has(pt))
+ f.add_point(pt);
+ if (f.input.has(pu))
+ f.remove_point(pu);
+ f.next();
+ }
+
+ // right columns (now just untake old points)
+ for (; p_dir <= pmax_dir; ++cu, ++p_dir)
+ {
+ if (f.input.has(pu))
+ f.remove_point(pu);
+ f.next();
+ }
+
+ p_dir = pmin_dir;
+
+ for (int c = F::dim - 1; c >= 0; --c)
+ {
+ if (c == int(f.dir))
+ continue;
+ if (f.p[c] != pmax[c])
+ {
+ ++f.p[c];
+ break;
+ }
+ f.p[c] = pmin[c];
+ }
+ } while (f.p != pmin);
+
+ f.final();
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::canvas::browsing
+
+ } // end of namespace mln::canvas
+
+} // end of namespace mln
+
+#endif // ! MLN_CANVAS_DIR_RICARD51_HH
Index: trunk/milena/mln/canvas/browsing/directional.hh
===================================================================
--- trunk/milena/mln/canvas/browsing/directional.hh (revision 1238)
+++ trunk/milena/mln/canvas/browsing/directional.hh (revision 1239)
@@ -25,10 +25,10 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_CANVAS_DIRBROWSING_HH
-# define MLN_CANVAS_DIRBROWSING_HH
+#ifndef MLN_CANVAS_DIRECTIONAL_HH
+# define MLN_CANVAS_DIRECTIONAL_HH
-/*! \file mln/canvas/dirbrowsing.hh
+/*! \file mln/canvas/browsing/directional.hh
*
* \brief Directional browsing of an image.
*/
@@ -115,4 +115,4 @@
} // end of namespace mln
-#endif // ! MLN_CANVAS_DIRBROWSING_HH
+#endif // ! MLN_CANVAS_DIRECTIONAL_HH
1
0