https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
Add image conversion to p_array.
* mln/convert/to_p_array.hh (to_p_array): Add.
to_p_array.hh | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
Index: mln/convert/to_p_array.hh
--- mln/convert/to_p_array.hh (revision 2091)
+++ mln/convert/to_p_array.hh (working copy)
@@ -52,6 +52,11 @@
p_array<mln_psite(W)> to_p_array(const Window<W>& win,
const mln_psite(W)& p);
+ /// Convert an image \p img into a p_array.
+ template <typename I>
+ p_array<mln_point(I)>
+ to_p_array(const Image<I>& img);
+
# ifndef MLN_INCLUDE_ONLY
@@ -83,6 +88,23 @@
return v;
}
+ template <typename I>
+ inline
+ p_array<mln_point(I)>
+ to_p_array(const Image<I>& img_)
+ {
+ const I& img = exact(img_);
+
+ p_array<mln_point(I)> a;
+
+ mln_piter(I) p(img.domain());
+ for_all(p)
+ if (img(p))
+ a.append(p);
+
+ return a;
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::convert