
* mln/accu/max_site.hh: add a missing include. * mln/fun/x2x/rotation.hh: Replace 'float' by 'C', the template parameter. * mln/fun/x2x/translation.hh: fix header. * mln/graph/attribute/representative.hh: avoid a warning. * mln/make/p_edges_with_mass_centers.hh, * mln/make/p_vertices_with_mass_centers.hh: improve interface. * mln/math/pi.hh: use a more precise value. * mln/topo/skeleton/crest.hh: add more documentation. * mln/transformation/all.hh: fix wrong include. * tests/make/p_edges_with_mass_centers.cc, * tests/make/p_vertices_with_mass_centers.cc: update the call of the routine. * tests/transformation/rotate.cc: fix wrong reference result. * tests/util/Makefile.am: remove a non existing test. --- milena/ChangeLog | 30 +++++++++++++ milena/mln/accu/max_site.hh | 1 + milena/mln/fun/x2x/rotation.hh | 48 ++++++++++---------- milena/mln/fun/x2x/translation.hh | 2 +- milena/mln/graph/attribute/representative.hh | 2 +- milena/mln/make/p_edges_with_mass_centers.hh | 5 +- milena/mln/make/p_vertices_with_mass_centers.hh | 5 +- milena/mln/math/pi.hh | 2 +- milena/mln/topo/skeleton/crest.hh | 34 +++++++++++++++ milena/mln/transformation/all.hh | 2 +- milena/tests/make/p_edges_with_mass_centers.cc | 2 +- milena/tests/make/p_vertices_with_mass_centers.cc | 2 +- milena/tests/transformation/rotate.cc | 4 +- milena/tests/util/Makefile.am | 1 - 14 files changed, 101 insertions(+), 39 deletions(-) diff --git a/milena/ChangeLog b/milena/ChangeLog index 83247d6..310c143 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,5 +1,35 @@ 2009-05-18 Guillaume Lazzara <lazzara@lrde.epita.fr> + Small fixes. + + * mln/accu/max_site.hh: add a missing include. + + * mln/fun/x2x/rotation.hh: Replace 'float' by 'C', the template + parameter. + + * mln/fun/x2x/translation.hh: fix header. + + * mln/graph/attribute/representative.hh: avoid a warning. + + * mln/make/p_edges_with_mass_centers.hh, + * mln/make/p_vertices_with_mass_centers.hh: improve interface. + + * mln/math/pi.hh: use a more precise value. + + * mln/topo/skeleton/crest.hh: add more documentation. + + * mln/transformation/all.hh: fix wrong include. + + * tests/make/p_edges_with_mass_centers.cc, + * tests/make/p_vertices_with_mass_centers.cc: update the call of the + routine. + + * tests/transformation/rotate.cc: fix wrong reference result. + + * tests/util/Makefile.am: remove a non existing test. + +2009-05-18 Guillaume Lazzara <lazzara@lrde.epita.fr> + Fix nondeterminism in generators. * doc/generate_dist_files.sh, diff --git a/milena/mln/accu/max_site.hh b/milena/mln/accu/max_site.hh index 56bd2c2..2f9358c 100644 --- a/milena/mln/accu/max_site.hh +++ b/milena/mln/accu/max_site.hh @@ -35,6 +35,7 @@ /// /// \todo Use accu::pair just like in accu::min_max. +# include <mln/core/concept/meta_accumulator.hh> # include <mln/accu/internal/base.hh> # include <mln/util/pix.hh> diff --git a/milena/mln/fun/x2x/rotation.hh b/milena/mln/fun/x2x/rotation.hh index b38cffb..04938d3 100644 --- a/milena/mln/fun/x2x/rotation.hh +++ b/milena/mln/fun/x2x/rotation.hh @@ -62,14 +62,14 @@ namespace mln { template < unsigned n, typename C > algebra::h_mat<n, C> - get_rot_h_mat(const float alpha_, const algebra::vec<n,C>& axis_) + get_rot_h_mat(const C alpha_, const algebra::vec<n,C>& axis_) { mln_assertion(!"get_h_mat : n not implemented"); } template <typename C > algebra::h_mat<3, C> - get_rot_h_mat(const float alpha_, const algebra::vec<3,C>& axis_) + get_rot_h_mat(const C alpha_, const algebra::vec<3,C>& axis_) { //test axis is valid typedef algebra::vec<3,C> vec_t; @@ -80,14 +80,14 @@ namespace mln algebra::vec<3,C> axis = axis_; axis.normalize(); - const float cos_a = cos(alpha_); - const float sin_a = sin(alpha_); - const float u = axis_[0]; - const float v = axis_[1]; - const float w = axis_[2]; - const float u2 = u * u; - const float v2 = v * v; - const float w2 = w * w; + const C cos_a = cos(alpha_); + const C sin_a = sin(alpha_); + const C u = axis_[0]; + const C v = axis_[1]; + const C w = axis_[2]; + const C u2 = u * u; + const C v2 = v * v; + const C w2 = w * w; algebra::h_mat<3, C> m_; @@ -116,10 +116,10 @@ namespace mln template <typename C > algebra::h_mat<2, C> - get_rot_h_mat(const float alpha_, const algebra::vec<2,C>&) + get_rot_h_mat(const C alpha_, const algebra::vec<2,C>&) { - const float cos_a = cos(alpha_); - const float sin_a = sin(alpha_); + const C cos_a = cos(alpha_); + const C sin_a = sin(alpha_); algebra::h_mat<2, C> m_; @@ -149,7 +149,7 @@ namespace mln /// Constructor without argument. rotation(); /// Constructor with radian alpha and a facultative direction (rotation axis). - rotation(float alpha, const algebra::vec<n,float>& axis); + rotation(C alpha, const algebra::vec<n,C>& axis); /// Constructor with quaternion rotation(const algebra::quat& q); /// Constructor with h_mat. @@ -160,9 +160,9 @@ namespace mln algebra::vec<n,C> operator()(const algebra::vec<n,C>& v) const; /// Set a new grade alpha. - void set_alpha(float alpha); + void set_alpha(C alpha); /// Set a new rotation axis. - void set_axis(const algebra::vec<n,float>& axis); + void set_axis(const algebra::vec<n,C>& axis); protected: void update(); @@ -170,8 +170,8 @@ namespace mln /// FIXME: Is it useful? - float alpha_; - algebra::vec <n,float> axis_; + C alpha_; + algebra::vec <n,C> axis_; }; @@ -185,7 +185,7 @@ namespace mln template <unsigned n, typename C> inline - rotation<n,C>::rotation(float alpha, const algebra::vec<n,float>& axis) + rotation<n,C>::rotation(C alpha, const algebra::vec<n,C>& axis) :alpha_(alpha), axis_(axis) { @@ -201,13 +201,13 @@ namespace mln mlc_bool(n == 3)::check(); mln_precondition(q.is_unit()); - float + C w = q.to_vec()[0], x = q.to_vec()[1], x2 = 2*x*x, xw = 2*x*w, y = q.to_vec()[2], y2 = 2*y*y, xy = 2*x*y, yw = 2*y*w, z = q.to_vec()[3], z2 = 2*z*z, xz = 2*x*z, yz = 2*y*z, zw = 2*z*w; - float t[9] = {1.f - y2 - z2, xy - zw, xz + yw, + C t[9] = {1.f - y2 - z2, xy - zw, xz + yw, xy + zw, 1.f - x2 - z2, yz - xw, xz - yw, yz + xw, 1.f - x2 - y2}; @@ -262,7 +262,7 @@ namespace mln template <unsigned n, typename C> inline void - rotation<n,C>::set_alpha(float alpha) + rotation<n,C>::set_alpha(C alpha) { alpha_ = alpha; update(); @@ -271,7 +271,7 @@ namespace mln template <unsigned n, typename C> inline void - rotation<n,C>::set_axis(const algebra::vec<n,float>& axis) + rotation<n,C>::set_axis(const algebra::vec<n,C>& axis) { axis_ = axis; update(); @@ -300,7 +300,7 @@ namespace mln p = tmp / norm::l2(tmp), p_rot_1 = q.rotate(p), p_rot_2 = (*this)(p); - return norm::l2(p_rot_1 - p_rot_2) < mln_epsilon(float); + return norm::l2(p_rot_1 - p_rot_2) < mln_epsilon(C); } # endif // ! MLN_INCLUDE_ONLY diff --git a/milena/mln/fun/x2x/translation.hh b/milena/mln/fun/x2x/translation.hh index a6e8a39..e30d27c 100644 --- a/milena/mln/fun/x2x/translation.hh +++ b/milena/mln/fun/x2x/translation.hh @@ -1,5 +1,5 @@ // Copyright (C) 2007, 2009 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 // of the GNU General Public License version 2 as published by the diff --git a/milena/mln/graph/attribute/representative.hh b/milena/mln/graph/attribute/representative.hh index 88ed258..584b3aa 100644 --- a/milena/mln/graph/attribute/representative.hh +++ b/milena/mln/graph/attribute/representative.hh @@ -86,7 +86,7 @@ namespace mln deja_vu_[id] = true; } - void process_vertex(unsigned id) + void process_vertex(unsigned) {} bool to_be_queued(unsigned id) diff --git a/milena/mln/make/p_edges_with_mass_centers.hh b/milena/mln/make/p_edges_with_mass_centers.hh index 8a1db50..eb9269d 100644 --- a/milena/mln/make/p_edges_with_mass_centers.hh +++ b/milena/mln/make/p_edges_with_mass_centers.hh @@ -61,7 +61,6 @@ namespace mln /// adjacent regions. /// /// \param wst_ A watershed image. - /// \param nbasins The number of basins. /// \param g_ A region adjacency graph. /// /// \return A p_edges. @@ -72,7 +71,6 @@ namespace mln inline p_edges<G, fun::i2v::array<util::site_pair<mln_site(W)> > > p_edges_with_mass_centers(const Image<W>& wst_, - const mln_value(W)& nbasins, const Graph<G>& g_); @@ -83,7 +81,6 @@ namespace mln inline p_edges<G, fun::i2v::array<util::site_pair<mln_site(W)> > > p_edges_with_mass_centers(const Image<W>& wst_, - const mln_value(W)& nbasins, const Graph<G>& g_) { trace::entering("make::p_edges_with_mass_centers"); @@ -95,6 +92,8 @@ namespace mln typedef mln_site(W) P; + // nbasins does not include the background label. + mln_value(W) nbasins = g.v_nmax() - 1; util::array<mln_vec(P)> mass_centers = labeling::compute(accu::center<P>(), wst, nbasins); diff --git a/milena/mln/make/p_vertices_with_mass_centers.hh b/milena/mln/make/p_vertices_with_mass_centers.hh index 064cdbc..cb7db48 100644 --- a/milena/mln/make/p_vertices_with_mass_centers.hh +++ b/milena/mln/make/p_vertices_with_mass_centers.hh @@ -57,7 +57,6 @@ namespace mln /// corresponding region. /// /// \param wst_ A watershed image. - /// \param nbasins The number of basins. /// \param g_ A region adjacency graph. /// /// \return A p_vertices. @@ -68,7 +67,6 @@ namespace mln inline p_vertices<G, fun::i2v::array<mln_site(W)> > p_vertices_with_mass_centers(const Image<W>& wst_, - const mln_value(W)& nbasins, const Graph<G>& g_); @@ -79,7 +77,6 @@ namespace mln inline p_vertices<G, fun::i2v::array<mln_site(W)> > p_vertices_with_mass_centers(const Image<W>& wst_, - const mln_value(W)& nbasins, const Graph<G>& g_) { trace::entering("make::p_vertices_with_mass_centers"); @@ -92,6 +89,8 @@ namespace mln typedef mln_site(W) P; typedef fun::i2v::array<P> vertex_sites_t; + // nbasins does not include the background label. + mln_value(W) nbasins = g.v_nmax() - 1; vertex_sites_t vertex_sites; convert::from_to(labeling::compute(accu::center<P>(), wst, nbasins), vertex_sites); diff --git a/milena/mln/math/pi.hh b/milena/mln/math/pi.hh index 08f6d07..581b236 100644 --- a/milena/mln/math/pi.hh +++ b/milena/mln/math/pi.hh @@ -39,7 +39,7 @@ namespace mln # ifndef MLN_INCLUDE_ONLY - const double pi = 3.1415926535; + const double pi = 3.1415926535897932385; # endif // ! MLN_INCLUDE_ONLY diff --git a/milena/mln/topo/skeleton/crest.hh b/milena/mln/topo/skeleton/crest.hh index 432b57c..db7a617 100644 --- a/milena/mln/topo/skeleton/crest.hh +++ b/milena/mln/topo/skeleton/crest.hh @@ -32,6 +32,11 @@ /// /// Compute skeletization constraints. +# include <mln/core/concept/image.hh> +# include <mln/core/concept/neighborhood.hh> + +# include <mln/data/fill.hh> + namespace mln { @@ -52,6 +57,35 @@ namespace mln /// /// \result A binary image. // + /*! + * + * This implementation is based on the following article: + * K. W. Kang, J. W. Suh, and J. H. Kim. Skeletonization of grayscale + * character images using pixel superiority index. In Proc. 3rd IAPR + * Workshop on Document Analysis Systems, pages 326-335, Nagano, + * Japan, 1998. + * + * Abstract: + * "In this paper, we present pixel superiority index as a tool for + * designing a skeletonization algorithm which utilizes topographic + * features efficiently. We clarify a relationship between pixel + * superiority index and topographic features. Then, using the + * relationship, we transform a problem of skeletonization into a + * problem of skeleton growing. [...]" + * + * + * In Milena, the Pixel Superiority index is defined as follow: + * Let v = p.val(), the Pixel superiority index of p is the number of + * neighbor pixels having their value/level inferior or equal to + * p.val(). + * + * This algorithm keeps sites having their pixel superiority index + * greater than 5. + * + * For good results with 2D images, we advice you to use c8() as + * neighborhood. + * + */ template <typename I, typename D, typename N> mln_concrete(I) crest(const Image<I>& input_, const Image<D>& dist_map_, diff --git a/milena/mln/transformation/all.hh b/milena/mln/transformation/all.hh index 1379093..dd1adb8 100644 --- a/milena/mln/transformation/all.hh +++ b/milena/mln/transformation/all.hh @@ -40,6 +40,6 @@ namespace mln } // end of namespace mln -# include <mln/transformation/rotation.hh> +# include <mln/transformation/rotate.hh> # endif // ! MLN_TRANSFORMATION_ALL_HH_ diff --git a/milena/tests/make/p_edges_with_mass_centers.cc b/milena/tests/make/p_edges_with_mass_centers.cc index 967320c..04f3757 100644 --- a/milena/tests/make/p_edges_with_mass_centers.cc +++ b/milena/tests/make/p_edges_with_mass_centers.cc @@ -68,7 +68,7 @@ int main() L nbasins = 4; typedef p_edges<G,fun::i2v::array<util::site_pair<point2d> > > pe_t; - pe_t pe = make::p_edges_with_mass_centers(wst, nbasins, g); + pe_t pe = make::p_edges_with_mass_centers(wst, g); typedef util::site_pair<point2d> P; typedef p_array<P> arr_t; diff --git a/milena/tests/make/p_vertices_with_mass_centers.cc b/milena/tests/make/p_vertices_with_mass_centers.cc index 2d103df..29b3d06 100644 --- a/milena/tests/make/p_vertices_with_mass_centers.cc +++ b/milena/tests/make/p_vertices_with_mass_centers.cc @@ -66,7 +66,7 @@ int main() L nbasins = 4; typedef p_vertices<G,fun::i2v::array<point2d> > pv_t; - pv_t pv = make::p_vertices_with_mass_centers(wst, nbasins, g); + pv_t pv = make::p_vertices_with_mass_centers(wst, g); typedef p_array<point2d> arr_t; arr_t arr; diff --git a/milena/tests/transformation/rotate.cc b/milena/tests/transformation/rotate.cc index 8bdd90c..d0dfaee 100644 --- a/milena/tests/transformation/rotate.cc +++ b/milena/tests/transformation/rotate.cc @@ -34,14 +34,13 @@ # include <mln/make/image.hh> # include <mln/level/compare.hh> -# include <mln/debug/println.hh> int main() { using namespace mln; bool ref_values[][5] = { { 0, 1, 0, 0, 0 }, - { 0, 1, 1, 0, 0 }, + { 0, 0, 1, 0, 0 }, { 0, 0, 1, 1, 0 }, { 0, 0, 0, 1, 1 }, { 0, 0, 0, 0, 1 } }; @@ -56,5 +55,6 @@ int main() image2d<bool> ref = make::image(ref_values); image2d<bool> ima_rot = transformation::rotate(ima, 45); + mln_assertion(ima_rot == ref); } diff --git a/milena/tests/util/Makefile.am b/milena/tests/util/Makefile.am index 1e49416..334feb5 100644 --- a/milena/tests/util/Makefile.am +++ b/milena/tests/util/Makefile.am @@ -18,7 +18,6 @@ check_PROGRAMS = \ soft_heap \ tree \ tree_fast \ - tree_fast_to_image \ tree_to_fast adjacency_matrix_SOURCES = adjacency_matrix.cc -- 1.5.6.5
participants (1)
-
Guillaume Lazzara