Index: olena/ChangeLog
from Giovanni Palma <giovanni(a)lrde.epita.fr>
* oln/morpho/attribute_union_find.hh: Change sort algorithm.
* oln/morpho/attributes.hh: Add volume attribute.
* oln/utils/qsort.hh: Add file.
Index: olena/oln/morpho/erosion.hh
--- olena/oln/morpho/erosion.hh Thu, 18 Mar 2004 18:24:14 +0100 van-vl_n
(oln/b/4_erosion.hh 1.21 600)
+++ olena/oln/morpho/erosion.hh Wed, 12 May 2004 14:55:31 +0200 palma_g
(oln/b/4_erosion.hh 1.21 640)
@@ -88,7 +88,6 @@
{
mlc::eq<I::dim, E::dim>::ensure();
oln_concrete_type(I) output(input.size());
- se.delta();
input.border_adapt_copy(se.delta());
oln_iter_type(I) p(input);
for_all (p)
Index: olena/oln/utils/histogram.hh
--- olena/oln/utils/histogram.hh Sat, 27 Mar 2004 15:56:32 +0100 van-vl_n
(oln/10_histogram. 1.6.1.14.1.12 600)
+++ olena/oln/utils/histogram.hh Sun, 23 May 2004 07:52:57 +0200 palma_g
(oln/10_histogram. 1.6.1.14.1.12 640)
@@ -682,7 +682,7 @@
ensure_type;
// check the size
- precondition(v.size() == im.npoints());
+ precondition(v.size() == im/*.npoints()*/);
// calculate the histogram of the image
utils::histogram<val> histo(im);
Index: olena/oln/morpho/attribute_union_find.hh
--- olena/oln/morpho/attribute_union_find.hh Mon, 15 Mar 2004 15:32:27 +0100 van-vl_n
(oln/q/50_attribute_ 1.18 600)
+++ olena/oln/morpho/attribute_union_find.hh Sun, 23 May 2004 08:31:37 +0200 palma_g
(oln/q/50_attribute_ 1.18 640)
@@ -34,6 +34,7 @@
#include <vector>
#include <oln/utils/histogram.hh>
+#include <oln/utils/qsort.hh>
#include <oln/morpho/attributes.hh>
namespace oln {
@@ -89,10 +90,13 @@
{
lambda_ = λ
- std::vector<point_type> I(input_.npoints());
-
- oln::utils::select_distrib_sort<closing>()(input_, I);
+ std::vector<point_type> I;//(/*input_.npoints()*/);
+ // oln::utils::select_distrib_sort<closing>()(input_, I);
+ if (closing)
+ oln::utils::qsort_inv(input_, I);
+ else
+ oln::utils::qsort(input_, I);
level::fill(aux_data_, ntg_sup_val(lambda_type));
aux_data_.border_adapt_assign(Ng.delta(), ntg_sup_val(lambda_type));
Index: olena/oln/morpho/attributes.hh
--- olena/oln/morpho/attributes.hh Sat, 15 May 2004 19:16:56 +0200 van-vl_n
(oln/j/45_attributes 1.13.1.2 600)
+++ olena/oln/morpho/attributes.hh Sun, 23 May 2004 12:14:50 +0200 palma_g
(oln/j/45_attributes 1.13.1.2 600)
@@ -345,6 +345,169 @@
};
};
+ /*-----------*
+ | volume |
+ *-----------*/
+ /*!
+ ** \brief Integral attribute.
+ **
+ ** It is equivalent to volume in 2D, and weight in 3D.
+ ** \todo FIXME: Change the name and explain the diferences with integral.
+ */
+ template <class I, class Exact = mlc::final>
+ class volume_type:
+ public attribute<mlc_2_exact_vt_type(volume_type, I, Exact)>
+ {
+ public:
+ typedef volume_type<I, Exact> self_type; /*!< Self type of the class. */
+ attr_type_decl(self_type);
+
+ /*!
+ ** \brief Basic Ctor.
+ **
+ ** \warning After this call, the object is only instantiated
+ ** (not initialized).
+ */
+ volume_type()
+ {
+ };
+
+ /*!
+ ** \brief Ctor from a lambda_type value.
+ */
+ volume_type(const lambda_type &lambda): value_(lambda)
+ {
+ };
+
+ /*!
+ ** \brief Ctor from a point and an image.
+ */
+ template <class J>
+ volume_type(const abstract::image<J> &,
+ const oln_point_type(J) &p,
+ const env_type &e) :
+ reflevel_(e.getImage()[p]),
+ area_(1),
+ value_(1)
+ {
+ };
+
+ // interface part
+ /*!
+ ** \brief Accessor to value_.
+ **
+ ** Virtual method.
+ ** \see getValue_impl()
+ */
+ const value_type &getValue() const
+ {
+ mlc_dispatch(getValue)();
+ };
+
+ /*!
+ ** \brief Accessor to the reference level.
+ **
+ ** \see getReflevel_impl()
+ */
+ const value_type &getReflevel() const
+ {
+ mlc_dispatch(getReflevel)();
+ };
+
+ /*!
+ ** \brief Accessor to the current area.
+ **
+ ** \see getArea_impl()
+ */
+ const value_type &getArea() const
+ {
+ mlc_dispatch(getArea)();
+ };
+
+ // impl part
+ /*!
+ ** \brief Implementation of getValue().
+ **
+ ** Override this method in order to provide a new version of
+ ** getValue().
+ **
+ ** \warning Do not call this method, use getValue() instead.
+ */
+ const value_type &getValue_impl() const
+ {
+ return value_;
+ };
+
+ /*!
+ ** \brief Implementation of getReflevel().
+ **
+ ** Override this method in order to provide a new version of
+ ** getReflevel().
+ **
+ ** \warning Do not call this method, use getReflevel() instead.
+ */
+ const value_type &getReflevel_impl() const
+ {
+ return reflevel_;
+ };
+
+ /*!
+ ** \brief Implementation of getArea().
+ **
+ ** Override this method in order to provide a new version of
+ ** getArea().
+ **
+ ** \warning Do not call this method, use getArea() instead.
+ */
+ const value_type &getArea_impl() const
+ {
+ return area_;
+ };
+
+ /*!
+ ** \brief += operator implementation.
+ **
+ ** This is an implementation of the += operator. Override this
+ ** method to provide a new implementation of this operator.
+ ** \warning This method SHOULDN'T directly be called.
+ */
+ void pe_impl(const volume_type &rhs)
+ {
+ value_ += rhs.getValue() + area_ * tools::diffabs(reflevel_, rhs.getReflevel());
+ area_ += rhs.getArea();
+ };
+
+ /*!
+ ** \brief "<" operator implementation.
+ **
+ ** This is an implementation of the += operator. Override this
+ ** method to provide a new implementation of this operator.
+ ** \warning This method SHOULDN'T directly be called.
+ */
+ bool less_impl(const lambda_type &lambda) const
+ {
+ return value_ < lambda;
+ };
+
+ /*!
+ ** \brief != operator implementation.
+ **
+ ** This is an implementation of the += operator. Override this
+ ** method to provide a new implementation of this operator.
+ ** \warning This method SHOULDN'T directly be called.
+ */
+ bool ne_impl(const lambda_type &lambda) const
+ {
+ return lambda != value_;
+ };
+
+ protected:
+ value_type reflevel_; ///< Reference level.
+ value_type area_; ///< Current area.
+ value_type value_; ///< Current value (deduced from area and level).
+ };
+
+
/*--------------*
| integral |
*------------*/
@@ -1858,6 +2021,16 @@
typedef integral_type<T, NewExact> ret;
};
+ /*!
+ ** \brief Trait specialization for the volume attribute.
+ */
+ template <class I, class Exact>
+ struct attr_traits<volume_type<I, Exact> >
+ {
+ typedef unsigned value_type;
+ typedef value_type lambda_type;
+ typedef env::OtherImageEnv<I> env_type;
+ };
}// !attr
} // !morpho
} //!oln
--
Giovanni Palma
EPITA - promo 2005 - membre d'EpX - LRDE
Mob. : +33 (0)6 60 97 31 74