1982: Add some morphological routines to Roland's sandbox.

https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox Those files were in my working copy for ages... I'll try to finish the conversion from Olena proto-1.0 to Milena someday. Index: ChangeLog from Roland Levillain <roland@lrde.epita.fr> Add some morphological routines to Roland's sandbox. * levillain/morpho/: New directory. * levillain/morpho/lower_completion.hh, * levillain/morpho/shortest_path_watershed.hh: New (imported from Olena proto-1.0). lower_completion.hh | 29 +++++++++++------ shortest_path_watershed.hh | 76 +++++++++++++++++---------------------------- 2 files changed, 49 insertions(+), 56 deletions(-) Index: levillain/morpho/lower_completion.hh --- levillain/morpho/lower_completion.hh (revision 0) +++ levillain/morpho/lower_completion.hh (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2005 EPITA Research and Development Laboratory +// Copyright (C) 2005, 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 @@ -25,15 +25,26 @@ // reasons why the executable file might be covered by the GNU General // Public License. -#ifndef OLENA_MORPHO_LOWER_COMPLETION_HH -# define OLENA_MORPHO_LOWER_COMPLETION_HH +#ifndef MLN_MORPHO_LOWER_COMPLETION_HH +# define MLN_MORPHO_LOWER_COMPLETION_HH + +/* FIXME: This file comes from Olena proto-1.0, and needs some + adjustments. + + Translate it into the Milena dialect, e.g., + - replace `oln_' and `oln::' by `mln_' and `mln::'; + - replace `internal::' by `impl::'; + - adjust the names of interfaces and types; + - adjust other names; + - adjust calling conventions; + - adjust contracts (static/dynamic pre-/postconditions, etc.); + - etc. */ # include <queue> -# include <oln/basics.hh> -# include <oln/level/fill.hh> +# include <mln/level/fill.hh> -namespace oln { +namespace mln { namespace morpho { @@ -133,8 +144,8 @@ return output; } - } // end of namespace oln::morpho + } // end of namespace mln::morpho -} // end of namespace oln +} // end of namespace mln -#endif // ! OLENA_MORPHO_LOWER_COMPLETION_HH +#endif // ! MLN_MORPHO_LOWER_COMPLETION_HH Index: levillain/morpho/shortest_path_watershed.hh --- levillain/morpho/shortest_path_watershed.hh (revision 0) +++ levillain/morpho/shortest_path_watershed.hh (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2005 EPITA Research and Development Laboratory +// Copyright (C) 2005, 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 @@ -25,52 +25,34 @@ // reasons why the executable file might be covered by the GNU General // Public License. -#ifndef OLENA_MORPHO_SHORTEST_PATH_WATERSHED_HH -# define OLENA_MORPHO_SHORTEST_PATH_WATERSHED_HH +#ifndef MLN_MORPHO_SHORTEST_PATH_WATERSHED_HH +# define MLN_MORPHO_SHORTEST_PATH_WATERSHED_HH + +/* FIXME: This file comes from Olena proto-1.0, and needs some + adjustments. + + Translate it into the Milena dialect, e.g., + - replace `oln_' and `oln::' by `mln_' and `mln::'; + - replace `internal::' by `impl::'; + - adjust the names of interfaces and types; + - adjust other names; + - adjust calling conventions; + - adjust contracts (static/dynamic pre-/postconditions, etc.); + - etc. */ # include <queue> -# include "oln/level/fill.hh" -# include "oln/level/extrema_components.hh" -# include "oln/morpho/lower_completion.hh" +# include <mln/level/fill.hh> +# include <mln/level/extrema_components.hh> +# include <mln/morpho/lower_completion.hh> +# include <mln/trait/value_.hh> -namespace oln { +namespace mln { namespace morpho { namespace internal { - /// Functor used in ordered queues of points. - template <typename I> - class greater_point_type - { - public: - typedef oln_type_of(I, point) point_type; - - greater_point_type(const abstract::image<I>& im) : - im_ (im) - { - } - - /// Is \a x greater than \a y? - bool operator()(const point_type& x, const point_type& y) - { - return im_[x] > im_[y]; - } - - private: - const abstract::image<I>& im_; - }; - - /// Facade to build a oln::level::greater_point_type. - template <typename I> - greater_point_type<I> - greater_point(const abstract::image<I>& im) - { - return greater_point_type<I>(im); - } - - // FIXME: To be rewritten. Moreover, the distance d(p, q) is not // taken into account in this version of cost (but it should not // bother us as long as we are using first-order neighborhoods). @@ -107,16 +89,16 @@ typename ch_value_type<I, DestValue>::ret shortest_path_watershed_(const abstract::image_with_nbh<I>& input) { - mlc_is_a(I, abstract::scalar_valued_image)::ensure(); + // FIXME: Ensure the input image has scalar values. - const DestValue wshed = ntg_min_val(DestValue); + const DestValue wshed = min_val(DestValue); // We keep a track of already processed points. typename ch_value_type<I, bool>::ret processed (input.size(), input.nbh_get()); level::fill (processed, false); - // Initialise output with the minima components. + // Initialize output with the minima components. typename ch_value_type<I, DestValue>::ret output = level::minima_components<DestValue>(input); @@ -139,9 +121,9 @@ typedef std::priority_queue<point_type, std::vector<point_type>, - internal::greater_point_type<dist_type> > + util::greater_point<dist_type> > ordered_queue_type; - ordered_queue_type q(internal::greater_point(dist)); + ordered_queue_type q(util::make_greater_point(dist)); // Fill the ordered queue with the points of the border of the // minima of the (lower complete) input. for_all_p (p) @@ -197,7 +179,7 @@ return output; } - } // End of namespace oln::morpho::internal. + } // End of namespace mln::morpho::internal. /*! Watershed transform w.r.t. topographical distance based on @@ -231,8 +213,8 @@ return internal::shortest_path_watershed_<DestValue>(input); } - } // end of namespace oln::morpho + } // end of namespace mln::morpho -} // end of namespace oln +} // end of namespace mln -#endif // ! OLENA_MORPHO_SHORTEST_PATH_WATERSHED_HH +#endif // ! MLN_MORPHO_SHORTEST_PATH_WATERSHED_HH
participants (1)
-
Roland Levillain