Commit ba2462f4 authored by Guillaume Lazzara's avatar Guillaume Lazzara
Browse files

Remove the useless '_' postfix in all the accumulators.

git-svn-id: https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008@2563 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent 77b7409b
2008-14-07 Guillaume Lazzara <z@lrde.epita.fr>
2008-15-07 Guillaume Lazzara <z@lrde.epita.fr>
Remove the useless '_' postfix in all the accumulators.
* milena/doc/examples/tuto_bis.cc,
* milena/doc/tutorial/examples/accu.cc,
* milena/mln/accu/bbox.hh,
* milena/mln/accu/count.hh,
* milena/mln/accu/count_adjacent_vertices.hh,
* milena/mln/accu/height.hh,
* milena/mln/accu/histo.hh,
* milena/mln/accu/max_h.hh,
* milena/mln/accu/mean.hh,
* milena/mln/accu/median_alt.hh,
* milena/mln/accu/median_h.hh,
* milena/mln/accu/nil.hh,
* milena/mln/accu/p.hh,
* milena/mln/accu/rank.hh,
* milena/mln/accu/rank_bool.hh,
* milena/mln/accu/rank_high_quant.hh,
* milena/mln/accu/sum.hh,
* milena/mln/accu/tuple.hh,
* milena/mln/accu/v.hh,
* milena/mln/accu/volume.hh,
* milena/mln/canvas/morpho/algebraic_union_find.hh,
* milena/mln/estim/mean.hh,
* milena/mln/estim/sum.hh,
* milena/mln/make/voronoi.hh,
* milena/mln/morpho/closing_area.hh,
* milena/mln/morpho/closing_area_on_vertices.hh,
* milena/mln/morpho/closing_height.hh,
* milena/mln/morpho/closing_volume.hh,
* milena/mln/morpho/erosion.spe.hh,
* milena/mln/morpho/opening_area.hh,
* milena/mln/morpho/opening_area_on_vertices.hh,
* milena/mln/morpho/opening_height.hh,
* milena/mln/morpho/opening_volume.hh,
* milena/mln/morpho/rank_filter.hh,
* milena/tests/accu/all_accus.cc,
* milena/tests/accu/count.cc,
* milena/tests/accu/nil.cc,
* milena/tests/accu/pair.cc,
* milena/tests/accu/rank.cc,
* milena/tests/accu/tuple.cc,
* milena/tests/labeling/compute.cc:
Update.
2008-15-07 Guillaume Lazzara <z@lrde.epita.fr>
Update accus to make them work with the new q_result typedef.
* milena/mln/accu/bbox.hh,
......
......@@ -50,7 +50,7 @@ namespace mln
ima.at(nrows, c) = v;
}
}
} // mln::border
namespace accu
......@@ -63,7 +63,7 @@ namespace mln
const Image<L>& label_,
V& v)
{
mlc_is_a(A_, Meta_Accumulator)::check();
mlc_is_a(A_, Meta_Accumulator)::check();
trace::entering("accu::compute");
const I& input = exact(input_);
......@@ -94,7 +94,7 @@ namespace mln
{
mln_concrete(I) output;
initialize(output, input);
accu::min_max_<mln_value(I)> mm;
accu::min_max<mln_value(I)> mm;
mln_piter(I) p(input.domain());
mln_niter(N) n(nbh, p);
......@@ -117,7 +117,7 @@ namespace mln
mln_concrete(I) output;
initialize(output, input);
accu::max_<V> m;
accu::max<V> m;
mln_piter(I) p(input.domain());
mln_niter(N) n(nbh, p);
......
......@@ -5,9 +5,9 @@ int main()
{
using namespace mln;
mlc_bool(accu::mean_<int>::proxy_level == 1)::check();
mlc_bool(accu::mean<int>::proxy_level == 1)::check();
accu::mean_<int> m;
accu::mean<int> m;
m.take(100);
m.take(2);
mln_assertion(m == 51);
......
......@@ -88,7 +88,7 @@ namespace mln
template <typename T>
struct with
{
typedef mln::accu::bbox<T> ret;
typedef accu::bbox<T> ret;
};
};
......
......@@ -43,17 +43,17 @@ namespace mln
/// \brief Generic counter accumulator class.
/// The parameter \a T is the type to be count.
template <typename T>
struct count_ : public mln::accu::internal::base< std::size_t , count_<T> >
struct count : public mln::accu::internal::base< std::size_t , count<T> >
{
typedef T argument;
count_();
count();
/// Manipulators.
/// \{
void init();
void take(const argument&);
void take(const count_<T>& other);
void take(const count<T>& other);
/// Force the value of the counter to \a c.
void set_value(std::size_t c);
......@@ -68,7 +68,7 @@ namespace mln
protected:
/// The value of the counter.
std::size_t count__;
std::size_t count_;
};
namespace meta
......@@ -80,7 +80,7 @@ namespace mln
template <typename T>
struct with
{
typedef count_<T> ret;
typedef accu::count<T> ret;
};
};
......@@ -91,7 +91,7 @@ namespace mln
template <typename T>
inline
count_<T>::count_()
count<T>::count()
{
init();
}
......@@ -99,47 +99,47 @@ namespace mln
template <typename T>
inline
void
count_<T>::init()
count<T>::init()
{
count__ = 0;
count_ = 0;
}
template <typename T>
inline
void
count_<T>::take(const argument&)
count<T>::take(const argument&)
{
++count__;
++count_;
}
template <typename T>
inline
void
count_<T>::take(const count_<T>& other)
count<T>::take(const count<T>& other)
{
count__ += other.count__;
count_ += other.count_;
}
template <typename T>
inline
std::size_t
count_<T>::to_result() const
count<T>::to_result() const
{
return count__;
return count_;
}
template <typename T>
inline
void
count_<T>::set_value(std::size_t c)
count<T>::set_value(std::size_t c)
{
count__ = c;
count_ = c;
}
template <typename T>
inline
bool
count_<T>::is_valid() const
count<T>::is_valid() const
{
return true;
}
......
......@@ -53,21 +53,21 @@ namespace mln
/// This accumulator is used by mln::closing_area_on_vertices and
/// mln::opening_area_on_vertices.
template <typename P, typename V>
struct count_adjacent_vertices_
struct count_adjacent_vertices
: public mln::accu::internal::base< std::size_t,
count_adjacent_vertices_<P, V> >
count_adjacent_vertices<P, V> >
{
typedef mln::util::pix< mln::line_graph_image<P, V> > argument;
count_adjacent_vertices_();
count_adjacent_vertices();
/// Manipulators.
/// \{
void init();
void take(const argument& arg);
void take(const count_adjacent_vertices_<P, V>& other);
void take(const count_adjacent_vertices<P, V>& other);
/// Force the value of the counter to \a c.
/// Force the value of the counter to \a c.
void set_value(std::size_t c);
/// \}
......@@ -86,23 +86,28 @@ namespace mln
};
/// \brief Meta accumulator for count_adjacent_vertices.
struct count_adjacent_vertices
: public Meta_Accumulator< count_adjacent_vertices >
namespace meta
{
template <typename P, typename V>
struct with
/// \brief Meta accumulator for count_adjacent_vertices.
struct count_adjacent_vertices
: public Meta_Accumulator< count_adjacent_vertices >
{
typedef count_adjacent_vertices_<P, V> ret;
template <typename P, typename V>
struct with
{
typedef accu::count_adjacent_vertices<P, V> ret;
};
};
};
} // end of namespace mln::accu::meta
# ifndef MLN_INCLUDE_ONLY
template <typename P, typename V>
inline
count_adjacent_vertices_<P, V>::count_adjacent_vertices_()
count_adjacent_vertices<P, V>::count_adjacent_vertices()
{
init();
}
......@@ -110,7 +115,7 @@ namespace mln
template <typename P, typename V>
inline
void
count_adjacent_vertices_<P, V>::init()
count_adjacent_vertices<P, V>::init()
{
vertices_.clear();
update_();
......@@ -119,7 +124,7 @@ namespace mln
template <typename P, typename V>
inline
void
count_adjacent_vertices_<P, V>::take(const argument& arg)
count_adjacent_vertices<P, V>::take(const argument& arg)
{
vertices_.insert(arg.p().first_id());
vertices_.insert(arg.p().second_id());
......@@ -129,7 +134,7 @@ namespace mln
template <typename P, typename V>
inline
void
count_adjacent_vertices_<P, V>::take(const count_adjacent_vertices_<P, V>& other)
count_adjacent_vertices<P, V>::take(const count_adjacent_vertices<P, V>& other)
{
vertices_.insert (other.vertices_.begin(), other.vertices_.end());
update_();
......@@ -138,7 +143,7 @@ namespace mln
template <typename P, typename V>
inline
std::size_t
count_adjacent_vertices_<P, V>::to_result() const
count_adjacent_vertices<P, V>::to_result() const
{
return count__;
}
......@@ -146,7 +151,7 @@ namespace mln
template <typename P, typename V>
inline
void
count_adjacent_vertices_<P, V>::set_value(std::size_t c)
count_adjacent_vertices<P, V>::set_value(std::size_t c)
{
count__ = c;
/// Reset the other member.
......@@ -156,7 +161,7 @@ namespace mln
template <typename P, typename V>
inline
void
count_adjacent_vertices_<P, V>::update_()
count_adjacent_vertices<P, V>::update_()
{
count__ = vertices_.size();
}
......
......@@ -35,7 +35,7 @@
This accumulator uses an mln::util::pix (pixel) to update the
height information of the component.
The class mln/accu/height_ is not a general-purpose accumulator;
The class mln/accu/height is not a general-purpose accumulator;
it is used to implement height-based connected filters.
\see mln::morpho::closing_height
\see mln::morpho::opening_height */
......@@ -58,8 +58,8 @@ namespace mln
/// The parameter \p I is the image type on which the accumulator
/// of pixels is built.
template <typename I>
struct height_
: public mln::accu::internal::base< std::size_t , height_<I> >
struct height
: public mln::accu::internal::base< std::size_t , height<I> >
{
/// \brief The accumulated data type.
///
......@@ -71,13 +71,13 @@ namespace mln
/// The value type associated to the pixel type.
typedef typename argument::value value;
height_();
height();
/// Manipulators.
/// \{
void init();
void take(const argument&);
void take(const height_<I>& other);
void take(const height<I>& other);
/// Force the value of the counter to \a h.
void set_value(std::size_t h);
......@@ -96,7 +96,7 @@ namespace mln
/// The maximum level in the component.
value max_level__;
/// The height of the component.
std::size_t height__;
std::size_t height_;
};
......@@ -107,10 +107,10 @@ namespace mln
struct height : public Meta_Accumulator< height >
{
template <typename I>
struct with
{
typedef height_<I> ret;
};
struct with
{
typedef accu::height<I> ret;
};
};
} // end of namespace mln::accu::meta
......@@ -119,7 +119,7 @@ namespace mln
template <typename I>
inline
height_<I>::height_()
height<I>::height()
{
init();
}
......@@ -127,47 +127,47 @@ namespace mln
template <typename I>
inline
void
height_<I>::init()
height<I>::init()
{
min_level__ = mln_max(value);
max_level__ = mln_min(value);
height__ = 0;
height_ = 0;
}
template <typename I>
inline
void
height_<I>::take(const argument& t)
height<I>::take(const argument& t)
{
min_level__ = math::min(min_level__, t.v());
max_level__ = math::max(max_level__, t.v());
height__ = max_level__ - min_level__;
height_ = max_level__ - min_level__;
}
template <typename I>
inline
void
height_<I>::take(const height_<I>& other)
height<I>::take(const height<I>& other)
{
min_level__ = math::min(min_level__, other.min_level__);
max_level__ = math::max(max_level__, other.max_level__);
height__ = max_level__ - min_level__;
height_ = max_level__ - min_level__;
}
template <typename I>
inline
std::size_t
height_<I>::to_result() const
height<I>::to_result() const
{
return height__;
return height_;
}
template <typename I>
inline
void
height_<I>::set_value(std::size_t h)
height<I>::set_value(std::size_t h)
{
height__ = h;
height_ = h;
// Reset the other members.
min_level__ = mln_max(value);
max_level__ = mln_min(value);
......@@ -176,7 +176,7 @@ namespace mln
template <typename I>
inline
bool
height_<I>::is_valid() const
height<I>::is_valid() const
{
return true;
}
......
......@@ -106,7 +106,7 @@ namespace mln
template <typename V>
struct with
{
typedef mln::accu::histo<V> ret;
typedef accu::histo<V> ret;
};
};
......
......@@ -101,9 +101,7 @@ namespace mln
namespace meta
{
/*!
* \brief Meta accumulator for max.
*/
/// Meta accumulator for max.
struct max_h : public Meta_Accumulator< max_h >
{
template <typename T>
......
......@@ -58,17 +58,17 @@ namespace mln
template <typename T,
typename S = mln_sum(T),
typename M = S>
struct mean_ : public mln::accu::internal::base< M , mean_<T,S,M> >
struct mean : public mln::accu::internal::base< M , mean<T,S,M> >
{
typedef T argument;
mean_();
mean();
/// Manipulators.
/// \{
void init();
void take(const argument& t);
void take(const mean_<T,S,M>& other);
void take(const mean<T,S,M>& other);
/// \}
/// Get the value of the accumulator.
......@@ -80,14 +80,14 @@ namespace mln
protected:
accu::count_<T> count_;
accu::sum_<T,S> sum_;
accu::count<T> count_;
accu::sum<T,S> sum_;
};
template <typename I, typename S, typename M>
struct mean_< util::pix<I>, S,M >;
struct mean< util::pix<I>, S,M >;
namespace meta
......@@ -101,7 +101,7 @@ namespace mln
typename M = S >
struct with
{
typedef mean_<T,S,M> ret;
typedef accu::mean<T,S,M> ret;
};
};
......@@ -112,7 +112,7 @@ namespace mln
template <typename T, typename S, typename M>
inline
mean_<T,S,M>::mean_()
mean<T,S,M>::mean()
{
init();
}
......@@ -120,7 +120,7 @@ namespace mln
template <typename T, typename S, typename M>
inline
void
mean_<T,S,M>::init()
mean<T,S,M>::init()
{
count_.init();
sum_.init();
......@@ -128,7 +128,7 @@ namespace mln
template <typename T, typename S, typename M>
inline
void mean_<T,S,M>::take(const argument& t)
void mean<T,S,M>::take(const argument& t)
{
count_.take(t);
sum_.take(t);
......@@ -137,7 +137,7 @@ namespace mln
template <typename T, typename S, typename M>
inline
void
mean_<T,S,M>::take(const mean_<T,S,M>& other)
mean<T,S,M>::take(const mean<T,S,M>& other)
{
count_.take(other.count_);
sum_.take(other.sum_);
......@@ -146,7 +146,7 @@ namespace mln
template <typename T, typename S, typename M>
inline
M
mean_<T,S,M>::to_result() const
mean<T,S,M>::to_result() const
{
return sum_.to_result() / count_.to_result();
}
......@@ -154,7 +154,7 @@ namespace mln
template <typename T, typename S, typename M>
inline
bool
mean_<T,S,M>::is_valid() const
mean<T,S,M>::is_valid() const
{
return count_.to_result() != 0;
}
......
......@@ -96,6 +96,23 @@ namespace mln
};
namespace meta
{
/// Meta accumulator for median_alt.
struct median_alt : public Meta_Accumulator< median_alt >
{
template <typename V>
struct with
{
typedef accu::median_alt<V> ret;
};
};
} // end of namespace mln::accu::meta
template <typename T>
struct median_alt_on : public median_alt< value::set<T> >
{
......
......@@ -92,6 +92,24 @@ namespace mln
};
namespace meta
{
/// Meta accumulator for median_h.
struct median_h : public Meta_Accumulator< median_h >
{
template <typename V>
struct with
{
typedef accu::median_h<V> ret;
};
};
} // end of namespace mln::accu::meta