https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Introduce make::image.
When there is no ambiguity, the user can call make::image.
* milena/mln/make/image2d.hh: Rename as...
* milena/mln/make/image.hh: ...this.
Import code from...
* milena/mln/make/image1d.hh: ...this removed file.
* milena/mln/make/all.hh: Update.
* milena/tests/debug/iota.cc,
* milena/tests/draw/graph.cc,
* milena/tests/level/abs.cc,
* milena/tests/level/replace.cc,
* milena/tests/level/stretch.cc,
* milena/tests/level/apply.cc,
* milena/tests/level/compare.cc,
* milena/tests/level/saturate.cc,
* milena/tests/arith/minus.cc,
* milena/tests/arith/times.cc,
* milena/tests/arith/plus.cc,
* milena/tests/arith/revert.cc,
* milena/tests/accu/compute.cc,
* milena/tests/geom/resize.cc,
* milena/tests/geom/seed2tiling_roundness.cc,
* milena/tests/geom/seed2tiling.cc,
* milena/tests/display/color_pretty.cc,
* milena/tests/logical/or.cc,
* milena/tests/logical/not.cc,
* milena/tests/logical/and_not.cc,
* milena/tests/logical/and.cc,
* milena/tests/canvas/chamfer.cc,
* milena/tests/util/tree_to_image.cc,
* milena/tests/util/lemmings.cc,
* milena/tests/util/tree_fast_to_image.cc,
* milena/tests/labeling/compute.cc,
* milena/mln/core/image/image1d.hh: Update.
* milena/mln/core/image/image2d.hh: Update.
(todo): New.
* milena/mln/core/w_window.hh (from_to): New overload.
* milena/mln/make/w_window2d.hh: Change tests into checks.
* milena/mln/convert/from_to.hxx: Update.
* milena/mln/canvas/browsing/directional.hh: .
* milena/tests/core/alias/w_window2d_int.cc: Add alt code.
mln/canvas/browsing/directional.hh | 8 -------
mln/convert/from_to.hxx | 7 ++++++
mln/core/image/image1d.hh | 5 ++--
mln/core/image/image2d.hh | 7 +++++-
mln/core/w_window.hh | 36 ++++++++++++++++++++------------
mln/make/all.hh | 2 +
mln/make/image.hh | 40 +++++++++++++++++++++++++++---------
mln/make/w_window2d.hh | 28 +++++++++----------------
tests/accu/compute.cc | 2 -
tests/arith/minus.cc | 2 -
tests/arith/plus.cc | 2 -
tests/arith/revert.cc | 2 -
tests/arith/times.cc | 2 -
tests/canvas/chamfer.cc | 6 ++---
tests/core/alias/w_window2d_int.cc | 4 +++
tests/debug/iota.cc | 2 -
tests/display/color_pretty.cc | 4 +--
tests/draw/graph.cc | 4 +--
tests/geom/resize.cc | 2 -
tests/geom/seed2tiling.cc | 4 +--
tests/geom/seed2tiling_roundness.cc | 4 +--
tests/labeling/compute.cc | 2 -
tests/level/abs.cc | 2 -
tests/level/apply.cc | 2 -
tests/level/compare.cc | 4 +--
tests/level/replace.cc | 4 +--
tests/level/saturate.cc | 2 -
tests/level/stretch.cc | 4 +--
tests/logical/and.cc | 6 ++---
tests/logical/and_not.cc | 6 ++---
tests/logical/not.cc | 4 +--
tests/logical/or.cc | 6 ++---
tests/util/lemmings.cc | 2 -
tests/util/tree_fast_to_image.cc | 2 -
tests/util/tree_to_image.cc | 2 -
35 files changed, 129 insertions(+), 92 deletions(-)
Index: milena/tests/debug/iota.cc
--- milena/tests/debug/iota.cc (revision 2747)
+++ milena/tests/debug/iota.cc (working copy)
@@ -48,7 +48,7 @@
{9, 10,11,12},
{13,14,15,16} };
- image2d<int> ref = make::image2d(vs);
+ image2d<int> ref = make::image(vs);
image2d<int> ima(4, 4);
debug::iota(ima);
Index: milena/tests/core/alias/w_window2d_int.cc
--- milena/tests/core/alias/w_window2d_int.cc (revision 2747)
+++ milena/tests/core/alias/w_window2d_int.cc (working copy)
@@ -56,6 +56,10 @@
-1, 0, 1 };
w_window2d_int w_win = make::w_window2d(ws);
+// w_window2d_int w_win;
+// convert::from_to(ws, w_win);
+// std::cout << w_win << std::endl;
+
image2d<int> ima = convert::to_image(w_win);
w_window2d_int w_win_2 = convert::to<w_window2d_int>(ima);
mln_assertion(w_win_2 == w_win);
Index: milena/tests/draw/graph.cc
--- milena/tests/draw/graph.cc (revision 2747)
+++ milena/tests/draw/graph.cc (working copy)
@@ -90,7 +90,7 @@
{0, 1, 0},
{0, 0, 2}
};
- image2d<int> ref (make::image2d(vs));
+ image2d<int> ref (make::image(vs));
// Points associated to nodes.
points_type points;
@@ -117,7 +117,7 @@
{0, 0, 0, 1, 1},
{0, 0, 0, 2, 2},
};
- image2d<int> ref (make::image2d(vs));
+ image2d<int> ref (make::image(vs));
// Points associated to nodes.
points_type points;
Index: milena/tests/level/abs.cc
--- milena/tests/level/abs.cc (revision 2747)
+++ milena/tests/level/abs.cc (working copy)
@@ -51,7 +51,7 @@
};
- image2d<int> ima(make::image2d(vs));
+ image2d<int> ima(make::image(vs));
image2d<int> out(ima.domain());
level::abs(ima, out);
box_fwd_piter_<point2d> p(ima.domain());
Index: milena/tests/level/replace.cc
--- milena/tests/level/replace.cc (revision 2747)
+++ milena/tests/level/replace.cc (working copy)
@@ -47,7 +47,7 @@
};
- image2d<int> rhs = make::image2d(vs);
+ image2d<int> rhs = make::image(vs);
level::replace(rhs, 10, 11);
@@ -58,6 +58,6 @@
{ 8, 9, 11 },
};
- mln_assertion(make::image2d(vs_ref) == rhs);
+ mln_assertion(make::image(vs_ref) == rhs);
}
Index: milena/tests/level/stretch.cc
--- milena/tests/level/stretch.cc (revision 2747)
+++ milena/tests/level/stretch.cc (working copy)
@@ -47,7 +47,7 @@
{ 1000, 2000, 3000 },
{ 1000, 2000, 3000 }
};
- image2d<int> ima(make::image2d(vs));
+ image2d<int> ima(make::image(vs));
image2d<int_u8> out(3, 3);
@@ -57,7 +57,7 @@
{ 0, 127, 255 }
};
- image2d<int_u8> ref(make::image2d(ws));
+ image2d<int_u8> ref(make::image(ws));
level::stretch(ima, out);
box_fwd_piter_<point2d> p(out.domain());
for_all(p)
Index: milena/tests/level/apply.cc
--- milena/tests/level/apply.cc (revision 2747)
+++ milena/tests/level/apply.cc (working copy)
@@ -47,7 +47,7 @@
{ 6, 6, 6 }
};
- image2d<int> ref(make::image2d(vs));
+ image2d<int> ref(make::image(vs));
debug::iota(ima);
level::apply(ima, fun::v2v::saturate<int>(2, 6));
box_fwd_piter_<point2d> p(ima.domain());
Index: milena/tests/level/compare.cc
--- milena/tests/level/compare.cc (revision 2747)
+++ milena/tests/level/compare.cc (working copy)
@@ -57,7 +57,7 @@
};
- rhs = make::image2d(vs);
+ rhs = make::image(vs);
mln_assertion(! (lhs == rhs));
mln_assertion( (lhs <= rhs));
@@ -80,7 +80,7 @@
};
- rhs = make::image2d(ws);
+ rhs = make::image(ws);
mln_assertion(! (lhs == rhs));
mln_assertion( (lhs <= rhs));
Index: milena/tests/level/saturate.cc
--- milena/tests/level/saturate.cc (revision 2747)
+++ milena/tests/level/saturate.cc (working copy)
@@ -47,7 +47,7 @@
{ 6, 6, 6 }
};
- image2d<int> ref(make::image2d(vs));
+ image2d<int> ref(make::image(vs));
debug::iota(ima);
level::saturate_inplace(ima, 2, 6);
box_fwd_piter_<point2d> p(ima.domain());
Index: milena/tests/arith/minus.cc
--- milena/tests/arith/minus.cc (revision 2747)
+++ milena/tests/arith/minus.cc (working copy)
@@ -51,7 +51,7 @@
{6, 7, 8}
};
- image2d<int> ref(make::image2d(vs));
+ image2d<int> ref(make::image(vs));
mln_assertion (ima - 1 == ref);
}
Index: milena/tests/arith/times.cc
--- milena/tests/arith/times.cc (revision 2747)
+++ milena/tests/arith/times.cc (working copy)
@@ -51,7 +51,7 @@
{14, 16, 18}
};
- image2d<int> ref(make::image2d(vs));
+ image2d<int> ref(make::image(vs));
mln_assertion (ima * 2 == ref);
}
Index: milena/tests/arith/plus.cc
--- milena/tests/arith/plus.cc (revision 2747)
+++ milena/tests/arith/plus.cc (working copy)
@@ -52,7 +52,7 @@
};
ima += 2;
- image2d<int> ref(make::image2d(vs));
+ image2d<int> ref(make::image(vs));
mln_assertion (ima + 1 == ref);
}
Index: milena/tests/arith/revert.cc
--- milena/tests/arith/revert.cc (revision 2747)
+++ milena/tests/arith/revert.cc (working copy)
@@ -52,7 +52,7 @@
{ -8, -9, -10}
};
- image2d<int> ref(make::image2d(vs));
+ image2d<int> ref(make::image(vs));
arith::revert_inplace(ima);
mln_assertion (ima == ref);
Index: milena/tests/accu/compute.cc
--- milena/tests/accu/compute.cc (revision 2747)
+++ milena/tests/accu/compute.cc (working copy)
@@ -48,7 +48,7 @@
// {6,5,4},
// {3,2,1} };
-// image2d<int_u8> ima = make::image2d(vs);
+// image2d<int_u8> ima = make::image(vs);
// int a = accu::compute<accu::min>(ima);
// std::cout << a << std::endl;
Index: milena/tests/geom/resize.cc
--- milena/tests/geom/resize.cc (revision 2747)
+++ milena/tests/geom/resize.cc (working copy)
@@ -60,7 +60,7 @@
{105, 107, 109, 111, 113, 115, 117, 119}
};
- image2d<int> ref(make::image2d(ws));
+ image2d<int> ref(make::image(ws));
mln_assertion (out == ref);
}
Index: milena/tests/geom/seed2tiling_roundness.cc
--- milena/tests/geom/seed2tiling_roundness.cc (revision 2747)
+++ milena/tests/geom/seed2tiling_roundness.cc (working copy)
@@ -82,9 +82,9 @@
{1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3}
};
- image2d<unsigned> ima (make::image2d(vs));
+ image2d<unsigned> ima (make::image(vs));
image2d<unsigned> out = geom::seeds2tiling_roundness(ima, w_win, max, c4());
- image2d<unsigned> ref (make::image2d(ws));
+ image2d<unsigned> ref (make::image(ws));
mln_assertion (ref == out);
}
Index: milena/tests/geom/seed2tiling.cc
--- milena/tests/geom/seed2tiling.cc (revision 2747)
+++ milena/tests/geom/seed2tiling.cc (working copy)
@@ -78,8 +78,8 @@
{1 ,1 ,1 ,1 ,1 ,1 ,3 ,3 ,3 ,3 ,3 ,3 ,3 ,3 ,3 ,3}
};
- image2d<unsigned> ima (make::image2d(vs));
+ image2d<unsigned> ima (make::image(vs));
image2d<unsigned> out = geom::seeds2tiling(ima, c4());
- image2d<unsigned> ref (make::image2d(ws));
+ image2d<unsigned> ref (make::image(ws));
mln_assertion (ref == out);
}
Index: milena/tests/display/color_pretty.cc
--- milena/tests/display/color_pretty.cc (revision 2747)
+++ milena/tests/display/color_pretty.cc (working copy)
@@ -63,7 +63,7 @@
{value::rgb8(255, 0, 0), value::rgb8(51, 51, 51)}
};
- image2d<value::rgb8> ref (make::image2d(vs));
+ image2d<value::rgb8> ref (make::image(vs));
mln_assertion (ref == out);
}
@@ -87,7 +87,7 @@
{value::rgb8(0, 0, 255), value::rgb8(0, 0, 0)}
};
- image2d<value::rgb8> ref (make::image2d(vs));
+ image2d<value::rgb8> ref (make::image(vs));
mln_assertion (ref == out);
}
}
Index: milena/tests/logical/or.cc
--- milena/tests/logical/or.cc (revision 2747)
+++ milena/tests/logical/or.cc (working copy)
@@ -57,9 +57,9 @@
{1, 1, 1}
};
- image2d<bool> ima1 (make::image2d(vs));
- image2d<bool> ima2 (make::image2d(us));
- image2d<bool> ref (make::image2d(ws));
+ image2d<bool> ima1 (make::image(vs));
+ image2d<bool> ima2 (make::image(us));
+ image2d<bool> ref (make::image(ws));
mln_assertion (logical::or_(ima1, ima2) == ref);
}
Index: milena/tests/logical/not.cc
--- milena/tests/logical/not.cc (revision 2747)
+++ milena/tests/logical/not.cc (working copy)
@@ -51,8 +51,8 @@
{0, 1, 0}
};
- image2d<bool> ima (make::image2d(vs));
- image2d<bool> ref (make::image2d(ws));
+ image2d<bool> ima (make::image(vs));
+ image2d<bool> ref (make::image(ws));
mln_assertion (logical::not_(ima) == ref);
}
Index: milena/tests/logical/and_not.cc
--- milena/tests/logical/and_not.cc (revision 2747)
+++ milena/tests/logical/and_not.cc (working copy)
@@ -57,8 +57,8 @@
{1, 0, 1}
};
- image2d<bool> ima1 (make::image2d(vs));
- image2d<bool> ima2 (make::image2d(us));
- image2d<bool> ref (make::image2d(ws));
+ image2d<bool> ima1 (make::image(vs));
+ image2d<bool> ima2 (make::image(us));
+ image2d<bool> ref (make::image(ws));
mln_assertion (logical::and_not(ima1, ima2) == ref);
}
Index: milena/tests/logical/and.cc
--- milena/tests/logical/and.cc (revision 2747)
+++ milena/tests/logical/and.cc (working copy)
@@ -57,9 +57,9 @@
{1, 0, 1}
};
- image2d<bool> ima1 (make::image2d(vs));
- image2d<bool> ima2 (make::image2d(us));
- image2d<bool> ref (make::image2d(ws));
+ image2d<bool> ima1 (make::image(vs));
+ image2d<bool> ima2 (make::image(us));
+ image2d<bool> ref (make::image(ws));
mln_assertion (logical::and_(ima1, ima2) == ref);
}
Index: milena/tests/canvas/chamfer.cc
--- milena/tests/canvas/chamfer.cc (revision 2747)
+++ milena/tests/canvas/chamfer.cc (working copy)
@@ -69,7 +69,7 @@
{16, 14, 12, 10, 8, 10, 12, 14, 16}
};
- image2d<unsigned> ref (make::image2d(r));
+ image2d<unsigned> ref (make::image(r));
mln_assertion (out == ref);
}
@@ -92,7 +92,7 @@
{12, 11, 10, 9, 8, 9, 10, 11, 12}
};
- image2d<unsigned> ref (make::image2d(r));
+ image2d<unsigned> ref (make::image(r));
mln_assertion (out == ref);
}
@@ -118,7 +118,7 @@
{12, 10, 9, 8, 8, 8, 9, 10, 12}
};
- image2d<unsigned> ref (make::image2d(r));
+ image2d<unsigned> ref (make::image(r));
mln_assertion (out == ref);
}
Index: milena/tests/util/tree_to_image.cc
--- milena/tests/util/tree_to_image.cc (revision 2747)
+++ milena/tests/util/tree_to_image.cc (working copy)
@@ -133,6 +133,6 @@
};
- image2d<int_u8> ref (make::image2d(vs));
+ image2d<int_u8> ref (make::image(vs));
mln_assertion(ref == output);
}
Index: milena/tests/util/lemmings.cc
--- milena/tests/util/lemmings.cc (revision 2747)
+++ milena/tests/util/lemmings.cc (working copy)
@@ -46,7 +46,7 @@
{3, 3, 4, 4},
{3, 3, 4, 4}};
- I ima = make::image2d<int>(vals);
+ I ima = make::image<int>(vals);
mln_site_(I) pt1(1, 0);
mln_site_(I) pt2(0, 2);
Index: milena/tests/util/tree_fast_to_image.cc
--- milena/tests/util/tree_fast_to_image.cc (revision 2747)
+++ milena/tests/util/tree_fast_to_image.cc (working copy)
@@ -132,6 +132,6 @@
};
debug::printl (output);
- image2d<int_u8> ref (make::image2d(vs));
+ image2d<int_u8> ref (make::image(vs));
mln_assertion(ref == output);
}
Index: milena/tests/labeling/compute.cc
--- milena/tests/labeling/compute.cc (revision 2747)
+++ milena/tests/labeling/compute.cc (working copy)
@@ -52,7 +52,7 @@
{2, 0, 3, 3, 3},
{2, 0, 0, 0, 0}
};
- image2d<int_u8> ima = make::image2d(vals);
+ image2d<int_u8> ima = make::image(vals);
int_u8 nlabels = 3;
accu::sum<int_u8> sum;
Index: milena/mln/core/image/image1d.hh
--- milena/mln/core/image/image1d.hh (revision 2747)
+++ milena/mln/core/image/image1d.hh (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 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
@@ -600,6 +601,6 @@
} // end of namespace mln
-# include <mln/make/image1d.hh>
+# include <mln/make/image.hh>
#endif // ! MLN_CORE_IMAGE_IMAGE1D_HH
Index: milena/mln/core/image/image2d.hh
--- milena/mln/core/image/image2d.hh (revision 2747)
+++ milena/mln/core/image/image2d.hh (working copy)
@@ -31,6 +31,8 @@
/// \file mln/core/image/image2d.hh
/// \brief Definition of the basic mln::image2d class.
+///
+/// \todo Re-activate include at EOF when make::image2d is up again.
# include <mln/core/internal/image_primary.hh>
# include <mln/core/internal/fixme.hh>
@@ -687,6 +689,9 @@
} // end of namespace mln
-# include <mln/make/image2d.hh>
+
+# include <mln/make/image.hh>
+// # include <mln/make/image2d.hh>
+
#endif // ! MLN_CORE_IMAGE_IMAGE2D_HH
Index: milena/mln/core/w_window.hh
--- milena/mln/core/w_window.hh (revision 2747)
+++ milena/mln/core/w_window.hh (working copy)
@@ -37,12 +37,14 @@
# include <mln/core/concept/weighted_window.hh>
# include <mln/core/concept/image.hh>
+# include <mln/core/site_set/box.hh>
# include <mln/core/window.hh>
# include <mln/core/dpsites_piter.hh>
# include <mln/value/ops.hh>
# include <mln/util/ord.hh>
# include <mln/metal/converts_to.hh>
+# include <mln/metal/math/root.hh>
# include <mln/literal/zero.hh>
# include <mln/convert/to.hh>
@@ -150,7 +152,7 @@
template <typename V, unsigned S, typename D, typename W>
void
- from_to(const V (&values)[S], w_window<D,W>& to);
+ from_to(const V (&weight)[S], w_window<D,W>& to);
} // end of namespace mln::convert
@@ -343,18 +345,26 @@
to.insert(ima(p), convert::to<D>(p));
}
-// template <typename V, unsigned S, typename D, typename W>
-// void
-// from_to(const V (&values)[S], w_window<D,W>& to)
-// {
-// enum { d = D::dim,
-// s = mlc_root(d,S)::value / 2 };
-// metal::bool_<(mlc_pow_int(2 * s + 1, d) == S)>::check();
-// to.clear();
-// D dp;
-// dp.set_all(-s);
-// FIXME
-// }
+ template <typename V, unsigned S, typename D, typename W>
+ void
+ from_to(const V (&weight)[S], w_window<D,W>& to)
+ {
+ mlc_converts_to(V, W)::check();
+ enum { d = D::dim,
+ s = mlc_root(d,S)::value / 2 };
+ metal::bool_<(mlc_pow_int(2 * s + 1, d) == S)>::check();
+ to.clear();
+ typedef mln_site(D) P;
+ box<P> b(all_to(-s), all_to(+s));
+ mln_fwd_piter(box<P>) p(b);
+ unsigned i = 0;
+ for_all(p)
+ {
+ if (weight[i] != literal::zero)
+ to.insert(weight[i], convert::to<D>(p));
+ ++i;
+ }
+ }
} // end of namespace mln::convert
Index: milena/mln/make/image.hh
--- milena/mln/make/image.hh (revision 2746)
+++ milena/mln/make/image.hh (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 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,14 +26,15 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_MAKE_IMAGE2D_HH
-# define MLN_MAKE_IMAGE2D_HH
+#ifndef MLN_MAKE_IMAGE_HH
+# define MLN_MAKE_IMAGE_HH
-/*! \file mln/make/image2d.hh
+/*! \file mln/make/image.hh
*
- * \brief Routine to create an mln::image2d in the 2D case.
+ * \brief Routine to create an image from various input.
*/
+# include <mln/core/image/image1d.hh>
# include <mln/core/image/image2d.hh>
@@ -42,6 +44,16 @@
namespace make
{
+ /*! \brief Create an image1d from an 1d array of values.
+ *
+ * \param[in] values 1d array.
+ *
+ * \return A 1D image.
+ */
+ template <typename V, unsigned L>
+ mln::image1d<V> image1d(V (&values)[L]);
+
+
/*! \brief Create an image2d from an 2d array of values.
*
* \param[in] values 2d array.
@@ -49,15 +61,25 @@
* \return A 2D image.
*/
template <typename V, unsigned R, unsigned C>
- mln::image2d<V> image2d(V (&values)[R][C]);
+ mln::image2d<V> image(V (&values)[R][C]);
# ifndef MLN_INCLUDE_ONLY
+ template <typename V, unsigned L>
+ mln::image1d<V>
+ image1d(V (&values)[L])
+ {
+ mlc_bool(L != 0)::check();
+ mln::image1d<V> tmp(L);
+ for (unsigned ind = 0; ind < L; ++ind)
+ tmp(point1d(ind)) = values[ind];
+ return tmp;
+ }
+
template <typename V, unsigned R, unsigned C>
- inline
mln::image2d<V>
- image2d(V (&values)[R][C])
+ image(V (&values)[R][C])
{
mln::image2d<V> tmp(R, C);
for (unsigned row = 0; row < R; ++row)
@@ -73,4 +95,4 @@
} // end of namespace mln
-#endif // ! MLN_MAKE_IMAGE2D_HH
+#endif // ! MLN_MAKE_IMAGE_HH
Property changes on: milena/mln/make/image.hh
___________________________________________________________________
Added: svn:mergeinfo
Index: milena/mln/make/w_window2d.hh
--- milena/mln/make/w_window2d.hh (revision 2747)
+++ milena/mln/make/w_window2d.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -33,10 +33,9 @@
* \brief Routine to create an mln::w_window in the 2D case.
*/
-# include <cmath>
-
# include <mln/core/w_window.hh>
# include <mln/core/alias/dpoint2d.hh>
+# include <mln/metal/math/sqrt.hh>
namespace mln
@@ -49,32 +48,25 @@
*
* \param[in] weights Array.
*
- * \pre The array size, \c M, has to be a square of an odd integer.
+ * \pre The array size, \c S, has to be a square of an odd integer.
*
* \return A 2D weighted window.
*/
- template <typename W, unsigned M>
- mln::w_window<mln::dpoint2d, W> w_window2d(W (&weights)[M]);
+ template <typename W, unsigned S>
+ mln::w_window<mln::dpoint2d, W> w_window2d(W (&weights)[S]);
# ifndef MLN_INCLUDE_ONLY
- template <typename W, unsigned M>
+ template <typename W, unsigned S>
inline
mln::w_window<mln::dpoint2d, W>
- w_window2d(W (&weights)[M])
+ w_window2d(W (&weights)[S])
{
- int h = unsigned(std::sqrt(float(M))) / 2;
- mln_precondition((2 * h + 1) * (2 * h + 1) == M);
+ enum { s = mlc_sqrt_int(S) / 2 };
+ metal::bool_<(((2 * s + 1) * (2 * s + 1)) == S)>::check();
mln::w_window<mln::dpoint2d, W> tmp;
- unsigned i = 0;
- for (int row = - h; row <= h; ++row)
- for (int col = - h; col <= h; ++col)
- {
- if (weights[i] != 0)
- tmp.insert(weights[i], dpoint2d(row, col));
- i++;
- }
+ convert::from_to(weights, tmp);
return tmp;
}
Index: milena/mln/make/all.hh
--- milena/mln/make/all.hh (revision 2747)
+++ milena/mln/make/all.hh (working copy)
@@ -1,4 +1,5 @@
// Copyright (C) 2007, 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
@@ -47,6 +48,7 @@
# include <mln/make/box2d_h.hh>
# include <mln/make/box3d.hh>
# include <mln/make/dpoint2d_h.hh>
+# include <mln/make/image.hh>
# include <mln/make/mat.hh>
# include <mln/make/pixel.hh>
# include <mln/make/pix.hh>
Index: milena/mln/convert/from_to.hxx
--- milena/mln/convert/from_to.hxx (revision 2747)
+++ milena/mln/convert/from_to.hxx (working copy)
@@ -138,11 +138,18 @@
void
from_to(const Gpoint<P>& from, mln_delta(P)& to);
+
// Image -> w_window
template <typename I, typename D, typename W>
void
from_to(const Image<I>& from, w_window<D,W>& to);
+ // C-array -> w_window
+ template <typename V, unsigned S, typename D, typename W>
+ void
+ from_to(const V (&weight)[S], w_window<D,W>& to);
+
+
// neighb<W> -> W
template <typename W>
void
Index: milena/mln/canvas/browsing/directional.hh
--- milena/mln/canvas/browsing/directional.hh (revision 2747)
+++ milena/mln/canvas/browsing/directional.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -105,7 +105,6 @@
void
directional_t::operator()(F& f) const
{
- trace::entering("canvas::browsing::directional");
mln_precondition(f.dir < f.dim);
typedef typename F::I I;
@@ -115,9 +114,7 @@
f.p = pmin;
- trace::entering("canvas::browsing::directional::init");
f.init();
- trace::exiting("canvas::browsing::directional::init");
do
{
@@ -147,10 +144,7 @@
} while (f.p != pmin);
- trace::entering("canvas::browsing::directional::final");
f.final();
- trace::exiting("canvas::browsing::directional::final");
- trace::exiting("canvas::browsing::directional");
}
# endif // ! MLN_INCLUDE_ONLY