Commit e4ab17b1 authored by Roland Levillain's avatar Roland Levillain
Browse files

Clean up accumulators related to connected filters.

	* mln/accu/count.hh,
	* mln/accu/volume.hh:
	Add more documentation.
	Aesthetic changes.
	(mln::accu::count_<T>::result)
	(mln::accu::volume_<I>::result): 
	Remove useless typedef.
	* mln/accu/volume.hh:
	(mln::accu::volume_<I>::height__): Rename member as...
	(mln::accu::volume_<I>::ref_level__): ...this.
	(mln::accu::volume_<I>::take)
	(mln::accu::volume_<I>::set_value):
	Adjust.
	(mln::accu::volume_<I>::init): Likewise.
	Actually initialize all members.
	(mln::accu::count_adjacent_vertices_<P, V>::set_value): Reset
	member ref_level__ and area__. 
	* mln/accu/count_adjacent_vertices.hh
	(mln::accu::count_adjacent_vertices_<P, V>::set_value): Reset
	member vertices_.


git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@1992 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent 967aa7bb
2008-06-03 Roland Levillain <roland@lrde.epita.fr>
Clean up accumulators related to connected filters.
* mln/accu/count.hh,
* mln/accu/volume.hh:
Add more documentation.
Aesthetic changes.
(mln::accu::count_<T>::result)
(mln::accu::volume_<I>::result):
Remove useless typedef.
* mln/accu/volume.hh:
(mln::accu::volume_<I>::height__): Rename member as...
(mln::accu::volume_<I>::ref_level__): ...this.
(mln::accu::volume_<I>::take)
(mln::accu::volume_<I>::set_value):
Adjust.
(mln::accu::volume_<I>::init): Likewise.
Actually initialize all members.
(mln::accu::count_adjacent_vertices_<P, V>::set_value): Reset
member ref_level__ and area__.
* mln/accu/count_adjacent_vertices.hh
(mln::accu::count_adjacent_vertices_<P, V>::set_value): Reset
member vertices_.
2008-06-03 Roland Levillain <roland@lrde.epita.fr>
Add height closing and opening.
......
// Copyright (C) 2007 EPITA Research and Development Laboratory
// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
......@@ -28,52 +28,47 @@
#ifndef MLN_ACCU_COUNT_HH
# define MLN_ACCU_COUNT_HH
/*! \file mln/accu/count.hh
*
* \brief Define an accumulator that counts.
*/
/// \file mln/accu/count.hh
/// \brief Define an accumulator that counts.
# include <mln/accu/internal/base.hh>
# include <mln/core/concept/meta_accumulator.hh>
namespace mln
{
namespace accu
{
/*!
* \brief Generic counter accumulator class.
*
* The parameter \a T is the type to be count.
*/
/// \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> >
{
typedef T argument;
typedef std::size_t result; // FIXME: Up in Accumulator.
count_();
/// Manipulators.
/// \{
void init();
// FIXME : should we add a take() without argument?
void take(const argument&);
void take(const count_<T>& other);
std::size_t to_result() const;
/// Force the value of the counter to \a c.
void set_value(std::size_t c);
/// \}
protected:
/// Get the value of the accumulator.
std::size_t to_result() const;
protected:
/// The value of the counter.
std::size_t count__;
};
/*!
* \brief Meta accumulator for count.
*/
/// \brief Meta accumulator for count.
struct count : public Meta_Accumulator< count >
{
template <typename T>
......
......@@ -149,6 +149,8 @@ namespace mln
count_adjacent_vertices_<P, V>::set_value(std::size_t c)
{
count__ = c;
/// Reset the other member.
vertices_.clear();
}
template <typename P, typename V>
......
......@@ -33,7 +33,7 @@
component through one of its pixels.
This accumulator uses an mln::util::pix (pixel) to update the
height, area and volume information of the component.
reference level, area and volume information of the component.
The class mln/accu/volume_ is not a general-purpose accumulator;
it is used to implement volume-based connected filters.
......@@ -67,20 +67,30 @@ namespace mln
/// mln::morpho::opening_volume for actual uses of this
/// accumulator.
typedef util::pix<I> argument;
typedef std::size_t result; // FIXME: Up in Accumulator.
/// The value type associated to the pixel type.
typedef typename argument::value value;
volume_();
/// Manipulators.
/// \{
void init();
void take(const argument&);
void take(const argument& pixel);
void take(const volume_<I>& other);
/// Force the value of the counter to \a v.
void set_value(std::size_t v);
/// \}
/// Get the value of the accumulator.
std::size_t to_result() const;
void set_value(std::size_t c);
protected:
typename argument::value height__;
/// The reference level (the level of the component's root).
value ref_level__;
/// The area of the component.
std::size_t area__;
/// The volume of the component.
std::size_t volume__;
};
......@@ -110,17 +120,30 @@ namespace mln
void
volume_<I>::init()
{
height__ = literal::zero;
volume__ = 0;
ref_level__ = literal::zero;
volume__ = 0;
area__ = 0;
}
template <typename I>
inline
void
volume_<I>::take(const argument& t)
volume_<I>::take(const argument& pixel)
{
height__ = t.v();
/* FIXME: Growing a component using this particular `take'
routine won't work, since the update does not take care of
the reference level to compute the new volume. Maybe we
could distinguish two cases:
1. the empty accumulator case (which corresponds to the
following code);
2. the non-empty accumulator case (which sohuld act as in
`take(const volume_<I>& other)').
Currently, the implementation is only valid if the
accumulator was initialy empty before the call to
`take(const argument&)'. */
ref_level__ = pixel.v();
++area__;
++volume__;
}
......@@ -135,8 +158,9 @@ namespace mln
the latter, but both the ISMM 2005 paper and Olena 0.11 use
the former. */
volume__ +=
other.volume__ + other.area__ * math::abs(other.height__ - height__);
// Member height__ is not touched.
other.volume__ +
other.area__ * math::abs(other.ref_level__ - ref_level__);
// Member ref_level__ is not touched.
}
template <typename I>
......@@ -150,10 +174,12 @@ namespace mln
template <typename I>
inline
void
volume_<I>::set_value(std::size_t c)
volume_<I>::set_value(std::size_t v)
{
volume__ = c;
// FIXME: What about area__ and height__ ?
volume__ = v;
// Reset the other members.
ref_level__ = literal::zero;
area__ = 0;
}
# endif // ! MLN_INCLUDE_ONLY
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment