URL:
https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2009-04-17 Edwin Carlinet <carlinet(a)lrde.epita.fr>
Remove check save + modification in compute attribute method.
* mln/io/pgm/save.hh: Remove static check unit_8 while saving pgm.
* mln/morpho/tree/compute_attribute_image.hh: Add extra
argument where the accumulator image will be store.
---
io/pgm/save.hh | 3 -
morpho/tree/compute_attribute_image.hh | 57 ++++++++++++++++++++++-----------
2 files changed, 38 insertions(+), 22 deletions(-)
Index: trunk/milena/mln/morpho/tree/compute_attribute_image.hh
===================================================================
--- trunk/milena/mln/morpho/tree/compute_attribute_image.hh (revision 3683)
+++ trunk/milena/mln/morpho/tree/compute_attribute_image.hh (revision 3684)
@@ -35,6 +35,7 @@
///
/// \todo Specialize for low quant (and try fastest).
+# include <mln/core/routine/duplicate.hh>
# include <mln/core/concept/image.hh>
# include <mln/morpho/tree/data.hh>
# include <mln/trait/accumulators.hh>
@@ -42,7 +43,6 @@
# include <mln/data/fill.hh>
-
namespace mln
{
@@ -52,25 +52,38 @@
namespace tree
{
- /// Compute a tree with a parent relationship between sites.
- ///
- /// Warning: \p s translates the ordering related to the
- /// "natural" childhood relationship. The parenthood is thus
- /// inverted w.r.t. to \p s.
- ///
- /// It is very convenient since all processing upon the parent
- /// tree are performed following \p s (in the default "forward"
- /// way).
- ///
- /// FIXME: Put it more clearly...
- ///
- /// The parent result image verifies: \n
- /// - p is root iff parent(p) == p \n
- /// - p is a node iff either p is root or f(parent(p)) != f(p).
-
+ /**
+ ** Compute an attribute image using tree with a parent
+ ** relationship between sites. In the attribute image, the
+ ** resulting value at a node is the 'sum' of its sub-components
+ ** value + the attribute value at this node.
+ **
+ ** Warning: \p s translates the ordering related to the
+ ** "natural" childhood relationship. The parenthood is thus
+ ** inverted w.r.t. to \p s.
+ **
+ ** It is very convenient since all processing upon the parent
+ ** tree are performed following \p s (in the default "forward"
+ ** way).
+ **
+ ** FIXME: Put it more clearly...
+ **
+ ** The parent result image verifies: \n
+ ** - p is root iff parent(p) == p \n
+ ** - p is a node iff either p is root or f(parent(p)) != f(p).
+ **
+ ** @param[in] a Attribute.
+ ** @param[in] t Component tree.
+ ** @param[out] accu_image Optional argument used to store image
+ ** of attribute accumulator.
+ **
+ ** @return The attribute image.
+ */
template <typename A, typename T>
mln_ch_value(typename T::function, mln_result(A))
- compute_attribute_image(const Accumulator<A>& a, const T& t);
+ compute_attribute_image(const Accumulator<A>& a,
+ const T& t,
+ mln_ch_value(typename T::function, A)* accu_image = 0);
@@ -121,7 +134,9 @@
template <typename A, typename T>
inline
mln_ch_value(typename T::function, mln_result(A))
- compute_attribute_image(const Accumulator<A>& a_, const T& t)
+ compute_attribute_image(const Accumulator<A>& a_,
+ const T& t,
+ mln_ch_value(typename T::function, A)* accu_image = 0)
{
trace::entering("morpho::tree::compute_attribute_image");
@@ -161,6 +176,10 @@
}
}
+ // Store accumulator image.
+ if (accu_image)
+ *accu_image = duplicate(acc);
+
typedef typename T::function I;
mln_ch_value(I, mln_result(A)) output;
initialize(output, acc);
Index: trunk/milena/mln/io/pgm/save.hh
===================================================================
--- trunk/milena/mln/io/pgm/save.hh (revision 3683)
+++ trunk/milena/mln/io/pgm/save.hh (revision 3684)
@@ -82,9 +82,6 @@
// FIXME: Is it exhaustive?
mlc_is_not_a(mln_value(I), value::Vectorial)::check();
mlc_converts_to(mln_value(I),unsigned)::check();
- /// Make sure this is a low quantification value type
- /// (mln_card returns 0 if it is not)
- metal::bool_<mln_card(mln_value(I)) != 0>::check();
trace::entering("mln::io::pgm::save");
io::pnm::save(PGM, exact(ima), filename);