Commit d7cfbdbf authored by Thierry Geraud's avatar Thierry Geraud
Browse files

Renaming.

	* mln/core/fimage.hh,
	* tests/fimage.cc: Rename as...
	* mln/pw/image.hh,
	* tests/pw_image.cc: ...these.
	* mln/pw/all.hh,
	* mln/draw/line.hh,
	* tests/line2d.cc: Update.
	
	* mln/core/pqueue.hh,
	* mln/core/pvec.hh,
	* mln/core/pvec_piter.hh,
	* mln/core/pset.hh,
	* tests/pqueue.cc,
	* tests/pset.cc: Rename as...
	* mln/core/queue_p.hh,
	* mln/core/vec_p.hh,
	* mln/core/vec_p_piter.hh,
	* mln/core/set_p.hh,
	* tests/queue_p.cc,
	* tests/set_p.cc: ...these.
	* mln/core/line2d.hh: Update.
	
	* mln/core/psubset.hh,
	* mln/core/psubset_piter.hh,
	* mln/core/subimage.hh,
	* tests/psubset.cc,
	* tests/subimage.cc: Rename as...
	* mln/core/pset_if.hh,
	* mln/core/pset_if_piter.hh,
	* mln/core/image_if.hh,
	* tests/pset_if.cc,
	* tests/image_if.cc: ...these.
	* tests/to_image.cc: Update.

	* mln/accu/counter.hh: Rename as...
	* mln/accu/count.hh: ...this.
	* mln/accu/count.hh,
	* mln/accu/mean.hh,
	* mln/accu/sum.hh (operator+=): New.
	* mln/value/props.hh (mln_sum, sum): New.
	* mln/accu/mean.hh,
	* mln/accu/sum.hh,
	* mln/value/int_u.hh,
	* mln/value/int_s.hh: Update.
	* mln/level/apply.hh: Move accumulator version into...
	* mln/level/take.hh: ...this new file.
	* mln/level/run.hh: New.
	* mln/estim/mean.hh: Update.
	
	* mln/core/internal/set_of.hh (operator==): Remove;
	too error-prone.
	* mln/core/concept/window.hh (operator==): New.
	* tests/rectangle2d.cc: Fix.


