https://svn.lrde.epita.fr/svn/oln/trunk
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Change oln_ into mln_.
* milena/morpho/erosion.hh: New.
* milena/io: New.
* milena/value/props.hh: New.
* milena/border: New.
* milena/test/main.cc,
* milena/debug/println.hh,
* milena/level/fill.hh,
* milena/core/dpoints_qiter.hh,
* milena/core/macros.hh,
* milena/core/box_piter.hh,
* milena/core/concept/image.hh,
* milena/core/concept/genpoint.hh,
* milena/core/concept/piter.hh,
* milena/core/concept/point_set.hh,
* milena/core/concept/window.hh,
* milena/core/concept/box.hh,
* milena/core/concept/point.hh,
* milena/core/concept/dpoint.hh,
* milena/core/internal/image_adaptor.hh,
* milena/core/internal/image_base.hh,
* milena/core/safe_image.hh,
* milena/mlc/same_point.hh: Change oln_ into mln_.
core/box_piter.hh | 6 +--
core/concept/box.hh | 2 -
core/concept/dpoint.hh | 4 +-
core/concept/genpoint.hh | 22 ++++++-------
core/concept/image.hh | 20 +++++------
core/concept/piter.hh | 4 +-
core/concept/point.hh | 8 ++--
core/concept/point_set.hh | 10 ++---
core/concept/window.hh | 6 +--
core/dpoints_qiter.hh | 10 ++---
core/internal/image_adaptor.hh | 18 +++++-----
core/internal/image_base.hh | 10 ++---
core/macros.hh | 44 +++++++++++++-------------
core/safe_image.hh | 16 ++++-----
debug/println.hh | 6 +--
level/fill.hh | 6 +--
mlc/same_point.hh | 2 -
morpho/erosion.hh | 69 +++++++++++++++++++++++++++++++++++++++++
test/main.cc | 3 +
value/props.hh | 47 +++++++++++++++++++++++++++
20 files changed, 216 insertions(+), 97 deletions(-)
Index: milena/test/main.cc
--- milena/test/main.cc (revision 983)
+++ milena/test/main.cc (working copy)
@@ -5,6 +5,8 @@
#include <core/window2d.hh>
#include <core/rectangle2d.hh>
+#include <morpho/erosion.hh>
+
int main()
{
@@ -26,6 +28,7 @@
std::cout << win << std::endl;
debug::println(ima, win);
+ morpho::erosion(ima, win);
rectangle2d rec(1, 2);
std::cout << rec << std::endl;
Index: milena/morpho/erosion.hh
--- milena/morpho/erosion.hh (revision 0)
+++ milena/morpho/erosion.hh (revision 0)
@@ -0,0 +1,69 @@
+#ifndef MLN_MORPHO_EROSION_HH
+# define MLN_MORPHO_EROSION_HH
+
+# include <core/concept/image.hh>
+# include <core/concept/window.hh>
+// FIXME: # include <border/assign.hh>
+# include <value/props.hh>
+
+
+namespace mln
+{
+
+ namespace morpho
+ {
+
+ template <typename I, typename W>
+ I erosion(const Image<I>& input, const Window<W>& win);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace impl
+ {
+
+ template <typename I, typename W>
+ I erosion(const Image<I>& input_, const Window<W>& win_)
+ {
+ const I& input = exact(input_);
+ const W& win = exact(win_);
+
+ typedef mln_value(I) value;
+
+ I output(input.domain());
+ mln_piter(I) p(input.domain());
+ mln_qiter(W) q(win, p);
+ for_all(p)
+ {
+ value v = mln_max(value);
+ for_all(q) if (input.owns_(q))
+ {
+ if (input(q) < v)
+ v = input(q);
+ }
+ output(p) = v;
+ }
+ return output;
+ }
+
+ // ...
+
+ } // end of namespace mln::morpho::impl
+
+
+ // facade
+
+ template <typename I, typename W>
+ I erosion(const Image<I>& input, const Window<W>& win)
+ {
+ return impl::erosion(exact(input), exact(win));
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::morpho
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MORPHO_EROSION_HH
Index: milena/debug/println.hh
--- milena/debug/println.hh (revision 983)
+++ milena/debug/println.hh (working copy)
@@ -25,7 +25,7 @@
void println(const Image<I>& input_)
{
const I& input = exact(input_);
- oln_piter(I) p(input.domain());
+ mln_piter(I) p(input.domain());
for_all(p)
std::cout << input(p) << ' ';
std::cout << std::endl;
@@ -39,8 +39,8 @@
const I& input = exact(input_);
const W& win = exact(win_);
- oln_piter(I) p(input.domain());
- oln_qiter(W) q(win, p);
+ mln_piter(I) p(input.domain());
+ mln_qiter(W) q(win, p);
for_all(p)
{
std::cout << input(p) << ':';
Index: milena/level/fill.hh
--- milena/level/fill.hh (revision 983)
+++ milena/level/fill.hh (working copy)
@@ -11,16 +11,16 @@
{
template <typename I>
- void fill(Image<I>& ima_, const oln_value(I)& value);
+ void fill(Image<I>& ima_, const mln_value(I)& value);
# ifndef MLN_INCLUDE_ONLY
template <typename I>
- void fill(Image<I>& ima_, const oln_value(I)& value)
+ void fill(Image<I>& ima_, const mln_value(I)& value)
{
I& ima = exact(ima_);
- oln_piter(I) p(ima.domain());
+ mln_piter(I) p(ima.domain());
for_all(p)
ima(p) = value;
}
Index: milena/core/dpoints_qiter.hh
--- milena/core/dpoints_qiter.hh (revision 983)
+++ milena/core/dpoints_qiter.hh (working copy)
@@ -16,9 +16,9 @@
enum { dim = D::dim };
typedef D dpoint;
- typedef oln_point(D) point;
+ typedef mln_point(D) point;
typedef point psite;
- typedef oln_coord(D) coord;
+ typedef mln_coord(D) coord;
template <typename Dps, typename Pref>
dpoints_fwd_qiter(const Dps& dps,
@@ -57,14 +57,14 @@
}
template <typename D>
- dpoints_fwd_qiter<D>::operator point() const
+ dpoints_fwd_qiter<D>::operator mln_point(D)() const
{
assert(is_valid());
return p_;
}
template <typename D>
- const oln_point(D)*
+ const mln_point(D)*
dpoints_fwd_qiter<D>::pointer() const
{
return & p_;
@@ -109,7 +109,7 @@
}
template <typename D>
- oln_coord(D)
+ mln_coord(D)
dpoints_fwd_qiter<D>::operator[](unsigned i) const
{
return p_[i];
Index: milena/core/macros.hh
--- milena/core/macros.hh (revision 983)
+++ milena/core/macros.hh (working copy)
@@ -2,27 +2,27 @@
# define MLN_CORE_MACROS_HH
-# define oln_point(T) typename T::point
-# define oln_dpoint(T) typename T::dpoint
-# define oln_psite(T) typename T::psite
-# define oln_pset(T) typename T::pset
-# define oln_box(T) typename T::box
-# define oln_coord(T) typename T::coord
-
-# define oln_piter(T) typename T::piter
-# define oln_fwd_piter(T) typename T::fwd_piter
-# define oln_bkd_piter(T) typename T::bkd_piter
-
-# define oln_qiter(T) typename T::qiter
-# define oln_fwd_qiter(T) typename T::fwd_qiter
-# define oln_bkd_qiter(T) typename T::bkd_qiter
-
-# define oln_niter(T) typename T::niter
-# define oln_fwd_niter(T) typename T::fwd_niter
-# define oln_bkd_niter(T) typename T::bkd_niter
-
-# define oln_value(T) typename T::value
-# define oln_rvalue(T) typename T::rvalue
-# define oln_lvalue(T) typename T::lvalue
+# define mln_point(T) typename T::point
+# define mln_dpoint(T) typename T::dpoint
+# define mln_psite(T) typename T::psite
+# define mln_pset(T) typename T::pset
+# define mln_box(T) typename T::box
+# define mln_coord(T) typename T::coord
+
+# define mln_piter(T) typename T::piter
+# define mln_fwd_piter(T) typename T::fwd_piter
+# define mln_bkd_piter(T) typename T::bkd_piter
+
+# define mln_qiter(T) typename T::qiter
+# define mln_fwd_qiter(T) typename T::fwd_qiter
+# define mln_bkd_qiter(T) typename T::bkd_qiter
+
+# define mln_niter(T) typename T::niter
+# define mln_fwd_niter(T) typename T::fwd_niter
+# define mln_bkd_niter(T) typename T::bkd_niter
+
+# define mln_value(T) typename T::value
+# define mln_rvalue(T) typename T::rvalue
+# define mln_lvalue(T) typename T::lvalue
#endif // ! MLN_CORE_MACROS_HH
Index: milena/core/box_piter.hh
--- milena/core/box_piter.hh (revision 983)
+++ milena/core/box_piter.hh (working copy)
@@ -17,8 +17,8 @@
typedef P psite;
typedef P point;
- typedef oln_coord(P) coord;
- typedef oln_dpoint(P) dpoint;
+ typedef mln_coord(P) coord;
+ typedef mln_dpoint(P) dpoint;
box_fwd_piter_(const box_<P>& b)
: b_(b)
@@ -89,7 +89,7 @@
typedef P psite;
typedef P point;
- typedef oln_coord(P) coord;
+ typedef mln_coord(P) coord;
box_bkd_piter_(const box_<P>& b)
: b_(b)
Index: milena/core/concept/image.hh
--- milena/core/concept/image.hh (revision 983)
+++ milena/core/concept/image.hh (working copy)
@@ -52,13 +52,13 @@
{
// provided by internal::image_base_:
- typedef oln_pset(E) pset;
- typedef oln_point(E) point;
- typedef oln_psite(E) psite;
-
- typedef oln_piter(E) piter;
- typedef oln_fwd_piter(E) fwd_piter;
- typedef oln_bkd_piter(E) bkd_piter;
+ typedef mln_pset(E) pset;
+ typedef mln_point(E) point;
+ typedef mln_psite(E) psite;
+
+ typedef mln_piter(E) piter;
+ typedef mln_fwd_piter(E) fwd_piter;
+ typedef mln_bkd_piter(E) bkd_piter;
bool (E::*m1)(const psite& p) const = & E::has;
m1 = 0;
@@ -67,9 +67,9 @@
// to be provided in concrete image classes:
- typedef oln_value(E) value;
- typedef oln_rvalue(E) rvalue;
- typedef oln_lvalue(E) lvalue;
+ typedef mln_value(E) value;
+ typedef mln_rvalue(E) rvalue;
+ typedef mln_lvalue(E) lvalue;
bool (E::*m3)() const = & E::has_data;
m3 = 0;
Index: milena/core/concept/genpoint.hh
--- milena/core/concept/genpoint.hh (revision 983)
+++ milena/core/concept/genpoint.hh (working copy)
@@ -38,12 +38,12 @@
bool operator<(const GenPoint<Pl>& lhs, const GenPoint<Pr>&
rhs);
template <typename Pl, typename Pr>
- oln_dpoint(Pl)
+ mln_dpoint(Pl)
operator-(const GenPoint<Pl>& lhs, const GenPoint<Pr>& rhs);
template <typename P>
- oln_point(P)
- operator+(const GenPoint<P>& lhs, const oln_dpoint(P)& rhs);
+ mln_point(P)
+ operator+(const GenPoint<P>& lhs, const mln_dpoint(P)& rhs);
template <typename P>
std::ostream& operator<<(std::ostream& ostr, const GenPoint<P>&
p);
@@ -54,9 +54,9 @@
template <typename E>
GenPoint<E>::GenPoint()
{
- typedef oln_point(E) point;
- typedef oln_dpoint(E) dpoint;
- typedef oln_coord(E) coord;
+ typedef mln_point(E) point;
+ typedef mln_dpoint(E) dpoint;
+ typedef mln_coord(E) coord;
const point* (E::*m1)() const = & E::pointer;
m1 = 0;
coord (E::*m2)(unsigned i) const = & E::operator[];
@@ -92,12 +92,12 @@
template <typename Pl, typename Pr>
- oln_dpoint(Pl)
+ mln_dpoint(Pl)
operator-(const GenPoint<Pl>& lhs, const GenPoint<Pr>& rhs)
{
const Pl& lhs_ = force_exact<Pl>(lhs);
const Pr& rhs_ = force_exact<Pr>(rhs);
- oln_dpoint(Pl) tmp;
+ mln_dpoint(Pl) tmp;
for (unsigned i = 0; i < Pl::dim; ++i)
tmp[i] = lhs_[i] - rhs_[i];
return tmp;
@@ -105,11 +105,11 @@
template <typename P>
- oln_point(P)
- operator+(const GenPoint<P>& lhs, const oln_dpoint(P)& rhs)
+ mln_point(P)
+ operator+(const GenPoint<P>& lhs, const mln_dpoint(P)& rhs)
{
const P& lhs_ = force_exact<P>(lhs);
- oln_point(P) tmp;
+ mln_point(P) tmp;
for (unsigned i = 0; i < P::dim; ++i)
tmp[i] = lhs_[i] + rhs[i];
return tmp;
Index: milena/core/concept/piter.hh
--- milena/core/concept/piter.hh (revision 983)
+++ milena/core/concept/piter.hh (working copy)
@@ -31,8 +31,8 @@
template <typename E>
Piter<E>::Piter()
{
- typedef oln_psite(E) psite;
- typedef oln_point(E) point;
+ typedef mln_psite(E) psite;
+ typedef mln_point(E) point;
const point* (E::*m)() const = & E::pointer;
m = 0;
}
Index: milena/core/concept/point_set.hh
--- milena/core/concept/point_set.hh (revision 983)
+++ milena/core/concept/point_set.hh (working copy)
@@ -35,11 +35,11 @@
template <typename E>
Point_Set<E>::Point_Set()
{
- typedef oln_point(E) point;
- typedef oln_psite(E) psite;
- typedef oln_piter(E) piter;
- typedef oln_fwd_piter(E) fwd_piter;
- typedef oln_bkd_piter(E) bkd_piter;
+ typedef mln_point(E) point;
+ typedef mln_psite(E) psite;
+ typedef mln_piter(E) piter;
+ typedef mln_fwd_piter(E) fwd_piter;
+ typedef mln_bkd_piter(E) bkd_piter;
bool (E::*m1)(const psite& p) const = & E::has;
m1 = 0;
Index: milena/core/concept/window.hh
--- milena/core/concept/window.hh (revision 983)
+++ milena/core/concept/window.hh (working copy)
@@ -30,9 +30,9 @@
template <typename E>
Window<E>::Window()
{
- typedef oln_qiter(E) qiter;
- typedef oln_fwd_qiter(E) fwd_qiter;
- typedef oln_bkd_qiter(E) bkd_qiter;
+ typedef mln_qiter(E) qiter;
+ typedef mln_fwd_qiter(E) fwd_qiter;
+ typedef mln_bkd_qiter(E) bkd_qiter;
bool (E::*m1)() const = & E::is_empty;
m1 = 0;
Index: milena/core/concept/box.hh
--- milena/core/concept/box.hh (revision 983)
+++ milena/core/concept/box.hh (working copy)
@@ -33,7 +33,7 @@
template <typename E>
Box<E>::Box()
{
- typedef oln_point(E) point;
+ typedef mln_point(E) point;
point (E::*m1)() const = & E::pmin;
m1 = 0;
point (E::*m2)() const = & E::pmax;
Index: milena/core/concept/point.hh
--- milena/core/concept/point.hh (revision 983)
+++ milena/core/concept/point.hh (working copy)
@@ -20,10 +20,10 @@
template <typename P>
- P& operator+=(Point<P>& lhs, const oln_dpoint(P)& rhs);
+ P& operator+=(Point<P>& lhs, const mln_dpoint(P)& rhs);
template <typename P>
- P& operator-=(Point<P>& lhs, const oln_dpoint(P)& rhs);
+ P& operator-=(Point<P>& lhs, const mln_dpoint(P)& rhs);
@@ -41,7 +41,7 @@
}
template <typename P>
- P& operator+=(Point<P>& lhs, const oln_dpoint(P)& rhs)
+ P& operator+=(Point<P>& lhs, const mln_dpoint(P)& rhs)
{
for (unsigned i = 0; i < P::dim; ++i)
exact(lhs)[i] += rhs[i];
@@ -49,7 +49,7 @@
}
template <typename P>
- P& operator-=(Point<P>& lhs, const oln_dpoint(P)& rhs)
+ P& operator-=(Point<P>& lhs, const mln_dpoint(P)& rhs)
{
for (unsigned i = 0; i < P::dim; ++i)
exact(lhs)[i] -= rhs[i];
Index: milena/core/concept/dpoint.hh
--- milena/core/concept/dpoint.hh (revision 983)
+++ milena/core/concept/dpoint.hh (working copy)
@@ -42,8 +42,8 @@
template <typename E>
Dpoint<E>::Dpoint()
{
- typedef oln_point(E) point;
- typedef oln_coord(E) coord;
+ typedef mln_point(E) point;
+ typedef mln_coord(E) coord;
enum { dim = E::dim };
coord (E::*m)(unsigned i) const = & E::operator[];
m = 0;
Index: milena/core/internal/image_adaptor.hh
--- milena/core/internal/image_adaptor.hh (revision 983)
+++ milena/core/internal/image_adaptor.hh (working copy)
@@ -11,14 +11,14 @@
{
template <typename I, typename E>
- struct image_adaptor_ : public internal::image_base_< oln_pset(I), E >
+ struct image_adaptor_ : public internal::image_base_< mln_pset(I), E >
{
- typedef oln_psite(I) psite;
- typedef oln_pset(I) pset;
+ typedef mln_psite(I) psite;
+ typedef mln_pset(I) pset;
- typedef oln_value(I) value;
- typedef oln_rvalue(I) rvalue;
- typedef oln_lvalue(I) lvalue;
+ typedef mln_value(I) value;
+ typedef mln_rvalue(I) rvalue;
+ typedef mln_lvalue(I) lvalue;
bool has_data() const;
@@ -51,21 +51,21 @@
}
template <typename I, typename E>
- const oln_pset(I)&
+ const mln_pset(I)&
image_adaptor_<I,E>::domain() const
{
return adaptee_.domain();
}
template <typename I, typename E>
- oln_rvalue(I)
+ mln_rvalue(I)
image_adaptor_<I,E>::operator()(const psite& p) const
{
return adaptee_(p);
}
template <typename I, typename E>
- oln_lvalue(I)
+ mln_lvalue(I)
image_adaptor_<I,E>::operator()(const psite& p)
{
return adaptee_(p);
Index: milena/core/internal/image_base.hh
--- milena/core/internal/image_base.hh (revision 983)
+++ milena/core/internal/image_base.hh (working copy)
@@ -14,11 +14,11 @@
struct image_base_ : public Image<E>
{
typedef S pset;
- typedef oln_psite(S) psite;
- typedef oln_point(S) point;
+ typedef mln_psite(S) psite;
+ typedef mln_point(S) point;
- typedef oln_fwd_piter(S) fwd_piter;
- typedef oln_bkd_piter(S) bkd_piter;
+ typedef mln_fwd_piter(S) fwd_piter;
+ typedef mln_bkd_piter(S) bkd_piter;
typedef fwd_piter piter;
bool has(const psite& p) const;
@@ -47,7 +47,7 @@
}
template <typename S, typename E>
- const box_<oln_point(S)>&
+ const box_<mln_point(S)>&
image_base_<S,E>::bbox() const
{
return exact(this)->domain().bbox();
Index: milena/core/safe_image.hh
--- milena/core/safe_image.hh (revision 983)
+++ milena/core/safe_image.hh (working copy)
@@ -15,8 +15,8 @@
safe_image(Image<I>& ima);
- oln_rvalue(I) operator()(const oln_psite(I)& p) const;
- oln_lvalue(I) operator()(const oln_psite(I)& p);
+ mln_rvalue(I) operator()(const mln_psite(I)& p) const;
+ mln_lvalue(I) operator()(const mln_psite(I)& p);
};
@@ -36,20 +36,20 @@
}
template <typename I>
- oln_rvalue(I)
- safe_image<I>::operator()(const oln_psite(I)& p) const
+ mln_rvalue(I)
+ safe_image<I>::operator()(const mln_psite(I)& p) const
{
- static oln_value(I) tmp;
+ static mln_value(I) tmp;
if (not this->owns_(p))
return tmp;
return this->adaptee_(p);
}
template <typename I>
- oln_lvalue(I)
- safe_image<I>::operator()(const oln_psite(I)& p)
+ mln_lvalue(I)
+ safe_image<I>::operator()(const mln_psite(I)& p)
{
- static oln_value(I) tmp;
+ static mln_value(I) tmp;
if (not this->owns_(p))
return tmp;
return this->adaptee_(p);
Index: milena/mlc/same_point.hh
--- milena/mlc/same_point.hh (revision 983)
+++ milena/mlc/same_point.hh (working copy)
@@ -12,7 +12,7 @@
{
template <typename T1, typename T2>
- struct same_point : mlc::equal<oln_point(T2), oln_point(T2)>
+ struct same_point : mlc::equal<mln_point(T2), mln_point(T2)>
{
};
Index: milena/value/props.hh
--- milena/value/props.hh (revision 0)
+++ milena/value/props.hh (revision 0)
@@ -0,0 +1,47 @@
+#ifndef MLN_VALUE_PROPS_HH
+# define MLN_VALUE_PROPS_HH
+
+# include <limits>
+
+# define mln_min(T) mln::value::props<T>::min()
+# define mln_max(T) mln::value::props<T>::max()
+
+
+namespace mln
+{
+
+ namespace value
+ {
+
+ template <typename T>
+ struct props
+ {
+ static T min();
+ static T max();
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <>
+ struct props<unsigned char>
+ {
+ static unsigned char min() { return 0; }
+ static unsigned char max() { return 255; }
+ };
+
+ template <>
+ struct props<int>
+ {
+ static int min() { return std::numeric_limits<int>::min(); }
+ static int max() { return std::numeric_limits<int>::max(); }
+ };
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::value
+
+} // end of namespace mln
+
+
+#endif // ! MLN_VALUE_PROPS_HH