2186: Sandbox: virtual transform, Add concept check.

https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox Index: ChangeLog from Ugo Jardonnet <ugo.jardonnet@lrde.epita.fr> Sandbox: virtual transform, Add concept check. * jardonnet/virtual/access.hh: Add concept check. * jardonnet/virtual/access.cc: Update in consequence. access.cc | 4 ++-- access.hh | 30 ++++++++++++++++++++++-------- 2 files changed, 24 insertions(+), 10 deletions(-) Index: jardonnet/virtual/access.hh --- jardonnet/virtual/access.hh (revision 2185) +++ jardonnet/virtual/access.hh (working copy) @@ -3,7 +3,8 @@ # include <mln/core/image1d.hh> # include <mln/core/image2d.hh> -# include <mln/math/round.hh> +# include <mln/metal/is.hh> +# include <mln/core/concept/function.hh> namespace mln { @@ -11,10 +12,13 @@ namespace interpolation { + template < typename I > struct nearest_neighbor + : public Function_x2x< nearest_neighbor<I> > { + typedef mln_value(I) result; - template <typename I, typename V> + template < typename V > mln_value(I) operator()(const I& img, const V& v) const { @@ -24,9 +28,13 @@ }; + template < typename I > struct linear + : public Function_x2x< linear<I> > { - template <typename I, typename C> + typedef mln_value(I) result; + + template <typename C> mln_value(I) operator()(const I& img, const algebra::vec<1,C>& v) const @@ -43,7 +51,7 @@ return img(xa); // p2 - double xb = mln_point(I)::coord(v[0] + 0.49999); + double xb = mln_point(I)::coord(v[0] + 1); double yb = img(point1d(xb)); // Taylor-young @@ -51,10 +59,13 @@ } }; - + template < typename I > struct bilinear + : public Function_x2x< bilinear<I> > { - template <typename I, typename V> + typedef mln_value(I) result; + + template <typename V> mln_value(I) operator()(const I& img, const V& v) const { @@ -69,9 +80,9 @@ double y = v[1]; double x1 = mln_point(I)::coord(v[0]); - double x2 = mln_point(I)::coord(v[0]+ 4.9999); + double x2 = mln_point(I)::coord(v[0]+ 1); double y1 = mln_point(I)::coord(v[1]); - double y2 = mln_point(I)::coord(v[1]+ 4.9999); + double y2 = mln_point(I)::coord(v[1]+ 1); point2d q11 = point2d(x1, y1); point2d q12 = point2d(x1, y2); @@ -101,6 +112,9 @@ access(const I& img, const mln_point(I)& p, const T& trans, const F& interp) { + mlc_is(T, Bijection_x2x<T>)::check(); + mlc_is(F, Function_x2x<F>)::check(); + return interp(img, (trans.inv())(p)); } Index: jardonnet/virtual/access.cc --- jardonnet/virtual/access.cc (revision 2185) +++ jardonnet/virtual/access.cc (working copy) @@ -13,7 +13,7 @@ point2d p(5,5); algebra::vec<2,float> v = make::vec(3,4); fun::x2x::translation<2,float> t(v); - interpolation::nearest_neighbor nn; + interpolation::nearest_neighbor< image2d<int> > nn; debug::iota(img); @@ -30,7 +30,7 @@ { for (int j = 4; j < 54; j++) std::cout << - access::access(img, point2d(i,j), t, nn); + mln::access::access(img, point2d(i,j), t, nn); std::cout << std::endl; } }
participants (1)
-
Ugo Jardonnet