git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@1048 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent 4059f50a
2007-08-27 Thierry Geraud <thierry.geraud@lrde.epita.fr>
Renaming.
* mln/core/fimage.hh,
* tests/fimage.cc: Rename as...
* mln/pw/image.hh,
* tests/pw_image.cc: ...these.
* mln/pw/all.hh,
* mln/draw/line.hh,
* tests/line2d.cc: Update.
* mln/core/pqueue.hh,
* mln/core/pvec.hh,
* mln/core/pvec_piter.hh,
* mln/core/pset.hh,
* tests/pqueue.cc,
* tests/pset.cc: Rename as...
* mln/core/queue_p.hh,
* mln/core/vec_p.hh,
* mln/core/vec_p_piter.hh,
* mln/core/set_p.hh,
* tests/queue_p.cc,
* tests/set_p.cc: ...these.
* mln/core/line2d.hh: Update.
* mln/core/psubset.hh,
* mln/core/psubset_piter.hh,
* mln/core/subimage.hh,
* tests/psubset.cc,
* tests/subimage.cc: Rename as...
* mln/core/pset_if.hh,
* mln/core/pset_if_piter.hh,
* mln/core/image_if.hh,
* tests/pset_if.cc,
* tests/image_if.cc: ...these.
* tests/to_image.cc: Update.
* mln/accu/counter.hh: Rename as...
* mln/accu/count.hh: ...this.
* mln/accu/count.hh,
* mln/accu/mean.hh,
* mln/accu/sum.hh (operator+=): New.
* mln/value/props.hh (mln_sum, sum): New.
* mln/accu/mean.hh,
* mln/accu/sum.hh,
* mln/value/int_u.hh,
* mln/value/int_s.hh: Update.
* mln/level/apply.hh: Move accumulator version into...
* mln/level/take.hh: ...this new file.
* mln/level/run.hh: New.
* mln/estim/mean.hh: Update.
* mln/core/internal/set_of.hh (operator==): Remove;
too error-prone.
* mln/core/concept/window.hh (operator==): New.
* tests/rectangle2d.cc: Fix.
2007-07-30 Nicolas Ballas <ballas@lrde.epita.fr>
Add RLE and Sparse image to milena.
......
......@@ -25,10 +25,10 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
#ifndef MLN_ACCU_COUNTER_HH
# define MLN_ACCU_COUNTER_HH
#ifndef MLN_ACCU_COUNT_HH
# define MLN_ACCU_COUNT_HH
/*! \file mln/accu/counter.hh
/*! \file mln/accu/count.hh
*
* \brief Define an accumulator that counts.
*/
......@@ -46,17 +46,19 @@ namespace mln
/*! Generic counter accumulator class.
*/
template <typename V>
struct counter : public Accumulator< counter<V> >
struct count : public Accumulator< count<V> >
{
typedef V value;
counter();
count();
void take(const value&);
void init();
operator std::size_t() const;
std::size_t to_value() const;
count<V>& operator+=(const count<V>& rhs);
protected:
std::size_t count_;
......@@ -67,38 +69,46 @@ namespace mln
# ifndef MLN_INCLUDE_ONLY
template <typename V>
counter<V>::counter()
count<V>::count()
{
init();
}
template <typename V>
void
counter<V>::take(const value&)
count<V>::take(const value&)
{
++count_;
}
template <typename V>
void
counter<V>::init()
count<V>::init()
{
count_ = 0;
}
template <typename V>
counter<V>::operator std::size_t() const
count<V>::operator std::size_t() const
{
return to_value();
}
template <typename V>
std::size_t
counter<V>::to_value() const
count<V>::to_value() const
{
return count_;
}
template <typename V>
count<V>&
count<V>::operator+=(const count<V>& rhs)
{
count_ += rhs.count_;
return *this;
}
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::accu
......@@ -106,4 +116,4 @@ namespace mln
} // end of namespace mln
#endif // ! MLN_ACCU_COUNTER_HH
#endif // ! MLN_ACCU_COUNT_HH
......@@ -33,7 +33,7 @@
* \brief Define an accumulator that computes a mean.
*/
# include <mln/accu/counter.hh>
# include <mln/accu/count.hh>
# include <mln/accu/sum.hh>
......@@ -48,10 +48,13 @@ namespace mln
*
* Parameter \c V 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 \c V. Parameter \c M is the type of the mean value;
* the default type of \c M is \c S.
* \c S is the summation type (property) of \c V. Parameter \c M
* is the type of the mean value; the default type of \c M is \c
* S.
*/
template <typename V, typename S = V, typename M = S>
template <typename V,
typename S = mln_sum(V),
typename M = S>
struct mean : public Accumulator< mean<V,S,M> >
{
typedef V value;
......@@ -62,10 +65,12 @@ namespace mln
operator M() const;
M to_value() const;
mean<V,S,M>& operator+=(const mean<V,S,M>& rhs);
protected:
accu::counter<V> count_;
accu::count<V> count_;
accu::sum<V,S> sum_;
};
......@@ -97,7 +102,7 @@ namespace mln
template <typename V, typename S, typename M>
mean<V,S,M>::operator M() const
{
return to_value;
return to_value();
}
template <typename V, typename S, typename M>
......@@ -107,6 +112,15 @@ namespace mln
return sum_.to_value() / count_.to_value();
}
template <typename V, typename S, typename M>
mean<V,S,M>&
mean<V,S,M>::operator+=(const mean<V,S,M>& rhs)
{
count_ += rhs.count_;
sum_ += rhs.sum_;
return *this;
}
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::accu
......
......@@ -34,6 +34,7 @@
*/
# include <mln/core/concept/accumulator.hh>
# include <mln/value/props.hh>
namespace mln
......@@ -46,10 +47,10 @@ namespace mln
/*! Generic sum accumulator class.
*
* Parameter \c V is the type of values that we sum. Parameter \c
* S is the type to store the sum value; the default type of
* \c S is \c V.
* S is the type to store the value sum; the default type of
* \c S is the summation type (property) of \c V.
*/
template <typename V, typename S = V>
template <typename V, typename S = mln_sum(V)>
struct sum : public Accumulator< sum<V,S> >
{
typedef V value;
......@@ -60,6 +61,8 @@ namespace mln
operator S() const;
S to_value() const;
sum<V,S>& operator+=(const sum<V,S>& rhs);
protected:
......@@ -99,7 +102,15 @@ namespace mln
S
sum<V,S>::to_value() const
{
return sum_ / count_;
return sum_;
}
template <typename V, typename S>
sum<V,S>&
sum<V,S>::operator+=(const sum<V,S>& rhs)
{
sum_ += rhs.sum_;
return *this;
}
# endif // ! MLN_INCLUDE_ONLY
......
......@@ -77,6 +77,14 @@ namespace mln
W operator-(const Window<W>& rhs);
/*! \brief Equality comparison between windows \p lhs and \p rhs.
*
* \relates mln::Window
*/
template <typename Wl, typename Wr>
bool operator==(const Window<Wl>& lhs, const Window<Wr>& rhs);
# ifndef MLN_INCLUDE_ONLY
template <typename E>
......@@ -107,6 +115,26 @@ namespace mln
return exact(rhs).sym_();
}
template <typename Wl, typename Wr>
bool operator==(const Window<Wl>& lhs, const Window<Wr>& rhs)
{
// FIXME: Same grid!
typedef mln_point(Wl) P;
mln_fwd_qiter(Wl) ql(exact(lhs), P::zero);
mln_fwd_qiter(Wr) qr(exact(rhs), P::zero);
for (ql.start(), qr.start();
ql.is_valid() && qr.is_valid();
ql.next(), qr.next())
if (ql != qr)
return false; // difference found
// both windows are equal only if both browsings are completed at
// the same time:
return ! ql.is_valid() && ! qr.is_valid();
}
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln
......
......@@ -25,16 +25,16 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
#ifndef MLN_CORE_SUBIMAGE_HH
# define MLN_CORE_SUBIMAGE_HH
#ifndef MLN_CORE_IMAGE_IF_HH
# define MLN_CORE_IMAGE_IF_HH
/*! \file mln/core/subimage.hh
/*! \file mln/core/image_if.hh
*
* \brief Definition of a base class for image adaptors.
*/
# include <mln/core/internal/image_adaptor.hh>
# include <mln/core/psubset.hh>
# include <mln/core/pset_if.hh>
namespace mln
......@@ -44,15 +44,15 @@ namespace mln
*
*/
template <typename I, typename F>
struct subimage : public internal::image_adaptor_< I,
subimage<I,F>,
psubset<mln_pset(I),F> >
struct image_if : public internal::image_adaptor_< I,
image_if<I,F>,
pset_if<mln_pset(I),F> >
{
/// Point_Set associated type.
typedef psubset<mln_pset(I), F> pset;
typedef pset_if<mln_pset(I), F> pset;
/// Constructor from an \p adaptee image.
subimage(I& adaptee, const F& f);
image_if(I& adaptee, const F& f);
/// Test if a pixel value is accessible at \p p.
bool owns_(const mln_psite(I)& p) const;
......@@ -63,7 +63,7 @@ namespace mln
template <typename T>
struct change_value
{
typedef subimage<mln_ch_value(I,T), F> ret;
typedef image_if<mln_ch_value(I,T), F> ret;
};
protected:
......@@ -71,17 +71,17 @@ namespace mln
pset pset_;
F f_;
typedef subimage<I,F> self_;
typedef image_if<I,F> self_;
typedef internal::image_adaptor_< I, self_, pset > super_;
};
template <typename I, typename F>
subimage<I, F>
image_if<I, F>
operator | (Image<I>& ima, const Function_p2b<F>& f)
{
subimage<I, F> tmp(exact(ima), exact(f));
image_if<I, F> tmp(exact(ima), exact(f));
return tmp;
}
......@@ -89,7 +89,7 @@ namespace mln
# ifndef MLN_INCLUDE_ONLY
template <typename I, typename F>
subimage<I,F>::subimage(I& adaptee, const F& f)
image_if<I,F>::image_if(I& adaptee, const F& f)
: super_(adaptee),
pset_(adaptee.domain() | f),
f_(f)
......@@ -98,14 +98,14 @@ namespace mln
template <typename I, typename F>
bool
subimage<I,F>::owns_(const mln_psite(I)& p) const
image_if<I,F>::owns_(const mln_psite(I)& p) const
{
return pset_.has(p);
}
template <typename I, typename F>
const psubset<mln_pset(I), F>&
subimage<I,F>::domain() const
const pset_if<mln_pset(I), F>&
image_if<I,F>::domain() const
{
return pset_;
}
......@@ -115,4 +115,4 @@ namespace mln
} // end of namespace mln
#endif // ! MLN_CORE_SUBIMAGE_HH
#endif // ! MLN_CORE_IMAGE_IF_HH
......@@ -173,16 +173,6 @@ namespace mln
std::ostream& operator<<(std::ostream& ostr, const set_of_<E>& s);
/*! \brief Test if both sets \p lhs and \p rhs are equal.
*
* \param[in] lhs A set.
* \param[in] rhs Another set.
*
* \relates mln::internal::set_of_
*/
template <typename E>
bool operator==(const set_of_<E>& lhs, const set_of_<E>& rhs);
# ifndef MLN_INCLUDE_ONLY
......@@ -279,18 +269,6 @@ namespace mln
return ostr;
}
template <typename E>
bool operator==(const set_of_<E>& lhs, const set_of_<E>& rhs)
{
if (lhs.nelements() != rhs.nelements())
return false;
const unsigned n = lhs.nelements();
for (unsigned i = 0; i < n; ++i)
if (rhs.element(i) != lhs.element(i))
return false;
return true;
}
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::internal
......
......@@ -36,7 +36,7 @@
# include <vector>
# include <mln/core/concept/point_set.hh>
# include <mln/core/pvec_piter.hh>
# include <mln/core/vec_p_piter.hh>
# include <mln/core/box2d.hh>
# include <mln/math/all.hh>
......@@ -58,10 +58,10 @@ namespace mln
typedef point2d psite;
/// Forward Point_Iterator associated type.
typedef pvec_fwd_piter_<point2d> fwd_piter;
typedef vec_p_fwd_piter_<point2d> fwd_piter;
/// Backward Point_Iterator associated type.
typedef pvec_bkd_piter_<point2d> bkd_piter;
typedef vec_p_bkd_piter_<point2d> bkd_piter;
/// Constructor from point \p beg to point \p end.
......
......@@ -25,12 +25,12 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
#ifndef MLN_CORE_PSUBSET_HH
# define MLN_CORE_PSUBSET_HH
#ifndef MLN_CORE_PSET_IF_HH
# define MLN_CORE_PSET_IF_HH
/*! \file mln/core/psubset.hh
/*! \file mln/core/pset_if.hh
*
* \brief This file defines a generic class for subset of point set.
* \brief Definition of the restriction of a point set w.r.t. a predicate.
*/
# include <mln/core/concept/point_set.hh>
......@@ -41,9 +41,9 @@ namespace mln
{
// Fwd decls.
template <typename S, typename F> struct psubset;
template <typename S, typename F> struct psubset_fwd_piter_;
template <typename S, typename F> struct psubset_bkd_piter_;
template <typename S, typename F> struct pset_if;
template <typename S, typename F> struct pset_if_fwd_piter_;
template <typename S, typename F> struct pset_if_bkd_piter_;
......@@ -54,7 +54,7 @@ namespace mln
* \return A subset of points.
*/
template <typename S, typename F>
psubset<S, F>
pset_if<S, F>
operator | (const Point_Set<S>& pset, const Function_p2b<F>& f);
......@@ -65,7 +65,7 @@ namespace mln
* from point to Boolean.
*/
template <typename S, typename F>
struct psubset : public Point_Set< psubset<S,F> >
struct pset_if : public Point_Set< pset_if<S,F> >
{
/// Point_Site associated type.
typedef mln_psite(S) psite;
......@@ -75,14 +75,14 @@ namespace mln
/// Forward Point_Iterator associated type.
typedef psubset_fwd_piter_<S,F> fwd_piter;
typedef pset_if_fwd_piter_<S,F> fwd_piter;
/// Backward Point_Iterator associated type.
typedef internal::fixme bkd_piter;
/// Constructor without argument.
psubset(const S& pset, const F& f);
pset_if(const S& pset, const F& f);
/// Test if \p p belongs to the subset.
......@@ -112,46 +112,46 @@ namespace mln
template <typename S, typename F>
psubset<S, F>
pset_if<S, F>
operator | (const Point_Set<S>& pset, const Function_p2b<F>& f)
{
psubset<S, F> tmp(exact(pset), exact(f));
pset_if<S, F> tmp(exact(pset), exact(f));
return tmp;
}
// psubset<S,F>
// pset_if<S,F>
template <typename S, typename F>
bool
psubset<S,F>::has(const psite& p) const
pset_if<S,F>::has(const psite& p) const
{
return pset_.has(p) && f_(p);
}
template <typename S, typename F>
const box_<mln_point(S)>&
psubset<S,F>::bbox() const
pset_if<S,F>::bbox() const
{
return pset_.bbox();
}
template <typename S, typename F>
const S&
psubset<S,F>::overset() const
pset_if<S,F>::overset() const
{
return pset_;
}
template <typename S, typename F>
bool
psubset<S,F>::pred(const psite& p) const
pset_if<S,F>::pred(const psite& p) const
{
return f_(p);
}
template <typename S, typename F>
psubset<S,F>::psubset(const S& pset, const F& f)
pset_if<S,F>::pset_if(const S& pset, const F& f)
: pset_(pset),
f_(f)
{
......@@ -163,7 +163,7 @@ namespace mln
# include <mln/core/psubset_piter.hh>
# include <mln/core/pset_if_piter.hh>
......@@ -174,7 +174,7 @@ namespace mln
template <typename S, typename F>
std::size_t
psubset<S,F>::npoints() const
pset_if<S,F>::npoints() const
{
std::size_t n = 0;
fwd_piter p(*this);
......@@ -188,4 +188,4 @@ namespace mln
} // end of namespace mln
#endif // ! MLN_CORE_PSUBSET_HH
#endif // ! MLN_CORE_PSET_IF_HH
......@@ -25,17 +25,18 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
#ifndef MLN_CORE_PSUBSET_PITER_HH
# define MLN_CORE_PSUBSET_PITER_HH
#ifndef MLN_CORE_PSET_IF_PITER_HH
# define MLN_CORE_PSET_IF_PITER_HH
/*! \file mln/core/psubset_piter.hh
/*! \file mln/core/pset_if_piter.hh
*
* \brief Definition of iterators on points of psubsetes.
* \brief Definition of iterators on points of pset_ifes.
*/
# include <mln/core/concept/point_iterator.hh>
# include <mln/core/internal/piter_adaptor.hh>
# include <mln/core/psubset.hh>
# include <mln/core/internal/fixme.hh>