olena: olena-2.0-819-g8fecc48 Milena: Exercise mln::interpolated and mln::tr_image together.

* tests/core/image/imorph/interpolated-tr_image.cc: New. * tests/core/image/imorph/Makefile.am (check_PROGRAMS): Add interpolated-tr_image. --- milena/ChangeLog | 8 +++ milena/tests/core/image/imorph/Makefile.am | 15 +++--- .../{interpolated.cc => interpolated-tr_image.cc} | 51 ++++++++++++++------ 3 files changed, 52 insertions(+), 22 deletions(-) copy milena/tests/core/image/imorph/{interpolated.cc => interpolated-tr_image.cc} (55%) diff --git a/milena/ChangeLog b/milena/ChangeLog index 5b9e6a3..382f48a 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,5 +1,13 @@ 2013-10-09 Roland Levillain <roland@lrde.epita.fr> + Milena: Exercise mln::interpolated and mln::tr_image together. + + * tests/core/image/imorph/interpolated-tr_image.cc: New. + * tests/core/image/imorph/Makefile.am (check_PROGRAMS): + Add interpolated-tr_image. + +2013-10-09 Roland Levillain <roland@lrde.epita.fr> + Milena: Make rotation axis optional. * mln/fun/x2x/rotation.hh diff --git a/milena/tests/core/image/imorph/Makefile.am b/milena/tests/core/image/imorph/Makefile.am index ddfc8b0..97a3ce6 100644 --- a/milena/tests/core/image/imorph/Makefile.am +++ b/milena/tests/core/image/imorph/Makefile.am @@ -1,4 +1,5 @@ -# Copyright (C) 2009, 2010 EPITA Research and Development Laboratory (LRDE) +# Copyright (C) 2009, 2010, 2013 EPITA Research and Development +# Laboratory (LRDE). # # This file is part of Olena. # @@ -17,11 +18,11 @@ include $(top_srcdir)/milena/tests/tests.mk check_PROGRAMS = \ - decorated_image \ - interpolated \ - labeled_image \ - safe_image \ - tr_image - + decorated_image \ + interpolated \ + interpolated-tr_image \ + labeled_image \ + safe_image \ + tr_image TESTS = $(check_PROGRAMS) diff --git a/milena/tests/core/image/imorph/interpolated.cc b/milena/tests/core/image/imorph/interpolated-tr_image.cc similarity index 55% copy from milena/tests/core/image/imorph/interpolated.cc copy to milena/tests/core/image/imorph/interpolated-tr_image.cc index 0ed5b16..de85d58 100644 --- a/milena/tests/core/image/imorph/interpolated.cc +++ b/milena/tests/core/image/imorph/interpolated-tr_image.cc @@ -1,5 +1,4 @@ -// Copyright (C) 2007, 2008, 2009, 2013 EPITA Research and Development -// Laboratory (LRDE). +// Copyright (C) 2013 EPITA Research and Development Laboratory (LRDE). // // This file is part of Olena. // @@ -25,36 +24,58 @@ // executable file might be covered by the GNU General Public License. /// \file -/// \brief Exercise mln::interpolated using mln::fun::x2v::bilinear. +/// \brief Exercise the mln::interpolated and mln::tr_image morphers +/// together. #include <iostream> #include <mln/core/image/image2d.hh> #include <mln/core/image/imorph/interpolated.hh> +#include <mln/core/image/imorph/safe.hh> +#include <mln/core/image/imorph/tr_image.hh> + #include <mln/fun/x2v/bilinear.hh> +#include <mln/fun/x2x/rotation.hh> + +#include <mln/math/pi.hh> #include <mln/algebra/vec.hh> +#include <mln/debug/iota.hh> #include <mln/debug/println.hh> +/// Sugar macro for mln::debug::println. +#define PRINTLN(Ima) mln::debug::println(#Ima " = ", Ima) + int main() { using namespace mln; - float tab[] = {1.f, 3.f, 5.f, 7.f, - 4.f, 7.f, 10.f, 13.f, - 7.f, 11.f, 15.f, 19.f, - 10.f, 15.f, 20.f, 25.f}; - image2d<float> ima = make::image2d(tab); - - interpolated<image2d<float>, fun::x2v::bilinear> inter(ima); + typedef image2d<float> I; + I ima(4, 4); + debug::iota(ima); + PRINTLN(ima); - algebra::vec<2, float> v1 = make::vec(2.3f, 0.6f); - algebra::vec<2, float> v2 = make::vec(3.2f, 1.8f); + // Step-by-step approach. + { + /// Wrap `ima' into a safe_image morpher to prevent out-of-domain + /// accesses due to the interpolation or the rotation below. + typedef mln::safe_image<I> S; + S safe(ima, 0.f); + PRINTLN(safe); - debug::println(ima); + /// Add an on-the-fly bilinear interpolation. + typedef interpolated<S, fun::x2v::bilinear> B; + B inter(safe); + PRINTLN(inter); - std::cout << "inter(" << v1 << ") = " << inter(v1) << std::endl; - std::cout << "inter(" << v2 << ") = " << inter(v2) << std::endl; + /// Rotate image on the fly. + float angle = math::pi / 4; + typedef fun::x2x::rotation<2, float> F; + F rotate(angle); + typedef tr_image<mln_domain_(B), B, F> R; + R rotated(inter.domain(), inter, rotate); + PRINTLN(rotated); + } } -- 1.7.10.4
participants (1)
-
Roland Levillain