
* headers.mk: update distributed header list. * doc/ref_guide/ref_guide.tex: update reference to clone(). * doc/tutorial/tutorial.tex: fix references. * mln/accu/center.hh: Fix meta accu. * mln/canvas/browsing/depth_first_search.hh: update functor interface. * mln/core/concept/function.hh: Introduce Function_i2b. * mln/debug/colorize.hh: call srand. * mln/fun/i2v/array.hh: update from_to overloads: add a special case for element[0]. * mln/io/pgm/save.hh: Check if the image is compatible with pgm format. * mln/labeling/level.hh, * mln/labeling/regional_maxima.hh: avoid warnings. * mln/labeling/relabel.hh: update call to make::relabelfun. * mln/make/graph.hh: adjust extension to structural element. * mln/util/array.hh: - add subject_impl specialization. - Update from_to overloads: add a special case for element[0]. * tests/accu/site_set/rectangularity.cc: add more tests. * tests/unit_test/unit-tests.mk: update unit test list. --- milena/ChangeLog | 41 +++++ milena/doc/Doxyfile.in | 2 +- milena/doc/ref_guide/ref_guide.tex | 4 +- milena/doc/tutorial/tutorial.tex | 50 +++--- milena/headers.mk | 14 ++- milena/mln/accu/center.hh | 5 +- milena/mln/canvas/browsing/depth_first_search.hh | 14 +- milena/mln/core/concept/function.hh | 38 ++++ milena/mln/debug/colorize.hh | 1 + milena/mln/fun/i2v/array.hh | 48 +++++- milena/mln/io/pgm/save.hh | 12 +- milena/mln/labeling/level.hh | 4 +- milena/mln/labeling/regional_maxima.hh | 2 +- milena/mln/labeling/relabel.hh | 2 +- milena/mln/make/graph.hh | 4 + milena/mln/util/array.hh | 197 +++++++++++++++++++++- milena/tests/accu/site_set/rectangularity.cc | 15 ++- milena/tests/unit_test/unit-tests.mk | 30 +++- 18 files changed, 410 insertions(+), 73 deletions(-) diff --git a/milena/ChangeLog b/milena/ChangeLog index 31180d8..cbbdf13 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,5 +1,46 @@ 2009-03-24 Guillaume Lazzara <lazzara@lrde.epita.fr> + Small fixes. + + * headers.mk: update distributed header list. + + * doc/Doxyfile.in: Do not use mln:: prefix in class name lists. + + * doc/ref_guide/ref_guide.tex: update reference to clone(). + + * doc/tutorial/tutorial.tex: fix references. + + * mln/accu/center.hh: Fix meta accu. + + * mln/canvas/browsing/depth_first_search.hh: update functor interface. + + * mln/core/concept/function.hh: Introduce Function_i2b. + + * mln/debug/colorize.hh: call srand. + + * mln/fun/i2v/array.hh: update from_to overloads: add a special case + for element[0]. + + * mln/io/pgm/save.hh: Check if the image is compatible with pgm + format. + + * mln/labeling/level.hh, + * mln/labeling/regional_maxima.hh: avoid warnings. + + * mln/labeling/relabel.hh: update call to make::relabelfun. + + * mln/make/graph.hh: adjust extension to structural element. + + * mln/util/array.hh: + - add subject_impl specialization. + - Update from_to overloads: add a special case for element[0]. + + * tests/accu/site_set/rectangularity.cc: add more tests. + + * tests/unit_test/unit-tests.mk: update unit test list. + +2009-03-24 Guillaume Lazzara <lazzara@lrde.epita.fr> + Fix compilation issues with Cygwin. * mln/convert/from_to.hxx, diff --git a/milena/doc/Doxyfile.in b/milena/doc/Doxyfile.in index 053cbe7..649ea2f 100644 --- a/milena/doc/Doxyfile.in +++ b/milena/doc/Doxyfile.in @@ -118,7 +118,7 @@ VERBATIM_HEADERS = YES #--------------------------------------------------------------------------- ALPHABETICAL_INDEX = YES COLS_IN_ALPHA_INDEX = 5 -IGNORE_PREFIX = +IGNORE_PREFIX = mln:: #--------------------------------------------------------------------------- # configuration options related to the HTML output #--------------------------------------------------------------------------- diff --git a/milena/doc/ref_guide/ref_guide.tex b/milena/doc/ref_guide/ref_guide.tex index 28bc543..43f8787 100644 --- a/milena/doc/ref_guide/ref_guide.tex +++ b/milena/doc/ref_guide/ref_guide.tex @@ -1483,7 +1483,7 @@ variable behaves like some mathematical variable. Put differently it is just a name to designate an image: \doxycode{ima2d-5} -If a deep copy of the image is needed, a clone() routine is available: +If a deep copy of the image is needed, a duplicate() routine is available: \doxycode{ima2d-6-clone} Output: \doxyoutput{ima2d-6-clone} @@ -1499,7 +1499,7 @@ Output: \begin{tabular}{l|p{8cm}} \hline Routine name & Description \\ \hline -level::clone() & creates a deep copy of an object. Any shared data is +duplicate() & creates a deep copy of an object. Any shared data is duplicated. \\ data::fill() & fill an object with a value. \\ diff --git a/milena/doc/tutorial/tutorial.tex b/milena/doc/tutorial/tutorial.tex index a36a365..ede9d90 100644 --- a/milena/doc/tutorial/tutorial.tex +++ b/milena/doc/tutorial/tutorial.tex @@ -318,7 +318,6 @@ $$ \backslash endhtmlonly \backslash page tutorial Tutorial -- \backslash subpage tuto0 - \backslash subpage tuto1 - \backslash subpage tuto2 - \backslash subpage tuto3 @@ -347,7 +346,6 @@ A copy of the license is provided in the file COPYING.DOC. \tableofcontents \end{latexonly} -%\begin{htmlonly} %==================================== \doxychapter{tuto1}{Welcome} @@ -475,7 +473,7 @@ We invite you to take a look at the description of the directory structure (\ref{tuto1dirstruct}. If you encounter any issues in the installation process or if you have any question, do not forget to join the mailing lists (\ref{tuto1mailinglists} -and/or use the other documentations ressources (\ref{tuto1ressources}). +and/or use the other documentations ressources (\ref{tuto1documentation}). @@ -488,11 +486,7 @@ and/or use the other documentations ressources (\ref{tuto1ressources}). Milena's packages can be downloaded from: -\begin{center} -\begin{verbatim} -http://www.lrde.epita.fr/Olena/Download -\end{verbatim} -\end{center} +\href{http://www.lrde.epita.fr/Olena/Download} On this page you will find the latest and past releases. Currently, we provide only '.tar.gz' and 'tar.bz2' archives. @@ -521,7 +515,7 @@ We invite you to take a look at the description of the directory structure (\ref{tuto1dirstruct}. If you encounter any issues in the installation process or if you have any question, do not forget to join the mailing lists (\ref{tuto1mailinglists} -and/or use the other documentations ressources (\ref{tuto1ressources}). +and/or use the other documentations ressources (\ref{tuto1documentation}). @@ -666,7 +660,7 @@ List of \hpath{doc}'s subdirectories: %************************** -\doxysection{tuto1ressources}{Documentation} +\doxysection{tuto1documentation}{Documentation} This tutorial is not the only documentation of Milena. Other documents are available: @@ -696,7 +690,7 @@ This tutorial is not the only documentation of Milena. Other documents are avail %************************** -\doxysection{tuto1ressources}{Community and Support} +\doxysection{tuto1community}{Community and Support} Even though Milena is currently developped by the LRDE in EPITA, we are open for new contributors. @@ -730,23 +724,27 @@ the mailing-lists (\ref{tuto1mailinglists}). There are other ways to get to know what is the status of the project. \begin{itemize} -\item Olena's trac --- \href{https://trac.lrde.org/olena} --- Here is the -roadmap, the current open tickets/bugs/improvements which are taken in -consideration. A source browser is also available. - -\item Olena's Buildfarm --- https://buildfarm.lrde.org/buildfarm/oln/ --- The -official buildfarm. Every night and after each commit, tests are compiled and run. -The buildfarm can show you whether it is safe to update your svn copy of Milena or not\ldots - -\item Test failures --- http://www.lrde.epita.fr/dload/olena/test-failures-daily.html ---- Through this page, you can see exactly which tests do not compile or pass. -This page is updated every night. +\item Olena's trac\\ + \href{https://trac.lrde.org/olena} \\ + Here is the roadmap, the current open tickets/bugs/improvements which + are taken in consideration. A source browser is also available. + +\item Olena's Buildfarm \\ + \href{https://buildfarm.lrde.org/buildfarm/oln/} \\ + The official buildfarm. Every night and after each commit, tests + are compiled and run. The buildfarm can show you whether it is safe + to update your svn copy of Milena or not\ldots + +\item Test failures + \href{http://www.lrde.epita.fr/dload/olena/test-failures-daily.html} + Through this page, you can see exactly which tests do not compile or pass. + This page is updated every night. \end{itemize} %************************** -\doxysection{tuto1ressources}{A brief history of Milena} +\doxysection{tuto1briefhistory}{A brief history of Milena} The Olena project aims at building a scientific computation platform oriented towards image processing, image recognition, and artificial vision. @@ -787,7 +785,6 @@ If you want to reach us directly, you can contact one of the following people: -%\begin{htmlonly} %==================================== \doxychapter{tuto2}{Installation} @@ -960,7 +957,7 @@ Text and image outputs will be respectively stored in -\doxysubsection{tuto2examples}{Tools} +\doxysubsection{tuto2tools}{Tools} Few tools are provided with Milena. They can be considered as full program examples. @@ -979,7 +976,7 @@ $ make \end{verbatim} -\doxysubsection{tuto2examples}{Tests} +\doxysubsection{tuto2tests}{Tests} The test suite used for Milena's development is shipped with the library. @@ -1008,7 +1005,6 @@ In the installed path prefix, Milena's files are located in: -%\begin{htmlonly} %==================================== \doxychapter{tuto3}{Getting started with Milena} diff --git a/milena/headers.mk b/milena/headers.mk index a74f35f..1a20506 100644 --- a/milena/headers.mk +++ b/milena/headers.mk @@ -116,7 +116,6 @@ mln/data/all.hh \ mln/data/paste.hh \ mln/data/fill_with_image.hh \ mln/data/fill_with_image.spe.hh \ -mln/data/swap.hh \ mln/data/fill_with_value.hh \ mln/data/fill_with_value.spe.hh \ mln/data/fill.hh \ @@ -331,6 +330,7 @@ mln/value/all.hh \ mln/value/super_value.hh \ mln/value/builtin/symbolics.hh \ mln/value/builtin/ops.hh \ +mln/value/builtin/carrays.hh \ mln/value/builtin/all.hh \ mln/value/builtin/promotions.hh \ mln/value/builtin/integers.hh \ @@ -373,6 +373,9 @@ mln/value/label_8.hh \ mln/value/essential.hh \ mln/accu/tuple.hh \ mln/accu/min_h.hh \ +mln/accu/site_set/rectangularity.hh \ +mln/accu/site_set/all.hh \ +mln/accu/site_set/essential.hh \ mln/accu/stat/deviation.hh \ mln/accu/max.hh \ mln/accu/lor.hh \ @@ -380,6 +383,7 @@ mln/accu/rank.hh \ mln/accu/transform_stop.hh \ mln/accu/maj_h.hh \ mln/accu/min_max.hh \ +mln/accu/internal/couple.hh \ mln/accu/internal/base.hh \ mln/accu/transform_snake.hh \ mln/accu/rank_high_quant.hh \ @@ -417,6 +421,7 @@ mln/accu/image/all.hh \ mln/accu/image/set_value.hh \ mln/accu/image/take.hh \ mln/accu/image/take_as_init.hh \ +mln/accu/image/essential.hh \ mln/accu/center.hh \ mln/accu/line.hh \ mln/accu/essential.hh \ @@ -479,8 +484,11 @@ mln/trait/promote.hh \ mln/trait/solve_binary.hh \ mln/trait/value_.hh \ mln/trait/all.hh \ +mln/trait/value/internal/all.hh \ +mln/trait/value/internal/comp.hh \ mln/trait/value/all.hh \ mln/trait/value/nature.hh \ +mln/trait/value/comp.hh \ mln/trait/value/quant.hh \ mln/trait/value/kind.hh \ mln/trait/value/print.hh \ @@ -651,7 +659,6 @@ mln/morpho/closing/leveling.hh \ mln/morpho/closing/area_on_vertices.hh \ mln/morpho/closing/area.hh \ mln/morpho/closing/volume.hh \ -mln/morpho/closing/sum.hh \ mln/morpho/closing/height.hh \ mln/morpho/closing/structural.hh \ mln/morpho/closing/essential.hh \ @@ -1021,6 +1028,7 @@ mln/test/predicate.hh \ mln/test/all.hh \ mln/test/positive.hh \ mln/test/essential.hh \ +mln/transform/distance_and_closest_point_geodesic.hh \ mln/transform/distance_geodesic.hh \ mln/transform/internal/all.hh \ mln/transform/internal/closest_point_functor.hh \ @@ -1028,9 +1036,9 @@ mln/transform/internal/distance_functor.hh \ mln/transform/internal/influence_zone_functor.hh \ mln/transform/all.hh \ mln/transform/influence_zone_front.hh \ +mln/transform/distance_and_influence_zone_geodesic.hh \ mln/transform/distance_front.hh \ mln/transform/influence_zone_geodesic.hh \ -mln/transform/closest_point_geodesic.hh \ mln/transform/essential.hh \ mln/arith/includes.hh \ mln/arith/min.spe.hh \ diff --git a/milena/mln/accu/center.hh b/milena/mln/accu/center.hh index f7caff3..8f793c6 100644 --- a/milena/mln/accu/center.hh +++ b/milena/mln/accu/center.hh @@ -84,10 +84,10 @@ namespace mln struct center : public Meta_Accumulator< center > { - template <typename P, typename V> + template <typename P> struct with { - typedef accu::center<P, V> ret; + typedef accu::center<P> ret; }; }; @@ -136,6 +136,7 @@ namespace mln V center<P,V>::to_result() const { + mln_precondition(is_valid()); return center_ / nsites_; } diff --git a/milena/mln/canvas/browsing/depth_first_search.hh b/milena/mln/canvas/browsing/depth_first_search.hh index a8d840e..179bf1c 100644 --- a/milena/mln/canvas/browsing/depth_first_search.hh +++ b/milena/mln/canvas/browsing/depth_first_search.hh @@ -103,26 +103,26 @@ namespace mln mln_vertex_iter(G) v(g); for_all(v) - if (f.to_be_treated(v.id())) + if (f.to_be_treated(v.id())) // <--- to_be_treated { std::queue<unsigned> queue; queue.push(v.id()); - f.update_treated(v.id()); + f.new_component_from_vertex(v.id()); // <--- new_component_from_vertex while (!queue.empty()) { util::vertex<G> current_v = g.vertex(queue.front()); + f.process_vertex(current_v); queue.pop(); for (unsigned nv = 0; nv < current_v.nmax_nbh_vertices(); ++nv) - if (f.to_be_queued(current_v.ith_nbh_vertex(nv))) + if (f.to_be_queued(current_v.ith_nbh_vertex(nv))) // <--- to_be_queued { - f.update_queued(current_v.ith_nbh_vertex(nv)); + f.added_to_queue(current_v.ith_nbh_vertex(nv)); // <--- added_to_queue queue.push(current_v.ith_nbh_vertex(nv)); } } - f.next(); + f.next_component(); // <-- next_component } - - f.final(); + f.final(); // <-- final trace::exiting("canvas::browsing::depth_first_search"); } diff --git a/milena/mln/core/concept/function.hh b/milena/mln/core/concept/function.hh index 2d8baff..ff3015f 100644 --- a/milena/mln/core/concept/function.hh +++ b/milena/mln/core/concept/function.hh @@ -44,6 +44,7 @@ namespace mln template <typename E> struct Function_v2v; template <typename E> struct Function_v2w2v; template <typename E> struct Function_v2w_w2v; + template <typename E> struct Function_i2b; template <typename E> struct Function_i2v; template <typename E> struct Function_p2v; template <typename E> struct Function_v2b; @@ -176,6 +177,29 @@ namespace mln /*-----------------. + | Index -> bool. | + `-----------------*/ + + template <> + struct Function_i2b<void> { typedef Function_v2b<void> super; }; + + /// Base class for implementation of function-objects from + /// index to value. + /// + /// The parameter \a E is the exact type. + /// + template <typename E> + struct Function_i2b : public Function_v2b<E> + { + typedef Function_i2b<void> category; + typedef bool result; + protected: + Function_i2b(); + Function_i2b(const Function_i2b&); + }; + + + /*-----------------. | Index -> Value. | `-----------------*/ @@ -476,6 +500,20 @@ namespace mln template <typename E> inline + Function_i2b<E>::Function_i2b() + { + } + + template <typename E> + inline + Function_i2b<E>::Function_i2b(const Function_i2b<E>& rhs) + : Function_v2b<E>(rhs) + { + } + + + template <typename E> + inline Function_i2v<E>::Function_i2v() { } diff --git a/milena/mln/debug/colorize.hh b/milena/mln/debug/colorize.hh index 15ecb47..4f492bf 100644 --- a/milena/mln/debug/colorize.hh +++ b/milena/mln/debug/colorize.hh @@ -117,6 +117,7 @@ namespace mln int diff_size = f.size() - label_count; if (diff_size < 0) { + srand(1); f.resize(label_count); unsigned i = f.size() + diff_size; // We want to treat comp 0 differently since it is the background. diff --git a/milena/mln/fun/i2v/array.hh b/milena/mln/fun/i2v/array.hh index cd00db5..c140cc3 100644 --- a/milena/mln/fun/i2v/array.hh +++ b/milena/mln/fun/i2v/array.hh @@ -43,7 +43,7 @@ # include <mln/core/concept/function.hh> # include <mln/fun/internal/array_base.hh> # include <mln/util/array.hh> - +# include <mln/metal/equal.hh> namespace mln { @@ -102,16 +102,36 @@ namespace mln namespace i2v { + + namespace internal + { + + template <typename T, bool B = false > + struct array_selector_ + : public Function_i2v< i2v::array<T> > + { + }; + + template <typename T> + struct array_selector_<T,true> + : public Function_i2b< i2v::array<T> > + { + }; + + } // end of namespace mln::fun::i2v::internal + + template <typename T> - class array : public Function_i2v< array<T> >, - public internal::array_base<T> + class array : public internal::array_selector_<T,mlc_equal(T,bool)::value>, + public fun::internal::array_base<T> { - typedef internal::array_base<T> super_base_; + typedef fun::internal::array_base<T> super_base_; public: /// Mutable result type. The function results can be modified. typedef typename super_base_::mutable_result mutable_result; + typedef typename fun::internal::array_base<T>::result result; /// Constructors /// \{ @@ -175,7 +195,15 @@ namespace mln { mlc_converts_to(T,U)::check(); - for (unsigned i = 0; i < from.nelements(); ++i) + to.reserve(from.nelements()); + + //Special case. Handle background component data. + if (from[0].is_valid()) + to.append(convert::to<U>(from[0])); + else + to.append(U()); + + for (unsigned i = 1; i < from.nelements(); ++i) to.append(convert::to<U>(from[i])); } @@ -194,7 +222,15 @@ namespace mln { mlc_converts_to(T,U)::check(); - for (unsigned i = 0; i < from.size(); ++i) + to.reserve(from.nelements()); + + //Special case. Handle background component data. + if (from[0].is_valid()) + to.append(convert::to<U>(from[0])); + else + to.append(U()); + + for (unsigned i = 1; i < from.size(); ++i) to.append(convert::to<U>(from[i])); } diff --git a/milena/mln/io/pgm/save.hh b/milena/mln/io/pgm/save.hh index f15c0eb..5e7df76 100644 --- a/milena/mln/io/pgm/save.hh +++ b/milena/mln/io/pgm/save.hh @@ -43,8 +43,9 @@ # include <mln/io/pnm/save.hh> # include <mln/geom/size2d.hh> -# include <mln/metal/templated_by.hh> # include <mln/metal/bexpr.hh> +# include <mln/metal/is_not_a.hh> +# include <mln/value/concept/vectorial.hh> namespace mln @@ -78,11 +79,10 @@ namespace mln inline void save(const Image<I>& ima, const std::string& filename) { - // FIXME : this is too restrictive. Check if I is compatible with PGM. - // mln::metal::or_< - // mln::metal::templated_by<mln_value(I), value::int_u >, - // mln::metal::templated_by<mln_value(I), value::int_u_sat > - // >::check(); + // FIXME: Is it exhaustive? + mlc_is_not_a(mln_value(I), value::Vectorial)::check(); + mlc_converts_to(mln_value(I),unsigned)::check(); + trace::entering("mln::io::pgm::save"); io::pnm::save(PGM, exact(ima), filename); trace::exiting("mln::io::pgm::save"); diff --git a/milena/mln/labeling/level.hh b/milena/mln/labeling/level.hh index 11b3a06..677b027 100644 --- a/milena/mln/labeling/level.hh +++ b/milena/mln/labeling/level.hh @@ -111,9 +111,9 @@ namespace mln bool handles(const P& p) const { return input(p) == val; } bool equiv(const P& n, const P&) const { return input(n) == val; } bool labels(const P&) const { return true; } - void do_no_union(const P& n, const P& p) {} + void do_no_union(const P&, const P&) {} void init_attr(const P&) {} - void merge_attr(const P& r, const P& p) {} + void merge_attr(const P&, const P&) {} // Fastest implementation diff --git a/milena/mln/labeling/regional_maxima.hh b/milena/mln/labeling/regional_maxima.hh index c7c2d53..ae2c8f4 100644 --- a/milena/mln/labeling/regional_maxima.hh +++ b/milena/mln/labeling/regional_maxima.hh @@ -95,7 +95,7 @@ namespace mln // Fastest implementation void init_() { data::fill(attr, true); } - bool handles_(unsigned p) const { return true; } + bool handles_(unsigned) const { return true; } bool labels_(unsigned p) const { return attr.element(p); } bool equiv_(unsigned n, unsigned p) const { return input.element(n) == input.element(p); } diff --git a/milena/mln/labeling/relabel.hh b/milena/mln/labeling/relabel.hh index 867a0fb..47ca647 100644 --- a/milena/mln/labeling/relabel.hh +++ b/milena/mln/labeling/relabel.hh @@ -187,7 +187,7 @@ namespace mln typedef fun::l2l::relabel<mln_value(I)> fv2v_t; fv2v_t fv2v = make::relabelfun(fv2b, nlabels, new_nlabels); - mln_concrete(I) output = labeling::relabel(label, nlabels, new_nlabels, fv2v); + mln_concrete(I) output = labeling::relabel(label, new_nlabels, fv2v); trace::exiting("labeling::relabel"); return output; diff --git a/milena/mln/make/graph.hh b/milena/mln/make/graph.hh index c9dddb1..9c0f33e 100644 --- a/milena/mln/make/graph.hh +++ b/milena/mln/make/graph.hh @@ -34,6 +34,9 @@ /// Create a graph from an influence zone image. /// /// \sa transform::influence_zone_geodesic. +/// +/// \todo Add dispatch for fast images. +/// \todo Use an adjacency matrix when available in the library. # include <mln/core/concept/image.hh> # include <mln/core/concept/neighborhood.hh> @@ -100,6 +103,7 @@ namespace mln mln::image2d<bool> adj(mln::box2d(nlabels.next(), nlabels.next())); data::fill(adj, false); + extension::adjust_fill(iz, nbh, 0u); typedef mln_value(I) L; mln_piter(I) p(iz.domain()); diff --git a/milena/mln/util/array.hh b/milena/mln/util/array.hh index da7c40c..9e646a5 100644 --- a/milena/mln/util/array.hh +++ b/milena/mln/util/array.hh @@ -56,7 +56,6 @@ namespace mln } // end of namespace mln::util - namespace convert { @@ -174,8 +173,12 @@ namespace mln /// Operator<<. template <typename T> std::ostream& operator<<(std::ostream& ostr, - const mln::util::array<T>& a); + const array<T>& a); + /// Operator== + template <typename T> + bool operator==(const array<T>& lhs, + const array<T>& rhs); // array_fwd_iter<T> @@ -272,6 +275,48 @@ namespace mln } // end of namespace mln::util + namespace internal + { + + template <typename T, typename E> + struct subject_impl<const util::array<T>&, E> + { + unsigned nelements() const; + bool is_empty() const; + const T& operator[](unsigned i) const; + const std::vector<T>& std_vector() const; + + private: + const E& exact_() const; + }; + + + template <typename T, typename E> + struct subject_impl<util::array<T>&, E> + : subject_impl<const util::array<T>&, E> + { + void reserve(unsigned n); + void resize(unsigned n); + void resize(unsigned n, const T& value); + + util::array<T>& append(const T& elt); + + template <typename U> + util::array<T>& append(const util::array<U>& other); + + T& operator[](unsigned i); + + void clear(); + + std::vector<T>& hook_std_vector_(); + + private: + E& exact_(); + }; + + + } // end of namespace mln::internal + # ifndef MLN_INCLUDE_ONLY @@ -288,9 +333,18 @@ namespace mln void from_to_(const util::array<T1>& from, util::array<T2>& to) { - to.resize(from.nelements()); - for (unsigned i = 0; i < from.nelements(); ++i) - from_to(from[i], to[i]); + mlc_converts_to(T1,T2)::check(); + + to.reserve(from.nelements()); + + //Special case. Handle background component data. + if (from[0].is_valid()) + to.append(convert::to<T2>(from[0])); + else + to.append(T2()); + + for (unsigned i = 1; i < from.nelements(); ++i) + to.append(convert::to<T2>(from[i])); } } // end of namespace mln::convert::over_load @@ -628,7 +682,7 @@ namespace mln template <typename T> std::ostream& operator<<(std::ostream& ostr, - const mln::util::array<T>& a) + const array<T>& a) { ostr << '['; const unsigned n = a.nelements(); @@ -642,12 +696,141 @@ namespace mln return ostr; } + + // Operator <<. + + template <typename T> + bool operator==(const array<T>& lhs, + const array<T>& rhs) + { + return lhs.std_vector() == rhs.std_vector(); + } + } // end of namespace mln::util -# endif // ! MLN_INCLUDE_ONLY + namespace internal + { + + template <typename T, typename E> + inline + void + subject_impl<util::array<T>&, E>::reserve(unsigned n) + { + exact_().get_subject().reserve(n); + } + + template <typename T, typename E> + inline + void + subject_impl<util::array<T>&, E>::resize(unsigned n) + { + exact_().get_subject().resize(n); + } + + template <typename T, typename E> + inline + void + subject_impl<util::array<T>&, E>::resize(unsigned n, const T& value) + { + exact_().get_subject().resize(n, value); + } + + template <typename T, typename E> + inline + util::array<T>& + subject_impl<util::array<T>&, E>::append(const T& elt) + { + return exact_().get_subject().append(elt); + } + + template <typename T, typename E> + template <typename U> + inline + util::array<T>& + subject_impl<util::array<T>&, E>::append(const util::array<U>& other) + { + return exact_().get_subject().append(other); + } + + template <typename T, typename E> + inline + T& + subject_impl<util::array<T>&, E>::operator[](unsigned i) + { + return exact_().get_subject()[i]; + } + + template <typename T, typename E> + inline + void + subject_impl<util::array<T>&, E>::clear() + { + exact_().get_subject().clear(); + } + + template <typename T, typename E> + inline + std::vector<T>& + subject_impl<util::array<T>&, E>::hook_std_vector_() + { + return exact_().get_subject().hook_std_vector_(); + } + + template <typename T, typename E> + inline + E& + subject_impl<util::array<T>&, E >::exact_() + { + return internal::force_exact<E>(*this); + } + template <typename T, typename E> + inline + unsigned + subject_impl<const util::array<T>&, E>::nelements() const + { + return exact_().get_subject().nelements(); + } + + template <typename T, typename E> + inline + bool + subject_impl<const util::array<T>&, E>::is_empty() const + { + return exact_().get_subject().is_empty(); + } + + template <typename T, typename E> + inline + const T& + subject_impl<const util::array<T>&, E>::operator[](unsigned i) const + { + return exact_().get_subject()[i]; + } + + template <typename T, typename E> + inline + const std::vector<T>& + subject_impl<const util::array<T>&, E>::std_vector() const + { + return exact_().get_subject().std_vector(); + } + + template <typename T, typename E> + inline + const E& + subject_impl<const util::array<T>&, E >::exact_() const + { + return internal::force_exact<const E>(*this); + } + + + } // end of namespace mln::internal + +# endif // ! MLN_INCLUDE_ONLY + } // end of namespace mln diff --git a/milena/tests/accu/site_set/rectangularity.cc b/milena/tests/accu/site_set/rectangularity.cc index 22e1e3e..ee6b6d1 100644 --- a/milena/tests/accu/site_set/rectangularity.cc +++ b/milena/tests/accu/site_set/rectangularity.cc @@ -29,11 +29,12 @@ /// /// Tests on mln::accu::site_set::rectangularity. - +#include <mln/core/image/image2d.hh> #include <mln/core/alias/point2d.hh> #include <mln/core/alias/box2d.hh> #include <mln/accu/site_set/rectangularity.hh> +#include <mln/set/compute.hh> int main() { @@ -53,8 +54,18 @@ int main() accu::site_set::rectangularity<point2d> accu; accu.take(point2d(0,0)); accu.take(point2d(1,1)); - std::cout << accu << std::endl; mln_assertion(accu.to_result() == 0.5f); } + + { + box2d b(2,2); + float r = set::compute(accu::site_set::rectangularity<point2d>(), b); + mln_assertion(r == 1.0f); + } + + { + accu::site_set::rectangularity<point2d> a; + accu::site_set::rectangularity<point2d> b = exact(a); + } } diff --git a/milena/tests/unit_test/unit-tests.mk b/milena/tests/unit_test/unit-tests.mk index 1449e41..d88724b 100644 --- a/milena/tests/unit_test/unit-tests.mk +++ b/milena/tests/unit_test/unit-tests.mk @@ -112,7 +112,6 @@ mln_data_memcpy_ \ mln_data_all \ mln_data_paste \ mln_data_fill_with_image \ -mln_data_swap \ mln_data_fill_with_value \ mln_data_fill \ mln_data_essential \ @@ -326,6 +325,7 @@ mln_value_all \ mln_value_super_value \ mln_value_builtin_symbolics \ mln_value_builtin_ops \ +mln_value_builtin_carrays \ mln_value_builtin_all \ mln_value_builtin_promotions \ mln_value_builtin_integers \ @@ -368,6 +368,9 @@ mln_value_label_8 \ mln_value_essential \ mln_accu_tuple \ mln_accu_min_h \ +mln_accu_site_set_rectangularity \ +mln_accu_site_set_all \ +mln_accu_site_set_essential \ mln_accu_stat_deviation \ mln_accu_max \ mln_accu_lor \ @@ -375,6 +378,7 @@ mln_accu_rank \ mln_accu_transform_stop \ mln_accu_maj_h \ mln_accu_min_max \ +mln_accu_internal_couple \ mln_accu_internal_base \ mln_accu_transform_snake \ mln_accu_rank_high_quant \ @@ -412,6 +416,7 @@ mln_accu_image_all \ mln_accu_image_set_value \ mln_accu_image_take \ mln_accu_image_take_as_init \ +mln_accu_image_essential \ mln_accu_center \ mln_accu_line \ mln_accu_essential \ @@ -472,8 +477,11 @@ mln_trait_promote \ mln_trait_solve_binary \ mln_trait_value_ \ mln_trait_all \ +mln_trait_value_internal_all \ +mln_trait_value_internal_comp \ mln_trait_value_all \ mln_trait_value_nature \ +mln_trait_value_comp \ mln_trait_value_quant \ mln_trait_value_kind \ mln_trait_value_print \ @@ -644,7 +652,6 @@ mln_morpho_closing_leveling \ mln_morpho_closing_area_on_vertices \ mln_morpho_closing_area \ mln_morpho_closing_volume \ -mln_morpho_closing_sum \ mln_morpho_closing_height \ mln_morpho_closing_structural \ mln_morpho_closing_essential \ @@ -995,6 +1002,7 @@ mln_test_predicate \ mln_test_all \ mln_test_positive \ mln_test_essential \ +mln_transform_distance_and_closest_point_geodesic \ mln_transform_distance_geodesic \ mln_transform_internal_all \ mln_transform_internal_closest_point_functor \ @@ -1002,9 +1010,9 @@ mln_transform_internal_distance_functor \ mln_transform_internal_influence_zone_functor \ mln_transform_all \ mln_transform_influence_zone_front \ +mln_transform_distance_and_influence_zone_geodesic \ mln_transform_distance_front \ mln_transform_influence_zone_geodesic \ -mln_transform_closest_point_geodesic \ mln_transform_essential \ mln_arith_includes \ mln_arith_plus \ @@ -1221,7 +1229,6 @@ mln_data_memcpy__SOURCES = mln_data_memcpy_.cc mln_data_all_SOURCES = mln_data_all.cc mln_data_paste_SOURCES = mln_data_paste.cc mln_data_fill_with_image_SOURCES = mln_data_fill_with_image.cc -mln_data_swap_SOURCES = mln_data_swap.cc mln_data_fill_with_value_SOURCES = mln_data_fill_with_value.cc mln_data_fill_SOURCES = mln_data_fill.cc mln_data_essential_SOURCES = mln_data_essential.cc @@ -1435,6 +1442,7 @@ mln_value_all_SOURCES = mln_value_all.cc mln_value_super_value_SOURCES = mln_value_super_value.cc mln_value_builtin_symbolics_SOURCES = mln_value_builtin_symbolics.cc mln_value_builtin_ops_SOURCES = mln_value_builtin_ops.cc +mln_value_builtin_carrays_SOURCES = mln_value_builtin_carrays.cc mln_value_builtin_all_SOURCES = mln_value_builtin_all.cc mln_value_builtin_promotions_SOURCES = mln_value_builtin_promotions.cc mln_value_builtin_integers_SOURCES = mln_value_builtin_integers.cc @@ -1477,6 +1485,9 @@ mln_value_label_8_SOURCES = mln_value_label_8.cc mln_value_essential_SOURCES = mln_value_essential.cc mln_accu_tuple_SOURCES = mln_accu_tuple.cc mln_accu_min_h_SOURCES = mln_accu_min_h.cc +mln_accu_site_set_rectangularity_SOURCES = mln_accu_site_set_rectangularity.cc +mln_accu_site_set_all_SOURCES = mln_accu_site_set_all.cc +mln_accu_site_set_essential_SOURCES = mln_accu_site_set_essential.cc mln_accu_stat_deviation_SOURCES = mln_accu_stat_deviation.cc mln_accu_max_SOURCES = mln_accu_max.cc mln_accu_lor_SOURCES = mln_accu_lor.cc @@ -1484,6 +1495,7 @@ mln_accu_rank_SOURCES = mln_accu_rank.cc mln_accu_transform_stop_SOURCES = mln_accu_transform_stop.cc mln_accu_maj_h_SOURCES = mln_accu_maj_h.cc mln_accu_min_max_SOURCES = mln_accu_min_max.cc +mln_accu_internal_couple_SOURCES = mln_accu_internal_couple.cc mln_accu_internal_base_SOURCES = mln_accu_internal_base.cc mln_accu_transform_snake_SOURCES = mln_accu_transform_snake.cc mln_accu_rank_high_quant_SOURCES = mln_accu_rank_high_quant.cc @@ -1521,6 +1533,7 @@ mln_accu_image_all_SOURCES = mln_accu_image_all.cc mln_accu_image_set_value_SOURCES = mln_accu_image_set_value.cc mln_accu_image_take_SOURCES = mln_accu_image_take.cc mln_accu_image_take_as_init_SOURCES = mln_accu_image_take_as_init.cc +mln_accu_image_essential_SOURCES = mln_accu_image_essential.cc mln_accu_center_SOURCES = mln_accu_center.cc mln_accu_line_SOURCES = mln_accu_line.cc mln_accu_essential_SOURCES = mln_accu_essential.cc @@ -1581,8 +1594,11 @@ mln_trait_promote_SOURCES = mln_trait_promote.cc mln_trait_solve_binary_SOURCES = mln_trait_solve_binary.cc mln_trait_value__SOURCES = mln_trait_value_.cc mln_trait_all_SOURCES = mln_trait_all.cc +mln_trait_value_internal_all_SOURCES = mln_trait_value_internal_all.cc +mln_trait_value_internal_comp_SOURCES = mln_trait_value_internal_comp.cc mln_trait_value_all_SOURCES = mln_trait_value_all.cc mln_trait_value_nature_SOURCES = mln_trait_value_nature.cc +mln_trait_value_comp_SOURCES = mln_trait_value_comp.cc mln_trait_value_quant_SOURCES = mln_trait_value_quant.cc mln_trait_value_kind_SOURCES = mln_trait_value_kind.cc mln_trait_value_print_SOURCES = mln_trait_value_print.cc @@ -1753,7 +1769,6 @@ mln_morpho_closing_leveling_SOURCES = mln_morpho_closing_leveling.cc mln_morpho_closing_area_on_vertices_SOURCES = mln_morpho_closing_area_on_vertices.cc mln_morpho_closing_area_SOURCES = mln_morpho_closing_area.cc mln_morpho_closing_volume_SOURCES = mln_morpho_closing_volume.cc -mln_morpho_closing_sum_SOURCES = mln_morpho_closing_sum.cc mln_morpho_closing_height_SOURCES = mln_morpho_closing_height.cc mln_morpho_closing_structural_SOURCES = mln_morpho_closing_structural.cc mln_morpho_closing_essential_SOURCES = mln_morpho_closing_essential.cc @@ -2104,6 +2119,7 @@ mln_test_predicate_SOURCES = mln_test_predicate.cc mln_test_all_SOURCES = mln_test_all.cc mln_test_positive_SOURCES = mln_test_positive.cc mln_test_essential_SOURCES = mln_test_essential.cc +mln_transform_distance_and_closest_point_geodesic_SOURCES = mln_transform_distance_and_closest_point_geodesic.cc mln_transform_distance_geodesic_SOURCES = mln_transform_distance_geodesic.cc mln_transform_internal_all_SOURCES = mln_transform_internal_all.cc mln_transform_internal_closest_point_functor_SOURCES = mln_transform_internal_closest_point_functor.cc @@ -2111,9 +2127,9 @@ mln_transform_internal_distance_functor_SOURCES = mln_transform_internal_distanc mln_transform_internal_influence_zone_functor_SOURCES = mln_transform_internal_influence_zone_functor.cc mln_transform_all_SOURCES = mln_transform_all.cc mln_transform_influence_zone_front_SOURCES = mln_transform_influence_zone_front.cc +mln_transform_distance_and_influence_zone_geodesic_SOURCES = mln_transform_distance_and_influence_zone_geodesic.cc mln_transform_distance_front_SOURCES = mln_transform_distance_front.cc mln_transform_influence_zone_geodesic_SOURCES = mln_transform_influence_zone_geodesic.cc -mln_transform_closest_point_geodesic_SOURCES = mln_transform_closest_point_geodesic.cc mln_transform_essential_SOURCES = mln_transform_essential.cc mln_arith_includes_SOURCES = mln_arith_includes.cc mln_arith_plus_SOURCES = mln_arith_plus.cc @@ -2137,6 +2153,8 @@ mln_io_cloud_load_SOURCES = mln_io_cloud_load.cc mln_io_cloud_all_SOURCES = mln_io_cloud_all.cc mln_io_cloud_save_SOURCES = mln_io_cloud_save.cc mln_io_all_SOURCES = mln_io_all.cc +mln_io_magick_load_SOURCES = mln_io_magick_load.cc +mln_io_magick_all_SOURCES = mln_io_magick_all.cc mln_io_dump_load_SOURCES = mln_io_dump_load.cc mln_io_dump_all_SOURCES = mln_io_dump_all.cc mln_io_dump_save_SOURCES = mln_io_dump_save.cc -- 1.5.6.5
participants (1)
-
Guillaume Lazzara