* mln/convert/to_p_array.hh: move conversion from here...
* mln/convert/impl/from_image_to_site_set.hh: to here... And update
dispatch accordingly.
* tests/registration/multiscale.cc: use a smaller image.
---
milena/ChangeLog | 10 ++
milena/mln/convert/impl/from_image_to_site_set.hh | 125 +++++++++++++--------
milena/mln/convert/to_p_array.hh | 10 +-
milena/tests/registration/multiscale.cc | 16 ++-
4 files changed, 103 insertions(+), 58 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 3427ea1..e8d9456 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,13 @@
+2009-01-27 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Fix conversion from Image to p_array.
+
+ * mln/convert/to_p_array.hh: move conversion from here...
+ * mln/convert/impl/from_image_to_site_set.hh: to here... And update
+ dispatch accordingly.
+
+ * tests/registration/multiscale.cc: use a smaller image.
+
2009-01-27 Ugo Jardonnet <jardonnet(a)lrde.epita.fr>
Fix mln::registration::multiscale test.
diff --git a/milena/mln/convert/impl/from_image_to_site_set.hh
b/milena/mln/convert/impl/from_image_to_site_set.hh
index 6304117..4effab4 100644
--- a/milena/mln/convert/impl/from_image_to_site_set.hh
+++ b/milena/mln/convert/impl/from_image_to_site_set.hh
@@ -65,18 +65,20 @@ namespace mln
# ifndef MLN_INCLUDE_ONLY
-
- // Case: binary image -> set of point runs.
-
- template <typename I, typename P, typename S>
- void
- from_image_to_site_set_(const I& input, const Gpoint<P>&,
- S& s, const mln::p_run<P>&)
+ namespace internal
{
- s.clear();
- mln_fwd_piter(I) p(input.domain());
- p.start();
- for (;;)
+
+ // Case: binary image -> set of point runs.
+
+ template <typename I, typename P, typename S>
+ void
+ from_image_to_site_set(const I& input, const Gpoint<P>&,
+ S& s, const mln::p_run<P>&)
+ {
+ s.clear();
+ mln_fwd_piter(I) p(input.domain());
+ p.start();
+ for (;;)
{
// Skip background.
while (p.is_valid() && input(p) == false)
@@ -87,28 +89,29 @@ namespace mln
P start = p, q;
// Go to run end.
do
- {
- q = p;
- p.next();
- }
+ {
+ q = p;
+ p.next();
+ }
while (p.is_valid() && input(p) == true &&
- // p follows q in a run, i.e., "p == q + right":
- cut_(p.to_site()) == cut_(q) && p.last_coord() == q.last_coord() + 1);
+ // p follows q in a run, i.e., "p == q + right":
+ cut_(p.to_site()) == cut_(q) && p.last_coord() == q.last_coord() + 1);
s.insert(p_run<P>(start, q));
}
- }
-
-
- template <typename I, typename P, typename S>
- void
- from_image_to_site_set_(const I& input, const Gpoint<P>&,
- S& s, const std::pair< mln_value(I), p_run<P> >&)
- {
- s.clear();
- mln_value(I) O = literal::zero;
- mln_fwd_piter(I) p(input.domain());
- p.start();
- for (;;)
+ }
+
+
+ template <typename I, typename P, typename S>
+ void
+ from_image_to_site_set(const I& input, const Gpoint<P>&,
+ S& s,
+ const std::pair< mln_value(I), p_run<P> >&)
+ {
+ s.clear();
+ mln_value(I) O = literal::zero;
+ mln_fwd_piter(I) p(input.domain());
+ p.start();
+ for (;;)
{
if (! p.is_valid()) // The end.
break;
@@ -116,27 +119,54 @@ namespace mln
P start = p, q;
// Go to run end.
do
- {
- q = p;
- p.next();
- }
+ {
+ q = p;
+ p.next();
+ }
while (p.is_valid() && input(p) == v &&
- cut_(p.to_site()) == cut_(q) && p.last_coord() == q.last_coord() + 1);
+ cut_(p.to_site()) == cut_(q) && p.last_coord() == q.last_coord() + 1);
s.insert(v, p_run<P>(start, q));
}
- }
+ }
- template <typename I, typename P, typename S>
- void
- from_image_to_site_set_(const I& input, const Gpoint<P>&,
- S& s, const std::pair< mln_value(I), P >&)
- {
- s.clear();
- mln_fwd_piter(I) p(input.domain());
- for_all(p)
- s.insert(input(p), p);
- }
+ template <typename I, typename P, typename S>
+ void
+ from_image_to_site_set(const I& input, const Gpoint<P>&,
+ S& s,
+ const std::pair< mln_value(I), P >&)
+ {
+ s.clear();
+ mln_fwd_piter(I) p(input.domain());
+ for_all(p)
+ s.insert(input(p), p);
+ }
+
+
+ template <typename I, typename S>
+ inline
+ void
+ from_image_to_site_set(const Image<I>& from, Site_Set<S>&
to)
+ {
+ from_image_to_site_set(exact(from), mln_deduce(I, pset, element)(),
+ exact(to), mln_i_element(S)());
+ }
+
+ template <typename I>
+ inline
+ void
+ from_image_to_site_set(const Image<I>& from_,
p_array<mln_psite(I)>& to)
+ {
+ const I& from = exact(from_);
+
+ mln_piter(I) p(from.domain());
+ for_all(p)
+ if (from(p))
+ to.append(p);
+ }
+
+
+ } // end of namespace mln::convert::impl::internal
// Facade.
@@ -146,8 +176,7 @@ namespace mln
void
from_image_to_site_set(const Image<I>& from, Site_Set<S>& to)
{
- from_image_to_site_set_(exact(from), mln_deduce(I, pset, element)(),
- exact(to), mln_i_element(S)());
+ internal::from_image_to_site_set(exact(from), exact(to));
}
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/mln/convert/to_p_array.hh b/milena/mln/convert/to_p_array.hh
index bac55dc..1f62a65 100644
--- a/milena/mln/convert/to_p_array.hh
+++ b/milena/mln/convert/to_p_array.hh
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
-// (LRDE)
+// Copyright (C) 2007, 2008, 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
@@ -30,7 +30,10 @@
# define MLN_CONVERT_TO_P_ARRAY_HH
/// \file mln/convert/to_p_array.hh
-/// \brief Conversions to mln::p_array.
+///
+/// Conversions to mln::p_array.
+///
+/// \todo Move these conversion in from_to related mechanisms.
# include <mln/core/site_set/p_array.hh>
# include <mln/core/concept/image.hh>
@@ -91,6 +94,7 @@ namespace mln
return v;
}
+ //FIXME: to remove, already added to from_image_to_site_set.hh.
template <typename I>
inline
p_array<mln_psite(I)>
diff --git a/milena/tests/registration/multiscale.cc
b/milena/tests/registration/multiscale.cc
index da2f203..754e7d0 100644
--- a/milena/tests/registration/multiscale.cc
+++ b/milena/tests/registration/multiscale.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2008, 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
@@ -25,10 +26,11 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/registration/registration.cc
- *
- * \brief Test on mln::registration::registration.cc
- */
+/// \file tests/registration/multiscale.cc
+///
+/// Test on mln::registration::multiscale.cc
+///
+/// FIXME: write a test!
#include "tests/data.hh"
#include <mln/io/pbm/all.hh>
@@ -43,8 +45,8 @@ int main()
image2d< bool > img2;
//load images
- io::pbm::load(img1, MLN_IMG_DIR "/lena.pbm");
- io::pbm::load(img2, MLN_IMG_DIR "/lena.pbm");
+ io::pbm::load(img1, MLN_IMG_DIR "/fly.pbm");
+ io::pbm::load(img2, MLN_IMG_DIR "/fly.pbm");
//FIXME: Auto test result
//FIXME: Make it pass
--
1.5.6.5